Beispiel #1
0
        protected void contentsControl_SelectedTopicChanged(object sender, EventArgs e)
        {
            if (!changingSelection)
            {
                changingSelection = true;
                ContentsSelected  = true;

                if (DocSiteNavigator.NavigateToTopic(contentsControl.SelectedTopic, false))
                {
                    indexControl.SelectedHelpFile = DocSiteNavigator.ResolveTopicHelpFile(contentsControl.SelectedTopic, false);
                }

                changingSelection = false;
            }
        }
        private void SyncSidebar()
        {
            string topic = null, helpFile = null;

            if (!Page.IsPostBack)
            {
                if (Request.QueryString["filenotfound"] != null)
                {
                    ContentPath = DocSiteManager.Settings.FileNotFoundPath;
                }
                else
                {
                    topic    = Request.QueryString["topic"];
                    helpFile = Request.QueryString["helpfile"];

                    if (!string.IsNullOrEmpty(topic))
                    {
                        topic = DocSiteNavigator.FormatTopic(topic, false);
                    }
                }
            }
            else
            {
                string topicPath = ContentUrl.Value;

                if (!string.IsNullOrEmpty(topicPath))
                {
                    Uri topicUri;

                    if (Uri.TryCreate(topicPath, UriKind.RelativeOrAbsolute, out topicUri) &&
                        (!topicUri.IsAbsoluteUri || topicUri.Host.Equals(Request.Url.Host, StringComparison.OrdinalIgnoreCase)))
                    {
                        helpFile = (topicUri.IsAbsoluteUri) ? topicUri.AbsolutePath : topicUri.ToString();

                        if (helpFile.StartsWith("/") || helpFile.StartsWith(@"\"))
                        {
                            helpFile = helpFile.Substring(1);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(helpFile))
            {
                helpFile = DocSiteNavigator.ResolveTopicHelpFile(topic, false) ?? DocSiteManager.Settings.HelpFileNotFoundPath;
            }

            if (string.IsNullOrEmpty(topic))
            {
                topic = DocSiteNavigator.ResolveHelpFileTopic(helpFile, false);

                if (topic == null)
                {
                    helpFile = DocSiteManager.Settings.HelpFileNotFoundPath;
                }
            }

            ContentPath = helpFile;

            Controls.DocSiteSidebar sidebar = ((DocSite)Page.Master).Sidebar;

            if (!sidebar.TableOfContents.SelectedTopic.Equals(topic, StringComparison.Ordinal))
            {
                sidebar.Initialize(topic, helpFile);
            }
        }