示例#1
0
        /// <summary>
        /// Restore the state of some models to before the current <see cref="IUndoableEdit"/>.
        /// </summary>
        /// <remarks>
        /// This calls <see cref="IUndoableEdit.Undo"/> on the current <see cref="EditToUndo"/>.
        /// This will raise a <see cref="IDiagramModel.Changed"/> event with a hint of
        /// <see cref="ModelChange.StartingUndo"/> before actually performing the undo, and will raise a
        /// Changed event with a hint of <see cref="ModelChange.FinishedUndo"/> afterwards.
        /// The <see cref="ModelChangedEventArgs.Data"/>
        /// is the <see cref="UndoManager.CompoundEdit"/> that was the value of
        /// <see cref="EditToUndo"/> before calling Undo.
        /// </remarks>
        /// <seealso cref="CanUndo"/>
        public virtual void Undo()
        {
            if (!CanUndo())
            {
                return;
            }
            IUndoableEdit edit = this.EditToUndo;

            try {
                foreach (IDiagramModel model in this.ModelsList)
                {
                    RaiseChanged(model, ModelChange.StartingUndo, edit, null, null);
                }
                this.IsUndoingRedoing = true;
                this.UndoEditIndex--;
                edit.Undo();
            } catch (Exception ex) {
                ModelHelper.Trace("Undo: " + ex.ToString());
                throw;
            } finally {
                this.IsUndoingRedoing = false;
                foreach (IDiagramModel model in this.ModelsList)
                {
                    RaiseChanged(model, ModelChange.FinishedUndo, edit, null, null);
                }
            }
        }
示例#2
0
 public virtual void Undo()
 {
     if (this.CanUndo())
     {
         try
         {
             this.myIsUndoing = true;
             IUndoableEdit edit1 = this.EditToUndo;
             this.myCurrentEditIndex--;
             edit1.Undo();
             foreach (DiagramDocument document1 in this.Documents)
             {
                 document1.InvalidateViews();
             }
         }
         catch (Exception exception1)
         {
             Shapes.DiagramShape.Trace("Undo: " + exception1.ToString());
             throw exception1;
         }
         finally
         {
             this.myIsUndoing = false;
         }
     }
 }
示例#3
0
 public virtual void Undo()
 {
     if (this.CanUndo())
     {
         for (int num1 = this.myEdits.Count - 1; num1 >= 0; num1--)
         {
             IUndoableEdit edit1 = (IUndoableEdit)this.myEdits[num1];
             edit1.Undo();
         }
     }
 }
示例#4
0
        /**
         * Undoes all changes from indexOfNextAdd to edit. Updates indexOfNextAdd accordingly.
         */
        protected void UndoTo(IUndoableEdit edit)
        {
            bool done = false;

            while (!done)

            {
                IUndoableEdit next = edits[--indexOfNextAdd];
                next.Undo();
                done = next == edit;
            }
        }
示例#5
0
 // partial undo, to implement rollback for nested RollbackTransaction() calls
 internal /*?? public */ void RollbackTo(int start)
 {
     for (int i = this.Edits.Count - 1; i >= start; i--)
     {
         IUndoableEdit edit = this.Edits[i];
         if (edit != null)
         {
             edit.Undo();
         }
         this.Edits.RemoveAt(i);
     }
 }
示例#6
0
 protected void UndoTo(IUndoableEdit e)
 {
     while (true)
     {
         IUndoableEdit edit = edits[--index];
         edit.Undo();
         if (edit == e)
         {
             return;
         }
     }
 }
示例#7
0
 /// <summary>
 /// Undo all of the <see cref="IUndoableEdit"/>s, in reverse order.
 /// </summary>
 public void Undo()
 {
     if (CanUndo())
     {
         for (int i = this.Edits.Count - 1; i >= 0; i--)
         {
             IUndoableEdit edit = this.Edits[i];
             if (edit != null)
             {
                 edit.Undo();
             }
         }
     }
 }
        public void ApplyRiskLevelToChildrenTest()
        {
            effect1 = new Effect(structure);
            StateObjectManager rlm = new StateObjectManager(effect1);

            eq11.AddEffect(effect1);
            IUndoableEdit edit = rlm.ChangeState(State.FAULTY);

            Assert.AreEqual(State.FAULTY, eq11.CurrentState);
            Assert.IsFalse(dep.Combinations.Contains(combi1));

            ((CompoundEdit)edit).EndAllEdits();
            edit.Undo();
            Assert.AreNotEqual(State.FAULTY, eq11.CurrentState);
            Assert.IsTrue(dep.Combinations.Contains(combi1));
            edit.Redo();
        }
        public void ApplyRiskLevelToChildrenTest()
        {
            effect1 = new Effect(structure);
            RiskLevelManager rlm = new RiskLevelManager(effect1);

            eq11.AddEffect(effect1);
            effect1.RiskLevel = 6;
            IUndoableEdit edit = rlm.ApplyRiskLevelToChildren();

            Assert.AreEqual(6, eq11.RiskLevel);
            Assert.AreEqual(6, combi2.RiskLevel);
            Assert.AreEqual(6, combi1.RiskLevel);
            Assert.AreEqual(6, test1.RiskLevel);
            ((CompoundEdit)edit).EndAllEdits();
            edit.Undo();
            Assert.AreNotEqual(6, eq11.RiskLevel);
            Assert.AreNotEqual(6, combi2.RiskLevel);
            Assert.AreNotEqual(6, combi1.RiskLevel);
            Assert.AreNotEqual(6, test1.RiskLevel);
            edit.Redo();
        }