Esempio n. 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handy little utility function for making a Reference string. When the end reference
		/// is not specified, it is treated as though it is the same as the start reference.
		/// </summary>
		/// <param name="bookName">The Scripture book name</param>
		/// <param name="startRef">The beginning Scripture reference</param>
		/// <param name="endRef">The ending Scripture reference</param>
		/// <param name="chapterVerseSeparator">Character(s) used to delimit the chapter and verse
		/// number</param>
		/// <param name="verseBridge">Character(s) used to connect two references, indicating a
		/// range</param>
		/// <param name="supressChapterForIntroMatter">Does not include the chapter number
		/// when the start and end reference chapter and verse are the same and that
		/// chapter and verse is 1:0</param>
		/// <returns>The reference range as a formatted string.</returns>
		/// ------------------------------------------------------------------------------------
		public static string MakeReferenceString(string bookName, BCVRef startRef,
			BCVRef endRef, string chapterVerseSeparator, string verseBridge,
			bool supressChapterForIntroMatter)
		{
			return MakeReferenceString(bookName, startRef, endRef, chapterVerseSeparator,
				verseBridge, null, supressChapterForIntroMatter ? String.Empty : null);
		}
Esempio n. 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// 
		/// </summary>
		/// <param name="e"></param>
		/// ------------------------------------------------------------------------------------
		protected override void OnKeyDown(KeyEventArgs e)
		{
			int buttonToGoTo = -1;

			switch(e.KeyCode)
			{
				case Keys.Up:    buttonToGoTo = CurrentButton.ButtonAbove; break;
				case Keys.Left:  buttonToGoTo = CurrentButton.ButtonLeft;  break;
				case Keys.Right: buttonToGoTo = CurrentButton.ButtonRight; break;
				case Keys.Down:
					if ((e.Modifiers & Keys.Alt) > 0)
					{
						bool fCancel = (m_nowShowing == ListTypes.Books);
						if (fCancel)
							m_scRef = BCVRef.Empty;
						Close(fCancel);
					}
					else
						buttonToGoTo = CurrentButton.ButtonBelow; 
					break;

				case Keys.Enter:
					if (m_nowShowing == ListTypes.Verses || m_fBooksOnly)
					{
						m_scRef.Verse = m_fBooksOnly ? 1 : CurrentButton.BCVValue;
						ScrPassageControl.ScReference = m_scRef;
						Close(false);
						return;
					}

					ButtonSelected(CurrentButton);
					break;

				case Keys.Escape:
					m_scRef = BCVRef.Empty;
					Close();
					break;

				default:
					if ((e.Modifiers & Keys.Alt) != 0 && (e.Modifiers & Keys.Control) != 0)
					{
						base.OnKeyDown(e);
						return;
					}

					string charPressed = ((char)e.KeyValue).ToString();
					for (int iButton = m_currButton < Controls.Count - 1 ? m_currButton + 1 : 0; iButton != m_currButton; iButton++)
					{
						if (m_buttons[iButton].Text.StartsWith(charPressed))
						{
							buttonToGoTo = iButton;
							break;
						}
						if (iButton == Controls.Count - 1)
							iButton = -1; // Keep looking from the start of the list
					}
					break;
			}
			
			if (buttonToGoTo > -1)
			{
				CurrentButton.ShadeWhenMouseOver = false;
				m_buttons[buttonToGoTo].ShadeWhenMouseOver = false;
				ButtonEnter(m_buttons[buttonToGoTo], null);
			}
		}
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handy little utility function for making a Reference string. When the end reference
		/// is not specified, it is treated as though it is the same as the start reference.
		/// </summary>
		/// <param name="bookName">The Scripture book name</param>
		/// <param name="startRef">The beginning Scripture reference</param>
		/// <param name="endRef">The ending Scripture reference</param>
		/// <param name="chapterVerseSeparator">Character(s) used to delimit the chapter and verse
		/// number</param>
		/// <param name="verseBridge">Character(s) used to connect two references, indicating a
		/// range</param>
		/// <returns>The reference range as a formatted string.</returns>
		/// ------------------------------------------------------------------------------------
		public static string MakeReferenceString(string bookName, BCVRef startRef,
			BCVRef endRef, string chapterVerseSeparator, string verseBridge)
		{
			return MakeReferenceString(bookName, startRef, endRef, chapterVerseSeparator,
				verseBridge, true);
		}
