Example #1
0
        public bool MoveToFollowing()
        {
            bool retval = false;
            GeneratorNodeHelper nodeHelper = new GeneratorNodeHelper(m_currentNode, m_index, m_sourceDataIndex);

            while (!retval)
            {
                retval = nodeHelper.MoveToNext();

                if (!retval)
                {
                    if (!nodeHelper.MoveToParent())
                    {
                        //cannot move to parent and could not move to next, this is the end of the chain.
                        break;
                    }
                }
            }

            if (retval)
            {
                m_currentNode     = nodeHelper.CurrentNode;
                m_index           = nodeHelper.Index;
                m_sourceDataIndex = nodeHelper.SourceDataIndex;
            }

            return(retval);
        }
        internal ReadOnlyCollection <Group> GetImmediateUIGroups(int generatorCurrentGeneration)
        {
            if ((m_cachedGeneratorCurrentGeneration != generatorCurrentGeneration) ||
                (m_readOnlyImmediateUIGroups == null))
            {
                Debug.WriteLineIf(((m_cachedGeneratorCurrentGeneration != generatorCurrentGeneration) && (m_readOnlyImmediateUIGroups == null)),
                                  "Creating Groups collection since generator version differs AND ReadOnlyCollection is null.");

                Debug.WriteLineIf(((m_cachedGeneratorCurrentGeneration != generatorCurrentGeneration) && (m_readOnlyImmediateUIGroups != null)),
                                  "Creating Groups collection since generator version differs.");

                Debug.WriteLineIf(((m_cachedGeneratorCurrentGeneration == generatorCurrentGeneration) && (m_readOnlyImmediateUIGroups == null)),
                                  "Creating Groups collection even if generator version is the same, since ReadOnlyCollection is null.");

                m_cachedGeneratorCurrentGeneration = generatorCurrentGeneration;

                // Ensure collections.
                if (m_immediateUIGroups == null)
                {
                    Debug.Assert(m_readOnlyImmediateUIGroups == null);
                    m_immediateUIGroups         = new Collection <Group>();
                    m_readOnlyImmediateUIGroups = new ReadOnlyCollection <Group>(m_immediateUIGroups);
                }
                else
                {
                    Debug.Assert(m_readOnlyImmediateUIGroups != null);
                    m_immediateUIGroups.Clear();
                }

                // Recalculate.
                GeneratorNodeHelper nodeHelper = new GeneratorNodeHelper(this, 0, 0); //index is not important

                while (nodeHelper.MoveToNext())
                {
                    GroupGeneratorNode groupGeneratorNode = nodeHelper.CurrentNode as GroupGeneratorNode;

                    if (groupGeneratorNode == null)
                    {
                        continue;
                    }

                    m_immediateUIGroups.Add(groupGeneratorNode.UIGroup);
                }
            }

            return(m_readOnlyImmediateUIGroups);
        }
Example #3
0
        public static GeneratorNode EvaluateChain(GeneratorNode chainStart, out int totalChildCount, out int chainLength)
        {
            //if we insert a chain of nodes, this GeneratorNodeHelper will help us
            GeneratorNodeHelper newHelper = new GeneratorNodeHelper(chainStart, 0, 0);

            //first determine the total number of childs from this "node"
            totalChildCount = 0;
            chainLength     = 0;

            do
            {
                totalChildCount += newHelper.CurrentNode.ItemCount;
                chainLength++;
            }while(newHelper.MoveToNext());

            //then, since we moved at the end of the "chain"
            return(newHelper.CurrentNode);
        }
Example #4
0
        public bool MoveForward()
        {
            bool recurseGroup = true;
            GeneratorNodeHelper nodeHelper = new GeneratorNodeHelper(m_currentNode, m_index, m_sourceDataIndex);

            do
            {
                GroupGeneratorNode groupNode = nodeHelper.CurrentNode as GroupGeneratorNode;

                if ((groupNode == null) && (nodeHelper.CurrentNode != m_currentNode) && (nodeHelper.CurrentNode.ItemCount != 0))
                {
                    m_currentNode     = nodeHelper.CurrentNode;
                    m_index           = nodeHelper.Index;
                    m_sourceDataIndex = nodeHelper.SourceDataIndex;
                    return(true);
                }

                if ((recurseGroup) && (nodeHelper.MoveToChild()))
                {
                    continue;
                }

                recurseGroup = true;

                if (nodeHelper.MoveToNext())
                {
                    continue;
                }

                if (nodeHelper.MoveToParent())
                {
                    recurseGroup = false;
                    continue;
                }

                break;
            }while(true);

            return(false);
        }