MenuCommandService MenuCommandService MenuCommandService MenuCommandService Class

Definition

Implements the IMenuCommandService interface.

public ref class MenuCommandService : IDisposable, System::ComponentModel::Design::IMenuCommandService
public class MenuCommandService : IDisposable, System.ComponentModel.Design.IMenuCommandService
type MenuCommandService = class
    interface IMenuCommandService
    interface IDisposable
Public Class MenuCommandService
Implements IDisposable, IMenuCommandService
Inheritance
MenuCommandServiceMenuCommandServiceMenuCommandServiceMenuCommandService
Implements

Remarks

The MenuCommandService class implements the IMenuCommandService interface, which is the managed interface used to add handlers for menu commands and to define verbs.

The MenuCommandService class is automatically offered by the package class to offer global commands for an entire package, and it is also offered by the Microsoft.VisualStudio.Shell.WindowPane class to offer commands for the current window. This offering is always done through the service container, so anyone deriving from the package or window pane classes can remove or replace the default implementation of the IMenuCommandService interface.

The MenuCommandService class utilizes several other services. All of these services are optional, so the behavior of the MenuCommandService class degrades if one or more services are missing. The following table shows which services are used and for what purpose.

Service Purpose
ISelectionService Used to discover the current selection in order to obtain verbs offered by the currently selected designer.
IDesignerHost Used to obtain the designer for the currently selected component, if any.
Microsoft.VisualStudio.Shell.Interop.IVsUIShell Used to notify Visual Studio that the command status has changed.
Microsoft.VisualStudio.Shell.Interop.IOleComponentUIManager Used to show context menus.

Constructors

MenuCommandService(IServiceProvider) MenuCommandService(IServiceProvider) MenuCommandService(IServiceProvider) MenuCommandService(IServiceProvider)

Initializes a new instance of the MenuCommandService class.

Properties

Verbs Verbs Verbs Verbs

Gets a collection of the designer verbs that are currently available.

Methods

AddCommand(MenuCommand) AddCommand(MenuCommand) AddCommand(MenuCommand) AddCommand(MenuCommand)

Adds a command handler to the menu command service.

AddVerb(DesignerVerb) AddVerb(DesignerVerb) AddVerb(DesignerVerb) AddVerb(DesignerVerb)

Adds a verb to the verb table of the MenuCommandService.

Dispose() Dispose() Dispose() Dispose()

Releases all resources used by the MenuCommandService.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases all resources used by the MenuCommandService.

EnsureVerbs() EnsureVerbs() EnsureVerbs() EnsureVerbs()

Ensures that the verb list has been created.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindCommand(CommandID) FindCommand(CommandID) FindCommand(CommandID) FindCommand(CommandID)

Searches for the MenuCommand associated with the given command ID.

FindCommand(Guid, Int32) FindCommand(Guid, Int32) FindCommand(Guid, Int32) FindCommand(Guid, Int32)

Searches for the MenuCommand associated with the given command.

GetCommandList(Guid) GetCommandList(Guid) GetCommandList(Guid) GetCommandList(Guid)

Gets the command list for a given GUID.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetService(Type) GetService(Type) GetService(Type) GetService(Type)

Gets a reference to the requested service.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
GlobalInvoke(CommandID) GlobalInvoke(CommandID) GlobalInvoke(CommandID) GlobalInvoke(CommandID)

Invokes the given command on the local form or in the global environment.

GlobalInvoke(CommandID, Object) GlobalInvoke(CommandID, Object) GlobalInvoke(CommandID, Object) GlobalInvoke(CommandID, Object)

Invokes the given command with the given parameter on the local form or in the global environment.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnCommandsChanged(MenuCommandsChangedEventArgs) OnCommandsChanged(MenuCommandsChangedEventArgs) OnCommandsChanged(MenuCommandsChangedEventArgs) OnCommandsChanged(MenuCommandsChangedEventArgs)

Raises the MenuCommandsChanged event.

RemoveCommand(MenuCommand) RemoveCommand(MenuCommand) RemoveCommand(MenuCommand) RemoveCommand(MenuCommand)

Removes the given menu command from the document.

RemoveVerb(DesignerVerb) RemoveVerb(DesignerVerb) RemoveVerb(DesignerVerb) RemoveVerb(DesignerVerb)

Removes the given verb from the document.

ShowContextMenu(CommandID, Int32, Int32) ShowContextMenu(CommandID, Int32, Int32) ShowContextMenu(CommandID, Int32, Int32) ShowContextMenu(CommandID, Int32, Int32)

Shows the shortcut menu with the given command ID at the given location.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Events

MenuCommandsChanged MenuCommandsChanged MenuCommandsChanged MenuCommandsChanged

Occurs when the status of a menu command has changed.

Applies to

See also