/// <summary>
        /// Builds the menu items of this CommandContextMenu from the specified CommandCollection.
        /// </summary>
        /// <param name="commandContextMenuDefinition">The CommandCollection.</param>
        private void BuildMenuItems(CommandCollection commandCollection)
        {
            CommandMenuBuilder commandMenuBuilder = new CommandMenuBuilder(commandBar ? MenuType.CommandBarContext : MenuType.Context);

            foreach (Command command in commandCollection)
            {
                if (command.On)
                {
                    commandMenuBuilder.MergeCommand(command);
                }
            }
            MenuItems.AddRange(commandMenuBuilder.CreateMenuItems());
        }
Exemple #2
0
        /// <summary>
        /// Builds a menu of the specified MenuType from the commands in the command manager.
        /// </summary>
        /// <param name="menuType">Specifies the type of menu to build.</param>
        /// <returns>An array of MenuItem values for the menu.</returns>
        public MenuItem[] BuildMenu(MenuType menuType)
        {
            //	Instantiate a new CommandMenuBuilder so we can build the menu from the set of
            //	commands in this command manager.
            CommandMenuBuilder commandMenuBuilder = new CommandMenuBuilder(menuType);

            //	Enumerate the commands and merge each one into the merge menu.
            foreach (CommandInstanceManager commandInstanceManager in commandTable.Values)
            {
                if (commandInstanceManager.ActiveCommandInstance != null && commandInstanceManager.ActiveCommandInstance.On)
                {
                    commandMenuBuilder.MergeCommand(commandInstanceManager.ActiveCommandInstance);
                }
            }

            //	Return the menu items.
            return(commandMenuBuilder.CreateMenuItems());
        }
        /// <summary>
        /// Builds a menu of the specified MenuType from the commands in the command manager.
        /// </summary>
        /// <param name="menuType">Specifies the type of menu to build.</param>
        /// <returns>An array of MenuItem values for the menu.</returns>
        public MenuItem[] BuildMenu(MenuType menuType)
        {
            //	Instantiate a new CommandMenuBuilder so we can build the menu from the set of
            //	commands in this command manager.
            CommandMenuBuilder commandMenuBuilder = new CommandMenuBuilder(menuType);

            //	Enumerate the commands and merge each one into the merge menu.
            foreach (CommandInstanceManager commandInstanceManager in commandTable.Values)
            {
                if (commandInstanceManager.ActiveCommandInstance != null && commandInstanceManager.ActiveCommandInstance.On)
                    commandMenuBuilder.MergeCommand(commandInstanceManager.ActiveCommandInstance);
            }

            //	Return the menu items.
            return commandMenuBuilder.CreateMenuItems();
        }
 /// <summary>
 /// Builds the menu items of this CommandContextMenu from the specified CommandCollection.
 /// </summary>
 /// <param name="commandContextMenuDefinition">The CommandCollection.</param>
 private void BuildMenuItems(CommandCollection commandCollection)
 {
     CommandMenuBuilder commandMenuBuilder = new CommandMenuBuilder(commandBar ? MenuType.CommandBarContext : MenuType.Context);
     foreach (Command command in commandCollection)
         if (command.On)
             commandMenuBuilder.MergeCommand(command);
     MenuItems.AddRange(commandMenuBuilder.CreateMenuItems());
 }