Description
The Forward
property represents a stack of Entry
objects that are used to manage redo operations in the UndoSystem
. This stack is cleared whenever a new undo action is added, ensuring that redo operations are only available for the most recent set of actions that have been undone.
Usage
Use the Forward
property to access the stack of redo entries. This stack is automatically managed by the UndoSystem
and should not be modified directly. Instead, use the Undo
and Redo
methods to manipulate the undo and redo stacks.
Example
// Example of using the UndoSystem with Forward stack
// Initialize the UndoSystem
UndoSystem undoSystem = new UndoSystem();
undoSystem.Initialize();
// Insert an undoable action
undoSystem.Insert("Change Color",
undo: () => { /* Code to undo the color change */ },
redo: () => { /* Code to redo the color change */ }
);
// Perform an undo operation
if (undoSystem.Undo())
{
// Check the Forward stack
var redoStack = undoSystem.Forward;
Console.WriteLine($"Redo stack count: {redoStack.Count}");
}
// Perform a redo operation
if (undoSystem.Redo())
{
// The Forward stack should be empty after a redo
Console.WriteLine($"Redo stack count after redo: {undoSystem.Forward.Count}");
}