Exemplo n.º 1
0
        private bool CallDynamicHelp(string searchTerm, bool keywordSearch)
        {
            if (!HtmlHelp2Environment.SessionIsInitialized || HtmlHelp2Environment.DynamicHelpIsBusy)
            {
                return(false);
            }

            IHxTopicList topics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchTerm);
            bool         result = (topics != null && topics.Count > 0);

            if (result)
            {
                // debug info
                this.debugPreElement +=
                    string.Format(CultureInfo.InvariantCulture,
                                  "{0} ({1}): {2} {3}<br>", searchTerm, (keywordSearch)?"Kwd":"DH",
                                  topics.Count, (topics.Count == 1)?"topic":"topics");

                List <IHxTopic> newTopics = SortTopics(topics);
                foreach (IHxTopic topic in newTopics)
                {
                    if ((keywordSearch)?SharpDevLanguage.CheckUniqueTopicLanguage(topic):SharpDevLanguage.CheckTopicLanguage(topic))
                    {
                        this.BuildNewChild(topic.Location,
                                           topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle,
                                                           HxTopicGetTitleDefVal.HxTopicGetTitleFileName),
                                           topic.URL);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        private void FilterChanged(object sender, EventArgs e)
        {
            string selectedFilterName = filterCombobox.SelectedItem.ToString();

            if (!string.IsNullOrEmpty(selectedFilterName))
            {
                HtmlHelp2Environment.FindFilterQuery(selectedFilterName);
            }
        }
Exemplo n.º 3
0
 private void LoadToc()
 {
     if (this.SetToc(HtmlHelp2Environment.CurrentFilterName))
     {
         filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged);
         HtmlHelp2Environment.BuildFilterList(filterCombobox);
         filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged);
     }
 }
Exemplo n.º 4
0
        private void NamespaceReloaded(object sender, EventArgs e)
        {
            this.UpdateControls();

            if (HtmlHelp2Environment.SessionIsInitialized)
            {
                filterCombobox.SelectedIndexChanged -= new EventHandler(FilterChanged);
                HtmlHelp2Environment.BuildFilterList(filterCombobox);
                filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged);
            }
        }
Exemplo n.º 5
0
 private void LoadIndex( )
 {
     if (this.SetIndex(HtmlHelp2Environment.CurrentFilterName))
     {
         searchTerm.Text = string.Empty;
         searchTerm.Items.Clear();
         filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged);
         HtmlHelp2Environment.BuildFilterList(filterCombobox);
         filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged);
     }
 }
Exemplo n.º 6
0
 private bool SetToc(string filterName)
 {
     try
     {
         tocControl.Hierarchy =
             HtmlHelp2Environment.GetTocHierarchy(HtmlHelp2Environment.FindFilterQuery(filterName));
         return(true);
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         LoggingService.Error("Help 2.0: Cannot connect to the IHxHierarchy interface.");
         return(false);
     }
 }
Exemplo n.º 7
0
 private bool SetIndex(string filterName)
 {
     try
     {
         indexControl.IndexData =
             HtmlHelp2Environment.GetIndex(HtmlHelp2Environment.FindFilterQuery(filterName));
         return(true);
     }
     catch (System.Runtime.InteropServices.COMException)
     {
         LoggingService.Error("Help 2.0: cannot connect to IHxIndex interface (Index)");
         return(false);
     }
 }
Exemplo n.º 8
0
        private void UpdateControls( )
        {
            titlesOnly.Enabled     = HtmlHelp2Environment.SessionIsInitialized;
            enableStemming.Enabled = HtmlHelp2Environment.SessionIsInitialized;
            hiliteTopics.Enabled   = HtmlHelp2Environment.SessionIsInitialized;
            filterCombobox.Enabled = HtmlHelp2Environment.SessionIsInitialized;
            searchTerm.Enabled     = HtmlHelp2Environment.SessionIsInitialized;

            searchTerm.Text = string.Empty;
            searchTerm.Items.Clear();
            filterCombobox.Items.Clear();

            if (HtmlHelp2Environment.SessionIsInitialized)
            {
                HtmlHelp2Environment.BuildFilterList(filterCombobox);
            }
        }
Exemplo n.º 9
0
        private void PerformFts(string searchWord, bool useDynamicHelp)
        {
            if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(searchWord) || searchIsBusy)
            {
                return;
            }

            HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance;

            HtmlHelp2Dialog searchDialog = new HtmlHelp2Dialog();

            try
            {
                searchIsBusy = true;
                IHxTopicList matchingTopics = null;

                HxQuery_Options searchFlags = HxQuery_Options.HxQuery_No_Option;
                searchFlags |= (titlesOnly.Checked)?HxQuery_Options.HxQuery_FullTextSearch_Title_Only:HxQuery_Options.HxQuery_No_Option;
                searchFlags |= (enableStemming.Checked)?HxQuery_Options.HxQuery_FullTextSearch_Enable_Stemming:HxQuery_Options.HxQuery_No_Option;
                searchFlags |= (reuseMatches.Checked)?HxQuery_Options.HxQuery_FullTextSearch_SearchPrevious:HxQuery_Options.HxQuery_No_Option;

                searchDialog.Text        = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSearchCaption}");
                searchDialog.ActionLabel = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSearchInProgress}",
                                                              new string[, ]
                {
                    { "0", searchWord }
                });
                searchDialog.Show();
                Application.DoEvents();
                Cursor.Current = Cursors.WaitCursor;
                if (useDynamicHelp)
                {
                    matchingTopics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchWord);
                }
                else
                {
                    matchingTopics = HtmlHelp2Environment.Fts.Query(searchWord, searchFlags);
                }

                Cursor.Current = Cursors.Default;

                try
                {
                    searchResults.CleanUp();
                    searchResults.SearchResultsListView.BeginUpdate();

                    foreach (IHxTopic topic in matchingTopics)
                    {
                        if (useCurrentLang.Checked && !useDynamicHelp && !SharpDevLanguage.CheckTopicLanguage(topic))
                        {
                            continue;
                        }

                        ListViewItem lvi = new ListViewItem();
                        lvi.Text = topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle,
                                                   HxTopicGetTitleDefVal.HxTopicGetTitleFileName);
                        lvi.Tag = topic;
                        lvi.SubItems.Add(topic.Location);
                        lvi.SubItems.Add(topic.Rank.ToString(CultureInfo.CurrentCulture));

                        searchResults.SearchResultsListView.Items.Add(lvi);
                    }

                    reuseMatches.Enabled = true;
                }
                finally
                {
                    searchResults.SearchResultsListView.EndUpdate();
                    searchResults.SetStatusMessage(searchTerm.Text);
                    SearchAndReplace.SearchResultPanel.Instance.ShowSearchResults(
                        new SearchAndReplace.SearchResult(searchTerm.Text, searchResults)
                        );
                    searchIsBusy = false;
                }
            }
            catch (System.Runtime.InteropServices.COMException ex)
            {
                LoggingService.Error("Help 2.0: cannot get matching search word; " + ex.ToString());

                foreach (Control control in this.mainPanel.Controls)
                {
                    control.Enabled = false;
                }
            }
            finally
            {
                searchDialog.Dispose();
            }
        }