/// <summary> /// Initializes a new instance of the CommandMenuBuilderEntry class. This constructor is used for /// the command menu entry. /// </summary> /// <param name="position">Merge menu entry position.</param> /// <param name="text">Merge menu entry text.</param> /// <param name="command">Merge menu entry command.</param> public CommandMenuBuilderEntry(CommandMenuBuilder commandMenuBuilder, int level, int position, string text, Command command) { this.commandMenuBuilder = commandMenuBuilder; this.level = level; this.position = position; this.text = text; // if (command != null) // this.text = command.Identifier; this.command = command; }
/// <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()); }
/// <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> /// Initializes a new instance of the CommandMenuBuilderEntry class. /// </summary> public CommandMenuBuilderEntry(CommandMenuBuilder commandMenuBuilder) { this.commandMenuBuilder = commandMenuBuilder; this.level = -1; }
/// <summary> /// Initializes a new instance of the CommandMenuBuilderEntry class. This constructor is used for /// top level and "container" menu items. /// </summary> /// <param name="position">Merge menu entry position.</param> /// <param name="text">Merge menu entry text.</param> public CommandMenuBuilderEntry(CommandMenuBuilder commandMenuBuilder, int level, int position, string text) : this(commandMenuBuilder, level, position, text, null) { }
/// <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()); }