Пример #1
0
 private void ClearRedoStack()
 {
     if (RedoStack.Count != 0)
     {
         RedoStack.Clear();
     }
 }
Пример #2
0
        public void Redo()
        {
            if (RedoStack.Count == 0)
            {
                return;
            }

            var operationNode        = RedoStack.Last;
            var currentTransactionId = operationNode.Value.TransactionId;

            while (operationNode != null && operationNode.Value.TransactionId == currentTransactionId)
            {
                var prev      = operationNode.Previous;
                var operation = RedoStack.Last.Value;
                operation.Redo();

                // Add operation into Undo stack.
                UndoStack.AddLast(operation);

                // Remove from redo stack.
                RedoStack.RemoveLast();

                operationNode = prev;
            }

            ++ActiveTransactionIdCount;
        }
Пример #3
0
 /// <summary>
 /// Reduce the size of the Undo stack to the specified maximum
 /// </summary>
 private void LimitRedoStackSize()
 {
     while (RedoStack.Count > _MaxStackSize)
     {
         RedoStack.RemoveAt(0);
     }
 }
        //pop items from undo stack and push in redo
        public string Undo()
        {
            string i = UndoStack.Pop();

            RedoStack.Push(i);
            return(UndoStack.First());
        }
        /// <summary>
        /// Constructor
        /// </summary>
        public UndoRedoStack()
            : base()
        {
            this.UndoCommand = new RelayCommand(() => {
                if (UndoStack.Count > 0)
                {
                    var cmd = UndoStack.Pop();
                    RedoStack.Push(cmd);
                    cmd.Undo();
                    CanExecuteChanged();
                }
            },
                                                () => UndoStack.Count > 0);

            this.RedoCommand = new RelayCommand(() => {
                if (RedoStack.Count > 0)
                {
                    var cmd = RedoStack.Pop();
                    UndoStack.Push(cmd);
                    cmd.Redo();
                    CanExecuteChanged();
                }
            },
                                                () => RedoStack.Count > 0);

            this.AddSavePointCommand        = new RelayCommand <string>(AddSavePoint, text => this.UndoStack.Count > 0 && !this.UndoStack.First().IsSavePoint);
            this.RollbackToSavePointCommand = new RelayCommand(RollbackSavePoint, () => {
                return(this.UndoStack.Any(cmd => cmd.IsSavePoint)
                    ? this.UndoStack.Multiple(c => c.IsSavePoint) ? true : !this.UndoStack.First().IsSavePoint
                    : false);
            });
        }
Пример #6
0
        /*******************************************************
         * Undo button Click
         *
         * Arguments: Object Sender and EventArgs e
         * Return Type: void
         * Use Case:
         ******************************************************/
        private void UndoButton_Click(object sender, EventArgs e)
        {
            textBox1.Text = "Undo";
            if (UndoStack.Count > 0)
            {
                string      action = UndoStack.Pop();
                PaintAction newAction;

                switch (action)
                {
                case "Line":
                    newAction = lines[lines.Count - 1];
                    RedoStack.Push(newAction);

                    lines.RemoveAt(lines.Count - 1);
                    lines.TrimExcess();
                    break;

                case "Stroke":
                    newAction = strokes[strokes.Count - 1];
                    RedoStack.Push(newAction);

                    strokes.RemoveAt(strokes.Count - 1);
                    strokes.TrimExcess();
                    break;

                default:
                    Console.WriteLine("Undo Button Error!");
                    break;
                }
            }

            PaintCanvas.Refresh();
        }
Пример #7
0
 /// <summary>
 /// 記録されている操作をクリアします。
 /// </summary>
 public void Clear()
 {
     UndoStack.Clear();
     RedoStack.Clear();
     LastCommittedOperation = null;
     OperationHistoryChanged?.Invoke(this, EventArgs.Empty);
 }
