예제 #1
0
        /**
         * A newer TextStorage is loaded using a memento object.
         */
        public void Redo()
        {
            SnapShot backup = RedoStack.PopFromStack();

            if (backup != null)
            {
                textStorage.RestoreStorage(backup.text);
            }
        }
예제 #2
0
 /**
  * If there exists a backup, it will be used to obtain
  * newer text written by the user.
  */
 public void Redo()
 {
     if (!RedoStack.IsEmpty())
     {
         if (backup != null)
         {
             backup.Redo();
         }
     }
     else
     {
         Console.WriteLine("There is nothing to redo...\n");
     }
 }
예제 #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);
            }
        }