public void RedoLastCommand() { if (UndoHistory.Count == 0) { throw new InvalidOperationException("Il n'y a aucune action à redo."); } Command LastCmdToRedo = UndoHistory.Pop().GetCommand(); if (LastCmdToRedo.CanDo(this)) { LastCmdToRedo.Do(this); CommandHistory.Push(new CommandMemento(LastCmdToRedo)); if (LastCmdToRedo is MovePiece) { MovePieceCount++; } if (LastCmdToRedo is MoveBall) { MoveBallCount++; } } else { throw new InvalidOperationException("Impossible de refaire la dernière action :" + LastCmdToRedo.GetType() + "\n"); } }
protected virtual void Dispose(bool isDisposing) { if (!isDisposing) { return; } if (this.editorElement != null) { TextCompositionManager.RemoveTextInputStartHandler((DependencyObject)this.editorElement, new TextCompositionEventHandler(this.OnTextInputStart)); TextCompositionManager.RemoveTextInputUpdateHandler((DependencyObject)this.editorElement, new TextCompositionEventHandler(this.OnTextInputUpdate)); this.editorElement.TextInput -= new TextCompositionEventHandler(this.OnTextInput); this.editorElement.KeyDown -= new KeyEventHandler(this.OnKeyDown); this.editorElement.MouseDown -= new MouseButtonEventHandler(this.OnMouseDown); this.editorElement = (FrameworkElement)null; } if (this.codeAidEngine != null) { this.codeAidEngine.Dispose(); this.codeAidEngine = (XamlCodeAidEngine)null; } if (this.undoHistory == null) { return; } this.undoHistory.UndoRedoHappened -= new EventHandler <UndoRedoEventArgs>(this.OnUndoRedoHappened); this.undoHistory = (UndoHistory)null; }
public void Update(Command cmd) { if (cmd.CanDo(this)) { cmd.Do(this); if (cmd is MoveBall) { MoveBallCount++; } if (cmd is MovePiece) { MovePieceCount++; } CommandHistory.Push(new CommandMemento(cmd)); UndoHistory.Clear(); //Console.Write(Board.ToString()); if (IsWin()) { VictoriousPlayer = Players[CurrentPlayer]; } if (IsEndTurn()) { Command endTurn = new EndTurn(); CommandHistory.Push(new CommandMemento(endTurn)); endTurn.Do(this); } } else { throw new InvalidOperationException("Impossible d'effectuer l'action " + cmd.GetType() + " : " + cmd.ToString()); } }
private void ProjectManager_ProjectChanged(object sender, EventArgs e) { UndoHistory.Clear(); RedoHistory.Clear(); HistoryLimitExceeded = false; CurrentChangeID = 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(); //} } } }
public override void DiscardChanges() { _directImage.Render(); UndoHistory.Clear(); RedoHistory.Clear(); NotifyOfPropertyChange(() => CanUndo); NotifyOfPropertyChange(() => CanRedo); }
public void ClearHistory() { UndoHistory.Clear(); RedoHistory.Clear(); HistoryLimitExceeded = false; ProjectIsModified = false; CurrentChangeID = 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); } }
/// <summary> /// Handles the event that occurs when the redo menu is clicked. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void RedoTextMenuClick(object sender, EventArgs e) { string edit = (string)UndoHistory.Pop(); // Edit string int loc = (int)UndoHistory.Pop(); // Location of edit bool isDel = (bool)UndoHistory.Pop(); // Indicates whether the edit is a deletion EditHistory.Push(isDel); EditHistory.Push(loc); EditHistory.Push(edit); DoEdit(isDel, loc, edit); }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private void AddAction(ChangeAction action) { RedoHistory.Clear(); UndoHistory.Add(action); action.ChangeID = ++CurrentChangeID; if (UndoHistory.Count > MaxHistory) { HistoryLimitExceeded = true; UndoHistory.RemoveAt(0); } UndoHistoryChanged?.Invoke(this, EventArgs.Empty); }
/// <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()); } }
/// <summary>Set up the chart for MouseOps</summary> private void InitNavigation() { m_nav_history = new UndoHistory <NavHistoryRecord> { IsDuplicate = NavHistoryRecord.ApproxEqual, ApplySnapshot = snapshot => { XAxis.Range = snapshot.XRange; YAxis.Range = snapshot.YRange; SetCameraFromRange(); Invalidate(); }, }; }
public CodeEditorOperations(CodeEditor codeEditor, ICompletionBroker completionBroker, ICodeAidProvider codeAidProvider) { this.editorElement = codeEditor.Element; this.editorOperations = codeEditor.EditorCommands; this.undoHistory = codeEditor.UndoHistory; this.textView = codeEditor.TextView; this.completionBroker = completionBroker; this.codeAidEngine = new XamlCodeAidEngine(codeEditor.TextBuffer, codeAidProvider, codeEditor.Environment); this.editorElement.TextInput += new TextCompositionEventHandler(this.OnTextInput); this.editorElement.KeyDown += new KeyEventHandler(this.OnKeyDown); this.editorElement.MouseDown += new MouseButtonEventHandler(this.OnMouseDown); this.undoHistory.UndoRedoHappened += new EventHandler <UndoRedoEventArgs>(this.OnUndoRedoHappened); TextCompositionManager.AddTextInputStartHandler((DependencyObject)this.editorElement, new TextCompositionEventHandler(this.OnTextInputStart)); TextCompositionManager.AddTextInputUpdateHandler((DependencyObject)this.editorElement, new TextCompositionEventHandler(this.OnTextInputUpdate)); }
public override void SaveChanges() { try { _directImage.SaveImage(); UndoHistory.Clear(); RedoHistory.Clear(); NotifyOfPropertyChange(() => CanUndo); NotifyOfPropertyChange(() => CanRedo); IsModified = false; var changeEvent = new ArrangerChangedEvent(_projectArranger, ArrangerChange.Pixels); _events.PublishOnUIThread(changeEvent); } catch (Exception ex) { _windowManager.ShowMessageBox($"Could not save the pixel arranger contents\n{ex.Message}\n{ex.StackTrace}", "Save Error"); } }
private void ImageControl_MouseDown(object sender, MouseButtonEventArgs e) { if (IsEydropping) { UserEyedrops(); } else { try { UndoHistory.Add(new Bitmap(LayeredImage.SelectedBitmapLayer.Source)); } catch (ArgumentOutOfRangeException) { } IsDrawing = true; UserDrawsOnBitmap(); RedoHistory = new List <Bitmap>(MaxItemsInHistory); } }
public void Redo() { if (RedoHistory.Any()) { BeginUndoRedo?.Invoke(this, EventArgs.Empty); var lastAction = RedoHistory.Last(); CurrentChangeID = lastAction.ChangeID; RedoHistory.Remove(lastAction); UndoHistory.Add(lastAction); ExecutingUndoRedo = true; lastAction.Redo(); ExecutingUndoRedo = false; EndUndoRedo?.Invoke(this, EventArgs.Empty); UndoHistoryChanged?.Invoke(this, EventArgs.Empty); } }
/// <summary> /// Records edits for undos /// </summary> private void RecordEdit() { bool isDel = Text.Length < LastText.Length; // Indicates whether the edit was a deletion int len = Math.Abs(Text.Length - LastText.Length); // The length of the string inserted or deleted int loc = isDel ? SelectionStart : (SelectionStart - len); // The location of the edit string edit = isDel ? LastText.Substring(loc, len) : Text.Substring(loc, len); // Gets the edit string if (Text.Length != 0 && edit == "\t") { Text = Text.Remove(loc, 1); // Remove tab edit = new string(' ', 4); Text = Text.Insert(loc, edit); // Insert spaces for tab SelectionStart = loc + 4; // Restore cursor location } EditHistory.Push(isDel); EditHistory.Push(loc); EditHistory.Push(edit); UndoHistory.Clear(); LastText = Text; }
// 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()); } }
/// <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(); }
/// <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(); }