Ejemplo n.º 1
0
        public void AddHandler(HistoryHandler handler)
        {
            handler.ActionPush += (sender, action) => {
                if (!_acceptNew)
                {
                    return;
                }

                _history.Push(action);
                Past.Add(action);
                _future.Clear();
                Future.Clear();
                CanRedo = false;
                CanUndo = true;
            };
        }
Ejemplo n.º 2
0
        public void Redo()
        {
            if (_future.Count == 0)
            {
                throw new NothingToRedoException();
            }

            IHistoryAction action = _future.Pop();

            _history.Push(action);
            Future.RemoveAt(0);
            Past.Add(action);
            _acceptNew = false;
            action.Redo();
            _acceptNew = true;

            CanUndo = true;
            CanRedo = _future.Count > 0;
        }