Пример #8
0
        private void ChangeSettings_Click(object sender, EventArgs e)
        {
            AcmeSettingsHost settings = new AcmeSettingsHost();

            settings.Telemetry = _telemetry;

            AcmeOptions tempOptions = new AcmeOptions(null);

            settings.TopLeft       = new Point(Left, Top);
            settings.EditorOptions = tempOptions;
            settings.Telemetry     = _telemetry;

            DialogResult dr = settings.ShowDialog();

            if (dr == DialogResult.OK)
            {
                _editorOptions = tempOptions.Clone();
                SetDisplayOptions();
                Display.Chemistry = _lastCml;
                RedoStack.SetOptions(_editorOptions);
                UndoStack.SetOptions(_editorOptions);
                UndoStack.ListOfDisplays.ItemsSource = StackToList(_undoStack);
                RedoStack.ListOfDisplays.ItemsSource = StackToList(_redoStack);
            }

            settings.Close();
        }
Пример #9
0
 internal void Clear()
 {
     LastSave = 0;
     UndoStack.Clear();
     RedoStack.Clear();
     UpdateUI();
 }
Пример #10
0
        public async Task GameTurn(CancellationTokenSource cancellationTokenSource)
        {
            if (PlayerOnTurn.IsAI)
            {
                await(PlayerOnTurn.TryToPlay(GameBoard, cancellationTokenSource));
            }
            if (!cancellationTokenSource.IsCancellationRequested)
            {
                if (!PlayerOnTurn.Finished)
                {
                    await PlayerOnTurn.Selection(ToIntToRow(SelectedPosition), ToIntToCol(SelectedPosition), GameBoard, cancellationTokenSource);

                    if (PlayerOnTurn.PlayerMove[(int)GameConstants.MoveParts.result] == (int)GameConstants.MoveResult.Fail && !PlayerOnTurn.StartPositionSelected)
                    {
                        SelectedPosition = "none - Failed Move, Play again.";
                    }
                }
                if (PlayerOnTurn.Finished)
                {
                    GameHistory.Push(new List <int>(PlayerOnTurn.PlayerMove));
                    PlayerOnTurn.PlayerMove.ForEach(Console.Write);
                    PlayerOnTurn.Finished = false;
                    CheckEndGame();
                    RedoStack.Clear();
                    BestMove = null;
                    EndTurn();
                }
            }
        }
Пример #11
0
 public void Redo()
 {
     var redo = RedoStack.Pop();
     UndoStack.Push(redo);
     redo.Redo();
     if (RedoStack.Count > 0) OnPropertyChanged(nameof(CanRedo));
 }
Пример #12
0
        /// <inheritdoc />
        public Task PointerPressedExecuteAsync()
        {
            // Add entry to UndoStack
            UndoStack.Push(ShapeList.DeepCopy());
            RedoStack.Clear();

            // Set pointer starting point
            _pointerStart = PointerEventArgs.GetCurrentPoint(Canvas).Position;


            // Create new shape
            PaintBase shape = new PaintShape(ShapeType);

            shape.X = _pointerStart.X;
            shape.Y = _pointerStart.Y;

            shape.Width  = 2;
            shape.Height = 2;

            ShapeList.Add(shape);
            current = shape;

            _page.Draw();
            _page.UpdateList();

            return(Task.CompletedTask);
        }
