public void Redo() { if (!CanRedo) { throw new InvalidOperationException("Redo stack is empty"); } var memento = redoStack.Pop(); changeTracker.TrackChanges = false; changeTracker.OnBeforeRedo(memento); if (BeforeRedo != null) { BeforeRedo(this, new UndoRedoEventArgs { Memento = memento }); } memento = memento.Restore(); undoStack.Push(memento); if (AfterRedo != null) { AfterRedo(this, new UndoRedoEventArgs { Memento = memento }); } changeTracker.TrackChanges = trackChanges; }
public void Redo() { if (!CanRedo) { throw new InvalidOperationException("Redo stack is empty"); } var memento = redoStack.Pop(); changeTracker.AddNewMementoCallback = AddUndoForRedo; if (BeforeRedo != null) { BeforeRedo(this, new UndoRedoEventArgs { Memento = memento }); } changeTracker.OnBeforeRedo(memento); try { EditActionSettings.Disabled = true; memento.Restore(); } finally { EditActionSettings.Disabled = false; } changeTracker.OnAfterRedo(memento); if (AfterRedo != null) { AfterRedo(this, new UndoRedoEventArgs { Memento = memento }); } changeTracker.AddNewMementoCallback = AddUndo; }