/* rde * private MRUCache<string, List<Term>> chapterCache; * * /// <summary> * /// All the terms that have at least one reference in the specified chapter, * /// cached for performance. * /// </summary> * /// <param name="vref"></param> * /// <returns></returns> * private IEnumerable<Term> TermsInChapter(VerseRef vref) * { * if (chapterCache == null) * chapterCache = new MRUCache<string, List<Term>>(10, GetTermsInChapter); * * return chapterCache.Get(vref.ToString()); * } */ /// <summary> /// Return all the terms in the specified chapter /// </summary> /// <param name="chapterRef">e.g. "GEN 3:1"</param> /// <returns></returns> private List <Term> GetTermsInChapter(string chapterRef) { VerseRef vref = new VerseRef(chapterRef); vref.Verse = "1"; int firstBCV = int.Parse(vref.BBBCCCVVV()); vref.Verse = vref.LastVerse.ToString(); int lastBCV = int.Parse(vref.BBBCCCVVV()); return(terms.Where(term => term.HasReferencesInRange(firstBCV, lastBCV)).ToList()); }
public List <Term> TermsInRange(VerseRef firstReference, VerseRef lastReference) { VerseRef first = firstReference.Clone(); VerseRef last = lastReference.Clone(); first.ChangeVersification(ScrVers.Original); last.ChangeVersification(ScrVers.Original); IEnumerable <Term> terms2; /* * if (first.Book == last.Book && first.Chapter == last.Chapter) * terms2 = TermsInChapter(first); * else */ terms2 = terms; int firstBCV = int.Parse(first.BBBCCCVVV()); int lastBCV = int.Parse(last.BBBCCCVVV()); return(terms2.Where(term => term.HasReferencesInRange(firstBCV, lastBCV)).ToList()); }
public void Show(AnchorsData theAnchors, StoryProjectData theStoryProject) { Show(); Cursor curCursor = Cursor; Cursor = Cursors.WaitCursor; try { #if DEBUG // Test the Sword names vs. the names used by Paratext foreach (string str in AnchorData.mapSwordToParatextBookCodes.Values) { VerseRef verser = new VerseRef(str + " 1:1"); } foreach (string str in AnchorData.mapSwordToParatextBookCodes.Keys) { string strAnchor = str + " 1:1"; AnchorData anchorData = new AnchorData(strAnchor, strAnchor); VerseRef verser = new VerseRef(anchorData.AnchorAsVerseRef); } #endif List <string> lstRefs = new List <string>(); foreach (AnchorData anAnchor in theAnchors) { VerseRef verseRef = new VerseRef(anAnchor.AnchorAsVerseRef); lstRefs.Add(verseRef.BBBCCCVVV()); } visibleTerms.Clear(); progressBarLoadingKeyTerms.Maximum = _biblicalTerms.Terms.Count; progressBarLoadingKeyTerms.Value = 0; foreach (Term term in _biblicalTerms.Terms) { foreach (Verse aVerseReference in term.References) { if (lstRefs.Contains(aVerseReference.VerseRef.BBBCCCVVV())) { visibleTerms.Add(term); break; } } progressBarLoadingKeyTerms.Value++; } // indicate that we've checked the key terms here. theAnchors.IsKeyTermChecked = true; if (visibleTerms.Count == 0) { MessageBox.Show(Localizer.Str("There are no Biblical Terms in this verse(s).")); return; } renderings = TermRenderingsList.GetTermRenderings(_projSettings.ProjectFolder, MainLang.LangCode); termLocalizations = TermLocalizations.Localizations; ColumnTermLemma.DefaultCellStyle.Font = new Font("Charis SIL", 12); ColumnStatus.DefaultCellStyle.Font = new Font("Wingdings", 11); ColumnRenderings.DefaultCellStyle.Font = MainLang.FontToUse; ColumnRenderings.DefaultCellStyle.ForeColor = MainLang.FontColor; termIndexRequested = -1; LoadTermsList(); } catch (Exception ex) { MessageBox.Show(String.Format(Properties.Resources.IDS_KeyTermsProblem, Environment.NewLine, ex.Message), Properties.Resources.IDS_Caption); return; } finally { Cursor = curCursor; } }