Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the user typed in string. Creates and returns a ScrReference object.
		/// </summary>
		/// <param name="sTextToBeParsed">Reference string the user types in.</param>
		/// <returns>The generated scReference object.</returns>
		/// ------------------------------------------------------------------------------------
		public override ScrReference ParseRefString(string sTextToBeParsed)
		{

			var scrRef = new ScrReference();
			var bookOrds = GetBookOrds();

			// Search for a reference that is actually in the database.
			for (var startBook = 0; startBook < 66; )
			{
				var prevStartBook = startBook;
				scrRef = base.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 (bookOrds != null && bookOrds.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 (!bookOrds.Contains(scrRef.Book) && m_scripture.ScriptureBooksOS.Count > 0)
			{
				// set it to the first book in the project.
				return new ScrReference(m_scripture.ScriptureBooksOS[0].CanonicalNum, 1, 1,
										m_scripture.Cache.LanguageProject.TranslatedScriptureOA.Versification);
			}
			return scrRef;
		}
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Construct a DummyScrImportFileInfo.
		/// </summary>
		/// <param name="fileName">Name of the file whose info this represents</param>
		/// <param name="domain">The import domain to which this file belongs</param>
		/// <param name="icuLocale">The ICU locale of the source to which this file belongs
		/// (null for Scripture source)</param>
		/// <param name="noteType">The CmAnnotationDefn of the source to which this file belongs
		/// (only used for Note sources)</param>
		/// <param name="booksInFile">A list of integers representing 1-based canonical book
		/// numbers that are in this file</param>
		/// <param name="fileEncoding">The file encoding</param>
		/// <param name="startRef">The first reference encountered in the file</param>
		/// ------------------------------------------------------------------------------------
		public DummyScrImportFileInfo(string fileName, ImportDomain domain, string icuLocale,
			ICmAnnotationDefn noteType, List<int> booksInFile, Encoding fileEncoding, ScrReference startRef) :
			base(fileName, null, domain, icuLocale, noteType, false)
		{
			m_booksInFile = booksInFile;
			m_fileEncoding = fileEncoding;
			m_startRef = startRef;
		}
Ejemplo n.º 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Non-default constructor
		/// </summary>
		/// <param name="reference">Initial reference</param>
		/// <param name="scr">Scripture project</param>
		/// ------------------------------------------------------------------------------------
		public DbScrPassageControl(ScrReference reference, IScripture scr) :
			base(reference, scr as IScrProjMetaDataProvider, scr.Versification)
		{
			if (DesignMode)
				return;

			ScriptureObject = scr;
			scr.BooksChanged += BooksChanged;
		}
Ejemplo n.º 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:ScrReferenceFilterDlg"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		internal ScrReferenceFilterDlg(ScrReference initialFromRef, ScrReference initialToRef,
			int[] canonicalBookIds)
		{
			InitializeComponent();
			scrPsgFrom.Initialize(initialFromRef, canonicalBookIds);
			scrPsgTo.Initialize(initialToRef, canonicalBookIds);
			m_firstAvailableRef = new ScrReference(canonicalBookIds[0], 1, 1, initialFromRef.Versification);
			m_lastAvailableRef = new ScrReference(canonicalBookIds.Last(), 1, 1, initialToRef.Versification);
			m_lastAvailableRef = m_lastAvailableRef.LastReferenceForBook;
			if (initialFromRef == m_firstAvailableRef && initialToRef == m_lastAvailableRef)
				btnClearFilter.Enabled = false;
		}
Ejemplo n.º 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="GotoReferenceDialog"/> class.
		/// </summary>
		/// <param name="reference">The initial reference to populate the control.</param>
		/// <param name="scr">The Scripture object.</param>
		/// <param name="helpProvider">The help provider.</param>
		/// ------------------------------------------------------------------------------------
		public GotoReferenceDialog(ScrReference reference, IScripture scr, IHelpTopicProvider helpProvider)
		{
			Logger.WriteEvent("Opening 'Goto Reference' dialog");

			m_scripture = scr;
			m_helpProvider = helpProvider;
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			scrPassageControl = new DbScrPassageControl(reference, m_scripture);
			scrPassageControl.Location = new System.Drawing.Point(16, 16);
			scrPassageControl.Name = "scrPassageControl";
			scrPassageControl.Size = new System.Drawing.Size(Width - 36, 24);
			Controls.Add(scrPassageControl);

			scrPassageControl.TabIndex = 0;
			btn_OK.TabIndex = 1;
			btn_cancel.TabIndex = 2;
			btn_help.TabIndex = 3;
		}
Ejemplo n.º 6
0
		public void ValidScrReferences()
		{
			ScrReference bcvRef = new ScrReference(1, 2, 3, ScrVers.English);
			Assert.IsTrue(bcvRef.Valid);
			Assert.IsFalse(bcvRef.IsBookTitle);
			Assert.AreEqual(1002003, (int)bcvRef);
			Assert.AreEqual(1, bcvRef.Book);
			Assert.AreEqual(2, bcvRef.Chapter);
			Assert.AreEqual(3, bcvRef.Verse);
			Assert.AreEqual(ScrVers.English, bcvRef.Versification);

			bcvRef = new ScrReference(4005006, ScrVers.Original);
			Assert.IsTrue(bcvRef.Valid);
			Assert.IsFalse(bcvRef.IsBookTitle);
			Assert.AreEqual(4005006, (int)bcvRef);
			Assert.AreEqual(4, bcvRef.Book);
			Assert.AreEqual(5, bcvRef.Chapter);
			Assert.AreEqual(6, bcvRef.Verse);
			Assert.AreEqual(ScrVers.Original, bcvRef.Versification);

			bcvRef = new ScrReference();
			Assert.IsFalse(bcvRef.Valid);
			Assert.IsFalse(bcvRef.IsBookTitle);
			Assert.AreEqual(0, (int)bcvRef);
			Assert.AreEqual(0, bcvRef.Book);
			Assert.AreEqual(0, bcvRef.Chapter);
			Assert.AreEqual(0, bcvRef.Verse);

			bcvRef = new ScrReference(5, 0, 0, ScrVers.English);
			Assert.IsFalse(bcvRef.Valid);
			Assert.IsTrue(bcvRef.IsBookTitle);
			Assert.AreEqual(5000000, (int)bcvRef);
			Assert.AreEqual(5, bcvRef.Book);
			Assert.AreEqual(0, bcvRef.Chapter);
			Assert.AreEqual(0, bcvRef.Verse);
		}
Ejemplo n.º 7
0
		public void GetLastChapterForBook()
		{
			ScrReference scrRef = new ScrReference("HAG 1:1", ScrVers.English);
			Assert.AreEqual(2, scrRef.LastChapter);
			scrRef.Book = ScrReference.BookToNumber("PSA");
			Assert.AreEqual(150, scrRef.LastChapter);
			scrRef.Book = 456;
			Assert.AreEqual(0, scrRef.LastChapter);
		}
Ejemplo n.º 8
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Copy a reference
 /// </summary>
 /// <param name="from">The ScrReference to copy.</param>
 /// ------------------------------------------------------------------------------------
 public ScrReference(ScrReference from)
     : this(from.Book, from.Chapter, from.Verse, from.Segment, from.m_versification)
 {
 }
Ejemplo n.º 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle a change in the scripture passage "from" control
		/// </summary>
		/// <param name="newReference">The new reference.</param>
		/// ------------------------------------------------------------------------------------
		protected void scrPsgFrom_PassageChanged(ScrReference newReference)
		{
			Logger.WriteEvent(string.Format("New scrPsgFrom reference is {0}", newReference.AsString));

			ScrReference scRefFrom = scrPsgFrom.ScReference;
			ScrReference scRefTo = scrPsgTo.ScReference;

			if (scRefFrom.Book > scRefTo.Book)
			{
				//set the scrPsgTo to the end of the book
				scRefTo.Book = scRefFrom.Book;
				scRefTo.Chapter = scRefTo.LastChapter;
				scRefTo.Verse = scRefTo.LastVerse;
				scrPsgTo.ScReference = scRefTo;
			}
		}
Ejemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <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
		}
