コード例 #1
0
 //public void RemoveAllBefore( UndoUnitNode node, Int32 newCount )
 //{
 // ArgumentValidator.ValidateNotNull( "Node", node );
 // // We have to make 'node' as new head
 // // Don't perform other sanity checks as this is not a public api...
 // var oldHead = this._head;
 // node.Previous = oldHead.Previous;
 // node.Previous.Next = node;
 // this._head = node;
 // this._count = newCount;
 //}
 private void AddToEmptyList(UndoUnitNode node)
 {
     node.Next     = node;
     node.Previous = node;
     this._head    = node;
     ++this._count;
     ++this._version;
 }
コード例 #2
0
 private void InsertNodeBefore(UndoUnitNode before, UndoUnitNode node)
 {
     node.Next            = before;
     node.Previous        = before.Previous;
     before.Previous.Next = node;
     before.Previous      = node;
     ++this._count;
     ++this._version;
 }
コード例 #3
0
 public void RemoveAllAfter(UndoUnitNode node, Int32 newCount)
 {
     ArgumentValidator.ValidateNotNull("Node", node);
     // Remember that tail is head's prev.
     // Therefore we have to make 'node' as new tail
     // Don't perform other sanity checks as this is not a public api...
     this._head.Previous = node;
     node.Next           = this._head;
     this._count         = newCount;
     ++this._version;
 }
コード例 #4
0
        private Boolean TryGetNextToUndoNode(out UndoUnitNode uNode)
        {
            // Get the next unit to undo
            var node = this._current;
            // If it is null, we can't undo anymore
            var retVal = node != null;

            // Get the unit, if can
            uNode = retVal ? node.Item1 : null;
            // Return success status
            return(retVal);
        }
コード例 #5
0
            public UndoUnitNode AddLast(T item)
            {
                var node = new UndoUnitNode(item);

                if (this._head == null)
                {
                    this.AddToEmptyList(node);
                }
                else
                {
                    this.InsertNodeBefore(this._head, node);
                }
                return(node);
            }
コード例 #6
0
                internal Enumerator(UndoUnitEnumerable enumerable)
                {
                    this._enumerable = enumerable;
                    UndoUnitNode node;

                    if (enumerable._isUndo)
                    {
                        // Undo-order
                        enumerable._buffer.TryGetNextToUndoNode(out node);
                    }
                    else
                    {
                        // Redo-order
                        enumerable._buffer.TryGetNextToRedoNode(out node);
                    }
                    this._startingNode = node;
                    this._node         = this._startingNode;
                    this._version      = enumerable._buffer._units.Version;
                }
コード例 #7
0
 private void RemoveNode(UndoUnitNode node)
 {
     // Special case - one item link, where head is also tail
     if (Object.ReferenceEquals(node, node.Next))
     {
         this._head = null;
     }
     else
     {
         // Fix prev and ndex
         node.Next.Previous = node.Previous;
         node.Previous.Next = node.Next;
         if (Object.ReferenceEquals(this._head, node))
         {
             this._head = node.Next;
         }
     }
     --this._count;
     ++this._version;
 }
コード例 #8
0
                public Boolean MoveNext()
                {
                    this.ThrowIfVersionMismatch();
                    var retVal = this._node != null;

                    if (retVal)
                    {
                        this._current = this._node.Value;
                        var isRedo = !this._enumerable._isUndo;
                        this._node = isRedo ? this._node.Next : this._node.Previous;
                        var list = this._enumerable._buffer._units;
                        if (Object.ReferenceEquals(
                                this._node,
                                isRedo ? list.First : list.Last
                                ))
                        {
                            this._node = null;
                        }
                    }
                    return(retVal);
                }
コード例 #9
0
        private Boolean TryGetNextToRedoNode(out UndoUnitNode uNode)
        {
            // Get next unit to undo
            var     node = this._current;
            Boolean retVal;

            // Check if we have anything to undo
            if (node == null)
            {
                // If there is nothing to undo, we can redo only if there are undo units in buffer
                retVal = this._units.Count > 0;
                // The undo unit will be the first unit of the buffer
                uNode = retVal ? this._units.First : null;
            }
            else
            {
                // If there is something to undo, we can redo only if next to undo is not the last unit in buffer
                retVal = !this.IsLast(node);
                // The undo unit will be the next value of the next-to-undo item.
                uNode = retVal ? node.Item1.Next : null;
            }
            return(retVal);
        }
コード例 #10
0
 public UndoUnitList()
 {
     this._head = null;
 }
コード例 #11
0
 public void Reset()
 {
     this.ThrowIfVersionMismatch();
     this._node = this._startingNode;
 }
コード例 #12
0
 public void Clear()
 {
     this._head  = null;
     this._count = 0;
     ++this._version;
 }