public void CreateScrBookRefs()
		{
			ReflectionHelper.CallMethod(typeof(TeScrBookRefsInit), "SetNamesAndAbbreviations",
				new DummyProgressDlg(), Cache);

			IFdoOwningSequence<IScrBookRef> books =
				Cache.ServiceLocator.GetInstance<IScrRefSystemRepository>().Singleton.BooksOS;

			// Make sure the right number of books was generated.
			Assert.AreEqual(66, books.Count);

			ILgWritingSystemFactory wsf = Cache.WritingSystemFactory;
			int wsEnglish = wsf.GetWsFromStr("en");
			int wsSpanish = wsf.GetWsFromStr("es");

			// Check English Genesis
			IScrBookRef genesis = books[0];
			Assert.AreEqual("Genesis",
				genesis.BookName.get_String(wsEnglish).Text);
			Assert.AreEqual("Gen",
				genesis.BookAbbrev.get_String(wsEnglish).Text);
			Assert.IsNull(genesis.BookNameAlt.get_String(wsEnglish).Text);

			// Check Spanish Matthew
			IScrBookRef mateo = books[39];
			Assert.AreEqual("Mateo",
				mateo.BookName.get_String(wsSpanish).Text);
			Assert.AreEqual("Mt",
				mateo.BookAbbrev.get_String(wsSpanish).Text);
			Assert.IsNull(mateo.BookNameAlt.get_String(wsSpanish).Text);

			// Check English 2 Corinthians
			IScrBookRef iiCor = books[46];
			Assert.AreEqual("2 Corinthians",
				iiCor.BookName.get_String(wsEnglish).Text);
			Assert.AreEqual("2Cor",
				iiCor.BookAbbrev.get_String(wsEnglish).Text);
			Assert.AreEqual("II Corinthians",
				iiCor.BookNameAlt.get_String(wsEnglish).Text);

			// Check Spanish Revelation
			IScrBookRef apocalipsis = books[65];
			Assert.AreEqual("Apocalipsis",
				apocalipsis.BookName.get_String(wsSpanish).Text);
			Assert.AreEqual("Ap",
				apocalipsis.BookAbbrev.get_String(wsSpanish).Text);
			Assert.IsNull(apocalipsis.BookNameAlt.get_String(wsSpanish).Text);

			MultilingScrBooks mlsb = new MultilingScrBooks(m_scr.ScrProjMetaDataProvider);

			foreach (IScrBookRef brf in books)
			{
				Assert.IsTrue(!String.IsNullOrEmpty(brf.BookName.get_String(wsEnglish).Text));
				Assert.IsTrue(!String.IsNullOrEmpty(brf.BookAbbrev.get_String(wsEnglish).Text));
			}
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize a list of book names available from the import file list.
		/// </summary>
		/// <returns>the number of books available for import</returns>
		/// ------------------------------------------------------------------------------------
		private int InitBookNameList()
		{
			List<int> booksPresent = null;
			try
			{
				booksPresent = m_importSettings.BooksForProject();
			}
			catch
			{
				// TODO: Add a message to tell the user that the paratext project could
				// not be loaded.
			}
			if (booksPresent == null || booksPresent.Count == 0)
			{
				// This can probably only happen in the weird case where a Paratext project
				// that previously had books now has none.
				radImportRange.Enabled = scrPsgFrom.Enabled = scrPsgTo.Enabled = false;
				return 0;
			}
			radImportRange.Enabled = true;
			scrPsgFrom.Enabled = scrPsgTo.Enabled = radImportRange.Checked;

			MultilingScrBooks mlBook = new MultilingScrBooks((IScrProjMetaDataProvider)m_scr);
			// Get list of books in import files
			BookLabel[] bookNames = new BookLabel[booksPresent.Count];
			int iName = 0;
			foreach (int bookOrd in booksPresent)
				bookNames[iName++] = new BookLabel(mlBook.GetBookName(bookOrd), bookOrd);
			scrPsgFrom.BookLabels = bookNames;
			scrPsgTo.BookLabels = bookNames;

			return bookNames.Length;
		}
Example #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void Dispose(bool disposing)
		{
			Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** ");
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Just in case we didn't remove our message filter (which would now be invalid
				// since we would be disposed) when losing focus, we remove it here (TE-8297)
				Application.RemoveMessageFilter(this);

				if (components != null)
					components.Dispose();
				if (m_dropdownForm != null)
					m_dropdownForm.Dispose();
			}
			m_mulScrBooks = null;
			m_versTable = null;
			m_rgnEncodings = null;
			m_availableBookIds = null;
			m_bookLabels = null;
			m_dropdownForm = null;
			base.Dispose( disposing );
		}
Example #4
0
		/// ------------------------------------------------------------------------------------
		/// <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);
		}
		public void TestSetup()
		{
			m_mlscrBook = new MultilingScrBooks(ScrVers.English);
		}
Example #6
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Get the name of the current book as a string.
		/// </summary>
		/// <param name="selLimitType">Specify Top or Bottom</param>
		/// <returns>The name of the current book, or <c>string.Empty</c> if we don't have a
		/// selection or the selection is in a place we don't know how to handle.</returns>
		/// -----------------------------------------------------------------------------------
		public virtual string CurrentBook(SelectionHelper.SelLimitType selLimitType)
		{
			CheckDisposed();

			// if there is no selection then there can be no book
			if (CurrentSelection == null || m_cache == null)
				return string.Empty;

			int iBook = ((ITeView)Control).LocationTracker.GetBookIndex(
				CurrentSelection, selLimitType);

			if (iBook < 0)
				return string.Empty;

			IScrBook book = BookFilter.GetBook(iBook);
			string sBook = book.Name.UserDefaultWritingSystem.Text;
			if (sBook != null)
				return sBook;

			MultilingScrBooks multiScrBooks = new MultilingScrBooks((IScrProjMetaDataProvider)m_scr);
			return multiScrBooks.GetBookName(book.CanonicalNum);
		}
Example #7
0
 public void TestSetup()
 {
     m_mlscrBook = new MultilingScrBooks(ScrVers.English);
 }