ICommandExtension::Execute Method (IMenuCommand^)
Visual Studio 2015
Invoked when the user clicks this command on the menu.
Assembly: Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)
Parameters
- command
-
Type:
Microsoft.VisualStudio.Modeling.ExtensionEnablement::IMenuCommand^
IMenuCommand
Declare an imported property Context in order to access the diagram and model:
[Import]
public IDiagramContext Context { get; set; }
public void Execute (IMenuCommand command)
{
foreach (IShape<IElement> in
Context.CurrentDiagram.GetSelectedShapes<IElement>())
{...}}
If your command performs more than one change in the model, consider grouping them together in a single transaction using ILinkedUndoTransaction, so that the user can undo them with a single undo operation.
For more information, see Define a menu command on a modeling diagram.
Show: