Exemplo n.º 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();


                    //}
                }
            }
        }
Exemplo n.º 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);
     }
 }
Exemplo n.º 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);
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 5
0
        // 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());
            }
        }
Exemplo n.º 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();
 }
Exemplo n.º 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();
 }