Example #1
0
        public void Add(ICommand state, bool callDo = true)
        {
            while (_list.Last != _currentState)
            {
                _list.RemoveLast();
            }
            ICommand clonedState = state.ShallowClone();
            if (_currentState == null)
            {
                _list.AddFirst(clonedState);
            }
            else
            {
                _list.AddAfter(_currentState, clonedState);
            }

            if (callDo)
            {
                clonedState.Do();
            }
            if (_list.Count > UndoSteps + 1)
            {
                _list.RemoveFirst();
            }
            _currentState = _list.Last;
        }