public void Undo() { try { _undoInProgress = true; Debug.WriteLine("UndoRedo Manager Available undo actions count: " + _undoActions.Count); if (_undoActions.Count == 0) { return; } object oUndoAction = ListOperations.Pop(_undoActions); Type undoDataType = oUndoAction.GetType(); if (typeof(UndoTransaction).Equals(undoDataType)) { StartTransaction(oUndoAction as UndoTransaction); } undoDataType.InvokeMember("Execute", BindingFlags.InvokeMethod, null, oUndoAction, null); } catch (Exception ex) { Debug.WriteLine(ex.Message); } finally { _undoInProgress = false; EndTransaction(_curTran); } }
public void EndTransaction(UndoTransaction tran) { if (_curTran == tran) { _curTran = null; if (_undoActions.Count > 0) { UndoTransaction t = _undoActions[0] as UndoTransaction; if (t != null && t.OperationsCount == 0) { ListOperations.Pop(_undoActions); } } if (_redoActions.Count > 0) { UndoTransaction t = _redoActions[0] as UndoTransaction; if (t != null && t.OperationsCount == 0) { ListOperations.Pop(_redoActions); } } } }