示例#1
0
        public void Redo()
        {
            if (!CanRedo())
            {
                return;
            }
            bool documentChanged = false;
            int  e = GetTransactionEndIndex();

            while (currentIndex < e)
            {
                bool b = AnyChangingOperationWithinRange(currentIndex, e);
                if (b && documentChanged)
                {
                    break;
                }
                documentChanged |= b;
                for (; currentIndex < e; currentIndex++)
                {
                    Processors.Invert(operations[currentIndex]);
                }
                e = GetTransactionEndIndex();
            }
            OnChange();
        }
示例#2
0
        public void RollbackTransaction()
        {
            AssertTransaction();
            var index = transactionStartIndices.Peek();

            if (currentIndex != index)
            {
                operations.RemoveRange(currentIndex, GetTransactionEndIndex() - currentIndex);
                for (; currentIndex > index; currentIndex--)
                {
                    Processors.Invert(operations[currentIndex - 1]);
                }
            }
        }
示例#3
0
        public void Undo()
        {
            if (!CanUndo())
            {
                return;
            }
            bool documentChanged = false;
            int  s = GetTransactionStartIndex();

            while (currentIndex > 0 && !documentChanged)
            {
                documentChanged |= AnyChangingOperationWithinRange(s, currentIndex);
                for (; currentIndex > s; currentIndex--)
                {
                    Processors.Invert(operations[currentIndex - 1]);
                }
                s = GetTransactionStartIndex();
            }
            OnChange();
        }