Пример #13
0
        private void HandleChangedCml(string cml, string captionPrefix)
        {
            var cc = new CMLConverter();

            if (_lastCml != EmptyCml)
            {
                var clone = cc.Import(_lastCml);
                Debug.WriteLine(
                    $"Pushing F: {clone.ConciseFormula} BL: {clone.MeanBondLength.ToString("#,##0.00")} onto Stack");
                _undoStack.Push(clone);
            }

            Model m = cc.Import(cml);

            m.Relabel(true);
            m.EnsureBondLength(20, false);
            _lastCml = cc.Export(m);

            // Cause re-read of settings (in case they have changed)
            _editorOptions = new AcmeOptions(null);
            SetDisplayOptions();
            RedoStack.SetOptions(_editorOptions);
            UndoStack.SetOptions(_editorOptions);

            ShowChemistry($"{captionPrefix} {m.ConciseFormula}", m);
        }
Пример #14
0
 /// <summary>
 /// Moves the entire redo stack onto the undo stack, in order.
 /// </summary>
 public void MoveRedoStackBackToUndo()
 {
     while (RedoStack.Count > 0)
     {
         UndoStack.Push(RedoStack.Pop());
     }
 }
Пример #15
0
        private void ExecuteDeleteDiagramCommand(object parameter)
        {
            var redomemo = new Action <object>((obj) => Characters.Remove(parameter as DiagramViewModel));

            var undomemo = new Action <object>((obj) => ExecuteDropCommand(parameter));

            if (!_isUndoHandle)
            {
                UndoStack.Push(new UndoRedoManager()
                {
                    ActionComment = $"delete diagram of {(parameter as DiagramViewModel).Name} . ",
                    RedoAction    = redomemo,
                    UndoAction    = undomemo,
                });
            }
            else
            {
                RedoStack.Push(new UndoRedoManager()
                {
                    ActionComment = $"undo delete diagram of {(parameter as DiagramViewModel).Name} . ",
                    RedoAction    = undomemo,
                    UndoAction    = redomemo,
                });

                _isUndoHandle = false;
            }

            redomemo(null);
        }
Пример #16
0
        /// <summary>
        /// Sets top property from RedoStack to old value
        /// </summary>
        public static void Redo()
        {
            _lastChangeWasUndo = true;
            PropertyInfo propinfo = MainRoot.GetType().GetProperty(RedoStack.Peek().Property);

            propinfo.SetValue(MainRoot, RedoStack.Pop().OldValue);
        }
Пример #17
0
 /// <summary>
 /// Add an undo state to the current stage (if one is active) or directly
 /// to the stack as a new stage (if one isn't).
 /// </summary>
 /// <param name="state"></param>
 /// <param name="clearRedo">If true, the redo stack will be invalidated</param>
 public void AddUndoState(UndoState state, bool clearRedo = true)
 {
     if (!Locked && Active)
     {
         if (state != null && state.IsValid)
         {
             if (ActiveStage != null)// && !ActiveStage.Contains(state))
             {
                 ActiveStage.Add(state);
                 if (!UndoStack.Contains(ActiveStage))
                 {
                     AddUndoStage(ActiveStage);
                 }
             }
             else
             {
                 UndoStage stage = new UndoStage();
                 stage.Add(state);
                 AddUndoStage(stage);
             }
         }
         if (clearRedo)
         {
             RedoStack.Clear();
         }
     }
 }
Пример #18
0
 public void AddScope(UndoScope scope)
 {
     if (scope == null) return;
     if (!scope.HasChanges) return;
     RedoStack.Clear();
     UndoStack.Push(scope);
     if (UndoStack.Count == 1) OnPropertyChanged(nameof(CanUndo));
 }
Пример #19
0
 private void OnRedoCommandExecute()
 {
     disableUndoRedoLogic = true;
     Text = RedoStack.Pop();
     UndoStack.Push(Text);
     ((DelegateCommand)UndoCommand).RaiseCanExecuteChanged();
     ((DelegateCommand)RedoCommand).RaiseCanExecuteChanged();
 }
Пример #20
0
 public void Undo()
 {
     var undo = UndoStack.Pop();
     RedoStack.Push(undo);
     undo.Undo();
     if (UndoStack.Count > 0) OnPropertyChanged(nameof(CanUndo));
     OnPropertyChanged(nameof(CanRedo));
 }
Пример #21
0
        private void DoUndo()
        {
            var undoCommand = UndoStack.Pop();

            undoCommand.Undo();
            RedoStack.Push(undoCommand);
            StackStatesChanged();
        }
Пример #22
0
        /// <summary>
        /// Juggles stacks to "Undo" the latest recorded action
        /// </summary>
        public void Undo()
        {
            var undoAct = UndoStack.Pop();

            undoAct();
            BackupStack.Push(undoAct);
            RedoStack.Push(DoStack.Pop());
        }
Пример #23
0
        /// <summary>
        /// Juggles stacks to "Redo the latest recorded undone action"
        /// </summary>
        public void Redo()
        {
            var redoAct = RedoStack.Pop();

            redoAct();
            DoStack.Push(redoAct);
            UndoStack.Push(BackupStack.Pop());
        }
Пример #24
0
        private void DoRedo()
        {
            var redoCommand = RedoStack.Pop();

            redoCommand.Do();
            UndoStack.Push(redoCommand);
            StackStatesChanged();
        }
Пример #25
0
        /// <summary>
        /// 直後の操作をやり直します。
        /// </summary>
        public void Redo()
        {
            IOperation op = RedoStack.Pop();

            op.Redo();
            UndoStack.Push(op);
            OperationHistoryChanged?.Invoke(this, EventArgs.Empty);
        }
Пример #26
0
        private void ExecuteRedoCommand(object parameter)
        {
            var redo = RedoStack.Pop();

            _isUndoHandle = false;

            redo.RedoAction(redo);
        }
Пример #27
0
 private void UpdateControls()
 {
     SetDisplayOptions();
     Display.Chemistry = _lastCml;
     RedoStack.SetOptions(_editorOptions);
     UndoStack.SetOptions(_editorOptions);
     UndoStack.ListOfDisplays.ItemsSource = StackToList(_undoStack);
     RedoStack.ListOfDisplays.ItemsSource = StackToList(_redoStack);
 }
Пример #28
0
 /// <summary>
 /// Calls the Do function for the top item in the RedoStack. If there is nothing in the stack, does nothing.
 /// </summary>
 public void Redo()
 {
     if (CanRedo)
     {
         IAction a = RedoStack.Pop();
         a.DoAction();
         UndoStack.Push(a);
     }
 }
Пример #29
0
 /// <summary>
 /// Calls the Undo function for the top item in the UndoStack. If there is nothing in the stack, does nothing.
 /// </summary>
 public void Undo()
 {
     if (CanUndo)
     {
         IAction a = UndoStack.Pop();
         a.UndoAction();
         RedoStack.Push(a);
     }
 }
Пример #30
0
        private void DesignerWindow_Load(object sender, EventArgs e)
        {
            redoStack      = new RedoStack();
            undoStack      = new UndoStack();
            copyCollection = new List <BaseGump>();

            designerFrame.BeforeBaseGumpChanged += new EventHandler <EventArgs>(designerFrame_BeforeBaseGumpChanged);
            designerFrame.BeforeBaseGumpMoved   += new EventHandler <EventArgs>(designerFrame_BeforeBaseGumpMoved);
        }
Пример #31
0
        protected override void OnLoad(EventArgs e)
        {
            Location = new Point(Program.Settings.GetValue<int>("mainform_x", Location.X),
                Program.Settings.GetValue<int>("mainform_y", Location.Y));
            Size = new Size(Program.Settings.GetValue<int>("mainform_width", Width),
                Program.Settings.GetValue<int>("mainform_height", Height));

            toolbox.AlphaButtonClick += new EventHandler<EventArgs>(toolbox_AlphaButtonClick);
            toolbox.BackgroundButtonClick += new EventHandler<EventArgs>(toolbox_BackgroundButtonClick);
            toolbox.ButtonButtonClick += new EventHandler<EventArgs>(toolbox_ButtonButtonClick);
            toolbox.CheckboxButtonClick += new EventHandler<EventArgs>(toolbox_CheckboxButtonClick);
            toolbox.HtmlButtonClick += new EventHandler<EventArgs>(toolbox_HtmlButtonClick);
            toolbox.ImageButtonClick += new EventHandler<EventArgs>(toolbox_ImageButtonClick);
            toolbox.ItemButtonClick += new EventHandler<EventArgs>(toolbox_ItemButtonClick);
            toolbox.LabelButtonClick += new EventHandler<EventArgs>(toolbox_LabelButtonClick);
            toolbox.RadioButtonClick += new EventHandler<EventArgs>(toolbox_RadioButtonClick);
            toolbox.TextEntryButtonClick += new EventHandler<EventArgs>(toolbox_TextEntryButtonClick);
            toolbox.TiledImageButtonClick += new EventHandler<EventArgs>(toolbox_TiledImageButtonClick);
            toolbox.InitializeClickHandlers();

            undoStack = new UndoStack();
            redoStack = new RedoStack();
        }
Пример #32
0
        private void DesignerWindow_Load(object sender, EventArgs e)
        {
            redoStack = new RedoStack();
            undoStack = new UndoStack();
            copyCollection = new List<BaseGump>();

            designerFrame.BeforeBaseGumpChanged += new EventHandler<EventArgs>(designerFrame_BeforeBaseGumpChanged);
            designerFrame.BeforeBaseGumpMoved += new EventHandler<EventArgs>(designerFrame_BeforeBaseGumpMoved);
        }