示例#1
0
        protected virtual void CreateControlHierarchy()
        {
            if (!this.Visible)
            {
                return;
            }

            ArrayList   nodes = new ArrayList();
            SiteMapNode node  = Provider.CurrentNode;

            if ((node == null) && (overrideCurrentNode != null))
            {
                node = overrideCurrentNode;
            }

            if (node == null)
            {
                return;
            }

            int levels = ParentLevelsDisplayed != -1 ? ParentLevelsDisplayed + 1 : int.MaxValue;

            while (node != null && levels > 0)
            {
                if (nodes.Count > 0)
                {
                    mojoSiteMapNodeItem sep = new mojoSiteMapNodeItem(nodes.Count, SiteMapNodeItemType.PathSeparator);
                    InitializeItem(sep);
                    SiteMapNodeItemEventArgs sargs = new SiteMapNodeItemEventArgs(sep);
                    OnItemCreated(sargs);
                    nodes.Add(sep);
                }

                SiteMapNodeItemType nt;
                if (nodes.Count == 0)
                {
                    nt = SiteMapNodeItemType.Current;
                }
                else if (node.ParentNode == null)
                {
                    nt = SiteMapNodeItemType.Root;
                }
                else
                {
                    nt = SiteMapNodeItemType.Parent;
                }

                mojoSiteMapNodeItem it = new mojoSiteMapNodeItem(nodes.Count, nt);
                it.SiteMapNode = node;
                InitializeItem(it);

                SiteMapNodeItemEventArgs args = new SiteMapNodeItemEventArgs(it);
                OnItemCreated(args);

                nodes.Add(it);
                node = node.ParentNode;
                levels--;
            }

            if (PathDirection == PathDirection.RootToCurrent)
            {
                for (int n = nodes.Count - 1; n >= 0; n--)
                {
                    Controls.Add((Control)nodes[n]);
                }
            }
            else
            {
                for (int n = 0; n < nodes.Count; n++)
                {
                    Controls.Add((Control)nodes[n]);
                }
            }
        }
示例#2
0
        protected virtual void CreateControlHierarchy()
        {
            if (!this.Visible) { return; }

            ArrayList nodes = new ArrayList ();
            SiteMapNode node = Provider.CurrentNode;

            if ((node == null) && (overrideCurrentNode != null)) { node = overrideCurrentNode; }

            if (node == null) { return; }

            int levels = ParentLevelsDisplayed != -1 ? ParentLevelsDisplayed + 1 : int.MaxValue;

            while (node != null && levels > 0) {
                if (nodes.Count > 0) {
                    mojoSiteMapNodeItem sep = new mojoSiteMapNodeItem(nodes.Count, SiteMapNodeItemType.PathSeparator);
                    InitializeItem (sep);
                    SiteMapNodeItemEventArgs sargs = new SiteMapNodeItemEventArgs (sep);
                    OnItemCreated (sargs);
                    nodes.Add (sep);
                }

                SiteMapNodeItemType nt;
                if (nodes.Count == 0)
                    nt = SiteMapNodeItemType.Current;
                else if (node.ParentNode == null)
                    nt = SiteMapNodeItemType.Root;
                else
                    nt = SiteMapNodeItemType.Parent;

                mojoSiteMapNodeItem it = new mojoSiteMapNodeItem(nodes.Count, nt);
                it.SiteMapNode = node;
                InitializeItem (it);

                SiteMapNodeItemEventArgs args = new SiteMapNodeItemEventArgs (it);
                OnItemCreated (args);

                nodes.Add (it);
                node = node.ParentNode;
                levels--;
            }

            if (PathDirection == PathDirection.RootToCurrent) {
                for (int n=nodes.Count - 1; n>=0; n--)
                    Controls.Add ((Control)nodes[n]);
            } else {
                for (int n=0; n<nodes.Count; n++)
                    Controls.Add ((Control)nodes[n]);
            }
        }