Ejemplo n.º 1
0
        /// <summary>
        /// Pushes new action to the stack.
        /// </summary>
        public void Add(EditAction action)
        {
            if (_GroupingUndoChain != null)
            {
                // put given action to the head of the chain
                action.Next        = _GroupingUndoChain;
                _GroupingUndoChain = action;
            }
            else
            {
                // if there is no more space, expand buffer
                if (_Stack.Length <= _NextIndex)
                {
                    Utl.ResizeArray(ref _Stack, _Stack.Length + GrowSize);
                }

                // stack up this action
                _Stack[_NextIndex] = action;
                _NextIndex++;
                if (_NextIndex < _Stack.Length)
                {
                    _Stack[_NextIndex] = null;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Begins grouping up editing actions into a single UNDO action.
 /// </summary>
 public void BeginUndo()
 {
     if (_GroupingUndoChain == null)
     {
         _GroupingUndoChain = new EditAction(null,
                                             0, null, null,
                                             0, 0, null);
     }
     _GroupUndoDepth++;
 }
Ejemplo n.º 3
0
 public void SetSavedState()
 {
     if (0 < _NextIndex)
     {
         _LastSavedAction = _Stack[_NextIndex - 1];
     }
     else
     {
         _LastSavedAction = null;
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the action most recently done and remove it from stack.
        /// </summary>
        public EditAction GetRedoAction()
        {
            if (_NextIndex < _Stack.Length &&
                _Stack[_NextIndex] != null)
            {
                EditAction redoAction = _Stack[_NextIndex];
                _NextIndex++;
                return(redoAction);
            }

            return(null);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Ends grouping up editing actions.
 /// </summary>
 public void EndUndo()
 {
     _GroupUndoDepth--;
     if (_GroupUndoDepth <= 0)
     {
         if (_GroupingUndoChain != null)
         {
             EditAction groupedAction = _GroupingUndoChain;
             _GroupingUndoChain = null;
             if (groupedAction.HasNoEffect == false)
             {
                 Add(groupedAction);
             }
         }
         _GroupUndoDepth = 0;
     }
 }