Exemplo n.º 1
0
        /// <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();
            }
        }
Exemplo n.º 2
0
        public static IUndoRedoRecord Pop(this  List <IUndoRedoRecord> list)
        {
            IUndoRedoRecord ret = list[0];

            list.RemoveAt(0);
            return(ret);
        }
Exemplo n.º 3
0
 /// <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);
     }
 }
Exemplo n.º 4
0
 /// <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);
 }
Exemplo n.º 6
0
 public void AddUndoRedoOperation(IUndoRedoRecord operation)
 {
     _undoRedoOperations.Insert(0, operation);
 }
Exemplo n.º 7
0
 public static void Push(this List <IUndoRedoRecord> list, IUndoRedoRecord item)
 {
     list.Insert(0, item);
 }
 public void AddUndoRedoOperation(IUndoRedoRecord operation)
 {
     m_UndoRedoOperations.Push(operation);
 }
Exemplo n.º 9
0
 public void AddUndoRedoOperation(IUndoRedoRecord operation)
 {
     _undoRedoOperations.Insert(0, operation);
 }
Exemplo n.º 10
0
 /// <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);
     }
 }