OleMenuCommandService Class
This class derives from the MenuCommandService class and implements IOleCommandTarget. MenuCommandService is the managed class used to add handlers for menu commands and to define verbs.
This API is not CLS-compliant.
Inheritance Hierarchy
System.Object
System.ComponentModel.Design.MenuCommandService
Microsoft.VisualStudio.Shell.OleMenuCommandService
Namespace: Microsoft.VisualStudio.Shell
Assembly: Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
Syntax
'Declaration
<CLSCompliantAttribute(False)> _
<ComVisibleAttribute(True)> _
Public Class OleMenuCommandService _
Inherits MenuCommandService _
Implements IOleCommandTarget
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public class OleMenuCommandService : MenuCommandService,
IOleCommandTarget
[CLSCompliantAttribute(false)]
[ComVisibleAttribute(true)]
public ref class OleMenuCommandService : public MenuCommandService,
IOleCommandTarget
[<CLSCompliantAttribute(false)>]
[<ComVisibleAttribute(true)>]
type OleMenuCommandService =
class
inherit MenuCommandService
interface IOleCommandTarget
end
public class OleMenuCommandService extends MenuCommandService implements IOleCommandTarget
The OleMenuCommandService type exposes the following members.
Constructors
Name | Description | |
---|---|---|
OleMenuCommandService(IServiceProvider) | Creates a new menu command service. | |
OleMenuCommandService(IServiceProvider, IOleCommandTarget) | Creates a new menu command service. |
Top
Properties
Name | Description | |
---|---|---|
ParentTarget | Gets or sets the parent command target. | |
ServiceProvider | Obsolete. Gets the service provider. | |
Verbs | Gets a collection of the designer verbs that are currently available. (Inherited from MenuCommandService.) |
Top
Methods
Name | Description | |
---|---|---|
AddCommand | Adds a command handler to the menu command service. (Inherited from MenuCommandService.) | |
AddVerb | Adds a verb to the verb table of the MenuCommandService. (Inherited from MenuCommandService.) | |
Dispose() | Releases all resources used by the MenuCommandService. (Inherited from MenuCommandService.) | |
Dispose(Boolean) | Releases all resources used by the MenuCommandService. (Inherited from MenuCommandService.) | |
EnsureVerbs | Ensures that the verb list has been created. (Inherited from MenuCommandService.) | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FindCommand(CommandID) | Searches for the MenuCommand associated with the given command ID. (Inherited from MenuCommandService.) | |
FindCommand(Guid, Int32) | Searches for the MenuCommand associated with the given command. (Inherited from MenuCommandService.) | |
GetCommandList | Gets the command list for a given GUID. (Inherited from MenuCommandService.) | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetService | Gets a reference to the requested service. (Inherited from MenuCommandService.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GlobalInvoke(CommandID) | Can be used to invoke any command within Visual Studio. (Overrides MenuCommandService.GlobalInvoke(CommandID).) | |
GlobalInvoke(CommandID, Object) | Can be used to invoke any command within Visual Studio. (Overrides MenuCommandService.GlobalInvoke(CommandID, Object).) | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
OnCommandsChanged | Called by a menu command when its status has changed. (Overrides MenuCommandService.OnCommandsChanged(MenuCommandsChangedEventArgs).) | |
RemoveCommand | Removes the given menu command from the document. (Inherited from MenuCommandService.) | |
RemoveVerb | Removes the given verb from the document. (Inherited from MenuCommandService.) | |
ShowContextMenu | Shows the shortcut menu with the given command ID at the given location. (Overrides MenuCommandService.ShowContextMenu(CommandID, Int32, Int32).) | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Events
Name | Description | |
---|---|---|
MenuCommandsChanged | Occurs when the status of a menu command has changed. (Inherited from MenuCommandService.) |
Top
Explicit Interface Implementations
Name | Description | |
---|---|---|
IOleCommandTarget.Exec | Infrastructure. Executes the selected command. | |
IOleCommandTarget.QueryStatus | Infrastructure. Sets command status. |
Top
Remarks
OleMenuCommandService is automatically offered by the Package class (to offer global commands for an entire package), and it is also offered by the WindowPane class (to offer commands for the current window). This offering is always done via the service container, so anyone deriving from the Package or WindowPane classes can remove or replace the default implementation of this class. This class uses several other services. All of these services are optional, so the class's behavior will degrade if one or more services are missing. The following table shows which services are used and for what purpose:
Service |
Use |
---|---|
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. |
IVsUIShell |
Used to notify Visual Studio that the command status has changed. Used to execute global commands |
OleComponentUIManager |
Used to show context menus |
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.