Esempio n. 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Invoke the PassageChanged event
		/// </summary>
		/// <param name="reference">The reference.</param>
		/// ------------------------------------------------------------------------------------
		protected virtual void InvokePassageChanged(BCVRef reference)
		{
			if (PassageChanged != null)
				PassageChanged(new BCVRef(reference));
		}
Esempio n. 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Generates a cannonical text form of the given reference, consisting of
		/// book abbreviation (in primary writing system), chapter nbr, colon, verse nbr.
		/// </summary>
		/// <param name="scRef">The given scReference object.</param>
		/// <returns>The generated text string reference.</returns>
		/// ------------------------------------------------------------------------------------
		public virtual string GetRefString(BCVRef scRef)
		{
			return scRef.AsString;
			// GetAbbrev, replace 1st 3 with new abbrev
		}
Esempio n. 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initialization following the default constructor.
        /// </summary>
        /// <param name="reference">Initial reference</param>
        /// <param name="versification">The versification to use if scrProj is not set.</param>
        /// ------------------------------------------------------------------------------------
        public void Initialize(BCVRef reference, IScrVers versification)
        {
			Initialize(reference, versification, null);
        }
Esempio n. 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the user typed in string. Creates and returns a BCVRef object.
		/// </summary>
		/// <param name="sTextToBeParsed">Reference string the user types in.</param>
		/// <returns>The generated scReference object.</returns>
		/// ------------------------------------------------------------------------------------
		public BCVRef ParseRefString(string sTextToBeParsed)
		{
			if (m_availableBookIds == null)
				return m_mulScrBooks.ParseRefString(sTextToBeParsed);

            var scrRef = new BCVRef();

			if (m_availableBookIds.Count == 0)
				return scrRef;

			// Search for a reference that is actually in the database.)
			for (var startBook = 0; startBook < 66; )
			{
				var prevStartBook = startBook;
				scrRef = m_mulScrBooks.ParseRefString(sTextToBeParsed, startBook);

				// If the book is in the Scripture project 
				// (or if we get the same book back from the parse method or go back to the start)...
				if (m_availableBookIds.Contains(scrRef.Book) ||
					prevStartBook == scrRef.Book || prevStartBook > scrRef.Book)
				{
					break; // we're finished searching.
				}

				startBook = scrRef.Book; // start searching in next book returned.
			}

			// If the Scripture reference is not in the project (and we have books)...
			if (!m_availableBookIds.Contains(scrRef.Book))
			{
				// set it to the first book in the project.
				return new BCVRef(m_availableBookIds[0], 1, 1);
			}
			return scrRef;
		}
Esempio n. 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the given string representing the reference range.
		/// </summary>
		/// <param name="sRefRng">The string representing the reference range.</param>
		/// <param name="bcvRefStart">The BCV ref start.</param>
		/// <param name="bcvRefEnd">The BCV ref end.</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)
		{
			return ParseRefRange(sRefRng, ref bcvRefStart, ref bcvRefEnd, false);
		}
