Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
1/5/2010
This class specifies the enhancements to the default Shell View menu system.
Namespace: Microsoft.RemoteToolSdk.PluginComponents
Assembly: Microsoft.RemoteToolSdk (in microsoft.remotetoolsdk.dll)
Syntax
public class CommandUI
'Declaration
Public Class CommandUI
Remarks
Your code does not create this class, it is available via the CommandUI property of the T:Microsoft.RemoteToolSdk.PluginComponents.PluginComponent class.
This object contains a list of T:Microsoft.RemoteToolSdk.PluginComponents.CommandUICommand objects via the P:Microsoft.RemoteToolSdk.PluginComponents.CommandUI.PluginCommands property. Each CommandUICommand object defines one enhancement to the menu system. All of the CommandUICommand objects in the PluginCommands list will be available on the Shell menus while the associated plug-in is selected in the TreeView control.
If your plug-in wishes to have a menu item available when any TreeView node of the plug-in is selected (such as Help...About), you should add the menu enhancement in the OnInit()method of your T:Microsoft.RemoteToolSdk.PluginComponents.PluginComponent class.
If your plug-in wishes to have a menu item available only when a particular node is selected, you will need to add or remove the CommandUICommand object(s) in response to the PluginComponent.OnNodeSelected or PluginComponent.OnNodeUnselected method calls.
Inheritance Hierarchy
System.Object
Microsoft.RemoteToolSdk.PluginComponents.CommandUI
Example
The following example shows how to add a menu enhancement that is visible when any node of a certain plug-in is selected:
(implemented in your PluginComponent-based class)
protected override void OnInit(
bool standalone
)
{
... (code omitted for clarity) ...
CommandUICommand helpAbout =
new CommandUICommand(
CommandUI.CommandRoot.HelpMenu, // Root off the Help menu
"About My Plug-in..." // Text of our menu enhancement
);
helpAbout.Clicked +=
new EventHandler(helpAbout_Clicked);
base.CommandUI.PluginCommands.Add(helpAbout);
}
private void helpAbout_Clicked(object sender, EventArgs e)
{
AboutBox aboutBox = new AboutBox();
aboutBox.ShowDialog();
}
The following example shows how to add a menu enhancement for only when a node is selected.
(implemented in your PluginComponent-based class)
protected override void OnInit(
bool standalone
)
{
... (code omitted for clarity) ...
mySpecialNode = new PluginNode ( ... );
CommandUICommand nodeCommand =
new CommandUICommand(
CommandUI.CommandRoot.FileMenu, // Root off the File menu
"Properties..." // Text of our menu enhancement
);
nodeCommand.Clicked +=
new EventHandler(nodeCommand_Clicked);
}
protected override void OnNodeSelected(
PluginNode node
)
{
if (node == mySpecialNode)
{
base.CommandUI.PluginCommands.Add(nodeCommand);
}
}
protected override void OnNodeUnselected(
PluginNode node
)
{
if (node == mySpecialNode)
{
base.CommandUI.PluginCommands.Remove(nodeCommand);
}
}
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.
See Also
Reference
CommandUI Members
Microsoft.RemoteToolSdk.PluginComponents Namespace