Method BeginMacro
BeginMacro(string)
Begins composition of a macro command with the given text description.
An empty command described by the specified text is pushed on the stack. Any subsequent commands pushed on the stack will be appended to the macro command's children until EndMacro() is called.
While a macro is being composed, the stack is disabled. This means that:
- Events are not emitted.
- canRedo and canUndo will always return false.
- Calling Undo() or Redo() has no effect.
The stack is re-enabled when the macro is ended.
Here is an example of how to use macros:
undoStack.BeginMacro("Insert Red Text");
undoStack.Push(new InsertText(...));
undoStack.Push(new SetRedText(...));
undoStack.EndMacro();
This code is equivalent to:
var insertRedText = new UndoCommand("Insert Text");
new InsertText(..., insertRedText);
new SetRedText(..., insertRedText);
undoStack.Push(insertRedText);
Declaration
public void BeginMacro(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the macro command. |
Remarks
Nested calls to BeginMacro(string) are supported, but every call to BeginMacro(string) must have a corresponding call to EndMacro().