Esempio n. 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the given string representing the reference range.
		/// </summary>
		/// <param name="sRefRng">The string representing the reference range.</param>
		/// <param name="bcvRefStart">The BCV ref start.</param>
		/// <param name="bcvRefEnd">The BCV ref end.</param>
		/// <param name="fAllowDifferentBooks">if set to <c>true</c> range is allowed to span books.</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, bool fAllowDifferentBooks)
		{
			if (string.IsNullOrEmpty(sRefRng))
				return false;
			sRefRng = sRefRng.Trim();
			string[] pieces = sRefRng.Split(new [] { '-' }, StringSplitOptions.RemoveEmptyEntries);
			if (pieces.Length > 2 || pieces.Length == 0)
				return false;

			string sFirstRef = pieces[0];
			int bbcccvvvStart = bcvRefStart.BBCCCVVV;
			int intVal;

			if (Int32.TryParse(sFirstRef, out intVal))
			{
				if (intVal > 176)
				{
					bcvRefStart.BBCCCVVV = intVal;
					if (!bcvRefStart.Valid)
					{
						bcvRefStart.BBCCCVVV = bbcccvvvStart;
						return false;
					}
				}
				else
				{
					if (bcvRefStart.Book != bcvRefEnd.Book || bcvRefStart.Chapter != bcvRefEnd.Chapter)
						return false;
					bcvRefStart.Verse = intVal;
				}
			}
			else
			{
				// have to check *second* character because first character in a book code
				// can be a number; e.g. 2JN
				if (sFirstRef.Length < 3 || !Char.IsLetter(sFirstRef[1]))
				{
					if (bcvRefStart.Book != bcvRefEnd.Book)
						return false;
					sFirstRef = NumberToBookCode(bcvRefStart.Book) + " " + sFirstRef;
				}

				bcvRefStart.Parse(sFirstRef);
				if (!bcvRefStart.Valid)
				{
					bcvRefStart.BBCCCVVV = bbcccvvvStart;
					return false;
				}
			}
			if (pieces.Length == 1)
			{
				bcvRefEnd.BBCCCVVV = bcvRefStart.BBCCCVVV;
				return true;
			}

			string sEndRef = pieces[1];
			int bbcccvvvEnd = bcvRefEnd.BBCCCVVV;

			// The following handles the simple case of a verse number AND the more complex case of a verse
			// number followed by a sub-verse segment letter.
			if (Int32.TryParse(sEndRef, out intVal) ||
				(sEndRef.Length >= 2 && sEndRef.Length <= 4 && Char.IsLetter(sEndRef[sEndRef.Length - 1]) &&
				Int32.TryParse(sEndRef.Remove(sEndRef.Length - 1), out intVal)))
			{
				if (intVal > 176)
				{
					bcvRefEnd.BBCCCVVV = intVal;
					if (!bcvRefEnd.Valid)
					{
						bcvRefStart.BBCCCVVV = bbcccvvvStart;
						bcvRefEnd.BBCCCVVV = bbcccvvvEnd;
						return false;
					}
				}
				else
				{
					bcvRefEnd.BBCCCVVV = bcvRefStart.BBCCCVVV;
					bcvRefEnd.Verse = intVal;
				}
			}
			else
			{
				if (sEndRef.Length < 3 || !Char.IsLetter(sEndRef[1]))
					sEndRef = NumberToBookCode(bcvRefStart.Book) + " " + sEndRef;

				bcvRefEnd.Parse(sEndRef);
				if (!bcvRefEnd.Valid || bcvRefStart > bcvRefEnd ||
					(bcvRefStart.Book != bcvRefEnd.Book && !fAllowDifferentBooks))
				{
					bcvRefStart.BBCCCVVV = bbcccvvvStart;
					bcvRefEnd.BBCCCVVV = bbcccvvvEnd;
					return false;
				}
			}
			return true;
		}
Esempio n. 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Overloaded version of VerseToScrRef that ignores some parameters
		/// </summary>
		/// <param name="sourceString">string containing the verse number</param>
		/// <param name="firstRef">first reference that will have the verse portion adjusted</param>
		/// <param name="lastRef">last reference that will have the verse portion adjusted</param>
		/// <returns>true if converted successfully</returns>
		/// ------------------------------------------------------------------------------------
		public static bool VerseToScrRef(string sourceString, ref BCVRef firstRef,
			ref BCVRef lastRef)
		{
			string dummy1, dummy2;

			return VerseToScrRef(sourceString, out dummy1, out dummy2, ref firstRef, ref lastRef);
		}
