ICommandExtension::QueryStatus Method (IMenuCommand^)
Visual Studio 2015
Implement this to define whether your command should be visible and enabled. Set command.Visible and command.Enabled. Do not change the state of the model.
Assembly: Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)
Parameters
- command
-
Type:
Microsoft.VisualStudio.Modeling.ExtensionEnablement::IMenuCommand^
Set command.Visible = true if the command should appear on the menu. Set command.Enabled = true if the user can invoke the command.Set command.Text to vary the menu label.
Declare an imported property Context in order to access the diagram and model:
[Import]
public IDiagramContext Context { get; set; }
public void Execute (IMenuCommand command)
{
command.Enabled = command.Visible =
Context.CurrentDiagram
.GetSelectedShapes<IClassifier>().Count() > 2;
}
For more information, see Define a menu command on a modeling diagram.
Show: