MenuCommandService 類別

定義

實作 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
實作

備註

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

類別會由 package 類別自動提供, 以提供整個封裝的全域命令, 而且Microsoft.VisualStudio.Shell.WindowPane類別也會提供它, 以提供目前視窗的命令。 MenuCommandServiceThe 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 類別的新執行個體。Initializes a new instance of the MenuCommandService class.

屬性

Verbs

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

方法

AddCommand(MenuCommand)

將命令處理常式加入至功能表命令服務。Adds a command handler to the menu command service.

AddVerb(DesignerVerb)

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

Dispose()

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

Dispose(Boolean)

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

EnsureVerbs()

確定已建立動詞命令清單。Ensures that the verb list has been created.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
FindCommand(CommandID)

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

FindCommand(Guid, Int32)

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

GetCommandList(Guid)

取得指定 GUID 的命令清單。Gets the command list for a given GUID.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetService(Type)

取得所要求服務的參考。Gets a reference to the requested service.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GlobalInvoke(CommandID)

在本機表單上,或在全域環境中,叫用指定的命令。Invokes the given command on the local form or in the global environment.

GlobalInvoke(CommandID, Object)

在本機表單上,或在全域環境中,叫用具有指定參數的指定命令。Invokes the given command with the given parameter on the local form or in the global environment.

MemberwiseClone()

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

(繼承來源 Object)
OnCommandsChanged(MenuCommandsChangedEventArgs)

引發 MenuCommandsChanged 事件。Raises the MenuCommandsChanged event.

RemoveCommand(MenuCommand)

從文件中移除指定的功能表命令。Removes the given menu command from the document.

RemoveVerb(DesignerVerb)

從文件中移除指定的動詞命令。Removes the given verb from the document.

ShowContextMenu(CommandID, Int32, Int32)

在指定位置顯示具有指定命令 ID 的捷徑功能表。Shows the shortcut menu with the given command ID at the given location.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

事件

MenuCommandsChanged

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

適用於

另請參閱