Exemple #1
0
 private static CommandHandlerWrapper CreateCommandHandlerWrapper(
     Type commandDefinitionType, object commandHandler)
 {
     if (typeof(CommandDefinition).IsAssignableFrom(commandDefinitionType))
     {
         return(CommandHandlerWrapper.FromCommandHandler(CommandHandlerInterfaceType.MakeGenericType(commandDefinitionType), commandHandler));
     }
     if (typeof(CommandListDefinition).IsAssignableFrom(commandDefinitionType))
     {
         return(CommandHandlerWrapper.FromCommandListHandler(CommandListHandlerInterfaceType.MakeGenericType(commandDefinitionType), commandHandler));
     }
     throw new InvalidOperationException();
 }
 void ICommandUiItem.Update(CommandHandlerWrapper commandHandler)
 {
     // TODO
 }
Exemple #3
0
        void ICommandUiItem.Update(CommandHandlerWrapper commandHandler)
        {
            if (_command != null && _command.CommandDefinition.IsList && !IsListItem)
            {
                foreach (var listItem in _listItems)
                    _parent.Children.Remove(listItem);

                _listItems.Clear();

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

                _command.Visible = false;

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

                foreach (var command in listCommands)
                {
                    var newMenuItem = new CommandMenuItem(command, _parent)
                    {
                        IsListItem = true
                    };
                    _parent.Children.Insert(startIndex++, newMenuItem);
                    _listItems.Add(newMenuItem);
                }
            }
        }