Ejemplo n.º 11
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether the specified ScrReference is in the list of available books.
		/// </summary>
		/// <param name="scrRef">The given ScrReference</param>
		/// <returns><c>true</c> if the book reference is in the list of available books;
		/// otherwise, <c>false</c>.
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public bool IsReferenceValid(ScrReference scrRef)
		{
			return BookLabels != null && BookLabels.Any(bookLabel => bookLabel.BookNum == scrRef.Book);
		}
Ejemplo n.º 12
0
        public void CompareTo_int()
        {
            ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);

            Assert.AreEqual(0, ref1.CompareTo(1030001));
        }
Ejemplo n.º 13
0
		public void LessThan_UnknownVersification()
		{
			ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Unknown);
			ScrReference ref2 = new ScrReference("GEN 30:1", ScrVers.Original);
			Assert.IsFalse(ref1 < ref2);

			ref1 = new ScrReference("GEN 19:1", ScrVers.Unknown);
			ref2 = new ScrReference("GEN 21:1", ScrVers.English);
			Assert.IsTrue(ref1 < ref2);

			ref1 = new ScrReference("GEN 21:1", ScrVers.Unknown);
			ref2 = new ScrReference("GEN 19:1", ScrVers.English);
			Assert.IsFalse(ref1 < ref2);
		}
