Compartir a través de


ICommandExtension.Execute Method

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)

Syntax

'Declaration
Sub Execute ( _
    command As IMenuCommand _
)
void Execute(
    IMenuCommand command
)
void Execute(
    IMenuCommand^ command
)
abstract Execute : 
        command:IMenuCommand -> unit
function Execute(
    command : IMenuCommand
)

Parameters

Remarks

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 How to: Define a Menu Command on a Modeling Diagram.

.NET Framework Security

See Also

Reference

ICommandExtension Interface

Microsoft.VisualStudio.Modeling.ExtensionEnablement Namespace