Example #1
0
        /// <summary>
        /// Record the current state of the tracked object and add it to the Undo stack.
        /// </summary>
        /// <param name="tag">A tag associated with the recorded state</param>
        public void RecordState(object tag = null)
        {
            GetState(out T memento);
            _undoStack.Push(_currentState);
            _currentState = new StateRecord <T> {
                State = memento, Tag = tag
            };
            StateRecorded?.Invoke(this, new EventArgs());

            if (_redoStack.Count > 0)
            {
                _redoStack.Clear();
            }
        }
Example #2
0
 private void UndoService_StateRecorded(object sender, EventArgs e)
 {
     StateRecorded?.Invoke(this, e);
 }