示例#1
0
        private void SetupCollectionGeneratorNode(CollectionGeneratorNode newNode, GeneratorNode parent, GeneratorNode previous, GeneratorNode next)
        {
            if (previous != null)
            {
                previous.Next = newNode;
            }
            newNode.Previous = previous;

            if (next != null)
            {
                next.Previous = newNode;
            }
            newNode.Next = next;

            this.RegisterNodeCollectionChanged(( INotifyCollectionChanged )newNode.Items, new NotifyCollectionChangedEventHandler(newNode.OnCollectionChanged));

            newNode.CollectionChanged     += m_itemsChangedHandler;
            newNode.ExpansionStateChanged += m_expansionStateChangedHandler;

            if (parent != null)
            {
                newNode.AdjustItemCount(newNode.ItemCount);
            }
        }
示例#2
0
        //FindItem skips over itemless nodes.
        public int FindItem(object item)
        {
            //finding items can only be done in "forward" direction
            int retval = -1;

            GeneratorNode originalNode            = m_currentNode;
            int           originalIndex           = m_index;
            int           originalSourceDataIndex = m_sourceDataIndex;

            while (retval == -1)
            {
                ItemsGeneratorNode itemsNode = m_currentNode as ItemsGeneratorNode;

                if (itemsNode != null)
                {
                    int tmpIndex = itemsNode.Items.IndexOf(item);
                    if (tmpIndex > -1)
                    {
                        tmpIndex += itemsNode.CountDetailsBeforeDataIndex(tmpIndex);
                        //item is directly from this items node... then return the appropriate index!
                        retval = m_index + tmpIndex;
                        break;
                    }
                    else
                    {
                        //if the item is from a detail, then I don't want to "use" it!!!
                        retval = -1;
                        //but continue looping.... to find occurances of this item somewhere else in the tree
                    }
                }
                else
                {
                    CollectionGeneratorNode collectionNode = m_currentNode as CollectionGeneratorNode;

                    if (collectionNode != null)
                    {
                        int tmpIndex = collectionNode.IndexOf(item);

                        if (tmpIndex != -1)
                        {
                            retval = m_index + tmpIndex;
                            break;
                        }
                    }
                }

                //if we reach this point, it's because the item we are looking
                //for is not in this node... Try to access the child
                if (this.MoveToChild())
                {
                    continue;
                }

                //if we reach this point, it's because we have no child...
                if (this.MoveToNext())
                {
                    continue;
                }

                //final try, try "advancing" to the next item.
                if (this.MoveToFollowing())
                {
                    continue;
                }

                //up to this, we are in an endpoint, we failed.
                break;
            }

            if (retval == -1)
            {
                m_currentNode     = originalNode;
                m_index           = originalIndex;
                m_sourceDataIndex = originalSourceDataIndex;
            }

            return(retval);
        }
 public HeadersFootersGeneratorNode(IList list, GeneratorNode parent)
     : base(list, parent)
 {
 }
示例#4
0
 public ItemsGeneratorNode(IList list, GeneratorNode parent)
     : base(list, parent)
 {
 }
示例#5
0
 internal NotifyCollectionChangedGeneratorNode(GeneratorNode parent)
     : base(parent)
 {
 }
示例#6
0
 internal GeneratorNode(GeneratorNode parent)
 {
     this.Parent = parent;
 }
示例#7
0
        //-------------
        // Methods

        internal virtual void CleanGeneratorNode()
        {
            this.Previous = null;
            this.Parent   = null;
            this.Next     = null;
        }