ASP.NET Pack Programmer's Guide
CompositeCmd Class
Remarks See Also
 





Represents a set of Command instances as a single operation. Undoing or redoing the composite action, respectively undoes or redoes all its constituent subactions at the same time.

Namespace: MindFusion.Diagramming.Commands
Package: MindFusion.Diagramming

 Syntax

C#  Copy Code

public class CompositeCmd : Command

Visual Basic  Copy Code

Public Class CompositeCmd
    Inherits Command

 Remarks

To add a subaction to the composite call the AddSubCmd method. The Execute method executes all subactions and adds the composite to undo manager's history.

 Example

C#  Copy Code

if (diagram.Selection.Nodes.Count == 0)
    return;

// Make all changes seem like a single operation by
// putting them in composite Command
CompositeCmd composite = new CompositeCmd(diagram, "Change selection");

foreach (DiagramNode node in diagram.Selection.Nodes)
{
    ShapeNode shape = node as ShapeNode;
    if (shape == null)
        continue;

    // Save item state
    ChangeItemCmd propChange = new ChangeItemCmd(shape, "Change");

    // Change properties
    shape.Text = "new text";
    shape.Brush = new SolidBrush(Color.Blue);

    // Add to the composite
    composite.AddSubCmd(propChange);
}

// Store final state of all contained commands
composite.Execute();

Visual Basic  Copy Code

If diagram.Selection.Nodes.Count = 0 Then
    Return
End If

' Make all changes seem like a single operation by
' putting them in composite Command
Dim composite As CompositeCmd = New CompositeCmd(diagram, "Change selection")

Dim node As DiagramNode
For Each node In diagram.Selection.Nodes

    Dim shape As ShapeNode = CType(node, ShapeNode)

    If Not shape Is Nothing Then

        ' Save item state
        Dim propChange As ChangeItemCmd = New ChangeItemCmd(shape, "Change")

        ' Change properties
        shape.Text = "new text"
        shape.Brush = New SolidBrush(Color.Blue)

        ' Add to the composite
        composite.AddSubCmd(propChange)

    End If

Next

' Store final state of all contained commands
composite.Execute()

 Inheritance Hierarchy

System.Object
    MindFusion.Diagramming.Commands.Command
        MindFusion.Diagramming.Commands.CompositeCmd

 See Also

CompositeCmd Members
MindFusion.Diagramming.Commands Namespace