Beispiel #1
0
        public override void updateAction(UndoRedoAction action)
        {
            UndoRedoChangeDataAction curChangeDataAction = action as UndoRedoChangeDataAction;

            if (curChangeDataAction != null)
            {
                mNodeAfterChanges = curChangeDataAction.mNodeAfterChanges;
            }
        }
Beispiel #2
0
        public override bool affectsSameNode(UndoRedoAction action)
        {
            UndoRedoChangeDataAction curChangeDataAction = action as UndoRedoChangeDataAction;

            if (curChangeDataAction != null)
            {
                if (curChangeDataAction.mNode == mNode)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #3
0
        // Adds an action to the undo list.  The manager will be responsible for deleting
        // the action when necessary.
        public void addUndoRedoActionAndExecute(UndoRedoAction action)
        {
            float elapseTime = (float)((TimeSpan)(System.DateTime.Now - mLastActionTime)).TotalSeconds;

            mLastActionTime = System.DateTime.Now;

            // Check if we can update the last action.
            // (If we are changing the same object and a short period of time has passed since
            // last edit, then update the last UndoRedoAction instead of adding a new one.
            // This happens often with UndoRedoChangeDataAction when sliders or edit boxes
            // are changed).
            //

            if (canUndo() && (elapseTime < MAX_ELAPSED_TIME))
            {
                long prevUndoRedoIndex = mNextUndoRedoIndex - 1;
                if (prevUndoRedoIndex < 0)
                {
                    prevUndoRedoIndex = UNDO_REDO_STACK_SIZE - 1;
                }

                if (mUndoRedoStack[prevUndoRedoIndex].affectsSameNode(action))
                {
                    mUndoRedoStack[prevUndoRedoIndex].updateAction(action);

                    // Execute the action
                    mUndoRedoStack[prevUndoRedoIndex].redo();
                    markDocDirty();

                    return;
                }
            }


            // Add new action
            //

            action.treeView = mVisualPage.getVisualTreeView();

            // Delete the action in the next position if necessary
            if (mUndoRedoStack[mNextUndoRedoIndex] != null)
            {
                mUndoRedoStack[mNextUndoRedoIndex] = null;
            }

            mUndoRedoStack[mNextUndoRedoIndex] = action;

            // Move the index to the next insertion point
            mNextUndoRedoIndex++;
            if (mNextUndoRedoIndex >= UNDO_REDO_STACK_SIZE)
            {
                mNextUndoRedoIndex = 0;
            }

            // Zero out the next action now so it can be used as a delimiter in the
            // circular array.
            if (mUndoRedoStack[mNextUndoRedoIndex] != null)
            {
                mUndoRedoStack[mNextUndoRedoIndex] = null;
            }

            // Execute the action
            action.redo();
            markDocDirty();
        }
Beispiel #4
0
 public virtual void updateAction(UndoRedoAction action)
 {
 }
Beispiel #5
0
 public virtual bool affectsSameNode(UndoRedoAction action)
 {
     return(false);
 }