示例#1
0
 public void StartBatch()
 {
     if (_batch == null)
     {
         ClearRedoHistory();
         _batch = new UndoManagerBatch();
     }
 }
示例#2
0
        public void StartBatch()
        {
            if (_batch != null)
            {
                return;
            }

            ClearRedoHistory();
            _batch = new UndoManagerBatch();
        }
示例#3
0
 public void CloseBatch()
 {
     if (_batch != null)
     {
         if (_batch.Count > 0)
         {
             _undoEvents.Push(_batch);
         }
         _batch = null;
     }
 }
示例#4
0
 /// <summary>
 /// roll back everything in the currently open batch, not redoable
 /// </summary>
 public void UndoBatch()
 {
     _working = true;
     try
     {
         _batch?.Undo();
     }
     finally
     {
         _working = false;
         _batch   = null;
     }
 }
示例#5
0
        public void CloseBatch()
        {
            if (_batch == null)
            {
                return;
            }

            if (_batch.Count > 0)
            {
                bool emptyBefore = !_undoEvents.Any();
                _undoEvents.Push(_batch);
                if (emptyBefore)
                {
                    // no longer empty
                    NonEmpty?.Invoke(this, EventArgs.Empty);
                }
            }
            _batch = null;
        }
示例#6
0
        /// <summary>
        /// roll back everything in the currently open batch, not redoable
        /// </summary>
        public void UndoBatch()
        {
            Working = true;
            bool nonEmptyBefore = (_batch?.Count ?? 0) > 0 || _undoEvents.Any();

            try
            {
                _batch?.Undo();
            }
            finally
            {
                bool nowEmpty = !_undoEvents.Any();
                Working = false;
                _batch  = null;
                if (nonEmptyBefore && nowEmpty)
                {
                    Empty?.Invoke(this, EventArgs.Empty);
                }
            }
        }