public string getVerseText(int verseIdx) { BibleVerse bv = this[verseIdx]; if (bv == null) { return(""); } return(SwordW.Instance().getVerseText(version, bv.b + 1, bv.c, bv.v)); }
public BibleVersion(BackgroundWorker worker, DoWorkEventArgs evArg, string version, System.Data.DataTable replacements) { _version = version; _replacements = replacements; int i = 0, b = -1, book; System.EventArgs e = new System.EventArgs(); SWModule module = SwordW.Instance().getModule(version); VerseKey vk = new VerseKey("Gen 1:1"); while (vk.Error() == '\0') { if ((i % 300) == 0) { int progress = (int)(((float)i / 31102F) * 100); worker.ReportProgress(progress); } string t = DreamTools.Sword_ConvertEncoding(module.RenderText(vk)).Trim(); book = vk.Book(); // Book numbering is 1-based and starts back up from 1 in the New Testament // OT = 1, NT = 2 if (vk.Testament() == (char)2) { book += 39; } BibleVerse v = new BibleVerse(i, book - 1, vk.Chapter(), vk.Verse(), Replace(t)); verses[i] = v; // book is 1-based, b is 0-based if (b < book - 1) { b = book - 1; BibleBooks[b].Long = vk.getBookName(); Console.WriteLine("Processing " + BibleBooks[b].Long); if (worker.CancellationPending) { evArg.Cancel = true; } } i++; vk.increment(); } _VerseCount = i; for (i = 0; i < this.BibleBooks.Length; i++) { if (BibleBooks[i].Long == null) { BibleBooks[i].Long = ""; } string bk = BibleBooks[i].Long; bk = Regex.Replace(bk.Trim(), @"^III ", "3 "); bk = Regex.Replace(bk, @"^II ", "2 "); bk = Regex.Replace(bk, @"^I ", "1 "); BibleBooks[i].Long = bk; BibleBooks[i].Short = bk; } worker.ReportProgress(100); }