Ejemplo n.º 14
0
		public void CompareTo_BCVRef()
		{
			ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);
			BCVRef ref2 = new BCVRef("GEN 30:1");
			Assert.AreEqual(0, ref1.CompareTo(ref2));
		}
Ejemplo n.º 15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Scroll any note(s) with the given reference into view
		/// </summary>
		/// <param name="sender">The sender (can be null).</param>
		/// <param name="scrRef">The Scripture reference.</param>
		/// <param name="quotedText">The selected text (can be null).</param>
		/// ------------------------------------------------------------------------------------
		public void ScrollToReference(object sender, ScrReference scrRef, ITsString quotedText)
		{
			NotesDataEntryView view = ActiveView as NotesDataEntryView;
			Debug.Assert(view != null);
			if (view != null && sender != view)
				view.ScrollRefIntoView(scrRef, quotedText != null ? quotedText.Text : null);
		}
Ejemplo n.º 16
0
		public void IsRangeInKtRef_InRangeButAnchorAndEndAreDifferent()
		{
			ScrReference[] anchorRefRange = new ScrReference[2];
			ScrReference[] endRefRange = new ScrReference[2];
			anchorRefRange[0] = endRefRange[0] = new ScrReference(01001001, ScrVers.English);
			anchorRefRange[1] = new ScrReference(01001001, ScrVers.English);
			endRefRange[1] = new ScrReference(01001003, ScrVers.English);
			Assert.IsFalse(KeyTermsViewWrapper.IsRangeInKtRef(CreateCheckRef(01001001), anchorRefRange, endRefRange));
		}
Ejemplo n.º 17
0
 /// ------------------------------------------------------------------------------------
 /// <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);
 }
Ejemplo n.º 18
0
        public void ParseRefString_InvalidVersification()
        {
            ScrReference reference = new ScrReference("GEN 1:1", ScrVers.Unknown);

            Assert.IsFalse(reference.Valid);
        }
