Пример #1
0
        /// <summary>
        /// Ends the transaction under which all undo/redo operations take place
        /// </summary>
        /// <param name="tran"></param>
        public void EndTransaction(UndoRedoTransaction tran)
        {
            if (m_CurTran == tran)
            {
                m_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 (m_UndoStack.Count > 0)
                {
                    UndoRedoTransaction t = m_UndoStack[0] as UndoRedoTransaction;
                    if (t != null && t.OperationsCount == 0)
                    {
                        m_UndoStack.Pop();
                    }
                }

                if (m_RedoStack.Count > 0)
                {
                    UndoRedoTransaction t = m_RedoStack[0] as UndoRedoTransaction;
                    if (t != null && t.OperationsCount == 0)
                    {
                        m_RedoStack.Pop();
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Starts a transaction under which all undo redo operations take place
 /// </summary>
 /// <param name="tran"></param>
 public void StartTransaction(UndoRedoTransaction tran)
 {
     if (m_CurTran == null)
     {
         m_CurTran = tran;
         ///push an empty undo operation
         m_UndoStack.Push(new UndoRedoTransaction(tran.Name));
         m_RedoStack.Push(new UndoRedoTransaction(tran.Name));
     }
 }