Пример #1
0
 public HistoryManager()
 {
     savedPoint  = null;
     acceptNew   = true;
     forceNoSave = false;
     RecalculateValues();
 }
 public HistoryManager()
 {
     history    = new Stack <IHistoryAction>();
     future     = new Stack <IHistoryAction>();
     savedPoint = null;
     acceptNew  = true;
     RecalculateValues();
 }
Пример #3
0
        /// <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);
     }
 }
Пример #5
0
 private void OnAction(IHistoryAction action)
 {
     if (action is DatabaseFieldWithKeyHistoryAction fieldChanged)
     {
         if (!fieldChanged.Key.IsPhantomKey && keys.Contains(fieldChanged.Property))
         {
             return;
         }
     }
     PushAction(action);
 }
Пример #6
0
 /// <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);
 }
Пример #7
0
        /// <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();
        }
Пример #8
0
        /// <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();
        }
Пример #9
0
        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;
        }
Пример #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;
        }
Пример #12
0
        //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);
        }
Пример #13
0
        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;
        }
Пример #14
0
        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);
        }
Пример #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);
 }
Пример #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();
 }
Пример #17
0
 protected virtual void OnActionAdded(IHistoryAction <TAction, TSender, TState> historyAction)
 => ActionAdded?.Invoke(this, historyAction);
Пример #18
0
        private static void OnRegisterHistoryAction(IHistoryAction action)
        {
            Memento memento = _mementoOriginator.CreateMemento(action);

            _caretaker.InsertMementoForUndoRedo(memento);
        }
Пример #19
0
 public Memento(IHistoryAction action)
 {
     Action = action;
 }
Пример #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);
 }
Пример #22
0
 protected void PushAction(IHistoryAction action)
 {
     ActionPush(this, action);
 }