Esempio n. 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Extract the verse numbers from a verse string. Determine verse number begin and end 
		/// values as well as verse segment values. Ignore any unusual syntax.
		/// Limitations: This class does not have access to the FDO Scripture bridge character 
		/// or to a character property engine with PUA character information.
		/// </summary>
		/// <param name="sourceString">string from which to attempt extracting verse numbers
		/// </param>
		/// <param name="literalVerse">returns the text that was converted to a verse number
		/// </param>
		/// <param name="remainingText">returns the remaining text after the verse number
		/// </param>
		/// <param name="firstRef">returns the first reference</param>
		/// <param name="lastRef">returns the last reference in the case of a verse bridge
		/// </param>
		/// <returns>true if converted successfully</returns>
		/// ------------------------------------------------------------------------------------
		public static bool VerseToScrRef(string sourceString, out string literalVerse,
			out string remainingText, ref BCVRef firstRef, ref BCVRef lastRef)
		{
			int firstVerse = 0;
			int lastVerse = 0;
			bool inFirst = true;
			int stringSplitPos = 0;
			int iDashCount = 0;
			sourceString = sourceString.TrimStart();

			// break the string out into the verse number portion and the following text portion.
			char prevChar = '\0';
			int i = 0;
			while (i < sourceString.Length)
			{
				char ch = sourceString[i];
				if (Char.IsDigit(ch))
				{
					stringSplitPos = i + 1;
				}
				else if (Char.IsLetter(ch))
				{
					if (prevChar == '.')
					{
						stringSplitPos = i;
						break;
					}
					if (Char.IsLetter(prevChar) || Char.IsPunctuation(prevChar))
					{
						stringSplitPos = i - 1;
						break;
					}
				}
				else if (ch != '.' && Char.IsPunctuation(ch))
				{
					if (iDashCount > 0)
					{
						if (prevChar == '-')
							stringSplitPos = i - 1;
						else
							stringSplitPos = i;
						break;
					}
					iDashCount++;
				}
				else if (ch == '\u200f' || ch == '\u200e')
				{
					// RTL and LTR marks
					// don't let these characters be saved as prevChar
					i++;
					continue;
				}
				else if (ch == '.')
				{
				}
				else
				{
					// all other characters (including space) terminate the verse number
					stringSplitPos = i;
					break;
				}
				prevChar = ch;
				i++;
			}

			literalVerse = sourceString.Substring(0, stringSplitPos);
			remainingText = sourceString.Substring(stringSplitPos);
			if (remainingText == null)
				remainingText = string.Empty;

			// parse the verse string to get the verse numbers out.
			prevChar = '\0';
			int firstSegment = 0;
			int lastSegment = 0;
			foreach (char ch in literalVerse)
			{
				if (Char.IsDigit(ch))
				{
					// Add the digit to either the first or last verse in the bridge
					if (inFirst)
					{
						firstVerse = firstVerse * 10 + (int)Char.GetNumericValue(ch);
						if (firstVerse > Int16.MaxValue)
							return false; // whoops, we got too big!
					}
					else
					{
						lastVerse = lastVerse * 10 + (int)Char.GetNumericValue(ch);
						if (lastVerse > Int16.MaxValue)
							return false; // whoops, we got too big!
					}
				}
				else if (Char.IsLetter(ch))
				{
					// letters are used for segments
					if (Char.IsDigit(prevChar))
					{
						if (inFirst)
						{
							// for the first verse in the segment, look at the old
							// reference and increment the segment if the verse
							// number has not changed. Otherwise, start the segment
							// at 1.
							if (firstVerse == lastRef.Verse)
								firstSegment = lastRef.Segment + 1;
							else
								firstSegment = 1;
						}
						else
						{
							// If the verses are the same in the bridge, then the second segment
							// will be one greater than the first segment, otherwise it will be 1.
							if (firstVerse == lastVerse)
								lastSegment = firstSegment + 1;
							else
								lastSegment = 1;
						}
					}
					else
					{
						// if there is not a digit preceding a segment letter, this is an
						// error so quit.
						return false;
					}
				}
				else
				{
					// any other character will switch to the second verse in the bridge
					inFirst = false;
				}
				prevChar = ch;
			}

			if (lastVerse == 0)
			{
				lastVerse = firstVerse;
				lastSegment = firstSegment;
			}
			firstRef.Verse = firstVerse;
			firstRef.Segment = firstSegment;
			lastRef.Verse = lastVerse;
			lastRef.Segment = lastSegment;
			return true;
		}
