Provides methods to manage the global designer verbs and menu commands available in design mode, and to show some types of shortcut menus.
See Also: IMenuCommandService Members
This interface provides methods to:
Find, invoke, add and remove global designer verb commands.
Find, invoke, add and remove standard menu commands.
Alter the event handlers associated with standard menu commands.
Display a shortcut menu of standard commands that is associated with a menu System.ComponentModel.Design.CommandID.
Designer verbs represent custom-defined commands that are listed on the shortcut menu in design mode. A designer verb can provide a specified text label. Each designer verb is automatically assigned a unique System.ComponentModel.Design.CommandID. A designer can provide designer verbs through its IDesigner.Verbs property, but these are only available when the designer's component is currently selected. Global designer verbs are designer verb commands that can be accessed from a design-mode shortcut menu regardless of the selected component. This interface allows you to manage the set of global designer verbs that are available in design mode.
You can add a global designer verb using the IMenuCommandService.AddVerb(DesignerVerb) method, and you can remove a global designer verb using the IMenuCommandService.RemoveVerb(DesignerVerb) method. You can invoke a designer verb using the IMenuCommandService.GlobalInvoke(CommandID) method if you know the System.ComponentModel.Design.CommandID of the verb. The IMenuCommandService.Verbs property of this interface contains the current set of designer verb commands to display in a shortcut menu. This set of designer verb commands consists of all global designer verbs and any designer verbs offered by the designer of any currently selected component. This set of verbs is updated each time a component with a designer offering designer verb commands is selected or deselected.
Menu commands are limited to the set of predefined standard commands. Most of the predefined standard commands are defined in the System.ComponentModel.Design.StandardCommands and System.Windows.Forms.Design.MenuCommands enumerations. You can add, remove, and invoke menu commands, and search for menu commands that have been added to a menu using methods of this interface.
You can add a standard menu command using the IMenuCommandService.AddCommand(MenuCommand) method, and remove a standard menu command using the IMenuCommandService.RemoveCommand(MenuCommand) method. You can attach an event handler to a predefined standard menu command by following the procedure detailed in the documentation for the IMenuCommandService.AddCommand(MenuCommand) method. You can retrieve a menu command by System.ComponentModel.Design.CommandID if it has been added to a menu using the IMenuCommandService.FindCommand(CommandID) method. You can invoke a menu command or designer verb command by System.ComponentModel.Design.CommandID using the IMenuCommandService.GlobalInvoke(CommandID) method.
An attempt to add a menu command with an already existing System.ComponentModel.Design.CommandID will throw an InvalidOperationException. When adding a menu command, be sure to check that it is not already on a menu using the IMenuCommandService.FindCommand(CommandID) method, or use exception handling wisely.
A menu command can be added to a menu, and have its MenuCommand.Visible or MenuCommand.Enabled properties set to false. If you cannot visually locate a menu command that has been added on a menu, one of these properties may have been set to false.
You can show certain standard shortcut menus containing menu commands at a specified location using the IMenuCommandService.ShowContextMenu(CommandID, int, int) method. The documentation for this method contains a table listing the command IDs that specify the valid menus to show.