Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 5
0
 public LoadCommand(
     ISettingsModel settingsModel,
     ICommandLink commandLink,
     EepromFieldToLoadCommandConverter fieldToCommandConverter)
 {
     this.commandLink             = commandLink;
     this.settingsModel           = settingsModel;
     this.fieldToCommandConverter = fieldToCommandConverter;
 }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 8
0
 public ArmCommand(ICommandLink commandLink)
 {
     this.commandLink = commandLink;
 }
Exemplo n.º 9
0
 public static string GetMessageTypeFullName(this ICommandLink commandlink)
 {
     return(commandlink.CommandReference.Value.Parent.Namespace + "." + commandlink.CommandReference.Value.CodeIdentifier);
 }
Exemplo n.º 10
0
 public SaveCommand(ICommandLink commandLink)
 {
     this.commandLink = commandLink;
 }
Exemplo n.º 11
0
 public ThrottleCommand(ICommandLink commandLink)
 {
     this.commandLink = commandLink;
 }