/// <summary> /// Provides access to the ParseMappingLine method /// </summary> public static void ParseMappingLine(this ScrVers scrVers, string mappingLine) { Versification internalVers = scrVers.VersInfo; ReflectionHelper.CallMethodWithThrow(Versification.Table.Implementation, "ProcessVersLine", mappingLine, "testfile", ScrVersType.Unknown, "", internalVers); }
/// -------------------------------------------------------------------------------- /// <summary> /// Determines whether the ending reference of the previous section and the starting /// reference of the following section are contiguous. /// </summary> /// <param name="endRefOfSection">The ending reference of section.</param> /// <param name="startRefOfNextSection">The starting reference of following section.</param> /// <param name="bookId">The canonical number for the current book.</param> /// <param name="versification">The versification.</param> /// <returns> /// <c>true</c> if the sections do not have contiguous references, <c>false</c> /// otherwise /// </returns> /// -------------------------------------------------------------------------------- private static bool RefHasGap(BCVRef endRefOfSection, BCVRef startRefOfNextSection, int bookId, ScrVers versification) { if (endRefOfSection.Chapter == startRefOfNextSection.Chapter) { // For references in the same chapter, determine whether the starting verse // in the next section is the same or just one more than the end of the // current section. return((endRefOfSection.Verse + 1) < startRefOfNextSection.Verse); } VersificationTable verseTable = VersificationTable.Get(versification); if ((endRefOfSection.Chapter + 1) == startRefOfNextSection.Chapter) { if (endRefOfSection.Verse != verseTable.LastVerse(bookId, endRefOfSection.Verse) || startRefOfNextSection.Verse == 1) { // The current section's last verse is the end of the chapter and the // next section starts with the first verse of the next chapter. return(false); } } return(true); }
/// <summary> /// Provides access to the ParseExcludedVerseLine method /// </summary> public static void ParseExcludedVerseLine(this ScrVers scrVers, string excludeLine) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ReflectionHelper.CallMethodWithThrow(Versification.Table.Implementation, "ProcessVersLine", "#! " + excludeLine, "testfile", ScrVersType.Unknown, "", internalVers); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ScrPassageDropDown"/> class. /// </summary> /// <param name="owner"></param> /// <param name="fBooksOnly">If true, show only books without chapter and verse</param> /// <param name="versification">The current versification to use when creating /// instances of ScrReference</param> /// ----------------------------------------------------------------------------------- public ScrPassageDropDown(Control owner, bool fBooksOnly, ScrVers versification) { SnapToDefaultButton = false; CVButtonPreferredWidth = 30; BookButtonPreferredWidth = 100; ButtonHeight = 18; m_versification = versification; InitializeComponent(); InitializeButtons(); AttachedControl = owner; m_fBooksOnly = fBooksOnly; // Get reference from the main control m_scRef = ScrPassageControl.ScReference; LoadBooksButtons(); int initialBook = ScrPassageControl.ScReference.Book; // Verify that the book displayed in the text box portion of the scripture // passage control is valid. If it is, then find what button it corresponds to // and make that button current. if (ScrPassageControl.MulScrBooks.IsBookValid(initialBook) && Controls.Count > 0) { foreach (ScrDropDownButton button in m_buttons) { if (button.BCVValue == initialBook) { m_currButton = button.Index; button.State = ButtonState.Pushed; break; } } } }
public DblBundleText(ITokenizer <string, int> wordTokenizer, string id, string bundleFileName, string path, ScrVers versification = null) : base(wordTokenizer, id, versification) { _bundleFileName = bundleFileName; _path = path; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Gets the contiguous reference range for the sections beginning at iSection. /// </summary> /// <param name="sections">The sections.</param> /// <param name="iSection">The current index into the sections.</param> /// <param name="firstRef">The first reference.</param> /// <param name="lastRef">The last reference of the contiguous sections.</param> /// <returns>Index to the section after the lastRef.</returns> /// ------------------------------------------------------------------------------------ private static int GetReferenceRange(List <IScrSection> sections, int iSection, out BCVRef firstRef, out BCVRef lastRef) { firstRef = new BCVRef(sections[iSection].VerseRefStart); if (iSection == sections.Count - 1) { // We're on the last section, so the end reference is in this section. lastRef = new BCVRef(sections[iSection].VerseRefEnd); return(++iSection); } ScrVers versification = sections[iSection].Cache.LangProject.TranslatedScriptureOA.Versification; IScrBook book = (IScrBook)sections[iSection].Owner; while (iSection < sections.Count - 1) { // if the ending reference of the current section is not contiguous with the // start of the next section, we've found the last contiguous section. BCVRef endRefOfSection = new BCVRef(sections[iSection].VerseRefEnd); BCVRef startRefOfNextSection = new BCVRef(sections[iSection + 1].VerseRefStart); if (RefHasGap(endRefOfSection, startRefOfNextSection, book.CanonicalNum, versification)) { lastRef = new BCVRef(sections[iSection].VerseRefEnd); return(iSection + 1); } iSection++; } // We came to the last section, so set the ending verse to its end. lastRef = new BCVRef(sections[iSection].VerseRefEnd); return(iSection + 1); }
public void AssignAll_MultiverseQuoteWithTwoCharactersInFirstVerseAndOneCharacterInSecond_AssignedToCharacterRatherThanAmbiguous(ScrVersType vers) { var versification = new ScrVers(vers); var cvInfo = MockRepository.GenerateMock <ICharacterVerseInfo>(); StubGetCharactersForSingleVerse(cvInfo, kMATbookNum, 17, 26, versification, new[] { new CharacterSpeakingMode("Peter (Simon)", null, null, false), new CharacterSpeakingMode("Jesus", null, null, false), }); StubGetCharactersForSingleVerse(cvInfo, kMATbookNum, 17, 27, versification, new[] { new CharacterSpeakingMode("Jesus", null, null, false) }); var bookScript = new BookScript("MAT", new List <Block> { new Block { ChapterNumber = 17, InitialStartVerseNumber = 26, BlockElements = new List <BlockElement> { new ScriptText("This quote starts in verse 26 ") }, CharacterId = "Jesus", MultiBlockQuote = MultiBlockQuote.Start }, new Block { ChapterNumber = 17, InitialStartVerseNumber = 27, BlockElements = new List <BlockElement> { new Verse("27"), new ScriptText("and continues in verse 27") }, CharacterId = "Jesus", MultiBlockQuote = MultiBlockQuote.Continuation } }, versification ); Assert.AreEqual("Jesus", bookScript.Blocks[0].CharacterId); Assert.AreEqual("Jesus", bookScript.Blocks[1].CharacterId); Assert.AreEqual(MultiBlockQuote.Start, bookScript.Blocks[0].MultiBlockQuote); Assert.AreEqual(MultiBlockQuote.Continuation, bookScript.Blocks[1].MultiBlockQuote); var characterAssigner = new CharacterAssigner(cvInfo); characterAssigner.AssignAll(new[] { bookScript }, false); Assert.AreEqual("Jesus", bookScript.Blocks[0].CharacterId); Assert.AreEqual("Jesus", bookScript.Blocks[1].CharacterId); Assert.AreEqual(MultiBlockQuote.Start, bookScript.Blocks[0].MultiBlockQuote); Assert.AreEqual(MultiBlockQuote.Continuation, bookScript.Blocks[1].MultiBlockQuote); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs and returns a new ScrReference representing Revelation 22:21 (or whatver /// the last verse is in Revelation for the current default versification scheme). /// </summary> /// <param name="versification">The versification scheme.</param> /// ------------------------------------------------------------------------------------ public static ScrReference EndOfBible(ScrVers versification) { VersificationTable versificationTable = VersificationTable.Get(versification); int lastChapter = versificationTable.LastChapter(LastBook); return(new ScrReference(LastBook, lastChapter, versificationTable.LastVerse(LastBook, lastChapter), versification)); }
// Create empty versification table private VersificationTable(ScrVers vers) { this.scrVers = vers; bookList = new List <int[]>(); toStandard = new Dictionary <string, string>(); fromStandard = new Dictionary <string, string>(); }
protected UsfmTextBase(ITokenizer <string, int> wordTokenizer, string id, UsfmStylesheet stylesheet, Encoding encoding, ScrVers versification) : base(wordTokenizer, id) { _parser = new UsfmParser(stylesheet); _encoding = encoding; Versification = versification ?? ScrVers.English; }
private bool BlocksMatch(int bookNum, Block vernBlock, Block refBlock, ScrVers vernacularVersification) { var vernInitStartVerse = new VerseRef(bookNum, vernBlock.ChapterNumber, vernBlock.InitialStartVerseNumber, vernacularVersification); var refInitStartVerse = new VerseRef(bookNum, refBlock.ChapterNumber, refBlock.InitialStartVerseNumber, Versification); return(vernInitStartVerse.CompareTo(refInitStartVerse) == 0 && (vernBlock.CharacterId == refBlock.CharacterId || vernBlock.CharacterIsUnclear()) && BlocksEndWithSameVerse(bookNum, vernBlock, refBlock, vernacularVersification)); }
public void Initialize(ScrVers versification) { if (Versification != null) { throw new InvalidOperationException($"Initialize called more than once for {BookId}!"); } Versification = versification ?? throw new ArgumentNullException(nameof(versification)); }
public void Get_BuiltInVersificationsCached() { ScrVers english1 = ScrVers.English; ScrVers english2 = new ScrVers(ScrVersType.English); ScrVers english3 = new ScrVers("English"); Assert.IsTrue(ReferenceEquals(english1.VersInfo, english2.VersInfo)); Assert.IsTrue(ReferenceEquals(english2.VersInfo, english3.VersInfo)); }
public UsxFileTextCorpus(ITokenizer <string, int> wordTokenizer, string projectPath, ScrVers versification = null) { Versification = versification ?? ScrVers.English; foreach (string fileName in Directory.EnumerateFiles(projectPath, "*.usx")) { AddText(new UsxFileText(wordTokenizer, fileName, Versification)); } }
private bool BlocksMatch(int bookNum, Block vernBlock, Block refBlock, ScrVers vernacularVersification) { var vernInitStartVerse = vernBlock.StartRef(bookNum, vernacularVersification); var refInitStartVerse = refBlock.StartRef(bookNum, Versification); return(vernInitStartVerse.CompareTo(refInitStartVerse) == 0 && (vernBlock.CharacterId == refBlock.CharacterId || (vernBlock.CharacterIsUnclear && !refBlock.CharacterIsStandard)) && BlocksEndWithSameVerse(bookNum, vernBlock, refBlock, vernacularVersification)); }
public QuoteParser(ICharacterVerseInfo cvInfo, string bookId, IEnumerable <Block> blocks, ScrVers versification = null) { m_cvInfo = cvInfo; m_bookId = bookId; m_bookNum = BCVRef.BookToNumber(bookId); m_inputBlocks = blocks; m_versification = versification ?? ScrVers.English; GetRegExesForSplittingQuotes(); }
public UsfmFileTextCorpus(ITokenizer <string, int> wordTokenizer, string stylesheetFileName, Encoding encoding, string projectPath, ScrVers versification = null) { Versification = versification ?? ScrVers.English; var stylesheet = new UsfmStylesheet(stylesheetFileName); foreach (string sfmFileName in Directory.EnumerateFiles(projectPath, "*.SFM")) { AddText(new UsfmFileText(wordTokenizer, stylesheet, encoding, sfmFileName, Versification)); } }
public void FixtureSetup() { // Use a test version of the file so the tests won't break every time we fix a problem in the production control file. ControlCharacterVerseData.TabDelimitedCharacterVerseData = Resources.TestCharacterVerse; using (TempFile tempFile = new TempFile()) { File.WriteAllText(tempFile.Path, Resources.TestVersification); m_testVersification = Versification.Table.Load(tempFile.Path); } }
public void CleanUpMultiBlockQuotes(ScrVers versification) { var model = new BlockNavigatorViewModel(new[] { this }.ToReadOnlyList(), versification); foreach (IEnumerable <Block> multiBlock in GetScriptBlocks() .Where(b => b.MultiBlockQuote == MultiBlockQuote.Start) .Select(block => model.GetAllBlocksWhichContinueTheQuoteStartedByBlock(block))) { ProcessAssignmentForMultiBlockQuote(BCVRef.BookToNumber(BookId), multiBlock.ToList(), versification); } }
public void ApplyUserDecisions(BookScript sourceBookScript, ScrVers versification = null) { foreach (var sourceUnappliedSplit in sourceBookScript.UnappliedSplits) { List <Block> targetUnappliedSplit = sourceUnappliedSplit.Select(splitPart => splitPart.Clone()).ToList(); m_unappliedSplitBlocks.Add(targetUnappliedSplit); } ApplyUserSplits(sourceBookScript); ApplyUserAssignments(sourceBookScript, versification); CleanUpMultiBlockQuotes(versification); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Processes the versification settings. /// </summary> /// <returns><c>true</c> if versification settings changed, <c>false</c> if nothing /// changed.</returns> /// ------------------------------------------------------------------------------------ private bool ProcessVersificationSettings() { ScrVers selectedVers = (ScrVers)(m_cboVersification.SelectedIndex + 1); if (m_scr.Versification != selectedVers) { m_scr.Versification = selectedVers; return(true); } return(false); }
/// <summary> /// Clears all information from the internal versification for testing on a clean slate /// </summary> public static void ClearAllInfo(this ScrVers scrVers) { Versification internalVers = (Versification)ReflectionHelper.GetProperty(scrVers, "VersInfo"); ((List <int[]>)ReflectionHelper.GetField(internalVers, "bookList")).Clear(); scrVers.ClearExcludedVerses(); ((Dictionary <int, string[]>)ReflectionHelper.GetField(internalVers, "verseSegments")).Clear(); object mappings = ReflectionHelper.GetField(internalVers, "mappings"); ReflectionHelper.CallMethodWithThrow(mappings, "Clear"); }
public void Get_NumberValueAllowedAsName() { ScrVers number2 = new ScrVers("2"); Assert.AreEqual(ScrVersType.Unknown, number2.Type); Assert.AreEqual("2", number2.Name); ScrVers number27 = new ScrVers("27"); Assert.AreEqual(ScrVersType.Unknown, number27.Type); Assert.AreEqual("27", number27.Name); }
public ProjectCharacterVerseData(string fullPath, ScrVers versification) { Debug.Assert(versification != null); m_versification = versification; if (File.Exists(fullPath)) { LoadData(File.ReadAllText(fullPath)); } else { LoadData(""); } }
public PortionScript(string id, IEnumerable <Block> blocks, ScrVers versification) { BookId = id; if (blocks != null) { m_blocks = blocks.ToList(); } if (versification != null) { Initialize(versification); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Fills in the versification system combo box /// </summary> /// ------------------------------------------------------------------------------------ private void FillVersificationSchemes() { for (int iVers = 1; iVers <= 6; iVers++) { ScrVers vers = (ScrVers)iVers; m_cboVersification.Items.Add(TeResourceHelper.GetResourceString( "kstid" + vers.ToString() + "Versification")); if (m_scr.Versification == vers) { m_cboVersification.SelectedIndex = iVers - 1; } } }
public void Apply(ScrVers versification) { if (!AllScriptureBlocksMatch) { throw new InvalidOperationException("Cannot apply reference blocks unless all Scripture blocks have corresponding reference blocks."); } //var bogusRefBlock = GetInvalidReferenceBlockAtAnyLevel(CorrelatedBlocks); //if (bogusRefBlock != null) // throw new InvalidReferenceTextException(bogusRefBlock); if (m_numberOfBlocksAddedBySplitting > 0) { m_vernacularBook.ReplaceBlocks(m_iStartBlock, CorrelatedBlocks.Count - m_numberOfBlocksAddedBySplitting, CorrelatedBlocks.Select(b => b.Clone()).ToList()); } int bookNum = BCVRef.BookToNumber(m_vernacularBook.BookId); var origBlocks = m_vernacularBook.GetScriptBlocks(); for (int i = 0; i < CorrelatedBlocks.Count; i++) { var vernBlock = origBlocks[m_iStartBlock + i]; var refBlock = CorrelatedBlocks[i].ReferenceBlocks.Single(); vernBlock.SetMatchedReferenceBlock(refBlock); vernBlock.SetCharacterAndDeliveryInfo(CorrelatedBlocks[i], bookNum, versification); if (CorrelatedBlocks[i].UserConfirmed) { if (vernBlock.CharacterIsUnclear()) { throw new InvalidOperationException("Character cannot be confirmed as ambigous or unknown."); } vernBlock.UserConfirmed = true; } } if (m_numberOfBlocksAddedBySplitting == 0) { var lastBlockInMatchup = CorrelatedBlocks.Last(); foreach (var block in origBlocks.Skip(m_iStartBlock + OriginalBlockCount).TakeWhile(b => b.IsContinuationOfPreviousBlockQuote)) { block.CharacterId = lastBlockInMatchup.CharacterId; block.CharacterIdOverrideForScript = lastBlockInMatchup.CharacterIdOverrideForScript; } } else { m_numberOfBlocksAddedBySplitting = 0; } }
/// <summary> /// Gets all project-specific character/delivery pairs for the given verse or bridge. /// </summary> public override HashSet <CharacterSpeakingMode> GetCharacters(int bookId, int chapter, IVerse verseOrBridge, ScrVers versification = null, bool includeAlternatesAndRareQuotes = false, bool includeNarratorOverrides = false) { Debug.Assert(!includeAlternatesAndRareQuotes); Debug.Assert(!includeNarratorOverrides); Debug.Assert(versification == null || versification == m_versification); var result = new HashSet <CharacterSpeakingMode>(m_characterDeliveryEqualityComparer); foreach (var v in verseOrBridge.AllVerseNumbers) { var verseRef = new VerseRef(bookId, chapter, v, versification ?? m_versification); verseRef.ChangeVersification(ScrVers.English); result.AddRange(GetSpeakingModesForRef(verseRef)); } return(result); }
// Get path of this versification file. // Fall back to eng.vrs if not present. private static string FileName(ScrVers vers) { if (baseDir == null) { throw new InvalidOperationException("VersificationTable.Initialize must be called first"); } string fileName = Path.Combine(baseDir, GetFileNameForVersification(vers)); if (!File.Exists(fileName)) { fileName = Path.Combine(baseDir, GetFileNameForVersification(ScrVers.English)); } return(fileName); }
/// <summary> /// Get verse segment information. /// </summary> private static void CheckSegments(ScrVers scrVers, int numSegs, VerseRef verseRef, string[] expectedSegs) { Dictionary <int, string[]> verseSegments = scrVers.verseSegments(); Assert.IsNotNull(verseSegments); Assert.AreEqual(numSegs, verseSegments.Count); Assert.IsTrue(verseSegments.ContainsKey(verseRef.BBBCCCVVV)); Assert.AreEqual(expectedSegs.Length, verseSegments[verseRef.BBBCCCVVV].Length, "Unexpected number of segments"); for (int iSeg = 0; iSeg < expectedSegs.Length; iSeg++) { Assert.AreEqual(expectedSegs[iSeg], verseSegments[verseRef.BBBCCCVVV][iSeg], "Segment " + iSeg + 1 + " should have been " + expectedSegs[iSeg] + " but was " + verseSegments[verseRef.BBBCCCVVV][iSeg]); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Get the versification table for this versification /// </summary> /// <param name="vers"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static VersificationTable Get(ScrVers vers) { Debug.Assert(vers != ScrVers.Unknown); if (versifications == null) versifications = new VersificationTable[versificationFiles.GetUpperBound(0)]; // Read versification table if not already read if (versifications[(int)vers] == null) { versifications[(int)vers] = new VersificationTable(vers); ReadVersificationFile(FileName(vers), versifications[(int)vers]); } return versifications[(int)vers]; }
/// -------------------------------------------------------------------------------- /// <summary> /// Initializes a new object /// </summary> /// <param name="owner">The owner.</param> /// <param name="versification">The current versification to use when creating /// instances of ScrReference</param> /// -------------------------------------------------------------------------------- public DummyScrPassageDropDown(ScrPassageControl owner, ScrVers versification) : base(owner, false, versification) { }
// Create empty versification table private VersificationTable(ScrVers vers) { this.scrVers = vers; bookList = new List<int[]>(); toStandard = new Dictionary<string, string>(); fromStandard = new Dictionary<string, string>(); }
// Get path of this versification file. // Fall back to eng.vrs if not present. private static string FileName(ScrVers vers) { if (baseDir == null) throw new InvalidOperationException("VersificationTable.Initialize must be called first"); string fileName = Path.Combine(baseDir, GetFileNameForVersification(vers)); if (!File.Exists(fileName)) fileName = Path.Combine(baseDir, GetFileNameForVersification(ScrVers.English)); return fileName; }
/// <summary> /// Gets the name of this requested versification file. /// </summary> /// <param name="vers">Versification scheme</param> public static string GetFileNameForVersification(ScrVers vers) { return versificationFiles[(int)vers]; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Default constructor /// </summary> /// ------------------------------------------------------------------------------------ public ScrReference() { m_versification = ScrVers.Unknown; }
partial void ValidateVersification(ref ScrVers newValue) { // ENHANCE (TE-6620): Rather than blindly defaulting to English, we could: // a) Get a default from a local XML file or something to allow // branch defaults. // b) Make sure the .vrs file is present and choose another if not. if (newValue == ScrVers.Unknown) newValue = ScrVers.English; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:ScrReference"/> class. /// </summary> /// <param name="strReference">The reference as a string.</param> /// <param name="versification">The versification scheme.</param> /// ------------------------------------------------------------------------------------ public ScrReference(string strReference, ScrVers versification) : this(0, 0, 0, 0, versification) { Parse(strReference); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the object that can provide multi-lingual names and abbreviations for /// Scripture books. /// </summary> /// <param name="scrProj">The Scripture project meta-data provided (can be null).</param> /// <param name="versification">The default versification to use for references if /// scrProj is not set.</param> /// ------------------------------------------------------------------------------------ protected virtual void CreateMultilingScrBooks(IScrProjMetaDataProvider scrProj, ScrVers versification) { m_mulScrBooks = scrProj != null ? new MultilingScrBooks(scrProj) : new MultilingScrBooks(versification); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the object that can provide multi-lingual names and abbreviations for /// Scripture books. /// </summary> /// <param name="scrProj">The Scripture project.</param> /// <param name="versification">ignored</param> /// ------------------------------------------------------------------------------------ protected override void CreateMultilingScrBooks(IScrProjMetaDataProvider scrProj, ScrVers versification) { m_mulScrBooks = new DBMultilingScrBooks((IScripture)scrProj); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a reference with a book, chapter, and verse /// </summary> /// <param name="book">The book.</param> /// <param name="chapter">The chapter.</param> /// <param name="verse">The verse.</param> /// <param name="versification">The versification scheme</param> /// ------------------------------------------------------------------------------------ public ScrReference(int book, int chapter, int verse, ScrVers versification) : this(book, chapter, verse, 0, versification) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a reference with an initial BBCCCVVV value /// </summary> /// <param name="initialRef"></param> /// <param name="versification">The versification scheme</param> /// ------------------------------------------------------------------------------------ public ScrReference(int initialRef, ScrVers versification) : this(GetBookFromBcv(initialRef), GetChapterFromBcv(initialRef), GetVerseFromBcv(initialRef), versification) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a reference with an initial BBCCCVVV value, a source versification, and a /// target versification /// </summary> /// <param name="initialRef">An integer representation of a scripture reference, where /// the first two digits are the canonical book number, the next three hold the chapter /// and the last three hold the verse number</param> /// <param name="srcVersification">The versification scheme assumed to be that of the /// initial BBCCCVVV value</param> /// <param name="targetVersification">The versification scheme to convert to. This will /// be the versification of the constructed ScrReference</param> /// ------------------------------------------------------------------------------------ public ScrReference(int initialRef, ScrVers srcVersification, ScrVers targetVersification) : this(new ScrReference(initialRef, srcVersification), targetVersification) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor that takes a versification to use for references /// </summary> /// ------------------------------------------------------------------------------------ public ScrBookControl(ScrVers versification) : base(null, null, versification) { txtScrRef.ReadOnly = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="MultilingScrBooks"/> class when a /// single, fixed versification system is required. /// </summary> /// <param name="defaultVersification">The default versification system to use.</param> /// ------------------------------------------------------------------------------------ public MultilingScrBooks(ScrVers defaultVersification) : this(null) { m_defaultVersification = defaultVersification; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs and returns a new ScrReference representing Genesis 1:1 /// </summary> /// <param name="versification">The versification scheme.</param> /// ------------------------------------------------------------------------------------ public static ScrReference StartOfBible(ScrVers versification) { return new ScrReference(1, 1, 1, versification); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs and returns a new ScrReference representing Revelation 22:21 (or whatver /// the last verse is in Revelation for the current default versification scheme). /// </summary> /// <param name="versification">The versification scheme.</param> /// ------------------------------------------------------------------------------------ public static ScrReference EndOfBible(ScrVers versification) { VersificationTable versificationTable = VersificationTable.Get(versification); int lastChapter = versificationTable.LastChapter(LastBook); return new ScrReference(LastBook, lastChapter, versificationTable.LastVerse(LastBook, lastChapter), versification); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Promote a simple BCV reference to a ScrReference /// </summary> /// <param name="from">The BCVRef to promote to a ScrReference.</param> /// <param name="versification">The versification.</param> /// ------------------------------------------------------------------------------------ public ScrReference(BCVRef from, ScrVers versification) : this(from.Book, from.Chapter, from.Verse, from.Segment, versification) { }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ScrPassageDropDown"/> class. /// </summary> /// <param name="owner"></param> /// <param name="fBooksOnly">If true, show only books without chapter and verse</param> /// <param name="versification">The current versification to use when creating /// instances of ScrReference</param> /// ----------------------------------------------------------------------------------- public DbScrPassageDropDown(Control owner, bool fBooksOnly, ScrVers versification) : base(owner, fBooksOnly, versification) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a reference, given all the pieces /// </summary> /// <param name="book">The book.</param> /// <param name="chapter">The chapter.</param> /// <param name="verse">The verse.</param> /// <param name="segment">The segment.</param> /// <param name="versification">The versification scheme.</param> /// ------------------------------------------------------------------------------------ public ScrReference(int book, int chapter, int verse, int segment, ScrVers versification) : base(book, chapter, verse, segment) { m_versification = versification; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Non-default constructor /// </summary> /// <param name="reference">Initial reference</param> /// <param name="scrProj">Object that can provide meta-dat information about a Scripture /// project.</param> /// <param name="versification">The versification to use if scrProj is not set.</param> /// ------------------------------------------------------------------------------------ public ScrPassageControl(ScrReference reference, IScrProjMetaDataProvider scrProj, ScrVers versification) { m_scrProj = scrProj; SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true); // This call is required by the Windows.Forms Form Designer. InitializeComponent(); if (DesignMode) return; CreateMultilingScrBooks(scrProj, versification); Initialize(reference); m_dropdownForm = null; #if __MonoCS__ // Setting MinumumSize allows mono's buggy ToolStrip layout of ToolStripControlHost's to work. MinimumSize = new Size(100, 20); #endif }
/// ------------------------------------------------------------------------------------ /// <summary> /// Parses the given string representing the reference range. /// </summary> /// <param name="sRefRng">The string representing the reference range.</param> /// <param name="bcvRefStart">The start reference (passed by ref because we use it to /// infer any components of the reference that are misisng in sRefRng).</param> /// <param name="bcvRefEnd">The end reference.</param> /// <param name="versification">The versification.</param> /// <returns> /// <c>true</c> if successfully parsed; <c>false</c> otherwise /// </returns> /// ------------------------------------------------------------------------------------ public static bool ParseRefRange(string sRefRng, ref BCVRef bcvRefStart, ref BCVRef bcvRefEnd, ScrVers versification) { if (string.IsNullOrEmpty(sRefRng)) return false; if (!sRefRng.Contains("--")) return BCVRef.ParseRefRange(sRefRng, ref bcvRefStart, ref bcvRefEnd, false); sRefRng = sRefRng.Trim(); string[] pieces = sRefRng.Split(new string[] { "--" }, StringSplitOptions.RemoveEmptyEntries); if (pieces.Length != 2) return false; string sFirstRef = pieces[0]; int bbcccvvvStart = bcvRefStart.BBCCCVVV; bcvRefStart.Parse(sFirstRef); if (!bcvRefStart.Valid) { bcvRefStart.BBCCCVVV = bbcccvvvStart; return false; } string sEndRef = pieces[1]; int chapter; if (Int32.TryParse(sEndRef, out chapter)) { ScrReference scrRefEnd = new ScrReference(bcvRefStart.Book, chapter, 1, versification); scrRefEnd.Verse = scrRefEnd.LastVerse; bcvRefEnd.BBCCCVVV = scrRefEnd.BBCCCVVV; return true; } return false; }
/// -------------------------------------------------------------------------------- /// <summary> /// Determines whether the ending reference of the previous section and the starting /// reference of the following section are contiguous. /// </summary> /// <param name="endRefOfSection">The ending reference of section.</param> /// <param name="startRefOfNextSection">The starting reference of following section.</param> /// <param name="bookId">The canonical number for the current book.</param> /// <param name="versification">The versification.</param> /// <returns> /// <c>true</c> if the sections do not have contiguous references, <c>false</c> /// otherwise /// </returns> /// -------------------------------------------------------------------------------- private static bool RefHasGap(BCVRef endRefOfSection, BCVRef startRefOfNextSection, int bookId, ScrVers versification) { if (endRefOfSection.Chapter == startRefOfNextSection.Chapter) { // For references in the same chapter, determine whether the starting verse // in the next section is the same or just one more than the end of the // current section. return (endRefOfSection.Verse + 1) < startRefOfNextSection.Verse; } VersificationTable verseTable = VersificationTable.Get(versification); if ((endRefOfSection.Chapter + 1) == startRefOfNextSection.Chapter) { if (endRefOfSection.Verse != verseTable.LastVerse(bookId, endRefOfSection.Verse) || startRefOfNextSection.Verse == 1) { // The current section's last verse is the end of the chapter and the // next section starts with the first verse of the next chapter. return false; } } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Copy a reference, converting it to the specified versification if necessary /// </summary> /// ------------------------------------------------------------------------------------ public ScrReference(ScrReference from, ScrVers targetVersification) : this(from.Book, from.Chapter, from.Verse, from.Segment, from.m_versification) { VersificationTable.Get(targetVersification).ChangeVersification(this); }