コード例 #1
0
        private void bwSearch_DoWork(object sender, DoWorkEventArgs e)
        {
#if DEMO
            new DemoVersionOnly("Fulltext song searching").ShowDialog();
#else
            lock (lSearchResults)
            {
                // Get search terms
                List <string> searchTerms = SearchHelper.BreakSearchTerms(txtFulltextSearch.Text);
                lSearchResults = SongSearchHelper.Search(searchTerms);
            }
            Application.DoEvents();
#endif
        }
コード例 #2
0
        private void RefreshSearchList()
        {
            if (txtFulltextSearch.Text == "")
            {
                return;
            }

            pnlSearchSelection.BringToFront();
            lbSearchResults.SuspendLayout();
            lbSearchResults.Items.Clear();
            lock (lSearchResults)
            {
                #if !DEMO
                List <string> searchTerms = SearchHelper.BreakSearchTerms(txtFulltextSearch.Text); // Caller is responsible to make sure that search terms have not changed

                if (rRelevent.Checked && searchTerms.Count > 1)
                {
                    // Sort the verses based on score
                    SongSearchHelper.ScoreResults(lSearchResults, searchTerms);
                    SearchRelevancyComparer comp = new SearchRelevancyComparer();
                    lSearchResults.Sort(comp);
                }
                else
                {
                    lSearchResults.Sort(new SongNumberComparer());
                }

                // Add to list
                foreach (SongSearchResult ssr in lSearchResults)
                {
                    lbSearchResults.Items.Add(ssr);
                }
                #endif
            }
            lbSearchResults.ResumeLayout();

            lblTitleSearchResults.Text = Loc.Get("Search results:") + " (" + lSearchResults.Count + ")";
        }