コード例 #1
0
        UnitResult Repeat()
        {
            var unit = globallyRepeatableUnits.Peek();

            if (!unit.Repeatable)
            {
                return(UnitResult.NoUnit);
            }
            var eventArgs = new CancellableUndoServiceEventArgs(unit);

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

            globallyRedoableUnits.Clear();
            globallyRepeatableUnits.AddLast(unit);

            var undoableUnit = unit as IUndoableUnit;

            if (undoableUnit != null)
            {
                globallyUndoableUnits.AddLast(undoableUnit);
            }
            else
            {
                globallyUndoableUnits.Clear();
                globallyRedoableUnits.Clear();
            }

            var result = unit.PerformUnit(unit.Argument, UnitMode.Repeat);

            OnExecuted(new UndoServiceEventArgs(unit));
            return(result);
        }