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); }
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); } }
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); } }