protected void Do(IUndoMemento memento, IEditorItem extraUndoNode)
        {
            FireUndoableActionEvent(memento);
            DoRedoActions(this, memento);

            // Have to save the state after the edit is complete
            // so that subsequent ReDo commands can always go back to
            // this exact same state
            if (extraUndoNode != null)
            {
                saveNodeState(extraUndoNode, memento);
                var theirParent = extraUndoNode.Parent;
                while (theirParent != null)
                {
                    saveNodeState(theirParent, memento);
                    theirParent = theirParent.Parent;
                }
            }

            saveNodeState(this, memento);
            var myParent = Parent;

            while (myParent != null)
            {
                saveNodeState(myParent, memento);
                myParent = myParent.Parent;
            }
        }
 private void saveNodeState(INodeWrapper nodeWrapper, IUndoMemento memento)
 {
     if (nodeWrapper != null && memento != null)
     {
         var saveNodeWrapper = nodeWrapper;
         var saveNode        = saveNodeWrapper.Node;
         memento.RedoActions.Add(() => saveNodeWrapper.StealthSetNode(saveNode));
     }
 }
 public static void DoRedoActions(IUndoRedo context, IUndoMemento memento)
 {
     if (memento.Sender == context)
     {
         foreach (var redoAction in memento.RedoActions)
         {
             redoAction();
         }
     }
 }
예제 #4
0
 /// <summary>
 /// This gets called whenever there's *any* UndoableAction
 /// event below this in the page.  We record it in case
 /// the user wants to undo.
 /// </summary>
 void EditorRoot_UndoableAction(IUndoMemento memento)
 {
     m_redoStack.Clear();
     if (m_undoStack.Count > 0)
     {
         var last = m_undoStack.Peek();
         memento.BindWithPrevious = last.BindWithNext;
     }
     m_undoStack.Push(memento);
     boundUndoStackSize();
 }
        public void FireUndoableActionEvent(IUndoMemento memento)
        {
            var evt = UndoableAction;

            if (evt != null)
            {
                logger.Info("Firing UndoableActionEvent in item " + this.GetType().ToString());
                // When a re-do action happens, we're doing the edit again *at the source of the edit*
                // so all the parent, grandparent, etc. nodes have new ID's generated, when really we
                // want them to revert to their old IDs.  This just does a quick set of them back
                // to the original node values that existed before the edit was made.
                var origNode = Node;
                memento.UndoActions.Add(() => StealthSetNode(origNode));
                evt(memento);
            }
        }
 /// <summary>
 /// This is really a helper function so the derived Editor Item
 /// can just build up the memento and call Do() with it.  That will
 /// execute the Redo Actions and also fire off the event.
 /// </summary>
 protected void Do(IUndoMemento memento)
 {
     NotifySignals(() => Do(memento, null));
 }
 // Called when we want to execute a Redo at this node
 public virtual void Redo(IUndoMemento memento)
 {
     disableEditedDeletedEvents = true;
     NotifySignals(() => DoRedoActions(this, memento));
     disableEditedDeletedEvents = false;
 }
예제 #8
0
 public static void DoRedoActions(IUndoRedo context, IUndoMemento memento)
 {
     if (memento.Sender == context)
     {
         foreach (var redoAction in memento.RedoActions)
         {
             redoAction();
         }
     }
 }
예제 #9
0
 private void saveNodeState(INodeWrapper nodeWrapper, IUndoMemento memento)
 {
     if (nodeWrapper != null && memento != null)
     {
         var saveNodeWrapper = nodeWrapper;
         var saveNode = saveNodeWrapper.Node;
         memento.RedoActions.Add(() => saveNodeWrapper.StealthSetNode(saveNode));
     }
 }
예제 #10
0
        protected void Do(IUndoMemento memento, IEditorItem extraUndoNode)
        {
            FireUndoableActionEvent(memento);
            DoRedoActions(this, memento);

            // Have to save the state after the edit is complete
            // so that subsequent ReDo commands can always go back to
            // this exact same state
            if (extraUndoNode != null)
            {
                saveNodeState(extraUndoNode, memento);
                var theirParent = extraUndoNode.Parent;
                while (theirParent != null)
                {
                    saveNodeState(theirParent, memento);
                    theirParent = theirParent.Parent;
                }
            }

            saveNodeState(this, memento);
            var myParent = Parent;
            while (myParent != null)
            {
                saveNodeState(myParent, memento);
                myParent = myParent.Parent;
            }
        }
예제 #11
0
 /// <summary>
 /// This is really a helper function so the derived Editor Item 
 /// can just build up the memento and call Do() with it.  That will
 /// execute the Redo Actions and also fire off the event.
 /// </summary>
 protected void Do(IUndoMemento memento)
 {
     NotifySignals(() => Do(memento, null));
 }
예제 #12
0
 // Called when we want to execute an Undo at this node
 public virtual void Undo(IUndoMemento memento)
 {
     disableEditedDeletedEvents = true;
     NotifySignals(() => DoUndoActions(this, memento));
     disableEditedDeletedEvents = false;
 }
예제 #13
0
 public void FireUndoableActionEvent(IUndoMemento memento)
 {
     var evt = UndoableAction;
     if (evt != null)
     {
         logger.Info("Firing UndoableActionEvent in item " + this.GetType().ToString());
         // When a re-do action happens, we're doing the edit again *at the source of the edit*
         // so all the parent, grandparent, etc. nodes have new ID's generated, when really we
         // want them to revert to their old IDs.  This just does a quick set of them back
         // to the original node values that existed before the edit was made.
         var origNode = Node;
         memento.UndoActions.Add(() => StealthSetNode(origNode));
         evt(memento);
     }
 }