コード例 #1
0
        /// <summary>
        /// Clears the undo and redo stacks.
        /// </summary>
        public void Clear(object ownerKey = null)
        {
            if (ownerKey == null)
            {
                globallyRepeatableUnits.Clear();
                globallyUndoableUnits.Clear();
                globallyRedoableUnits.Clear();
                OnCleared(EventArgs.Empty);
                return;
            }

            if (repeatableDictionary.TryGetValue(ownerKey,
                                                 out UnitCollection <IInternalUnit> repeatableUnits))
            {
                repeatableUnits.Clear();
            }

            if (undoableDictionary.TryGetValue(ownerKey,
                                               out UnitCollection <IUndoableUnit> undoableUnits))
            {
                undoableUnits.Clear();
            }

            if (redoableDictionary.TryGetValue(ownerKey,
                                               out UnitCollection <IUndoableUnit> redoableUnits))
            {
                redoableUnits.Clear();
            }

            OnCleared(EventArgs.Empty);
        }
コード例 #2
0
        UnitResult PerformUnit <T>(UnitBase <T> unit, T argument)
        {
            var eventArgs = new CancellableUndoServiceEventArgs(unit);

            OnExecuting(eventArgs);

            if (eventArgs.Cancel)
            {
                return(UnitResult.Cancelled);
            }

            globallyRedoableUnits.Clear();
            globallyUndoableUnits.Clear();

            globallyRepeatableUnits.AddLast(unit);

            UnitResult result = unit.PerformUnit(argument, UnitMode.FirstTime);

            TrimIfRequired();

            OnExecuted(new UndoServiceEventArgs(unit));
            return(result);
        }
コード例 #3
0
 public void KillAll()
 {
     m_units.Clear();
 }