Esempio n. 1
0
        public void RedoLastCommand()
        {
            if (UndoHistory.Count == 0)
            {
                throw new InvalidOperationException("Il n'y a aucune action à redo.");
            }
            Command LastCmdToRedo = UndoHistory.Pop().GetCommand();

            if (LastCmdToRedo.CanDo(this))
            {
                LastCmdToRedo.Do(this);
                CommandHistory.Push(new CommandMemento(LastCmdToRedo));
                if (LastCmdToRedo is MovePiece)
                {
                    MovePieceCount++;
                }
                if (LastCmdToRedo is MoveBall)
                {
                    MoveBallCount++;
                }
            }
            else
            {
                throw new InvalidOperationException("Impossible de refaire la dernière action :" + LastCmdToRedo.GetType() + "\n");
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Undoes the last change made and pushes it to the redo stack,
 /// if possible.
 /// </summary>
 public void Undo()
 {
     if (CanUndo())
     {
         RedoHistory.Push(new AppPalUndo(Palette, UndoHistory.Peek().Name));
         var state = UndoHistory.Pop();
         SetPalette(state.Palette, false);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Handles the event that occurs when the redo menu is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RedoTextMenuClick(object sender, EventArgs e)
        {
            string edit  = (string)UndoHistory.Pop(); // Edit string
            int    loc   = (int)UndoHistory.Pop();    // Location of edit
            bool   isDel = (bool)UndoHistory.Pop();   // Indicates whether the edit is a deletion

            EditHistory.Push(isDel);
            EditHistory.Push(loc);
            EditHistory.Push(edit);
            DoEdit(isDel, loc, edit);
        }
Esempio n. 4
0
        /// <summary>
        /// Undoes the last change made and pushes it to the redo stack,
        /// if possible.
        /// </summary>
        public void Undo()
        {
            if (CanUndo())
            {
                RedoHistory.Push(new AppState(HsvColor, SchemeType));
                AppState s = UndoHistory.Pop();
                SetColor(s.Color, false, false);
                SetSchemeType(s.SchemeType, false, false);

                // because we didn't use the setters to fire events
                // because we'd be wastefully firing two otherwise
                OnResultChanged(new EventArgs());
            }
        }