コード例 #1
0
 internal void PushEvent(IUndoEvent undoEvent)
 {
     if (!IsBusy)
     {
         if (_activeGroups.Any())
         {
             _activeGroups.Peek().PushEvent(undoEvent);
         }
         else
         {
             _undoEvents.Push(undoEvent);
             _redoEvents.Clear();
         }
     }
 }
コード例 #2
0
ファイル: UndoManagerBase.cs プロジェクト: Vizzini/netgore
        /// <summary>
        /// Adds an IUndoEvent to the list, clears any events that have previously been undone.
        /// </summary>
        /// <param name="undoEvent">Event to be added to the list.</param>
        public void Push(IUndoEvent undoEvent)
        {
            //If there are any undone events (events after the cursor index in the list), remove them.
            if (_cursorIndex < _events.Count() - 1)
            {
                foreach (var eve in _events.GetRange(_cursorIndex + 1, _events.Count() - (_cursorIndex + 1)))
                {
                    eve.Dispose();
                }

                _events.RemoveRange(_cursorIndex + 1, _events.Count() - (_cursorIndex + 1));
            }

            //Add the IUndoEvent to the list.
            _events.Add(undoEvent);

            //Move the cursor to the end of the buffer.
            _cursorIndex = _events.Count() - 1;
        }
コード例 #3
0
        /// <summary>
        /// Adds an IUndoEvent to the list, clears any events that have previously been undone.
        /// </summary>
        /// <param name="undoEvent">Event to be added to the list.</param>
        public void Push(IUndoEvent undoEvent)
        {
            //If there are any undone events (events after the cursor index in the list), remove them.
            if (_cursorIndex < _events.Count() - 1)
            {
                foreach (var eve in _events.GetRange(_cursorIndex + 1, _events.Count() - (_cursorIndex + 1)))
                {
                    eve.Dispose();
                }

                _events.RemoveRange(_cursorIndex + 1, _events.Count() - (_cursorIndex + 1));
            }

            //Add the IUndoEvent to the list.
            _events.Add(undoEvent);

            //Move the cursor to the end of the buffer.
            _cursorIndex = _events.Count() - 1;
        }
コード例 #4
0
        private void UndoRedo(Stack <IUndoEvent> from, Stack <IUndoEvent> to)
        {
            if (IsBusy)
            {
                throw new InvalidOperationException();
            }

            using (new FilePackager.Base.WPF.AutoCursor(System.Windows.Input.Cursors.Wait))
            {
                try
                {
                    if (!from.Any())
                    {
                        throw new InvalidOperationException();
                    }

                    _currentUndoEvent = from.Pop();

                    // Do it
                    if (from == _undoEvents)
                    {
                        _currentUndoEvent.Undo();
                    }
                    else
                    {
                        _currentUndoEvent.Redo();
                    }

                    to.Push(_currentUndoEvent);
                }
                finally
                {
                    _currentUndoEvent = null;

                    // Notify
                    if (IsBusyOrGroupFinished != null)
                    {
                        IsBusyOrGroupFinished(this, EventArgs.Empty);
                    }
                }
            }
        }
コード例 #5
0
 public void PushEvent(IUndoEvent undoEvent)
 {
     _events.Add(undoEvent);
 }