/// <summary> /// Adds a HistorySet to the pending list and tries to commit it. /// </summary> public void Add(HistorySet hs) { _pendingUndo.Add(hs.Undo); _pendingRedo.Add(hs.Redo); TryCommit(); }
/// <summary> /// Restores the next state. /// </summary> public void Redo() { if (_redo.Count > 0) { HistorySet hs = _redo.Last.Value; _redo.RemoveLast(); hs.Redo(); _undo.AddLast(hs); } }
/// <summary> /// Commits pending undo and redo to the undo and redo stacks. /// </summary> public void Commit() { if (_pendingUndo.Count > 0 && _pendingRedo.Count > 0) { _pendingUndo.Reverse(); HistorySet hs = new HistorySet(_pendingUndo.ToArray(), _pendingRedo.ToArray()); _redo.Clear(); if (_historyHandler != null) { _historyHandler.Add(hs); } else { hs.Redo(); _undo.AddLast(hs); } _pendingRedo.Clear(); _pendingUndo.Clear(); } }