internal void PushEvent(IUndoEvent undoEvent) { if (!IsBusy) { if (_activeGroups.Any()) { _activeGroups.Peek().PushEvent(undoEvent); } else { _undoEvents.Push(undoEvent); _redoEvents.Clear(); } } }
/// <summary> /// Adds an IUndoEvent to the list, clears any events that have previously been undone. /// </summary> /// <param name="undoEvent">Event to be added to the list.</param> public void Push(IUndoEvent undoEvent) { //If there are any undone events (events after the cursor index in the list), remove them. if (_cursorIndex < _events.Count() - 1) { foreach (var eve in _events.GetRange(_cursorIndex + 1, _events.Count() - (_cursorIndex + 1))) { eve.Dispose(); } _events.RemoveRange(_cursorIndex + 1, _events.Count() - (_cursorIndex + 1)); } //Add the IUndoEvent to the list. _events.Add(undoEvent); //Move the cursor to the end of the buffer. _cursorIndex = _events.Count() - 1; }
private void UndoRedo(Stack <IUndoEvent> from, Stack <IUndoEvent> to) { if (IsBusy) { throw new InvalidOperationException(); } using (new FilePackager.Base.WPF.AutoCursor(System.Windows.Input.Cursors.Wait)) { try { if (!from.Any()) { throw new InvalidOperationException(); } _currentUndoEvent = from.Pop(); // Do it if (from == _undoEvents) { _currentUndoEvent.Undo(); } else { _currentUndoEvent.Redo(); } to.Push(_currentUndoEvent); } finally { _currentUndoEvent = null; // Notify if (IsBusyOrGroupFinished != null) { IsBusyOrGroupFinished(this, EventArgs.Empty); } } } }
public void PushEvent(IUndoEvent undoEvent) { _events.Add(undoEvent); }