Ejemplo n.º 19
0
        public void VerseToIntTest()
        {
            int nVerseStart, nVerseEnd;

            // Test invalid verse number strings
            ScrReference.VerseToInt("-12", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(12, nVerseStart);
            Assert.AreEqual(12, nVerseEnd);
            ScrReference.VerseToInt("14-", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(14, nVerseStart);
            Assert.AreEqual(14, nVerseEnd);
            ScrReference.VerseToInt("a3", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(3, nVerseStart);
            Assert.AreEqual(3, nVerseEnd);
            ScrReference.VerseToInt("15b-a", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(15, nVerseStart);
            Assert.AreEqual(15, nVerseEnd);
            ScrReference.VerseToInt("3bb", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(3, nVerseStart);
            Assert.AreEqual(3, nVerseEnd);
            ScrReference.VerseToInt("0", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(0, nVerseStart);
            Assert.AreEqual(0, nVerseEnd);
            ScrReference.VerseToInt(" 12", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(12, nVerseStart);
            Assert.AreEqual(12, nVerseEnd);
            ScrReference.VerseToInt("14 ", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(14, nVerseStart);
            Assert.AreEqual(14, nVerseEnd);
            ScrReference.VerseToInt("12-10", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(12, nVerseStart);
            //Assert.AreEqual(12, nVerseEnd); // end verse set to 12 instead of 10
            ScrReference.VerseToInt("139-1140", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(139, nVerseStart);
            //Assert.AreEqual(139, nVerseEnd); // end verse set to 999 instead of 139
            ScrReference.VerseToInt("177-140", out nVerseStart, out nVerseEnd);
            //Assert.AreEqual(140, nVerseStart); // start verse set to 177 instead of 140
            Assert.AreEqual(140, nVerseEnd);
            //Review: should this be a requirement?
            //			ScrReference.VerseToInt("177", out nVerseStart, out nVerseEnd);
            //			Assert.AreEqual(0, nVerseStart); // 177 is out of range of valid verse numbers
            //			Assert.AreEqual(0, nVerseEnd);
            ScrReference.VerseToInt(String.Empty, out nVerseStart, out nVerseEnd);
            Assert.AreEqual(0, nVerseStart);
            Assert.AreEqual(0, nVerseEnd);
            ScrReference.VerseToInt(String.Empty, out nVerseStart, out nVerseEnd);
            Assert.AreEqual(0, nVerseStart);
            Assert.AreEqual(0, nVerseEnd);

            // Test valid verse number strings
            ScrReference.VerseToInt("1a", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(1, nVerseStart);
            Assert.AreEqual(1, nVerseEnd);
            ScrReference.VerseToInt("2a-3b", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(2, nVerseStart);
            Assert.AreEqual(3, nVerseEnd);
            ScrReference.VerseToInt("4-5d", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(4, nVerseStart);
            Assert.AreEqual(5, nVerseEnd);
            ScrReference.VerseToInt("6", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(6, nVerseStart);
            Assert.AreEqual(6, nVerseEnd);
            ScrReference.VerseToInt("66", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(66, nVerseStart);
            Assert.AreEqual(66, nVerseEnd);
            ScrReference.VerseToInt("176", out nVerseStart, out nVerseEnd);
            Assert.AreEqual(176, nVerseStart);
            Assert.AreEqual(176, nVerseEnd);
            //We expect this test to pass
            //RTL verse bridge should be valid syntax
            ScrReference.VerseToInt("6" + '\u200f' + "-" + '\u200f' + "8", out nVerseStart,
                                    out nVerseEnd);
            Assert.AreEqual(6, nVerseStart);
            Assert.AreEqual(8, nVerseEnd);
        }
Ejemplo n.º 20
0
		public void ParseRefString_InvalidVersification()
		{
			ScrReference reference = new ScrReference("GEN 1:1", ScrVers.Unknown);
			Assert.IsFalse(reference.Valid);
		}
Ejemplo n.º 21
0
		public void Equal_DifferentVersification()
		{
			ScrReference ref1 = new ScrReference("GEN 31:55", ScrVers.English);
			ScrReference ref2 = new ScrReference("GEN 32:1", ScrVers.Original);
			Assert.IsTrue(ref1 == ref2);

			ref1 = new ScrReference("JOB 41:9", ScrVers.English);
			ref2 = new ScrReference("JOB 41:1", ScrVers.Original);
			Assert.IsTrue(ref1 == ref2);

			ref1 = new ScrReference("JOB 41:9", ScrVers.English);
			ref2 = new ScrReference("JOB 41:2", ScrVers.Original);
			Assert.IsFalse(ref1 == ref2);
		}
Ejemplo n.º 22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialization, either from constructor or elsewhere following the default constructor.
		/// </summary>
		/// <param name="reference">Initial reference</param>
		/// <param name="availableBooks">Array of canonical book IDs to include</param>
		/// ------------------------------------------------------------------------------------
		public void Initialize(ScrReference reference, int[] availableBooks)
		{
			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 ScrReference(m_bookLabels[0].BookNum, 1, 1, Versification);
			else
				ScReference = new ScrReference(0, 0, 0, Versification);

			Reference = m_mulScrBooks.GetRefString(ScReference);

			// Use a default versification scheme if one is not available.
			m_versTable = VersificationTable.Get(Versification);
		}
Ejemplo n.º 23
0
		public void LessThan_int()
		{
			ScrReference ref2 = new ScrReference("GEN 30:2", ScrVers.Original);
			Assert.IsTrue(1030001 < ref2);
		}
Ejemplo n.º 24
0
        public void LessThan_int()
        {
            ScrReference ref2 = new ScrReference("GEN 30:2", ScrVers.Original);

            Assert.IsTrue(1030001 < ref2);
        }
Ejemplo n.º 25
0
		public void CompareTo_int()
		{
			ScrReference ref1 = new ScrReference("GEN 30:1", ScrVers.Original);
			Assert.AreEqual(0, ref1.CompareTo(1030001));
		}
Ejemplo 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 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;
					}
				}
			}
		}
Ejemplo n.º 27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialization, either from constructor or elsewhere following the default constructor.
		/// </summary>
		/// <param name="reference">Initial reference</param>
		/// ------------------------------------------------------------------------------------
		public void Initialize(ScrReference reference)
		{
			Initialize(reference, null);
		}
Ejemplo n.º 28
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 = ScrReference.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 = ScrReference.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);
			}
		}
Ejemplo n.º 29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Parses the user typed in string. Creates and returns a ScrReference object.
		/// </summary>
		/// <param name="sTextToBeParsed">Reference string the user types in.</param>
		/// <returns>The generated scReference object.</returns>
		/// ------------------------------------------------------------------------------------
		public ScrReference ParseRefString(string sTextToBeParsed)
		{
			if (m_availableBookIds == null)
				return m_mulScrBooks.ParseRefString(sTextToBeParsed);

			var scrRef = new ScrReference();

			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 ScrReference(m_availableBookIds[0], 1, 1, Versification);
			}
			return scrRef;
		}
Ejemplo n.º 30
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 ScrReference(button.BCVValue, 1, 1, m_versification);
				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);
			}
		}
Ejemplo n.º 31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Invoke the PassageChanged event
		/// </summary>
		/// <param name="reference">The reference.</param>
		/// ------------------------------------------------------------------------------------
		protected virtual void InvokePassageChanged(ScrReference reference)
		{
			if (PassageChanged != null)
				PassageChanged(new ScrReference(reference));
		}
Ejemplo n.º 32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="DummyScrPassageControl"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public DummyScrPassageControl(ScrReference initialRef) : base(initialRef, null, ScrVers.English)
		{
		}
Ejemplo n.º 33
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the start and ending Scripture references that cover the entire range of books
		/// represented by this filter if the set of filtered books is contiguous books in the
		/// canon of Scripture. If the set of filtered books is not contiguous or there are no
		/// books in the filter, then "Empty" references are returned.
		/// </summary>
		/// <param name="start">The start reference.</param>
		/// <param name="end">The end reference.</param>
		/// ------------------------------------------------------------------------------------
		public void GetRefRangeForContiguousBooks(out ScrReference start, out ScrReference end)
		{
			start = new ScrReference(0, m_scr.Versification);
			end = new ScrReference(0, m_scr.Versification);
			if (BookCount == 0)
				return;

			List<int> bookIds = BookIds;
			for (int book = 0; book < bookIds.Count - 1; book++)
			{
				if (bookIds[book] + 1 != bookIds[book + 1])
					return;
			}
			start = new ScrReference(bookIds[0], 1, 1, m_scr.Versification);
			end = new ScrReference(bookIds.Last(), 1, 1, m_scr.Versification).LastReferenceForBook;
		}
Ejemplo n.º 34
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Check all files that are about to be imported in the given reference range to see
		/// if there are any reference overlaps. If so, resolve the conflict.
		/// </summary>
		/// <param name="start">Start reference</param>
		/// <param name="end">End Reference</param>
		/// ------------------------------------------------------------------------------------
		public void CheckForOverlappingFilesInRange(ScrReference start, ScrReference end)
		{
			lock (SyncRoot)
			{
				if (ImportTypeEnum != TypeOfImport.Other && ImportTypeEnum != TypeOfImport.Paratext5)
					throw new InvalidOperationException(
						"Don't call CheckForOverlappingFilesInRange for anything but file-based imports.");

				if (ImportTranslation)
					m_scrFileInfoList.CheckForOverlappingFilesInRange(start, end);

				if (ImportBackTranslation)
				{
					foreach (ScrSfFileList list in m_btFileInfoLists.Values)
						list.CheckForOverlappingFilesInRange(start, end);
				}

				if (ImportAnnotations)
				{
					foreach (ScrSfFileList list in m_notesFileInfoLists.Values)
						list.CheckForOverlappingFilesInRange(start, end);
				}
			}
		}
Ejemplo n.º 35
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle a change in the scripture passage "to" control
		/// </summary>
		/// <param name="newReference">The new reference.</param>
		/// ------------------------------------------------------------------------------------
		protected void scrPsgTo_PassageChanged(ScrReference newReference)
		{
			Logger.WriteEvent(string.Format("New scrPsgTo reference is {0}", newReference.AsString));

			ScrReference scRefFrom = scrPsgFrom.ScReference;
			ScrReference scRefTo = scrPsgTo.ScReference;
			if (scRefTo.Book < scRefFrom.Book)
				scrPsgFrom.ScReference = scRefTo;
		}
Ejemplo n.º 36
0
		public void InvalidScrReferences()
		{
			// Invalid BCVs
			ScrReference scrRef = new ScrReference(7, 8, 1001, ScrVers.English);
			Assert.IsFalse(scrRef.Valid);
			scrRef.MakeValid();
			Assert.AreEqual(7008035, (int)scrRef);
			Assert.AreEqual(7, scrRef.Book);
			Assert.AreEqual(8, scrRef.Chapter);
			Assert.AreEqual(35, scrRef.Verse);

			scrRef = new ScrReference(9, 1002, 10, ScrVers.English);
			Assert.IsFalse(scrRef.Valid);
			scrRef.MakeValid();
			Assert.AreEqual(9031010, (int)scrRef);
			Assert.AreEqual(9, scrRef.Book);
			Assert.AreEqual(31, scrRef.Chapter);
			Assert.AreEqual(10, scrRef.Verse);

			scrRef = new ScrReference(101, 11, 12, ScrVers.English);
			Assert.IsFalse(scrRef.Valid);
			scrRef.MakeValid();
			Assert.AreEqual(66011012, (int)scrRef);
			Assert.AreEqual(66, scrRef.Book);
			Assert.AreEqual(11, scrRef.Chapter);
			Assert.AreEqual(12, scrRef.Verse);
		}