Sometimes you might prefer having a set of actions undo and redo as a single atomic operation. WpfDiagram provides the CompositeCmd class to help you with that. CompositeCmd objects act as containers of other Command-derived objects. When Undo or Redo are invoked on a composite command, all its subcommands are respectively undone or redone.
To add a command to the composite call the AddSubCmd method. Call Execute to execute all subcommands contained in the composite. Subcommands are executed or redone in the same order in which they were added to the container, and are undone in the opposite order.
Often WpfDiagram implicitly generates Command objects in response to users actions or method calls, and automatically records them in the history queue. You do not have direct access to those commands and cannot add them to a composite by AddSubCmd. To enable creating composites in such cases, the undo manager provides the notion of active composite. Active composite is created by calling the StartComposite function of UndoManager. Each action executed after that is made part of the composite, instead of adding it directly to the command history. Invoking the Execute method of the current composite completes it and saves it in the history queue.
C# Copy Code |
---|
// Implicitly created undo records will be saved here |
Visual Basic Copy Code |
---|
' Implicitly created undo records will be saved here |