public HistoryManager()
 {
     savedPoint  = null;
     acceptNew   = true;
     forceNoSave = false;
     RecalculateValues();
 }
 public HistoryManager()
 {
     history    = new Stack <IHistoryAction>();
     future     = new Stack <IHistoryAction>();
     savedPoint = null;
     acceptNew  = true;
     RecalculateValues();
 }
        /// <summary>Add new action to the history. Clears the Redo list.</summary>
        public void Add(IHistoryAction action)
        {
            if (!IsOn)
            {
                return;
            }

            undo.Push(action);
            redo.Clear();
        }
 protected void PushAction(IHistoryAction action)
 {
     if (inBulkEditing)
     {
         bulkEditing.Add(action);
     }
     else
     {
         ActionPush(this, action);
     }
 }
Exemple #5
0
 private void OnAction(IHistoryAction action)
 {
     if (action is DatabaseFieldWithKeyHistoryAction fieldChanged)
     {
         if (!fieldChanged.Key.IsPhantomKey && keys.Contains(fieldChanged.Property))
         {
             return;
         }
     }
     PushAction(action);
 }
 /// <summary>
 /// ���X�g�ɃA�N�V������lj�����B
 /// �J�[�\���̌��݈ʒu�����ɂ���A�N�V������
 /// �폜�����B
 /// </summary>
 /// <param name="action">�lj�����A�N�V����</param>
 public void add(IHistoryAction action)
 {
     //�擪����J�[�\���ʒu�܂ł̃A�N�V������
     //�S�č폜����
     for(Int32 i = _pos; i > 0; i--)
     {
         _list.RemoveAt(0);
     }
     _pos = 0;
     _list.Insert(0, action);
 }
        /// <summary>Redo an action. Calls IHistoryAction.Do().</summary>
        /// <remarks>Does nothing if there is no action to redo.</remarks>
        public void Redo()
        {
            if (redo.Count == 0)
            {
                return;
            }

            IHistoryAction action = redo.Pop();

            undo.Push(action);
            action.Do();
        }
        /// <summary>Undo an action. Calls IHistoryAction.Undo().</summary>
        /// <remarks>Does nothing if there is no action to undo.</remarks>
        public void Undo()
        {
            if (undo.Count == 0)
            {
                return;
            }

            IHistoryAction action = undo.Pop();

            redo.Push(action);
            action.Undo();
        }
        public virtual IHistoryAction <TAction, TSender, TState> Redo()
        {
            if (_undoneActions.Count > 0)
            {
                _liveActions.Push(_undoneActions.Pop());

                var top = _undoneActions.Peek();
                top.RedoAction?.Invoke(top, _currentAction);
                RedoOccured?.Invoke(this, top);
                ActionOccured?.Invoke(this, EventArgs.Empty);
                _redoCommand.OnCanExecuteChanged();
                _currentAction = top;
                return(top);
            }
            return(null);
        }
        public void Redo()
        {
            if (_future.Count == 0)
            {
                throw new NothingToRedoException();
            }

            IHistoryAction action = _future.Pop();

            _history.Push(action);
            _acceptNew = false;
            action.Redo();
            _acceptNew = true;

            CanUndo = true;
            CanRedo = _future.Count > 0;
        }
Exemple #11
0
        public void Undo()
        {
            if (_history.Count == 0)
            {
                throw new NothingToUndoException();
            }

            IHistoryAction action = _history.Pop();

            _future.Push(action);
            Past.RemoveAt(Past.Count - 1);
            Future.Insert(0, action);
            _acceptNew = false;
            action.Undo();
            _acceptNew = true;

            CanUndo = _history.Count > 0;
            CanRedo = true;
        }
        //public HistoryManager()
        //{

        //}

        public virtual void PushHistoryAction(IHistoryAction <TAction, TSender, TState> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            _liveActions.Push(action);
            _currentAction = action;

            if (ClearFrontActionsOnNewAction)
            {
                _undoneActions.Clear();
            }

            _undoCommand.OnCanExecuteChanged();

            OnActionAdded(action);
        }
        public virtual void ClearHistory()
        {
            var keepRoot = _liveActions.Count > 0 && KeepRootOnClear;
            var root     = keepRoot
                ? _liveActions.LastOrDefault()
                : null;

            _liveActions.Clear();
            _undoneActions.Clear();

            if (keepRoot)
            {
                _liveActions.Push(root);
            }

            _undoCommand.OnCanExecuteChanged();
            _redoCommand.OnCanExecuteChanged();

            _currentAction = null;
        }
        public virtual IHistoryAction <TAction, TSender, TState> Undo()
        {
            var count = _liveActions.Count;

            if (count > 1)
            {
                var pop = _liveActions.Pop();
                if (!BackToActionOnUndo)
                {
                    _undoneActions.Push(pop);
                }

                var top = _liveActions.Peek();
                top.UndoAction?.Invoke(top, _currentAction);
                UndoOccured?.Invoke(this, top);
                ActionOccured?.Invoke(this, EventArgs.Empty);
                _undoCommand.OnCanExecuteChanged();
                _currentAction = top;
                return(top);
            }
            return(null);
        }
Exemple #15
0
 /// <summary>
 /// �A���h�D�”\�ȃA�N�V�����𗚗���X�g�ɒlj�����
 /// </summary>
 /// <param name="action">�A�N�V�����I�u�W�F�N�g</param>
 public void addEdit(IHistoryAction action)
 {
     //��X�AbeginEdit()���Ă΂�Ă���Ԃ�joinedHistoryAction��
     //������~�ς����悤�ɕύX����B
     _historyList.add(action);
 }
Exemple #16
0
 /// <summary>
 /// Adds new history element at top of history stack, and drops reverse stack
 /// </summary>
 /// <param name="item">Item to add</param>
 public void Push(IHistoryAction item)
 {
     _historyActions.PushFront(item);
     _reverseActions.Clear();
 }
 protected virtual void OnActionAdded(IHistoryAction <TAction, TSender, TState> historyAction)
 => ActionAdded?.Invoke(this, historyAction);
Exemple #18
0
        private static void OnRegisterHistoryAction(IHistoryAction action)
        {
            Memento memento = _mementoOriginator.CreateMemento(action);

            _caretaker.InsertMementoForUndoRedo(memento);
        }
Exemple #19
0
 public Memento(IHistoryAction action)
 {
     Action = action;
 }
Exemple #20
0
 public Memento CreateMemento(IHistoryAction action)
 {
     return(new Memento(action));
 }
 /// <summary>Add an action to the end of the ordered list.</summary>
 public void Add(IHistoryAction action)
 {
     actions.Add(action);
 }
Exemple #22
0
 protected void PushAction(IHistoryAction action)
 {
     ActionPush(this, action);
 }