Esempio n. 12
0
		/// ------------------------------------------------------------------------------------
		/// <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)
		{
		}
Esempio n. 13
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
Esempio n. 14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// 
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InternalBookSelected(ScrDropDownButton button)
		{

			// If the user picked a different book, then set the chapter and verse to 1 and
			// reparse the reference object to track with the user's selection.
			if (m_scRef.Book != button.BCVValue)
			{
				m_scRef = new BCVRef(button.BCVValue, 1, 1);
				ScrPassageControl.Reference = m_scRef.AsString;
			}

			if (BookSelected != null)
				BookSelected(m_scRef.Book);

			if (m_fBooksOnly)
			{
				OnKeyDown(new KeyEventArgs(Keys.Return));
				return;
			}

			List<int> chapterList = CurrentChapterList;

			// If there is only one chapter then there's no sense showing the chapter list so
			// go right to the verse list. This will be the case when the user picks a book
			// like Jude.
			if (chapterList.Count == 1)
				InternalChapterSelected(chapterList[0]);
			else
			{
				// Show the list of chapters.
				CurrentListType = ListTypes.Chapters;
				LoadCVButtons(chapterList, m_scRef.Chapter);
			}
		}
Esempio n. 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handy little utility function for making a Reference string. When the end reference
		/// is not specified, it is treated as though it is the same as the start reference.
		/// </summary>
		/// <param name="startRef">The beginning Scripture reference</param>
		/// <param name="endRef">The ending Scripture reference</param>
		/// <param name="chapterVerseSeparator">Character(s) used to delimit the chapter and verse
		/// number</param>
		/// <param name="verseBridge">Character(s) used to connect two references, indicating a
		/// range</param>
		/// <param name="literalTitleText">Literal text to use in place of chapter/verse number
		/// when the start and end reference chapter indicate a book title reference (i.e.,
		/// chapter is 0 and verse is 0). Pass an empty string to suppress the chapter number or
		/// <c>null</c> to just output the 0</param>
		/// <param name="literalIntroText">Literal text to use in place of chapter/verse number
		/// when the start and end reference chapter indicate an introduction reference (i.e.,
		/// chapter is 1 and verse is 0). Pass an empty string to suppress the chapter number or
		/// <c>null</c> to treat this as a chapter-only reference</param>
		/// <returns>The reference range as a formatted string.</returns>
		/// ------------------------------------------------------------------------------------
		public static string MakeReferenceString(BCVRef startRef, BCVRef endRef,
			string chapterVerseSeparator, string verseBridge,
			string literalTitleText, string literalIntroText)
		{
			return MakeReferenceString(NumberToBookCode(startRef.Book), startRef, endRef,
				chapterVerseSeparator, verseBridge, literalTitleText, literalIntroText);
		}
Esempio n. 16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy a reference
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public BCVRef(BCVRef from) : this(from.Book, from.Chapter, from.Verse, from.Segment)
		{
		}
