ICommandExtension::Execute Method (IMenuCommand^)

 

Invoked when the user clicks this command on the menu.

Namespace:   Microsoft.VisualStudio.Modeling.ExtensionEnablement
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

void Execute(
	IMenuCommand^ command
)

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.

Return to top
Show: