/// <summary> /// Performs an undo operation /// </summary> public void Undo() { try { _undoGoingOn = true; if (_undoStack.Count == 0) { throw new InvalidOperationException("Nothing in the undo stack"); } IUndoRedoRecord oUndoData = _undoStack.Pop(); Type undoDataType = oUndoData.GetType(); ///If the stored operation was a transaction, perform the undo as a transaction too. if (typeof(UndoTransaction).Equals(undoDataType)) { StartTransaction(oUndoData as UndoTransaction); } undoDataType.InvokeMember("Execute", BindingFlags.InvokeMethod, null, oUndoData, null); } catch (Exception ex) { Trace.TraceError(ex.Message); } finally { _undoGoingOn = false; EndTransaction(_curTran); FireUndoStackStatusChanged(); } }
public static IUndoRedoRecord Pop(this List <IUndoRedoRecord> list) { IUndoRedoRecord ret = list[0]; list.RemoveAt(0); return(ret); }
/// <summary> /// Adds the undo redo operation. /// </summary> /// <param name="operation">The operation.</param> public void AddUndoRedoOperation(IUndoRedoRecord operation) { if (this.isFifo) { this.undoRedoOperationsQueue.Enqueue(operation); } else { this.undoRedoOperationsStack.Push(operation); } }
/// <summary> /// Executes the operation saved in the collections. /// </summary> public void Execute() { if (this.isFifo) { while (this.undoRedoOperationsQueue.Count > 0) { IUndoRedoRecord currentRecord = this.undoRedoOperationsQueue.Dequeue(); currentRecord.Execute(); } } else { while (this.undoRedoOperationsStack.Count > 0) { IUndoRedoRecord currentRecord = this.undoRedoOperationsStack.Pop(); currentRecord.Execute(); } } }
/// <summary> /// Pushes the specified list. /// </summary> /// <param name="list">The list.</param> /// <param name="item">The item.</param> public static void Push(this List<IUndoRedoRecord> list, IUndoRedoRecord item) { list.Insert(0, item); }
public void AddUndoRedoOperation(IUndoRedoRecord operation) { _undoRedoOperations.Insert(0, operation); }
public static void Push(this List <IUndoRedoRecord> list, IUndoRedoRecord item) { list.Insert(0, item); }
public void AddUndoRedoOperation(IUndoRedoRecord operation) { m_UndoRedoOperations.Push(operation); }
public void AddUndoRedoOperation(IUndoRedoRecord operation) { _undoRedoOperations.Insert(0, operation); }
/// <summary> /// Adds the undo redo operation. /// </summary> /// <param name="operation">The operation.</param> public void AddUndoRedoOperation(IUndoRedoRecord operation) { if (this.isFifo) { this.undoRedoOperationsQueue.Enqueue(operation); } else { this.undoRedoOperationsStack.Push(operation); } }