private void AddApplicationBarMenu(ICommandLink commandLink) { if (this.Page.ApplicationBar == null) { return; } bool canExecute = commandLink.Command != null && commandLink.Command.CanExecute(null); var button = new ApplicationBarMenuItem() { Text = commandLink.Text, IsEnabled = canExecute }; if (commandLink.Command != null) { this.appBarSubscriptions.Add( Observable.FromEvent <EventHandler, EventArgs>( handler => new EventHandler(handler), handler => button.Click += handler, handler => button.Click -= handler).ObserveOnDispatcher().Subscribe( _ => commandLink.Command.Execute(null))); this.appBarSubscriptions.Add( Observable.FromEvent <EventArgs>(commandLink.Command, "CanExecuteChanged").Subscribe( ev => this.UpdateMenuItemCanExecute(commandLink, button))); this.appBarSubscriptions.Add( Observable.FromEvent <PropertyChangedEventArgs>(commandLink, "PropertyChanged").Subscribe( ev => button.Text = commandLink.Text)); } if (canExecute || !commandLink.HideWhenInactive) { this.Page.ApplicationBar.MenuItems.Add(button); } }
private void UpdateMenuItemCanExecute(ICommandLink commandLink, ApplicationBarMenuItem button) { if (commandLink == null || commandLink.Command == null) { return; } bool canExecute = commandLink.Command.CanExecute(null); button.IsEnabled = canExecute; button.Text = commandLink.Text; if (!commandLink.HideWhenInactive) { return; } if (this.Page == null || this.Page.ApplicationBar == null || this.Page.ApplicationBar.MenuItems == null || canExecute == this.Page.ApplicationBar.MenuItems.Contains(button)) { return; } if (canExecute) { this.Page.ApplicationBar.MenuItems.Add(button); } else { this.Page.ApplicationBar.MenuItems.Remove(button); } }
public MessageLink(ICommandLink commandLink, IEnumerable <IMessageParser> messageParsers) { this.commandLink = commandLink; this.messageParsers = messageParsers; this.incomingMessages = new Subject <IMessage>(); this.commandLink.IncomingCommands.Subscribe(this.OnNewCommand); }
private void CreateCommandLink(ICommandLink commandLink) { var commandNode = this.ViewModel.GetOrCreateCommandNode(this.FindViewModel(commandLink.CommandReference.Value.AsElement().Id)); foreach (var component in this.ViewModel.GetAllComponentsNode(commandLink.Parent.Parent.AsElement().Id)) { this.ViewModel.GetOrCreateCommandConnection(component, commandNode); } }
public LoadCommand( ISettingsModel settingsModel, ICommandLink commandLink, EepromFieldToLoadCommandConverter fieldToCommandConverter) { this.commandLink = commandLink; this.settingsModel = settingsModel; this.fieldToCommandConverter = fieldToCommandConverter; }
public TerminalViewModel(ICommandLink commandLink, IScheduler dispatcherScheduler) { this.Lines = new ObservableCollection <string>(); this.EnterLineCommand = new RelayCommand <string>(NewUserCommand, _ => true); this.commandLink = commandLink; this.commandLink.IncomingCommands .ObserveOn(dispatcherScheduler) .Subscribe(OnNewCommand); }
private void CreateCommandLink(ICommandLink commandLink) { var commandNode = this.ViewModel.GetOrCreateCommandNode(this.FindViewModel(commandLink.CommandReference.Value.AsElement().Id)); foreach (var component in this.ViewModel.GetAllComponentsNode(commandLink.Parent.Parent.AsElement().Id)) { this.ViewModel.GetOrCreateCommandConnection(component, commandNode); } }
public ArmCommand(ICommandLink commandLink) { this.commandLink = commandLink; }
public static string GetMessageTypeFullName(this ICommandLink commandlink) { return(commandlink.CommandReference.Value.Parent.Namespace + "." + commandlink.CommandReference.Value.CodeIdentifier); }
public SaveCommand(ICommandLink commandLink) { this.commandLink = commandLink; }
public ThrottleCommand(ICommandLink commandLink) { this.commandLink = commandLink; }