private void CheckPopUnit(PopUnitReason reason) { if ((reason != PopUnitReason.Normal) || !this._host.InTransaction) { UndoUnit unit = (UndoUnit)this._unitStack.Pop(); if (!unit.IsEmpty) { unit.Close(); if (reason != PopUnitReason.TransactionCancel) { if (this._unitStack.Count == 0) { this.AddUndoUnit(unit); } } else { unit.Undo(); if (this._unitStack.Count == 0) { this.DiscardUndoUnit(unit); } } } else if (this._unitStack.Count == 0) { this.DiscardUndoUnit(unit); } } }
public void DoRedo() { if (this.currentPos < this.undoUnitList.Count) { UndoUnit undoUnit = this.undoUnitList[this.currentPos]; undoUnit.Undo(); this.currentPos++; } this.UpdateUndoRedoMenuCommandsStatus(); }
public void DoUndo() { if (this.currentPos > 0) { UndoUnit undoUnit = this.undoUnitList[this.currentPos - 1]; undoUnit.Undo(); this.currentPos--; } this.UpdateUndoRedoMenuCommandsStatus(); }
public void Undo(int actionsCount) { if (actionsCount <= 0 || actionsCount > _undoUnits.Count) { return; } for (; actionsCount != 0; actionsCount--) { UndoUnit unit = _undoUnits.Pop(); // Console.WriteLine ("undo: " + unit.Name); unit.Undo(); _redoUnits.Push(unit); } }