Example #1
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);
                }
            }
        }
        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);
            //    }
            //}
        }
Example #3
0
 private static CommandHandlerWrapper CreateCommandHandlerWrapper(
     Type commandDefinitionType, object commandHandler)
 {
     if (typeof(CommandListDefinition).IsAssignableFrom(commandDefinitionType))
     {
         return(CommandHandlerWrapper.FromCommandListHandler(CommandListHandlerInterfaceType.MakeGenericType(commandDefinitionType), commandHandler));
     }
     if (typeof(CommandDefinition).IsAssignableFrom(commandDefinitionType))
     {
         return(CommandHandlerWrapper.FromCommandHandler(CommandHandlerInterfaceType.MakeGenericType(commandDefinitionType), commandHandler));
     }
     throw new InvalidOperationException();
 }
Example #4
0
        public Task <Result <TResult> > Execute <TResult>([NotNull] ICommand <TResult> command)
        {
            Guard.AgainstNullArgument("command", command);

            this._commandsCounter.Increment();

            Type    handlerType          = typeof(ICommandHandler <,>).MakeGenericType(command.GetType(), typeof(TResult));
            dynamic actualCommandHandler = this._container.Resolve(handlerType);

            var wrapper = new CommandHandlerWrapper <TResult>(this, actualCommandHandler);
            var result  = wrapper.Execute(command);

            this._commandsCounter.Decrement();

            return(result);
        }
Example #5
0
        /// <inheritdoc />
        /// <summary>
        /// Updates Menu
        /// </summary>
        /// <param name="commandHandler"></param>
        public void Update(CommandHandlerWrapper commandHandler)
        {
            foreach (var listItem in _listItems)
            {
                _parent.Items.Remove(listItem);
            }
            _listItems.Clear();
            var listCommands = new List <CommandDefinitionBase>();

            commandHandler.Populate(null, listCommands);
            var startIndex = _parent.Items.IndexOf(this) + 1;

            foreach (var command in listCommands)
            {
                var id          = new CommandBarCommandItemDefinition(Guid.Empty, (uint)startIndex, command);
                var newMenuItem = new MenuItem(id);
                if (command is CommandDefinition commandDefinition && commandDefinition.IsChecked)
                {
                    id.IsChecked = true;
                }
                _parent.Items.Insert(startIndex++, newMenuItem);
                _listItems.Add(newMenuItem);
            }
        }
Example #6
0
 void ICommandUiItem.Update(CommandHandlerWrapper commandHandler)
 {
     // TODO
 }