예제 #1
0
        public void DrawOnMap(Block blok, Point click)
        {
            if (QueueChecked)
            {
                //checkbox is checked
                if (CurrentMap.GetElement(blok.X, blok.Y) != Convert.ToInt32(blok.TypeBlock))
                {
                    RedoUndo newAction = new RedoUndo(blok, this);
                    UndoHistory.Push(newAction);
                    Queue tempQueue = new Queue(blok.X, blok.Y, Convert.ToInt32(blok.TypeBlock), this);
                    tempQueue.QueueTask();
                }
            }
            else
            {
                if (CurrentMap.GetElement(blok.X, blok.Y) != Convert.ToInt32(blok.TypeBlock))
                {
                    RedoUndo newAction = new RedoUndo(blok, this);
                    UndoHistory.Push(newAction);
                    CurrentMap.SetElement(blok.X, blok.Y, Convert.ToInt32(blok.TypeBlock));
                    //if ((int)click.X % BlockScale == 0 || (int)click.Y % BlockScale == 0)
                    //{


                    RenderMap();


                    //}
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Redos the last change made and pushes it to the undo stack,
 /// if possible.
 /// </summary>
 public void Redo()
 {
     if (CanRedo())
     {
         UndoHistory.Push(new AppPalUndo(Palette, RedoHistory.Peek().Name));
         var state = RedoHistory.Pop();
         SetPalette(state.Palette, false);
     }
 }
예제 #3
0
        /// <summary>
        /// Handles the event that occurs when the undo menu is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void UndoTextMenuClick(object sender, EventArgs e)
        {
            string edit  = (string)EditHistory.Pop(); // Edit string
            int    loc   = (int)EditHistory.Pop();    // Location of edit
            bool   isDel = (bool)EditHistory.Pop();   // Indicates whether the edit is a deletion

            UndoHistory.Push(isDel);
            UndoHistory.Push(loc);
            UndoHistory.Push(edit);
            DoEdit(!isDel, loc, edit);
        }
예제 #4
0
        /// <summary>
        /// Redos the last change made and pushes it to the undo stack,
        /// if possible.
        /// </summary>
        public void Redo()
        {
            if (CanRedo())
            {
                UndoHistory.Push(new AppState(HsvColor, SchemeType));
                AppState s = RedoHistory.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());
            }
        }
예제 #5
0
파일: Game.cs 프로젝트: mloup/diaballik
        // Ne Marche pas ! (Le Board de ma commande n'est pas le Board de ma game actuelle)
        public void UndoLastCommand()
        {
            Command LastCmdToUndo = CommandHistory.Pop().GetCommand();

            if (LastCmdToUndo.CanUndo(this))
            {
                LastCmdToUndo.Undo(this);
                UndoHistory.Push(new CommandMemento(LastCmdToUndo));
                if (LastCmdToUndo is MovePiece)
                {
                    MovePieceCount--;
                }
                if (LastCmdToUndo is MoveBall)
                {
                    MoveBallCount--;
                }
            }
            else
            {
                throw new InvalidOperationException("Impossible de défaire la dernière action :" + LastCmdToUndo.GetType() + " : " + LastCmdToUndo.ToString());
            }
        }
예제 #6
0
 /// <summary>
 /// Pushes the current state of the application to the undo stack, and purges the redo stack.
 /// </summary>
 private void PushUndo()
 {
     UndoHistory.Push(new AppState(HsvColor, SchemeType));
     RedoHistory.Clear();
 }
예제 #7
0
 /// <summary>
 /// Pushes the current state of the application to the undo stack, and purges the redo stack.
 /// </summary>
 private void PushUndo(string action)
 {
     UndoHistory.Push(new AppPalUndo(Palette, action));
     RedoHistory.Clear();
 }