コード例 #1
0
        void IMesCommandUiItem.Update(MesCommandHandlerWrapper commandHandler)
        {
            if (_command != null && _command.CommandDefinition.IsList && !IsListItem)
            {
                foreach (MesStandardMenuItem listItem in _listItems)
                {
                    _parent.Children.Remove(listItem);
                }

                _listItems.Clear();

                List <MesCommand> listCommands = new List <MesCommand>();
                commandHandler.Populate(_command, listCommands);

                _command.Visible = false;

                Int32 startIndex = _parent.Children.IndexOf(this) + 1;

                foreach (MesCommand command in listCommands)
                {
                    MesCommandMenuItem newMenuItem = new MesCommandMenuItem(command, _parent)
                    {
                        IsListItem = true
                    };
                    _parent.Children.Insert(startIndex++, newMenuItem);
                    _listItems.Add(newMenuItem);
                }
            }
        }
コード例 #2
0
        public async void Execute(Object parameter)
        {
            MesCommandHandlerWrapper commandHandler = _commandRouter.GetCommandHandler(_command.CommandDefinition);

            if (commandHandler == null)
            {
                return;
            }

            await commandHandler.Run(_command);
        }
コード例 #3
0
        public Boolean CanExecute(Object parameter)
        {
            MesCommandHandlerWrapper commandHandler = _commandRouter.GetCommandHandler(_command.CommandDefinition);

            if (commandHandler == null)
            {
                return(false);
            }

            commandHandler.Update(_command);

            return(_command.Enabled);
        }
コード例 #4
0
        private static MesCommandHandlerWrapper CreateCommandHandlerWrapper(Type commandDefinitionType, Object commandHandler)
        {
            if (typeof(MesCommandDefinition).IsAssignableFrom(commandDefinitionType))
            {
                return(MesCommandHandlerWrapper.FromCommandHandler(CommandHandlerInterfaceType.MakeGenericType(commandDefinitionType), commandHandler));
            }

            if (typeof(MesCommandListDefinition).IsAssignableFrom(commandDefinitionType))
            {
                return(MesCommandHandlerWrapper.FromCommandListHandler(CommandListHandlerInterfaceType.MakeGenericType(commandDefinitionType), commandHandler));
            }

            throw new InvalidOperationException();
        }
コード例 #5
0
 void IMesCommandUiItem.Update(MesCommandHandlerWrapper commandHandler)
 {
     // TODO
 }