Esempio n. 17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handy little utility function for making a Reference string. When the end reference
		/// is not specified, it is treated as though it is the same as the start reference.
		/// </summary>
		/// <param name="bookName">The Scripture book name</param>
		/// <param name="startRef">The beginning Scripture reference</param>
		/// <param name="endRef">The ending Scripture reference</param>
		/// <param name="chapterVerseSeparator">Character(s) used to delimit the chapter and verse
		/// number</param>
		/// <param name="verseBridge">Character(s) used to connect two references, indicating a
		/// range</param>
		/// <param name="literalTitleText">Literal text to use in place of chapter/verse number
		/// when the start and end reference chapter indicate a book title reference (i.e.,
		/// chapter is 0 and verse is 0). Pass an empty string to suppress the chapter number or
		/// <c>null</c> to just output the 0</param>
		/// <param name="literalIntroText">Literal text to use in place of chapter/verse number
		/// when the start and end reference chapter indicate an introduction reference (i.e.,
		/// chapter is 1 and verse is 0). Pass an empty string to suppress the chapter number or
		/// <c>null</c> to treat this as a chapter-only reference</param>
		/// <returns>The reference range as a formatted string.</returns>
		/// ------------------------------------------------------------------------------------
		public static string MakeReferenceString(string bookName, BCVRef startRef,
			BCVRef endRef, string chapterVerseSeparator, string verseBridge,
			string literalTitleText, string literalIntroText)
		{
			bookName = bookName.Trim();

			if (endRef == null || endRef.IsEmpty)
				endRef = startRef;

			// Build strings to use for the chapter/verse separator and the verse bridge.
			// This method is always used for displaying references in the UI and the separator
			// strings may be surrounded by direction characters. So, we want to get rid of the
			// direction characters before using the strings.
			if (chapterVerseSeparator.Length == 3)
				chapterVerseSeparator = chapterVerseSeparator.Substring(1, 1);
			if (verseBridge.Length == 3)
				verseBridge = verseBridge.Substring(1, 1);

			if (startRef.Chapter != endRef.Chapter)
			{
				string sref = startRef.Chapter.ToString();
				if (startRef.Verse > 0 || endRef.Verse > 0)
					sref += (chapterVerseSeparator + startRef.Verse.ToString());

				sref += (verseBridge + endRef.Chapter.ToString());
				if (startRef.Verse > 0 || endRef.Verse > 0)
					sref += (chapterVerseSeparator + endRef.Verse.ToString());

				return bookName + " " + sref;
			}
			
			if (startRef.Verse != endRef.Verse)
			{
				return bookName + " " + startRef.Chapter.ToString() + chapterVerseSeparator +
					startRef.Verse.ToString() + verseBridge + endRef.Verse.ToString();
			}
			
			if (startRef.Verse != 0)
			{
				return bookName + " " + startRef.Chapter.ToString() + chapterVerseSeparator +
					startRef.Verse.ToString();
			}

			string sLiteral = null;
			switch (startRef.Chapter)
			{
				case 0: sLiteral =  literalTitleText; break;
				case 1: sLiteral = literalIntroText; break;
			}

			return bookName + FormatChapterOnlyRef(startRef.Chapter, sLiteral);
		}
Esempio n. 18
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="startRef">The start reference</param>
		/// <param name="endRef">The end reference</param>
		/// ------------------------------------------------------------------------------------
		public RefRange(BCVRef startRef, BCVRef endRef)
		{
			m_startRef = new BCVRef(startRef);
			m_endRef = new BCVRef(endRef);
		}
Esempio n. 19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialization following the default constructor, with constrained set of books to
		/// display.
		/// </summary>
		/// <param name="reference">Initial reference</param>
        /// <param name="versification">The versification to use if scrProj is not set.</param>
        /// <param name="availableBooks">Array of canonical book IDs to include</param>
		/// ------------------------------------------------------------------------------------
        public void Initialize(BCVRef reference, IScrVers versification, int[] availableBooks)
		{
		    m_versification = versification;
            m_availableBookIds = null;

			if (availableBooks != null)
			{
				Array.Sort(availableBooks);
				m_availableBookIds = availableBooks.Distinct().ToList();
				InitializeBookLabels();
			}
			else
				BookLabels = m_mulScrBooks.BookLabels;

			if (reference != null && !reference.IsEmpty)
				ScReference = reference;
			else if (m_bookLabels != null && m_bookLabels.Length > 0)
				ScReference = new BCVRef(m_bookLabels[0].BookNum, 1, 1);
			else
				ScReference = BCVRef.Empty;

			Reference = m_mulScrBooks.GetRefString(ScReference);
		}
Esempio n. 20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Helper for equals operator that can be used by derived classes as well.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected static bool AreEqual(BCVRef left, BCVRef right)
		{
			if ((object)left == null && (object)right == null)
				return true;
			else if ((object)left == null || (object)right == null)
				return false;
			return left.CompareTo(right) == 0;
		}
Esempio n. 21
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether the specified BCVRef is in the list of available books.
		/// </summary>
		/// <param name="scrRef">The given BCVRef</param>
		/// <returns><c>true</c> if the book reference is in the list of available books; 
		/// otherwise, <c>false</c>.
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public bool IsReferenceValid(BCVRef scrRef)
		{
			return BookLabels != null && BookLabels.Any(bookLabel => bookLabel.BookNum == scrRef.Book);
		}
