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); }
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(); } }