Skip to content

Commit

Permalink
#444 Remove WINDOWS_PHONE compilation symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
nigel-sampson committed May 30, 2017
1 parent 4254cb2 commit 30574d8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 72 deletions.
13 changes: 0 additions & 13 deletions src/Caliburn.Micro.Platform/ActionMessage.cs
Expand Up @@ -39,10 +39,6 @@ public class ActionMessage : TriggerAction<FrameworkElement>, IHaveParameters {
static readonly ILog Log = LogManager.GetLog(typeof(ActionMessage));
ActionExecutionContext context;

#if WINDOWS_PHONE
internal Microsoft.Phone.Shell.IApplicationBarMenuItem applicationBarSource;
#endif

internal static readonly DependencyProperty HandlerProperty = DependencyProperty.RegisterAttached(
"Handler",
typeof(object),
Expand Down Expand Up @@ -341,15 +337,6 @@ void ElementUnloaded(object sender, RoutedEventArgs e)
/// </summary>
/// <remarks>Returns a value indicating whether or not the action is available.</remarks>
public static Func<ActionExecutionContext, bool> ApplyAvailabilityEffect = context => {
#if WINDOWS_PHONE
var message = context.Message;
if (message != null && message.applicationBarSource != null) {
if (context.CanExecute != null) {
message.applicationBarSource.IsEnabled = context.CanExecute();
}
return message.applicationBarSource.IsEnabled;
}
#endif
#if WinRT
var source = context.Source as Control;
Expand Down
2 changes: 1 addition & 1 deletion src/Caliburn.Micro.Platform/ConventionManager.cs
Expand Up @@ -202,7 +202,7 @@ public static class ConventionManager {
return View.ModelProperty;
};
#endif
#if !WINDOWS_PHONE && !WinRT
#if !WinRT
AddElementConvention<DatePicker>(DatePicker.SelectedDateProperty, "SelectedDate", "SelectedDateChanged");
#endif
#if WinRT81
Expand Down
58 changes: 0 additions & 58 deletions src/Caliburn.Micro.Platform/ViewModelBinder.cs
Expand Up @@ -22,10 +22,6 @@ namespace Caliburn.Micro
using System.Windows.Interactivity;
#endif

#if WINDOWS_PHONE
using Microsoft.Phone.Controls;
#endif

/// <summary>
/// Binds a view to a view model.
/// </summary>
Expand Down Expand Up @@ -239,15 +235,8 @@ public static class ViewModelBinder {
return;
}
#if WINDOWS_PHONE
BindAppBar(view);
#endif
if (!ShouldApplyConventions(element)) {
Log.Info("Skipping conventions for {0} and {1}.", element, viewModel);
#if WINDOWS_PHONE
view.SetValue(ConventionsAppliedProperty, true); // we always apply the AppBar conventions
#endif
return;
}
Expand All @@ -269,52 +258,5 @@ public static class ViewModelBinder {
view.SetValue(ConventionsAppliedProperty, true);
};

#if WINDOWS_PHONE
static void BindAppBar(DependencyObject view) {
var page = view as PhoneApplicationPage;
if (page == null || page.ApplicationBar == null) {
return;
}

var triggers = Interaction.GetTriggers(view);

foreach(var item in page.ApplicationBar.Buttons) {
var button = item as IAppBarActionMessage;
if (button == null || string.IsNullOrEmpty(button.Message)) {
continue;
}

var parsedTrigger = Parser.Parse(view, button.Message).First();
var trigger = new AppBarItemTrigger(button);
var actionMessages = parsedTrigger.Actions.OfType<ActionMessage>().ToList();
actionMessages.Apply(x => {
x.applicationBarSource = button;
parsedTrigger.Actions.Remove(x);
trigger.Actions.Add(x);
});

triggers.Add(trigger);
}

foreach (var item in page.ApplicationBar.MenuItems) {
var menuItem = item as IAppBarActionMessage;
if (menuItem == null || string.IsNullOrEmpty(menuItem.Message)) {
continue;
}

var parsedTrigger = Parser.Parse(view, menuItem.Message).First();
var trigger = new AppBarItemTrigger(menuItem);
var actionMessages = parsedTrigger.Actions.OfType<ActionMessage>().ToList();
actionMessages.Apply(x => {
x.applicationBarSource = menuItem;
parsedTrigger.Actions.Remove(x);
trigger.Actions.Add(x);
});

triggers.Add(trigger);
}
}
#endif
}
}

0 comments on commit 30574d8

Please sign in to comment.