//pop items from undo stack and push in redo public string Undo() { string i = UndoStack.Pop(); RedoStack.Push(i); return(UndoStack.First()); }
/// <summary> /// Sets top property in UndoStack to Old Value /// </summary> public static void Undo() { _lastChangeWasUndo = true; PropertyInfo propInfo = MainRoot.GetType().GetProperty(UndoStack.Peek().Property); propInfo.SetValue(MainRoot, UndoStack.Peek().OldValue); RedoStack.Push(UndoStack.Pop()); }
public void Undo() { var undo = UndoStack.Pop(); RedoStack.Push(undo); undo.Undo(); if (UndoStack.Count > 0) OnPropertyChanged(nameof(CanUndo)); OnPropertyChanged(nameof(CanRedo)); }
/// <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()); }
private void DoUndo() { var undoCommand = UndoStack.Pop(); undoCommand.Undo(); RedoStack.Push(undoCommand); StackStatesChanged(); }
/// <summary> /// 直前の操作を元に戻します。 /// </summary> public void Undo() { IOperation op = UndoStack.Pop(); op.Undo(); RedoStack.Push(op); OperationHistoryChanged?.Invoke(this, EventArgs.Empty); }
private void ExecuteDropLineCommand(object parameter) { //if (parameter == null || !(parameter is IConnectionLineViewModel)) return; if ((DroppingDataContext as LineViewModel) == null) { return; } var linevm = DroppingDataContext as IConnectionLineViewModel; //(parameter as IConnectionLineViewModel); //if (DraggedDataContext != null )// && DraggedDataContext is Tuple<object, object>) //{ var originvm = DraggedDataContext as IConnectionDiagramViewModel; //(DraggedDataContext as Tuple<object, object>).Item1 as IConnectionDiagramViewModel; var terminalvm = parameter as IConnectionDiagramViewModel; //(DraggedDataContext as Tuple<object, object>).Item2 as IConnectionDiagramViewModel; if (originvm != null) { linevm.OriginDiagramViewModel = originvm; } if (terminalvm != null) { linevm.TerminalDiagramViewModel = terminalvm; } //} var redomemo = new Action <object>((obj) => { linevm.OriginDiagramViewModel.DepartureLinesViewModel.Add(linevm); linevm.TerminalDiagramViewModel.ArrivalLinesViewModel.Add(linevm); (linevm as LineViewModel).Comment = $"{(linevm.OriginDiagramViewModel as DiagramViewModel).Name} And {(linevm.TerminalDiagramViewModel as DiagramViewModel).Name}"; }); var undomemo = new Action <object>((obj) => ExecuteDeleteLineCommand(linevm)); if (!_isUndoHandle) { UndoStack.Push(new UndoRedoManager() { ActionComment = $"add the line of {(linevm as LineViewModel).Comment}", RedoAction = redomemo, UndoAction = undomemo, }); } else { RedoStack.Push(new UndoRedoManager() { ActionComment = $"undo add the line of {(linevm as LineViewModel).Comment}", RedoAction = undomemo, UndoAction = redomemo, }); _isUndoHandle = false; } redomemo(null); }
/// <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); } }
public void Undo() { if (UndoStack.Count > 0) { var operation = UndoStack.Pop(); operation.Undo(); RedoStack.Push(operation); } }
/// <summary> /// returns the user to go back a step /// </summary> public void Undo() { if (UndoStack.Count > 0) { var command = UndoStack.Pop(); command.UnExecute(); RedoStack.Push(command); } }
public void Undo() { if (Gump != null && undoStack.Count > 0) { GumpState state = undoStack.Pop(); redoStack.Push(state); Gump.Items = state.StateCollection; } }
/// <inheritdoc/> public void Undo() { if (UndoStack.Count > 0) { var undoRedo = UndoStack.Pop(); undoRedo.Undo(); RedoStack.Push(undoRedo); Transacted?.Invoke(); } }
public void Rollback() { if (HistoryStack.Count == 0) { throw new InvalidOperationException("This is the first Version"); } RedoStack.Push(Current); Current = HistoryStack.Pop(); }
public void Undo() { if (UndoStack.Count == 0) { return; } ICommand currentundo = UndoStack.Pop(); RedoStack.Push(currentundo); currentundo.Undo(); }
private void OnUndoCommandExecute() { if (UndoStack.Count != 0) { RedoStack.Push(UndoStack.Pop()); disableUndoRedoLogic = true; Text = UndoStack.Count == 0 ? string.Empty : UndoStack.Peek(); ((DelegateCommand)UndoCommand).RaiseCanExecuteChanged(); ((DelegateCommand)RedoCommand).RaiseCanExecuteChanged(); } }
/// <summary> /// Revert data values for this sensor to the previous state held. /// </summary> public void Undo() { // This is because the undo stack has to have at least one item on it - the current state if (UndoStack.Count == 0) { throw new InvalidOperationException("Undo is not possible at this stage. There are no more possible states to undo to."); } RedoStack.Push(CurrentState); _currentState = UndoStack.Pop(); }
//Pop the top command off the undo stack, execute it and push it onto the redo stack. public virtual void UndoCommand() { if (!AllowUndo || UndoStack.Count == 0) { return; } Command command = UndoStack.Pop(); command.Undo(); RedoStack.Push(command); }
private void UndoExecuted(object sender, ExecutedRoutedEventArgs e) { if (UndoStack.Count > 0) { Performable p = UndoStack.Pop(); RedoStack.Push(p); p.Undo(); OnPropertyChanged("UndoDescription"); OnPropertyChanged("UndoEnabled"); OnPropertyChanged("RedoDescription"); OnPropertyChanged("RedoEnabled"); } }
/// <summary> /// 撤销操作 /// </summary> /// <returns></returns> public OperationStack Undo() { IsRecording = false; var stack = UndoStack.Pop(); Undoing?.Invoke(stack.Item1, stack.Item2); RedoStack.Push(stack); Undone?.Invoke(stack.Item1, stack.Item2); IsRecording = true; return(stack.Item1); }
/// <summary> /// 戻る /// </summary> public static void Undo() { if (UndoStack.Count == 0) { return; } var command = UndoStack.Pop(); isAction = true; command.Undo(); isAction = false; RedoStack.Push(command); OnUpdateData(); }
/// <summary> /// Sets top property in UndoStack to Old Value /// </summary> public static void Undo() { _lastChangeWasUndo = true; Change change = UndoStack.Pop(); if (change.ReverseProcess == null) { SetPropertyValue(change.Root, change.Property, change.OldValue); } else { change.ReverseProcess(change.ReverseProcessArguments); } RedoStack.Push(change); }
public void UndoMove() { if (GameHistory.Count != 0) { List <int> move = GameHistory.Peek(); GameBoard.Board[move[0], move[1]] = move[2]; GameBoard.Board[move[3], move[4]] = move[5]; RedoStack.Push(GameHistory.Pop()); PlayerOnTurn = PlayerSwap(); if (!GameInProgress) { GameInProgress = true; } } }
public void Undo() { lock (m_lockObject) { bool bWasRecording = IsRecording; IsRecording = false; CUndoItem undoItem = UndoStack.Pop(); undoItem.Undo(); RedoStack.Push(undoItem); IsRecording = bWasRecording; OnItemUndone?.Invoke(this, undoItem); } }
private void ExecuteDropCommand(object parameter) { if (parameter is DiagramViewModel) { if (DraggedDataContext != null && DraggedDataContext is DiagramModel) { (parameter as DiagramViewModel).Name = (DraggedDataContext as DiagramModel).Name; (parameter as DiagramViewModel).Detail = (DraggedDataContext as DiagramModel).Detail; // (parameter as DiagramViewModel).ImagePath = (DraggedDataContext as DiagramModel).ImagePath; (parameter as DiagramViewModel).Index = (DraggedDataContext as DiagramModel).Index; } var redomemo = new Action <object>((obj) => { if (!Characters.Any(item => item.Index == (parameter as DiagramViewModel).Index)) { Characters.Add(parameter as DiagramViewModel); } }); var undomemo = new Action <object>((obj) => ExecuteDeleteDiagramCommand(parameter)); if (!_isUndoHandle) { UndoStack.Push(new UndoRedoManager() { ActionComment = $"add the {(DraggedDataContext as DiagramModel)}", RedoAction = redomemo, UndoAction = undomemo, }); } else { RedoStack.Push(new UndoRedoManager() { ActionComment = $"add the {(DraggedDataContext as DiagramModel)}", RedoAction = undomemo, UndoAction = redomemo, }); _isUndoHandle = false; } redomemo(null); } }
/// <summary> /// 元に戻す /// </summary> /// <returns>破壊的命令をUndoしたか</returns> public bool Undo() { if (!UndoStack.Any()) { return(false); } var cmd = UndoStack.Pop(); cmd.Undo(); RedoStack.Push(cmd); if (cmd.IsDestructive) { EditCount--; } return(cmd.IsDestructive); }
public void Undo() { if (!UpdateUndoRedoStacks) { return; } if (UndoStack.Count > 0) { var pop = UndoStack.Pop(); foreach (var undo in pop.UndoActions.Reverse()) { undo(); } RedoStack.Push(pop); UpdateUndoRedoTooltips(); ChangedSinceLastSave = true; } }
public void UndoAction() { if (this.IsInActionGroup) { #if DEBUG throw new InvalidOperationException("Cannot undo when recording an action group."); #else System.Diagnostics.Debug.WriteLine("WARNING: Should not undo while recording an action group. Aborting & rolling back the pending action group."); while (this.IsInActionGroup) { this.AbortGroup(); } #endif } else { Action action = UndoStack.Pop(); action.Undo(this.World); RedoStack.Push(action); } }
public bool PlayMoveHistory(List <List <int> > moves, int saveHash) { Console.WriteLine(moves.Count); if (GetHash(moves) == saveHash) { foreach (var sublist in moves) { RedoStack.Push(sublist); } while (RedoStack.Count > 0) { RedoMove(); } return(true); } else { return(false); } }
private void ExecuteDeleteLineCommand(object parameter) { if (parameter == null || !(parameter is IConnectionLineViewModel)) { return; } var linevm = parameter as IConnectionLineViewModel; var redomemo = new Action <object>((obj) => { linevm.OriginDiagramViewModel.DepartureLinesViewModel.Remove(linevm); linevm.TerminalDiagramViewModel.ArrivalLinesViewModel.Remove(linevm); }); var undomemo = new Action <object>((obj) => ExecuteDropLineCommand(linevm)); if (!_isUndoHandle) { UndoStack.Push(new UndoRedoManager() { ActionComment = $"delete line {(parameter as LineViewModel).Comment}. ", RedoAction = redomemo, UndoAction = undomemo, }); } else { RedoStack.Push(new UndoRedoManager() { ActionComment = $"undo delete line {(parameter as LineViewModel).Comment}. ", RedoAction = undomemo, UndoAction = redomemo, }); _isUndoHandle = false; } redomemo(null); }
/// <summary> /// Adds an undo unit to the undo/redo stack, depending on current state. /// </summary> /// <param name="unit"> /// IUndoUnit to add /// </param> /// <exception cref="InvalidOperationException"> /// Thrown if: /// UndoManager is disabled /// unit is not IParentUndoUnit and there is no open IParentUndoUnit /// </exception> /// <exception cref="ArgumentNullException"> /// Thrown if unit is null /// </exception> internal void Add(IUndoUnit unit) { IParentUndoUnit parent; if (!IsEnabled) { throw new InvalidOperationException(SR.Get(SRID.UndoServiceDisabled)); } if (unit == null) { throw new ArgumentNullException("unit"); } parent = DeepestOpenUnit; if (parent != null) { parent.Add(unit); } else if (unit is IParentUndoUnit) { ((IParentUndoUnit)unit).Container = this; if (LastUnit is IParentUndoUnit) { ((IParentUndoUnit)LastUnit).OnNextAdd(); } SetLastUnit(unit); if (State == UndoState.Normal || State == UndoState.Redo) { if (++_topUndoIndex == UndoLimit) { _topUndoIndex = 0; } if (!(_topUndoIndex < UndoStack.Count && PeekUndoStack() == null) && // Non-null topmost stack item (UndoLimit == -1 || UndoStack.Count < UndoLimit)) { UndoStack.Add(unit); } else { if (PeekUndoStack() != null) { if (++_bottomUndoIndex == UndoLimit) { _bottomUndoIndex = 0; } } UndoStack[_topUndoIndex] = unit; } } else if (State == UndoState.Undo) { RedoStack.Push(unit); } else if (State == UndoState.Rollback) { // do nothing, throwing out the unit } } else { throw new InvalidOperationException(SR.Get(SRID.UndoNoOpenParentUnit)); } }