Beispiel #1
0
 private void UndoHiddenContainersOnOpenStack()
 {
     while (this.openStack.Count > 0)
     {
         IUndoUnitContainer undoUnitContainer = this.openStack.Pop();
         undoUnitContainer.Undo();
         undoUnitContainer.Dispose();
     }
 }
Beispiel #2
0
 public void Cancel()
 {
     this.CheckNotClosed();
     try
     {
         this.undoService.Cancel(this.container);
     }
     finally
     {
         this.container = (IUndoUnitContainer)null;
     }
 }
Beispiel #3
0
        private IUndoUnitContainer FirstNonHiddenContainer(Stack <IUndoUnitContainer> stack)
        {
            IUndoUnitContainer undoUnitContainer1 = (IUndoUnitContainer)null;

            foreach (IUndoUnitContainer undoUnitContainer2 in stack)
            {
                if (!undoUnitContainer2.IsHidden)
                {
                    undoUnitContainer1 = undoUnitContainer2;
                    break;
                }
            }
            return(undoUnitContainer1);
        }
Beispiel #4
0
        private void PopAndValidate(IUndoUnitContainer container)
        {
            if (this.openStackDepth == 0)
            {
                throw new InvalidOperationException(ExceptionStringTable.CannotEndWithoutOpenUndoContainer);
            }
            IUndoUnitContainer undoUnitContainer = this.openStack.Peek();

            if (container != undoUnitContainer)
            {
                throw new InvalidOperationException(ExceptionStringTable.CannotEndUndoContainersOutOfOrder);
            }
            container.IsClosed = true;
            this.openStack.Pop();
            --this.openStackDepth;
        }
Beispiel #5
0
 private void End(IUndoUnitContainer container)
 {
     this.PopAndValidate(container);
     if (container.IsEmpty)
     {
         return;
     }
     if (this.openStackDepth != 0)
     {
         this.openStack.Peek().Add((IUndoUnit)container);
     }
     else if (container.IsHidden)
     {
         if (this.openStack.Count > 0)
         {
             IUndoUnitContainer undoUnitContainer = this.openStack.Peek();
             if (undoUnitContainer != this.cleanMarker)
             {
                 undoUnitContainer.IsClosed = false;
                 undoUnitContainer.Add((IUndoUnit)container);
                 undoUnitContainer.IsClosed = true;
             }
             else
             {
                 this.openStack.Push(container);
             }
         }
         else
         {
             this.openStack.Push(container);
         }
     }
     else
     {
         IUndoUnitContainer[] undoUnitContainerArray = this.openStack.ToArray();
         for (int index = undoUnitContainerArray.Length - 1; index >= 0; --index)
         {
             this.undoStack.Push(undoUnitContainerArray[index]);
         }
         this.openStack.Clear();
         this.undoStack.Push(container);
         this.OnUndoStackChanged(new UndoStackChangedEventArgs(UndoStackChangeType.NodeAdded));
         this.ClearRedoStack();
         this.OnRedoStackChanged(new UndoStackChangedEventArgs(UndoStackChangeType.StackCleared));
     }
 }
Beispiel #6
0
 public UndoTransaction(UndoService undoService, string description, bool isHidden)
 {
     this.undoService = undoService;
     this.container   = this.undoService.Begin(description, isHidden);
 }
Beispiel #7
0
 private void Cancel(IUndoUnitContainer container)
 {
     this.PopAndValidate(container);
     container.Undo();
 }