Exemplo n.º 1
0
        public void OnNodeAdded(Object aChildNode, Object aParentNode, int aIndex)
        {
            // A new Element has been added somewhere. We must find the
            // parent menu and append it. To interoperate with the Content Builder,
            // the DataStore must provide |CommandTarget|s to this method.
            CommandTarget childTarget  = aChildNode as CommandTarget;
            CommandTarget parentTarget = aParentNode as CommandTarget;

            if (childTarget == null && parentTarget == null)
            {
                return;
            }

            // Determine based on conditions defined by the |TreeView|
            // whether or not this node should be built.
            if (!mTreeView.ShouldBuild(childTarget))
            {
                return;
            }

            int childKey = childTarget.Data.GetHashCode();

            if (!mNodes.ContainsKey(childKey))
            {
                int parentKey = parentTarget.Data.GetHashCode();

                ManticoreTreeNode parentNode;
                if (mNodes.ContainsKey(parentKey))
                {
                    parentNode = mNodes[parentKey] as ManticoreTreeNode;
                }
                else
                {
                    parentNode = mParent as ManticoreTreeNode;
                }

                if (parentNode != null)
                {
                    ManticoreTreeNode childNode = new ManticoreTreeNode(childTarget.Label,
                                                                        childTarget.Data);
                    if (parentNode != null)
                    {
                        int imageIndex = mTreeView.GetIconIndex(childTarget);
                        if (imageIndex > -1)
                        {
                            childNode.ImageIndex = imageIndex;
                        }

                        parentNode.Nodes.Insert(aIndex, childNode);
                        if (childTarget.IsContainer && childTarget.IsOpen)
                        {
                            childNode.Expand();
                        }
                        mNodes.Add(childKey, childNode);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Recurse(String aRoot, TreeNodeCollection aNodes)
        {
            IEnumerator items;

            mDataStore.GetElements(aRoot, out items);
            items.Reset();

            ManticoreTreeNode node;

            while (items.MoveNext())
            {
                // |id| is the item's unique identifier within the DataStore.
                // The handling code can use this to probe for more information
                // about the selected item.
                CommandTarget current = items.Current as CommandTarget;
                if (current != null)
                {
                    // Determine based on conditions defined by the |TreeView|
                    // whether or not this node should be built.
                    if (!mTreeView.ShouldBuild(current))
                    {
                        continue;
                    }

                    String id = current.Data as String;

                    int idKey = id.GetHashCode();

                    if (!mNodes.ContainsKey(idKey))
                    {
                        node = new ManticoreTreeNode(current.Label, id);

                        int imageIndex = mTreeView.GetIconIndex(current);
                        if (imageIndex > -1)
                        {
                            node.ImageIndex = imageIndex;
                        }
                        aNodes.Insert(mInsertionPoint++, node);
                        if (current.IsContainer && current.IsOpen)
                        {
                            node.Expand();
                        }
                        mNodes.Add(id.GetHashCode(), node);

                        // If we're a container, recurse
                        if (current.IsContainer)
                        {
                            Recurse(id, node.Nodes);
                        }
                    }
                }
            }

            ResetInsertionPoint();
        }
Exemplo n.º 3
0
        public void Recurse(String aRoot, TreeNodeCollection aNodes)
        {
            IEnumerator items;
              mDataStore.GetElements(aRoot, out items);
              items.Reset();

              ManticoreTreeNode node;

              while (items.MoveNext())
              {
            // |id| is the item's unique identifier within the DataStore.
            // The handling code can use this to probe for more information
            // about the selected item.
            CommandTarget current = items.Current as CommandTarget;
            if (current != null)
            {
              // Determine based on conditions defined by the |TreeView|
              // whether or not this node should be built.
              if (!mTreeView.ShouldBuild(current))
            continue;

              String id = current.Data as String;

              int idKey = id.GetHashCode();

              if (!mNodes.ContainsKey(idKey))
              {
            node = new ManticoreTreeNode(current.Label, id);

            int imageIndex = mTreeView.GetIconIndex(current);
            if (imageIndex > -1)
              node.ImageIndex = imageIndex;
            aNodes.Insert(mInsertionPoint++, node);
            if (current.IsContainer && current.IsOpen)
              node.Expand();
            mNodes.Add(id.GetHashCode(), node);

            // If we're a container, recurse
            if (current.IsContainer)
              Recurse(id, node.Nodes);
              }
            }
              }

              ResetInsertionPoint();
        }
Exemplo n.º 4
0
        public void OnNodeAdded(Object aChildNode, Object aParentNode, int aIndex)
        {
            // A new Element has been added somewhere. We must find the
              // parent menu and append it. To interoperate with the Content Builder,
              // the DataStore must provide |CommandTarget|s to this method.
              CommandTarget childTarget = aChildNode as CommandTarget;
              CommandTarget parentTarget = aParentNode as CommandTarget;
              if (childTarget == null && parentTarget == null)
            return;

              // Determine based on conditions defined by the |TreeView|
              // whether or not this node should be built.
              if (!mTreeView.ShouldBuild(childTarget))
            return;

              int childKey = childTarget.Data.GetHashCode();
              if (!mNodes.ContainsKey(childKey))
              {
            int parentKey = parentTarget.Data.GetHashCode();

            ManticoreTreeNode parentNode;
            if (mNodes.ContainsKey(parentKey))
              parentNode = mNodes[parentKey] as ManticoreTreeNode;
            else
              parentNode = mParent as ManticoreTreeNode;

            if (parentNode != null)
            {
              ManticoreTreeNode childNode = new ManticoreTreeNode(childTarget.Label,
            childTarget.Data);
              if (parentNode != null)
              {
            int imageIndex = mTreeView.GetIconIndex(childTarget);
            if (imageIndex > -1)
              childNode.ImageIndex = imageIndex;

            parentNode.Nodes.Insert(aIndex, childNode);
            if (childTarget.IsContainer && childTarget.IsOpen)
              childNode.Expand();
            mNodes.Add(childKey, childNode);
              }
            }
              }
        }