Inheritance: System.MarshalByRefObject
        public void Redo()
        {
            if (undoListCount == changeList.Count)
            {
                return;
            }

            UndoRedoChange change = (UndoRedoChange)changeList [undoListCount++];

            if (change.CheckValid())
            {
                UndoRedoChange res = change.ApplyChange();
                if (res != null)
                {
                    changeList [undoListCount - 1] = res;
                }
                else
                {
                    // Redo failed
                    undoListCount--;
                    changeList.RemoveAt(undoListCount);
                }
            }
            else
            {
                changeList.RemoveAt(--undoListCount);
                Redo();
            }
        }
        public void Undo()
        {
            if (undoListCount == 0)
            {
                return;
            }

            UndoRedoChange change = (UndoRedoChange)changeList [--undoListCount];

            if (change.CheckValid())
            {
                UndoRedoChange res = change.ApplyChange();
                if (res != null)
                {
                    changeList [undoListCount] = res;
                }
                else
                {
                    // Undo failed
                    changeList.RemoveAt(undoListCount);
                }
            }
            else
            {
                changeList.RemoveAt(undoListCount);
                Undo();
            }
        }
Exemplo n.º 3
0
		public void AddChange (UndoRedoChange change)
		{
			if (undoListCount < changeList.Count) {
				// Destroy all undone changes
				changeList.RemoveRange (undoListCount, changeList.Count - undoListCount);
			}
			changeList.Add (change);
			undoListCount = changeList.Count;
		}
 public void AddChange(UndoRedoChange change)
 {
     if (undoListCount < changeList.Count)
     {
         // Destroy all undone changes
         changeList.RemoveRange(undoListCount, changeList.Count - undoListCount);
     }
     changeList.Add(change);
     undoListCount = changeList.Count;
 }
 public void Purge()
 {
     for (int n = 0; n < changeList.Count; n++)
     {
         UndoRedoChange change = (UndoRedoChange)changeList [n];
         if (!change.CheckValid())
         {
             changeList.RemoveAt(n);
             if (n < undoListCount)
             {
                 undoListCount--;
             }
         }
     }
 }