예제 #1
0
        /// --------------------------------------------------------------------------------
        /// <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);
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <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(Paratext.ScrVers versification)
        {
            VersificationTable versificationTable = VersificationTable.Get(versification);
            int lastChapter = versificationTable.LastChapter(LastBook);

            return(new ScrReference(LastBook, lastChapter,
                                    versificationTable.LastVerse(LastBook, lastChapter), versification));
        }
예제 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the parameters needed for this check.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void GetParameters()
        {
            m_versificationScheme = m_checksDataSource.GetParameterValue(ksVerseSchemeParam);
            ScrVers scrVers;

            try
            {
                scrVers = (ScrVers)Enum.Parse(typeof(ScrVers),
                                              m_versificationScheme);
            }
            catch
            {
                // Default to English
                scrVers = ScrVers.English;
            }

            m_versification = VersificationTable.Get(scrVers);

            m_sBookId = m_checksDataSource.GetParameterValue(ksBookIdParam);
            if (!int.TryParse(m_checksDataSource.GetParameterValue(ksChapterParam), out m_nChapterToCheck))
            {
                m_nChapterToCheck = 0;
            }

            string temp        = m_checksDataSource.GetParameterValue(ksVerseBridgeParam);
            string verseBridge = (string.IsNullOrEmpty(temp)) ? "-" : temp;

            temp = m_checksDataSource.GetParameterValue(ksScriptDigitZeroParam);
            char   scriptDigitZero = (string.IsNullOrEmpty(temp)) ? '0' : temp[0];
            string numberRange     = string.Format("[{1}-{2}][{0}-{2}]*", scriptDigitZero,
                                                   (char)(scriptDigitZero + 1), (char)(scriptDigitZero + 9));

            temp = m_checksDataSource.GetParameterValue(ksSubVerseLetterAParam);
            if (!string.IsNullOrEmpty(temp))
            {
                m_subVerseA = temp;
            }

            temp = m_checksDataSource.GetParameterValue(ksSubVerseLetterBParam);
            if (!string.IsNullOrEmpty(temp))
            {
                m_subVerseB = temp;
            }
            string subverseRange = string.Format("[{0}{1}]?", m_subVerseA, m_subVerseB);

            // Original Regex for Roman script: "^[1-9][0-9]{0,2}[ab]?(-[1-9][0-9]{0,2}[ab]?)?$"
            m_verseNumberFormat = new Regex(String.Format("^{0}{1}({2}{0}{1})?$",
                                                          numberRange, subverseRange, verseBridge));
            m_chapterNumberFormat = new Regex("^" + numberRange + "$");
        }
예제 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Sends a sync. message to external application who may be monitoring a Santa Fe
        /// message (e.g. Paratext) or a Libronix message.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void SendExternalSyncMessage(ScrReference scrRef)
        {
            if (!TeProjectSettings.SendSyncMessages)
            {
                return;
            }

            m_fIgnoreNextRecvdSantaFeSyncMessage  = true;
            m_fIgnoreNextRecvdLibronixSyncMessage = true;
            VersificationTable.Get(ScrVers.English).ChangeVersification(scrRef);
            SantaFeFocusMessageHandler.SendFocusMessage(scrRef.ToString());

            // Make a new copy each time in case callee does something that modifies it.
            SyncLibronix(new ScrReference(scrRef));
        }
예제 #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Determine if the book is one that only has a single chapter
 /// </summary>
 /// <param name="book"></param>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 private bool SingleChapterBook(int book)
 {
     return(VersificationTable.Get(ScrVers.English).LastChapter(book) == 1);
 }
예제 #6
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Copy a reference, converting it to the specified versification if necessary
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ScrReference(ScrReference from, Paratext.ScrVers targetVersification)
     : this(from.Book, from.Chapter, from.Verse, from.Segment, from.m_versification)
 {
     VersificationTable.Get(targetVersification).ChangeVersification(this);
 }