Beispiel #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);
     }
 }
Beispiel #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);
            }
        }
Beispiel #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);
            }
        }
Beispiel #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);
 }
Beispiel #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);
 }