示例#1
0
        public void AddUndoItem(IUndoItem undoEvent)
        {
            if (Working)
            {
                return;
            }

            bool emptyBefore = (_batch?.Count ?? 0) == 0 && !_undoEvents.Any();

            if (_batch != null)
            {
                _batch.Add(undoEvent);
            }
            else
            {
                ClearRedoHistory();
                _undoEvents.Push(undoEvent);
                if (_undoEvents.Count > MAX_UNDO_ITEMS)
                {
                    // XXX: we throw away the current item? this should be a Dequeue so we can pop the front
                    _undoEvents.Pop();
                }
            }

            if (emptyBefore)
            {
                // no longer empty
                NonEmpty?.Invoke(this, EventArgs.Empty);
            }
        }
示例#2
0
 public void AddUndoItem(IUndoItem undoEvent)
 {
     if (!_working)
     {
         if (_batch != null)
         {
             _batch.Add(undoEvent);
         }
         else
         {
             ClearRedoHistory();
             _undoEvents.Push(undoEvent);
             if (_undoEvents.Count > MAX_UNDO_ITEMS)
             {
                 _undoEvents.Pop();
             }
         }
     }
 }