UndoList<T>

public class UndoList<T>
Provides an undo/redo list mechanism.
TType constraint.

Constructors

UndoList

#
public UndoList(T initial)
Create a new undo/redo list.
initial (T)Initial current state.

Properties

CanRedo

#
public bool CanRedo { get; }
Gets whether a redo operation is possible.

CanUndo

#
public bool CanUndo { get; }
Gets whether an undo operation is possible.

Current

#
public T Current { get; set; }
Gets or sets the current state. When set, the redo list will be cleared and the current "current" state will be pushing onto the undo stack.

RedoCount

#
public int RedoCount { get; }
Gets the number of redo records.

RedoRecords

#
public IEnumerable<T> RedoRecords { get; }
Enumerates over all redo records, starting with the most recent one.

UndoCount

#
public int UndoCount { get; }
Gets the number of undo records.

UndoRecords

#
public IEnumerable<T> UndoRecords { get; }
Enumerates over all undo records, starting with the most recent one.

Methods

Clear

#
public void Clear()
Erase all undo and redo records.

Clear

#
public void Clear(bool clearUndo, bool clearRedo)
Erase undo and/or redo records. Only call this overload if you know what you are doing. Typically you always want to clear *both* buffers at the same time.
clearUndo (bool)If true, the undo buffer will be erased.
clearRedo (bool)If true, the redo buffer will be erased.

FirstRedoRecord

#
public bool FirstRedoRecord(out T record)
Gets the first redo record, if any.
record (out T)First record.
True if there was a record.

FirstUndoRecord

#
public bool FirstUndoRecord(out T record)
Gets the first undo record, if any.
record (out T)First record.
True if there was a record.

PerformRedo

#
public bool PerformRedo()
Perform a single redo step. This will move a the current state onto the undo stack and pop the most recent redo record into the current state.
Redo record.

PerformUndo

#
public bool PerformUndo()
Perform a single undo step. This will move the current state onto the redo stack and pop the most recent undo record into the current state.
True if an undo was performed.

SetCurrentQuietly

#
public void SetCurrentQuietly(T state)
Set the current state without affecting the undo and redo stacks. Use this method if you wish to update the current state without recording an undo record.
state (T)