private void ClearRedoStack() { if (RedoStack.Count != 0) { RedoStack.Clear(); } }
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; }
/// <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); }); }
/******************************************************* * 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(); }
/// <summary> /// 記録されている操作をクリアします。 /// </summary> public void Clear() { UndoStack.Clear(); RedoStack.Clear(); LastCommittedOperation = null; OperationHistoryChanged?.Invoke(this, EventArgs.Empty); }
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(); }
internal void Clear() { LastSave = 0; UndoStack.Clear(); RedoStack.Clear(); UpdateUI(); }
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(); } } }
public void Redo() { var redo = RedoStack.Pop(); UndoStack.Push(redo); redo.Redo(); if (RedoStack.Count > 0) OnPropertyChanged(nameof(CanRedo)); }
/// <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); }
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); }
/// <summary> /// Moves the entire redo stack onto the undo stack, in order. /// </summary> public void MoveRedoStackBackToUndo() { while (RedoStack.Count > 0) { UndoStack.Push(RedoStack.Pop()); } }
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); }
/// <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); }
/// <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(); } } }
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)); }
private void OnRedoCommandExecute() { disableUndoRedoLogic = true; Text = RedoStack.Pop(); UndoStack.Push(Text); ((DelegateCommand)UndoCommand).RaiseCanExecuteChanged(); ((DelegateCommand)RedoCommand).RaiseCanExecuteChanged(); }
public void Undo() { var undo = UndoStack.Pop(); RedoStack.Push(undo); undo.Undo(); if (UndoStack.Count > 0) OnPropertyChanged(nameof(CanUndo)); OnPropertyChanged(nameof(CanRedo)); }
private void DoUndo() { var undoCommand = UndoStack.Pop(); undoCommand.Undo(); RedoStack.Push(undoCommand); StackStatesChanged(); }
/// <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()); }
/// <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()); }
private void DoRedo() { var redoCommand = RedoStack.Pop(); redoCommand.Do(); UndoStack.Push(redoCommand); StackStatesChanged(); }
/// <summary> /// 直後の操作をやり直します。 /// </summary> public void Redo() { IOperation op = RedoStack.Pop(); op.Redo(); UndoStack.Push(op); OperationHistoryChanged?.Invoke(this, EventArgs.Empty); }
private void ExecuteRedoCommand(object parameter) { var redo = RedoStack.Pop(); _isUndoHandle = false; redo.RedoAction(redo); }
private void UpdateControls() { SetDisplayOptions(); Display.Chemistry = _lastCml; RedoStack.SetOptions(_editorOptions); UndoStack.SetOptions(_editorOptions); UndoStack.ListOfDisplays.ItemsSource = StackToList(_undoStack); RedoStack.ListOfDisplays.ItemsSource = StackToList(_redoStack); }
/// <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); } }
/// <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); } }
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); }
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(); }
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); }