示例#1
0
 /**
  * Places the provided SnapShot on top
  * of the stack.
  *
  * parameter snapShot: The one to put on top of the stack
  */
 public static void PushToStack(SnapShot snapShot)
 {
     if (snapShot != null)
     {
         redoStack.Push(snapShot);
     }
 }
示例#2
0
        /**
         * A newer TextStorage is loaded using a memento object.
         */
        public void Redo()
        {
            SnapShot backup = RedoStack.PopFromStack();

            if (backup != null)
            {
                textStorage.RestoreStorage(backup.text);
            }
        }
示例#3
0
        /**
         * An older TextStorage is loaded using a memento object.
         * Allows Redo functionality by saving this SnapShot
         * to another stack.
         * Makes sure that text is empty if a backup doesn't exist.
         */
        public void Undo()
        {
            if (UndoStack.PeekAtStack() != null)
            {
                RedoStack.PushToStack(UndoStack.PeekAtStack());
            }

            SnapShot backup = UndoStack.PopFromStack();

            if (backup == null)
            {
                textStorage.RestoreStorage("");
            }
            else
            {
                textStorage.RestoreStorage(backup.text);
            }
        }
示例#4
0
 /**
  * Places the provided SnapShot on top
  * of the stack.
  *
  * parameter snapShot: The one to put on top of the stack
  */
 public static void PushToStack(SnapShot snapShot)
 {
     undoStack.Push(snapShot);
 }
示例#5
0
 /**
  * Makes a backup by creating a snapshot
  * of the provided TextStorage.
  *
  * parameter storage: The TextStorage object to create a backup of
  */
 public void MakeBackup(TextStorage storage)
 {
     backup = storage.CreateSnapshot();
     UndoStack.PushToStack(backup);
 }