MenuCommandService MenuCommandService MenuCommandService MenuCommandService Class


實作 IMenuCommandService 介面。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


MenuCommandService類別會實作IMenuCommandService介面,這是用來加入功能表命令的處理常式,並定義動詞命令的受管理的介面。The MenuCommandService class implements the IMenuCommandService interface, which is the managed interface used to add handlers for menu commands and to define verbs.

MenuCommandService類別會自動提供套件類別會提供全域命令的完整封裝,並也提供的Microsoft.VisualStudio.Shell.WindowPane類別,以提供目前視窗的命令。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. 此供應項目都是透過服務容器,所以任何人都衍生自封裝或視窗窗格類別可以移除或取代的預設實作IMenuCommandService介面。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.

MenuCommandService類別會利用數個其他服務。The MenuCommandService class utilizes several other services. 所有這些服務是選擇性的因此行為MenuCommandService類別會降低,如果有一個或更多服務已遺失。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 使用 Visual Studio 的命令狀態已變更的通知。Used to notify Visual Studio that the command status has changed.
Microsoft.VisualStudio.Shell.Interop.IOleComponentUIManager 用來顯示內容功能表。Used to show context menus.


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

初始化 MenuCommandService 類別的新執行個體。Initializes a new instance of the MenuCommandService class.


Verbs Verbs Verbs Verbs

取得目前可用的設計工具動詞命令集合。Gets a collection of the designer verbs that are currently available.


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)

將動詞命令加入至 MenuCommandService 的 verb 表格。Adds a verb to the verb table of the MenuCommandService.

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

釋放 MenuCommandService 所使用的所有資源。Releases all resources used by the MenuCommandService.

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

釋放 MenuCommandService 所使用的所有資源。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)

搜尋與指定命令 ID 相關聯的 MenuCommandSearches for the MenuCommand associated with the given command ID.

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

搜索與指定命令相關聯的 MenuCommandSearches for the MenuCommand associated with the given command.

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

取得指定 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()

取得目前執行個體的 TypeGets 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()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

引發 MenuCommandsChanged 事件。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)

在指定位置顯示具有指定命令 ID 的捷徑功能表。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)


MenuCommandsChanged MenuCommandsChanged MenuCommandsChanged MenuCommandsChanged

發生於功能表命令狀態變更時。Occurs when the status of a menu command has changed.