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
Assembly: MindFusion.Diagramming
Syntax
C#
Copy Code
|
---|
public class CompositeCmd : Command |
Visual Basic
Copy Code
|
---|
Public Class CompositeCmd Inherits Command |
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
See Also