示例#1
0
 private void InitializeView( )
 {
     _view = new HtmlHelp2SearchResultsView();
     this.Controls.Add(_view);
     _view.Parent = this;
     _view.Dock   = DockStyle.Fill;
     _view.Show();
 }
示例#2
0
        public bool PerformF1Fts(string keyword, bool useDynamicHelp)
        {
            if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(keyword) || searchIsBusy)
            {
                return(false);
            }

            this.PerformFts(keyword, useDynamicHelp);

            HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance;

            return(searchResults.SearchResultsListView.Items.Count > 0);
        }
示例#3
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();
            }
        }