Exemplo n.º 1
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;
		}
Exemplo n.º 2
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);
		}