Skip to content

Commit

Permalink
Updated for Win10 UAP
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottIsAFool committed Mar 24, 2015
1 parent 958e6fb commit bf2c4fe
Show file tree
Hide file tree
Showing 28 changed files with 1,185 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,6 +4,7 @@ Thumbs.db
*.suo
*.log
[Bb]in
[Oo]bj
*.cache
*.Cache
*.ncrunchsolution*
Expand Down
Expand Up @@ -117,7 +117,7 @@ private void UpdateSource()
{
_updating = true;

for (var index = 0; index < Count; index++)
for (var index = 0; index < this.Count; index++)
{
var multiBindingItem = this[index] as MultiBindingItem;

Expand Down
Expand Up @@ -51,7 +51,7 @@ public abstract class ValueConverterBase : DependencyObject, IValueConverter
/// <returns>The value to be passed to the source object.</returns>
public abstract object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);

#if WINDOWS_PHONE_APP || WINDOWS_APP
#if WINDOWS_PHONE_APP || WINDOWS_APP || WINDOWS_UAP
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
{
var cultureInfo = !string.IsNullOrEmpty(language) ? new CultureInfo(language) : null;
Expand Down
Expand Up @@ -18,6 +18,11 @@
using System.Windows.Interactivity;
using TriggerBase = System.Windows.Interactivity.TriggerBase;
using TriggerCollection = System.Windows.Interactivity.TriggerCollection;
#elif WINDOWS_UAP
using Windows.UI.Xaml;
using Cimbalino.Toolkit.Behaviors;
using Microsoft.Xaml.Interactivity;
using System.Linq;
#else
using System.Linq;
using Cimbalino.Toolkit.Behaviors;
Expand Down Expand Up @@ -67,7 +72,11 @@ public static T GetBehavior<T>(this FrameworkElement frameworkElement)

if (behaviorsCollection != null)
{
#if !WINDOWS_UAP
return behaviorsCollection.OfType<T>().FirstOrDefault();
#else
return (T)behaviorsCollection.FirstOrDefault(x => x.GetType() == typeof(T));
#endif
}

return null;
Expand Down
Expand Up @@ -164,7 +164,7 @@ public virtual double RawPixelsPerViewPixel
{
#if WINDOWS_PHONE
return 1.0;
#elif WINDOWS_PHONE_APP
#elif WINDOWS_PHONE_APP || WINDOWS_UAP
return DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel;
#else
return DisplayInformation.GetForCurrentView().LogicalDpi / 96.0;
Expand Down
6 changes: 5 additions & 1 deletion src/Cimbalino.Toolkit (WP8)/Services/EmailComposeService.cs
Expand Up @@ -19,6 +19,10 @@
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Email;
#elif WINDOWS_UAP
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Email;
#else
using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -79,7 +83,7 @@ public virtual Task ShowAsync(string to, string cc, string bcc, string subject,

return Task.FromResult(0);
}
#elif WINDOWS_PHONE_APP
#elif WINDOWS_PHONE_APP || WINDOWS_UAP
public async virtual Task ShowAsync(string to, string cc, string bcc, string subject, string body)
{
var emailMessage = new EmailMessage
Expand Down
6 changes: 4 additions & 2 deletions src/Cimbalino.Toolkit (WP8)/Services/MapManagerService.cs
Expand Up @@ -16,6 +16,8 @@
using Microsoft.Phone.Tasks;
#elif WINDOWS_PHONE_APP
using Windows.Services.Maps;
#elif WINDOWS_UAP
using Windows.Services.Maps;
#else
using System;
#endif
Expand All @@ -34,7 +36,7 @@ public virtual void ShowDownloadedMapsUI()
{
#if WINDOWS_PHONE
new MapDownloaderTask().Show();
#elif WINDOWS_PHONE_APP
#elif WINDOWS_PHONE_APP || WINDOWS_UAP
MapManager.ShowDownloadedMapsUI();
#else
throw new NotSupportedException();
Expand All @@ -48,7 +50,7 @@ public virtual void ShowMapsUpdateUI()
{
#if WINDOWS_PHONE
new MapUpdaterTask().Show();
#elif WINDOWS_PHONE_APP
#elif WINDOWS_PHONE_APP || WINDOWS_UAP
MapManager.ShowMapsUpdateUI();
#else
throw new NotSupportedException();
Expand Down
32 changes: 31 additions & 1 deletion src/Cimbalino.Toolkit (WP8)/Services/PhoneCallService.cs
Expand Up @@ -18,11 +18,20 @@
#elif WINDOWS_PHONE_APP
using System.Threading.Tasks;
using Windows.ApplicationModel.Calls;
using Cimbalino.Toolkit.Core.Helpers;
#elif WINDOWS_UAP
using System.Threading.Tasks;
using Windows.ApplicationModel.Calls;
using Cimbalino.Toolkit.Core.Helpers;
using System;
using Windows.System;
using Cimbalino.Toolkit.Extensions;
#else
using System;
using System.Threading.Tasks;
using Cimbalino.Toolkit.Extensions;
using Windows.System;
using Cimbalino.Toolkit.Core.Helpers;
#endif

namespace Cimbalino.Toolkit.Services
Expand Down Expand Up @@ -63,11 +72,32 @@ public virtual Task ShowAsync(string phoneNumber, string displayName)
public virtual Task ShowAsync(string phoneNumber, string displayName)
{
PhoneCallManager.ShowPhoneCallUI(phoneNumber, displayName);

return Task.FromResult(0);
}
#elif WINDOWS_UAP
public virtual Task ShowAsync(string phoneNumber, string displayName)
{
if (ApiHelper.SupportsPhoneCalls)
{
PhoneCallManager.ShowPhoneCallUI(phoneNumber, displayName);
}
else
{
return CallByUri(phoneNumber, displayName);
}

return Task.FromResult(0);
}
#else
public async virtual Task ShowAsync(string phoneNumber, string displayName)
public virtual Task ShowAsync(string phoneNumber, string displayName)
{
return CallByUri(phoneNumber, displayName);
}
#endif

#if WINDOWS_APP || WINDOWS_UAP
private async Task CallByUri(string phoneNumber, string displayName)
{
var phoneCallUri = new UriBuilder("tel:")
.SetPath(phoneNumber)
Expand Down
51 changes: 41 additions & 10 deletions src/Cimbalino.Toolkit (WP8)/Services/SmsComposeService.cs
Expand Up @@ -19,6 +19,13 @@
using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Chat;
#elif WINDOWS_UAP
using System;
using System.Threading.Tasks;
using Cimbalino.Toolkit.Core.Helpers;
using Cimbalino.Toolkit.Extensions;
using Windows.ApplicationModel.Chat;
using Windows.System;
#else
using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -61,22 +68,29 @@ public virtual Task ShowAsync(string recipient, string body)
return Task.FromResult(0);
}
#elif WINDOWS_PHONE_APP
public async virtual Task ShowAsync(string recipient, string body)
public virtual Task ShowAsync(string recipient, string body)
{
var chatMessage = new ChatMessage
{
Body = body
};

if (!string.IsNullOrEmpty(recipient))
return SendByChat(recipient, body);
}
#elif WINDOWS_UAP
public virtual Task ShowAsync(string recipient, string body)
{
if (ApiHelper.SupportsChat)
{
chatMessage.Recipients.Add(recipient);
return SendByChat(recipient, body);
}

await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
return SendByUri(recipient, body);
}
#else
public async virtual Task ShowAsync(string recipient, string body)
public virtual Task ShowAsync(string recipient, string body)
{
return SendByUri(recipient, body);
}
#endif

#if WINDOWS_APP || WINDOWS_UAP
private async Task SendByUri(string recipient, string body)
{
var smsUri = new UriBuilder("sms:")
.SetPath(recipient)
Expand All @@ -86,5 +100,22 @@ public async virtual Task ShowAsync(string recipient, string body)
await Launcher.LaunchUriAsync(smsUri);
}
#endif

#if WINDOWS_PHONE_APP || WINDOWS_UAP
private async Task SendByChat(string recipient, string body)
{
var chatMessage = new ChatMessage
{
Body = body
};

if (!string.IsNullOrEmpty(recipient))
{
chatMessage.Recipients.Add(recipient);
}

await ChatMessageManager.ShowComposeSmsMessageAsync(chatMessage);
}
#endif
}
}
19 changes: 15 additions & 4 deletions src/Cimbalino.Toolkit (WP8)/Services/VibrationService.cs
Expand Up @@ -16,6 +16,11 @@
using System;
using Microsoft.Devices;
#elif WINDOWS_PHONE_APP
using Cimbalino.Toolkit.Core.Helpers;
using System;
using Windows.Phone.Devices.Notification;
#elif WINDOWS_UAP
using Cimbalino.Toolkit.Core.Helpers;
using System;
using Windows.Phone.Devices.Notification;
#else
Expand Down Expand Up @@ -54,8 +59,11 @@ public virtual void Vibrate(TimeSpan duration)
{
#if WINDOWS_PHONE
VibrateController.Default.Start(duration);
#elif WINDOWS_PHONE_APP
VibrationDevice.GetDefault().Vibrate(duration);
#elif WINDOWS_PHONE_APP || WINDOWS_UAP
if (ApiHelper.SupportsVibrate)
{
VibrationDevice.GetDefault().Vibrate(duration);
}
#else
throw new NotSupportedException();
#endif
Expand All @@ -68,8 +76,11 @@ public virtual void Cancel()
{
#if WINDOWS_PHONE
VibrateController.Default.Stop();
#elif WINDOWS_PHONE_APP
VibrationDevice.GetDefault().Cancel();
#elif WINDOWS_PHONE_APP || WINDOWS_UAP
if (ApiHelper.SupportsVibrate)
{
VibrationDevice.GetDefault().Cancel();
}
#else
throw new NotSupportedException();
#endif
Expand Down

0 comments on commit bf2c4fe

Please sign in to comment.