private void bwSearch_DoWork(object sender, DoWorkEventArgs e) { #if DEMO new DemoVersionOnly("Bible searching").ShowDialog(); #else lock (lResults) { List <string> searchTerms = SearchHelper.BreakSearchTerms(txtBibSearch.Text); lResults = BibleSearchHelper.Search(searchTerms); } Application.DoEvents(); #endif }
private void RefreshSearchList() { if (txtBibSearch.Text == "") { return; } pnlSearchSelection.BringToFront(); lbSearchVerses.SuspendLayout(); lbSearchVerses.Items.Clear(); lock (lResults) { #if !DEMO // Get search terms List <string> searchTerms = SearchHelper.BreakSearchTerms(txtBibSearch.Text); // Caller is responsible to make sure that search terms have not changed // Sort the results BibleVerseComparer bvc = new BibleVerseComparer(); if (rRelevent.Checked && searchTerms.Count > 1) { // Sort the verses based on score BibleSearchHelper.ScoreResults(lResults, searchTerms); SearchRelevancyComparer comp = new SearchRelevancyComparer(); lResults.Sort(comp); } else { lResults.Sort(bvc); } // Double filter the results List <BibleSearchResult> lDoubleFilter = new List <BibleSearchResult>(); foreach (BibleSearchResult r in lResults) { foreach (BookData bd in lbBibleBook.Items) // Check book { if (bd.mappingName == r.bibVerse.RefBook) { lDoubleFilter.Add(r); break; } } } // Add to the list foreach (BibleSearchResult r in lDoubleFilter) { lbSearchVerses.Items.Add(r); } // Turn off the tumbler pnlInitTumbler.Visible = false; // Set visible items based on search result count pbNoItems.Visible = llNoResults.Visible = lDoubleFilter.Count == 0; lblSort.Visible = rNoSort.Visible = rRelevent.Visible = lbSearchVerses.Visible = !pbNoItems.Visible; lblTitleSearchResults.Text = Loc.Get("Search results:") + " (" + lDoubleFilter.Count + ")"; #endif } lbSearchVerses.ResumeLayout(); }