Ejemplo n.º 1
0
        }// InsertChildren

        internal void InsertSpecificChild(int iChild)
        {
            SCOPEDATAITEM sdi = new SCOPEDATAITEM();

            CNode nChild = CNodeManager.GetNode(iChild);

            sdi.mask = SDI.STR |
                       SDI.PARAM |
                       SDI.PARENT |
                       SDI.IMAGE |
                       SDI.OPENIMAGE |
                       SDI.CHILDREN;

            // The image index is going to be the same as the cookie value
            sdi.nImage = CResourceStore.GetIconCookie(nChild.IconHandle);
            // The open image is the same as the closed image
            sdi.nOpenImage = sdi.nImage;
            sdi.relativeID = m_iHScopeItem;
            // We set displayname to -1 to initiate a callback for the string
            // (We need to do it this way... it's an MMCism)
            sdi.displayname = (IntPtr)(-1);

            sdi.lParam = nChild.Cookie;

            // The children field is set to either 0 or 1 (if it has children or not)
            sdi.cChildren = (nChild.NumChildren == 0)?0:1;

            // Once the item has been inserted, we're given the HScopeItem value for the node
            // MMC uses this value to uniquely identify the node. We'll store it for future
            // use.
            nChild.HScopeItem = CNodeManager.InsertItem(sdi);

            // We'll also put in the parent's HScopeItem
            nChild.m_iParentHScopeItem = HScopeItem;

            // Also, we can be slick and expand this child's node too

            // We don't care about perf savings after startup... do the expansion now
            // Also, if we have a non MMC host, we're not sure how it will behave
            // if it doesn't have all the nodes. Let's force the expand if we're not
            // running under MMC
            if (m_fInitialCreationDone || CNodeManager.Console is INonMMCHost)
            {
                // Expand this child
                CNodeManager.ExpandNodeNamespace(nChild.HScopeItem);
            }
            else if (Cookie == 0)
            {
                Thread t = new Thread(new ThreadStart(nChild.LazyExpand));
                t.Start();
            }
        }// InsertSpecificChild
Ejemplo n.º 2
0
        }// onExpand

        internal void LazyExpand()
        {
            // Expand all non-root nodes on another thread to free
            // up the main thread so it can do what it needs to do when
            // starting up
            if (Cookie != CNodeManager.RootNodeCookie && !m_fInsertedChildrenOnExpand)
            {
                ArrayList al = new ArrayList();
                al.Add(Cookie);

                // We need to expand all the children in a non-recursive way.
                // We'll use a queue approach
                while (al.Count > 0)
                {
                    CNode node = CNodeManager.GetNode((int)al[0]);

                    // First "expand" this node so it can receive children
                    CNodeManager.ExpandNodeNamespace(node.HScopeItem);

                    node.InsertChildren(node.HScopeItem);

                    node.m_fInsertedChildrenOnExpand = true;

                    // Push this node's children into our queue
                    for (int i = 0; i < node.NumChildren; i++)
                    {
                        al.Add(node.Child[i]);
                    }

                    // Remove this node we're working on
                    al.RemoveAt(0);
                }

                // All done with the initial slew of nodes
                m_fInitialCreationDone = true;
                // Let the node manager know, in case there's something else we want to do
                CNodeManager.FinishedNodeLoading();
            }
        }// LazyExpand