Esempio n. 22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handy little utility function for making a Reference string using the SIL book code
		/// for the book name.
		/// </summary>
		/// <param name="startRef">The beginning Scripture reference</param>
		/// <param name="endRef">The ending Scripture reference</param>
		/// <param name="chapterVerseSeparator">Character(s) used to delimit the chapter and verse
		/// number</param>
		/// <param name="verseBridge">Character(s) used to connect two references, indicating a
		/// range</param>
		/// <returns>The reference range as a formatted string.</returns>
		/// ------------------------------------------------------------------------------------
		public static string MakeReferenceString(BCVRef startRef, BCVRef endRef,
			string chapterVerseSeparator, string verseBridge)
		{
			return MakeReferenceString(NumberToBookCode(startRef.Book), startRef, endRef,
				chapterVerseSeparator, verseBridge, true);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Notify all Santa Fe windows that a Scripture Reference focus change has occured.
		/// </summary>
		/// <param name="sRef">The string representation of the reference (e.g. MAT 1:1)</param>
		/// ------------------------------------------------------------------------------------
		public static void SendFocusMessage(string sRef)
		{
			BCVRef bcvRef = new BCVRef(sRef);
			if (!bcvRef.Valid)
				return;
			s_SantaFeRefKey.SetValue(null, sRef);
			PostMessage(new IntPtr(-1), s_FocusMsg, (uint)FocusTypes.ScriptureReferenceFocus, 0);
		}
Esempio n. 24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handy little utility function for making a Reference string using the SIL book code
		/// for the book name.
		/// </summary>
		/// <param name="startRef">The beginning Scripture reference</param>
		/// <param name="endRef">The ending Scripture reference</param>
		/// <param name="chapterVerseSeparator">Character(s) used to delimit the chapter and verse
		/// number</param>
		/// <param name="verseBridge">Character(s) used to connect two references, indicating a
		/// range</param>
		/// <param name="supressChapterForIntroMatter">Does not include the chapter number
		/// when the start and end reference chapter and verse are the same and that
		/// chapter and verse is 1:0</param>
		/// <returns>The reference range as a formatted string.</returns>
		/// ------------------------------------------------------------------------------------
		public static string MakeReferenceString(BCVRef startRef, BCVRef endRef,
			string chapterVerseSeparator, string verseBridge, bool supressChapterForIntroMatter)
		{
			return MakeReferenceString(NumberToBookCode(startRef.Book), startRef, endRef,
				chapterVerseSeparator, verseBridge, supressChapterForIntroMatter);
		}
Esempio n. 25
0
		// Parse lines giving number of verses for each chapter like
		// GEN 1:10 2:23 ...
		private static void ParseMappingLine(string fileName, VersificationTable versification, string line)
		{
			try
			{
				string[] parts = line.Split('=');
				string[] leftPieces = parts[0].Trim().Split('-');
				string[] rightPieces = parts[1].Trim().Split('-');

				BCVRef left = new BCVRef(leftPieces[0]);
				int leftLimit = leftPieces.GetUpperBound(0) == 0 ? 0 : int.Parse(leftPieces[1]);

				BCVRef right = new BCVRef(rightPieces[0]);

				while (true)
				{
					versification.toStandard[left.ToString()] = right.ToString();
					versification.fromStandard[right.ToString()] = left.ToString();

					if (left.Verse >= leftLimit)
						break;

					left.Verse = left.Verse + 1;
					right.Verse = right.Verse + 1;
				}
			}
			catch
			{
				// ENHANCE: Make it so the TE version of Localizer can have its own resources for stuff
				// like this.
				throw new Exception("Invalid [" + line + "] " + fileName);
			}
		}
Esempio n. 26
0
		/// -----------------------------------------------------------------------------------
		/// <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</param>
		/// -----------------------------------------------------------------------------------
		public ScrPassageDropDown(Control owner, bool fBooksOnly, IScrVers 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;
					}
				}
			}
		}