Пример #1
0
        public override void DataBind()
        {
            this.hedHeadline.InnerSpan = this.HeadingInnerSpan;
            this.hedHeadline.Level     = this.HeadingLevel;

            if (this.HeaderTemplate == null)
            {
                this.HeaderTemplate = new DefaultHeaderTemplate(this.RenderId ? this.ID : null, this.CssClass);
            }
            if (this.ItemTemplate == null)
            {
                this.ItemTemplate = new DefaultItemTemplate();
            }
            if (this.FooterTemplate == null)
            {
                this.FooterTemplate = new DefaultFooterTemplate();
            }
            if (this.PopulateNavigationItemDelegate == null)
            {
                this.PopulateNavigationItemDelegate = PopulateNavigationItem;
            }
            if (this.GetNavigationItemNameDelegate == null)
            {
                this.GetNavigationItemNameDelegate = GetNavigationItemName;
            }
            if (this.GetNavigationItemLinkDelegate == null)
            {
                this.GetNavigationItemLinkDelegate = GetNavigationItemLink;
            }
            if (this.GetNavigationItemDelegate == null)
            {
                this.GetNavigationItemDelegate = GetNavigationItem;
            }
            if (this.GetNavigationAnchorDelegate == null)
            {
                this.GetNavigationAnchorDelegate = GetNavigationAnchor;
            }
            if (this.CreateWebNavigationControlDelegate == null)
            {
                this.CreateWebNavigationControlDelegate = this.CreateWebNavigationControl;
            }

            this.OnDataBinding(EventArgs.Empty);

            if (this.StartLevelFromRoot < 0)
            {
                this.StartLevelFromRoot = this.ExpandAll ? 0 : 1;
            }

            if (this.SelectedNavigationPage == null)
            {
                this.SelectedNavigationPage = this.CurrentPage;
            }

            if (this.RootPage == null || this.RootPage.Id == null)
            {
                this.RootPage = this.SiteRoot;
            }

            if (!this.HeadingVisible && !this.HeadingAlwaysVisible)
            {
                hedHeadline.Visible = false;
            }

            if (this.NavPage == null)
            {
                this.NavPage = GetPageToExpand(this.RootPage, this.SelectedNavigationPage, this.StartLevelFromRoot);
            }

            if (this.NavPage == null && this.FallbackStartLevel >= 0)
            {
                this.NavPage = GetPageToExpand(this.RootPage, this.SelectedNavigationPage, this.FallbackStartLevel);
            }

            if (this.NavPage != null)
            {
                var npa = new WebNavigationPageArgs(this.NavPage);

                ancHeadline.Text = this.GetNavigationItemNameDelegate(npa);
                if (this.HeadingClickable)
                {
                    ancHeadline.NavigateUrl = this.GetNavigationItemLinkDelegate(npa);
                }
                else
                {
                    ancHeadline.NoLink = true;
                }

                NavigationPageCollection childNodes;
                if (this.IncludeRootLevelInList)
                {
                    childNodes = new NavigationPageCollection();
                    childNodes.Add(this.NavPage);
                }
                else if (this.NavPage.Id.Equals(this.RootPage.Id) ||
                         this.IncludeChildrenOfRemovedNodesMode.Equals(IncludeChildrenOfRemovedNodesMode.Always) ||
                         this.FilterNavigation(new NavigationPageCollection(new[] { this.NavPage }), null).Count.Equals(1))
                {
                    childNodes = this.GetChildren(this.NavPage);
                }
                else
                {
                    childNodes = new NavigationPageCollection();
                    if (this.IncludeChildrenOfRemovedNodesMode.Equals(IncludeChildrenOfRemovedNodesMode.OnlyInSelectedPath))
                    {
                        foreach (var child in this.GetChildren(this.NavPage))
                        {
                            if (this.IsPageInSelectedPath(this.RootPage, child, this.SelectedNavigationPage))
                            {
                                childNodes.Add(child);
                            }
                        }
                    }
                }

                var removedChildNodes =
                    !this.IncludeRootLevelInList && this.IncludeChildrenOfRemovedNodesMode > IncludeChildrenOfRemovedNodesMode.Never ?
                    new NavigationPageCollection() : null;
                childNodes = FilterNavigation(childNodes, removedChildNodes);

                if (!this.IncludeRootLevelInList &&
                    this.IncludeChildrenOfRemovedNodesMode > IncludeChildrenOfRemovedNodesMode.Never)
                {
                    var nonRemovedDescendants = GetNonRemovedDescendants(removedChildNodes);
                    if (this.IncludeChildrenOfRemovedNodesMode.Equals(IncludeChildrenOfRemovedNodesMode.OnlyInSelectedPath))
                    {
                        foreach (var descendant in nonRemovedDescendants)
                        {
                            if (this.IsPageInSelectedPath(this.RootPage, descendant, this.SelectedNavigationPage))
                            {
                                childNodes.Add(descendant);
                            }
                        }
                    }
                    else
                    {
                        childNodes.AddRange(nonRemovedDescendants);
                    }
                }
                rptNavigation.DataSource = childNodes;
                rptNavigation.DataBind();
            }

            if (this.visibleChildren == 0)
            {
                if (this.HeadingAlwaysVisible && ancHeadline.Text.Length > 0)
                {
                    rptNavigation.Visible = false;
                }
                else
                {
                    this.Visible = false;
                }
            }
            else
            {
                this.visibleLevels++;
            }
            OnDataBound(EventArgs.Empty);
        }
Пример #2
0
 public abstract string GetNavigationItemLink(WebNavigationPageArgs args);