/// <summary> /// Ends the transaction under which all undo/redo operations take place /// </summary> /// <param name="tran"></param> public void EndTransaction(UndoTransaction tran) { if (_curTran == tran) { _curTran = null; ///now we might have had no items added to undo and redo stack as a part of this transaction. Check empty transaction at top and remove them if (_undoStack.Count > 0) { UndoTransaction t = _undoStack[0] as UndoTransaction; if (t != null && t.OperationsCount == 0) { _undoStack.Pop(); } } if (_redoStack.Count > 0) { UndoTransaction t = _redoStack[0] as UndoTransaction; if (t != null && t.OperationsCount == 0) { _redoStack.Pop(); } } } }
/// <summary> /// Starts a transaction under which all undo redo operations take place /// </summary> /// <param name="tran"></param> public void StartTransaction(UndoTransaction tran) { if (_curTran == null) { _curTran = tran; ///push an empty undo operation _undoStack.Push(new UndoTransaction(tran.Name)); _redoStack.Push(new UndoTransaction(tran.Name)); } }