/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initialize the FDO cache and open database
		/// </summary>
		/// <remarks>This method is called before each test</remarks>
		/// ------------------------------------------------------------------------------------
		public override void TestSetup()
		{
			base.TestSetup();

			m_BookFilter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);
			m_BookFilter.ShowAllBooks();
			ConfigurePublication();
		}
Beispiel #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="TeHeaderFooterVc"/> class.
		/// </summary>
		/// <param name="cache">DB Connection</param>
		/// <param name="page">Page information</param>
		/// <param name="wsDefault">ID of default writing system</param>
		/// <param name="printDateTime">printing date/time</param>
		/// <param name="filterInstance">book filter instance</param>
		/// ------------------------------------------------------------------------------------
		public TeHeaderFooterVc(FdoCache cache, IPageInfo page, int wsDefault,
			DateTime printDateTime, int filterInstance)
			: base(page, wsDefault, printDateTime, cache)
		{
			m_scr = m_cache.LangProject.TranslatedScriptureOA;
			m_bookFilter = m_cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(filterInstance);
			m_autoAdjustColumns = true;
		}
Beispiel #3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// constructor
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public DummyExportUsfm(FdoCache cache, FilteredScrBooks filter) :
			base(cache, filter, string.Empty, null)
		{
			if (m_file != null)
				m_file.Close();
			m_file = new DummyFileWriter();
			// Usually this is set by the main window and most tests need this.
			m_requestedAnalWS = new int[] { m_defaultAnalWS };
		}
Beispiel #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ExportUsfmDialog"/> class.
		/// </summary>
		/// <param name="cache">database cache</param>
		/// <param name="filter">book filter to display which books we will export</param>
		/// <param name="appKey">location of registry</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The application</param>
		public ExportTbxDialog(FdoCache cache, FilteredScrBooks filter, RegistryKey appKey,
			IHelpTopicProvider helpTopicProvider, IApp app)
			: base(cache, filter, appKey, MarkupType.Toolbox, helpTopicProvider, app)
		{
			InitializeComponent();
			// Save default label for BT control
			m_defaultBtLabel = chkBackTranslation.Text;

			m_fileDialog = new TeImportExportFileDialog(m_cache.ProjectId.Name, FileType.ToolBox);
		}
Beispiel #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// lears member variables, cleans up temp files, shuts down the cache, etc.
		/// </summary>
		/// <remarks>This method is called after each test</remarks>
		/// ------------------------------------------------------------------------------------
		public override void TestTearDown()
		{
			m_exporter = null;
			m_filter = null;
			if (m_fileName != null)
				FileUtils.Delete(m_fileName);
			m_stylesheet = null;
			m_fileName = null;

			base.TestTearDown();
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="EditorialChecksViewWrapper"/> class.
		/// </summary>
		/// <param name="parent">The parent.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="bookFilter">The book filter.</param>
		/// <param name="draftViewProxy">View proxy used to create the view.</param>
		/// <param name="settingsRegKey">The settings reg key.</param>
		/// <param name="sProjectName">The name of the current project</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The application (needed to get the product name)</param>
		/// ------------------------------------------------------------------------------------
		public EditorialChecksViewWrapper(Control parent, FdoCache cache,
			FilteredScrBooks bookFilter, ViewProxy draftViewProxy, RegistryKey settingsRegKey,
			string sProjectName, IHelpTopicProvider helpTopicProvider, IApp app) :
			base(parent, cache, draftViewProxy, settingsRegKey)
		{
			Name = "EditorialChecks";
			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			m_sProjectName = sProjectName;
			m_bookFilter = bookFilter;
		}
Beispiel #7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Test setup
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void TestSetup()
		{
			base.TestSetup();
			m_fileName = FileUtils.GetTempFile("tmp");
			FileUtils.Delete(m_fileName);	// exporter pops up dialog if file exists!
			m_stylesheet = new FwStyleSheet();
			m_stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles);

			m_book = AddBookToMockedScripture(1, "Genesis");
			AddTitleToMockedBook(m_book, "Genesis");

			m_filter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(123);

			m_filter.ShowAllBooks();

			m_exporter = new ExportXhtml(m_fileName, Cache, m_filter, ExportWhat.AllBooks, 1, 0, 0,
				string.Empty, m_stylesheet, null, null);
		}
Beispiel #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructs a new instance of the <see cref="ExportXhtml"/> class.
		/// </summary>
		/// <param name="fileName">pathname of the XHTML file to create</param>
		/// <param name="cache">data source</param>
		/// <param name="filter">lists the books to export</param>
		/// <param name="what">tells what to export: everything, filtered list, or single book</param>
		/// <param name="nBook">if single book, number of the book to export</param>
		/// <param name="iFirstSection">if single book, index of first section to export</param>
		/// <param name="iLastSection">if single book, index of last section to export</param>
		/// <param name="sDescription">The s description.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="pub">The pub.</param>
		/// <param name="app">The application</param>
		/// ------------------------------------------------------------------------------------
		public ExportXhtml(string fileName, FdoCache cache, FilteredScrBooks filter,
			ExportWhat what, int nBook, int iFirstSection, int iLastSection, string sDescription,
			FwStyleSheet styleSheet, IPublication pub, IApp app)
		{
			m_fileName = fileName;
			m_cache = cache;
			m_bookFilter = filter;
			m_what = what;
			m_nBookSingle = nBook;
			m_iFirstSection = iFirstSection;
			m_iLastSection = iLastSection;
			m_sDescription = sDescription;
			m_styleSheet = styleSheet;
			m_pub = pub;
			m_app = app;

			m_scr = cache.LangProject.TranslatedScriptureOA;
		}
Beispiel #9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="DraftViewBase"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="filterInstance">The tag that identifies the book filter instance.</param>
		/// <param name="app">The application.</param>
		/// <param name="viewName">The name of the view.</param>
		/// <param name="fEditable"><c>true</c> if view is to be editable.</param>
		/// <param name="viewType">Bit-flags indicating type of view.</param>
		/// <param name="btWs">The back translation writing system (if needed).</param>
		/// ------------------------------------------------------------------------------------
		public DraftViewBase(FdoCache cache, int filterInstance, IApp app, string viewName,
			bool fEditable, TeViewType viewType, int btWs)
			: base(cache)
		{
			InitializePersistence();

			m_filterInstance = filterInstance;
			m_app = app;
			AccessibleName = Name = viewName;

			m_initialEditableState = fEditable;
			m_viewType = viewType;
			m_initialBtWs = btWs;
			m_locationTracker = new LocationTrackerImpl(cache, m_filterInstance, ContentType);
			m_bookFilter = cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);

			BackColor = EditableColor;
			DoSpellCheck = TeProjectSettings.ShowSpellingErrors;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets virtual property handler corresponding to filter instance.
		/// </summary>
		/// <param name="filterInstance">Number used to make filters unique for each main
		/// window</param>
		/// ------------------------------------------------------------------------------------
		public FilteredScrBooks GetFilterInstance(int filterInstance)
		{
			FilteredScrBooks bookFilter;
			// combination of cache hash code and filter instance is used as key so that
			// different filter will be used if either is different.
			if (m_filteredBooks.TryGetValue(filterInstance, out bookFilter))
			{
				// This can no longer be done. If it turns out this is needed, we need
				// to figure out a better way of doing it (possibly with an internal
				// method that doesn't take any parameters).
				//bookFilter.CheckListForDeletedBooks(ref bookFilter.m_filteredBooks);
				return bookFilter;
			}

			bookFilter = new FilteredScrBooks(m_cache);
			m_filteredBooks[filterInstance] = bookFilter;

			return bookFilter;
		}
		public override void TestSetup()
		{
			base.TestSetup();
			m_listOfChecks = new SortedList<ScrCheckKey, IScriptureCheck>();
			m_bookFilter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);

			m_editChecksControl = new EditorialChecksControl(
				Cache, null, m_bookFilter, "Dummy Caption", "Dummy Project", null, null);

			m_checksTree = ReflectionHelper.GetField(
				m_editChecksControl, "m_availableChecksTree") as TriStateTreeView;
		}
		public override void TestSetup()
		{
			base.TestSetup();

			// initialize the exporter class
			m_filter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(123);
			m_filter.ShowAllBooks();
			m_exporter = new DummyExportUsfm_NoStyleMapCreated(Cache, m_filter);
			m_exporter.SetContext(m_book);
			m_exporter.ParatextProjectShortName = "ABC";
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// constructor
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public DummyExportUsfm_NoStyleMapCreated(FdoCache cache, FilteredScrBooks filter) :
			base(cache, filter)
		{
			ParatextProjectShortName = "ABC";
			ParatextProjectFolder = Path.GetTempPath(); // @"C:\TEMP"; // Bad idea, since C:\TEMP might not exist.
			CreateStyleTables();
		}
Beispiel #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:ExportXmlDialog"/> class.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ExportXmlDialog(FdoCache cache, FilteredScrBooks filter, int defaultBookNum,
			IVwStylesheet stylesheet, FileType exportType, IHelpTopicProvider helpTopicProvider)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			m_helpTopicProvider = helpTopicProvider;
			m_scr = cache.LangProject.TranslatedScriptureOA;
			m_eExportType = exportType;

			string key;
			string descriptionFmt = "kstidOxesExportDescription";
			switch (m_eExportType)
			{
				case FileType.XHTML:
					Text = TeResourceHelper.GetResourceString("kstidExportXHTML"); // "Export XHTML"
					key = "ExportFolderForXhtml";
					break;
				case FileType.ODT:
					Text = TeResourceHelper.GetResourceString("kstidExportODT"); // "Export Open Office file"
					key = "ExportFolderForXhtml";
					break;
				case FileType.PDF:
					Text = TeResourceHelper.GetResourceString("kstidExportPDF"); // "Export Adobe Portable Document"
					key = "ExportFolderForXhtml";
					break;
				case FileType.OXEKT:
					Text = TeResourceHelper.GetResourceString("kstidExportOXEKT"); // "Export Open XML for Exchanging Key Terms"
					m_lblExportWhat.Text = TeResourceHelper.GetResourceString("kstidExportWhatOXEKT");
					key = "ExportFolderForXml";
					descriptionFmt = "kstidOxektExportDescription";
					break;
				case FileType.OXES:
				default:
					key = "ExportFolderForXml";
					break;
			}

			m_xmlFolder = new RegistryStringSetting(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
				key, FwSubKey.TE);
			string fileName = m_xmlFolder.Value;

			m_fileDialog = new TeImportExportFileDialog(cache.ProjectId.Name, m_eExportType);

			// Append a filename if it was set to just a directory
			if (Directory.Exists(fileName))
				fileName = Path.Combine(fileName, m_fileDialog.DefaultFileName);
			m_txtOutputFile.Text = fileName;
			// Ensure that the end of the filename is visible.
			m_txtOutputFile.Select(fileName.Length, 0);

			FillFilterListLabel(filter);

			// Set the single book from the current one in use if possible, otherwise set
			// it from the first available book, if any are available.
			if (defaultBookNum < 1 || defaultBookNum > BCVRef.LastBook)
			{
				defaultBookNum = 1;
				if (m_scr.ScriptureBooksOS.Count > 0)
					defaultBookNum = m_scr.ScriptureBooksOS[0].CanonicalNum;
			}

			m_scrBook.Initialize(defaultBookNum, m_scr.ScriptureBooksOS.Select(b => b.CanonicalNum).ToArray());
			m_scrBook.PassageChanged += m_scrBook_PassageChanged;

			// Initialize the combo boxes, and then adjust their heights (and the locations
			// of following controls) as needed.
			m_oldComboHeight = cboFrom.Height;
			m_gap = cboTo.Top - cboFrom.Bottom;
			m_fntVern = ((FwStyleSheet)stylesheet).GetUiFontForWritingSystem(
				cache.DefaultVernWs, FontInfo.kDefaultFontSize);
			cboFrom.Font = cboTo.Font = m_fntVern;

			// Now that the sizes are fixed, load the combo box lists.
			LoadSectionsForBook(defaultBookNum);

			m_nBookForSections = defaultBookNum;
			m_sRangeBookFmt = m_grpSectionRange.Text;
			UpdateBookSectionGroupLabel();

			//m_scrBook.Enabled = false;
			//m_grpSectionRange.Enabled = false;
			m_grpSectionRange.Visible = true;

			// Initialize the description.
			DateTime now = DateTime.Now;
			// "{0} exported by {1} on {2} {3}, {4} at {5}"
			m_txtDescription.Text = String.Format(DlgResources.ResourceString(descriptionFmt),
				cache.ProjectId.Name,
				System.Security.Principal.WindowsIdentity.GetCurrent().Name.Normalize(),
				now.ToString("MMMM"), now.Day, now.Year, now.ToShortTimeString());

			// TODO: Set export type from the stored registry setting.
		}
Beispiel #15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Build a string containing a comma delimited list of book names, and display it as
		/// the list of books in the filter.
		/// </summary>
		/// <param name="filter"></param>
		/// ------------------------------------------------------------------------------------
		private void FillFilterListLabel(FilteredScrBooks filter)
		{
			StringBuilder sb = new StringBuilder();
			if (filter != null)
			{
				for (int i = 0; i < filter.BookCount; ++i)
				{
					IScrBook book = m_scr.FindBook(filter.BookIds[i]);
					if (i > 0)
						sb.Append(", ");
					sb.Append(book.Name.UserDefaultWritingSystem.Text);
				}
			}
			m_lblFilterList.Text = sb.ToString();
			if (sb.Length == 0)
				m_rdoFilteredBooks.Enabled = false;
		}
Beispiel #16
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			// Must not be run more than once.
			if (IsDisposed)
			{
				Debug.Assert(m_cpe == null);
				return;
			}

			if (disposing)
			{
				// Log disposing event - removed logging as part of fix for TE-6551
				//string message = "Disposing TeEditingHelper...\n" +
				//    "Stack Trace:\n" + Environment.StackTrace;
				//SIL.Utils.Logger.WriteEvent(message);

				// Dispose managed resources here.
				if (m_InsertVerseMessageFilter != null)
					Application.RemoveMessageFilter(m_InsertVerseMessageFilter);
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			PasteFixTssEvent -= RemoveHardFormatting;
			m_scr = null;
			m_bookFilter = null;
			m_InsertVerseMessageFilter = null;
			m_restoreCursor = null;
			m_lastFootnoteTextRepSelection = null;
			m_oldReference = null;
				m_cpe = null;

			base.Dispose(disposing);
		}
Beispiel #17
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ExportUsfmDialog"/> class.
		/// </summary>
		/// <param name="cache">database cache</param>
		/// <param name="filter">book filter to display which books we will export</param>
		/// <param name="appKey">location of registry</param>
		/// <param name="markup">type of markup format for export:
		/// Paratext (one domain, non-interleaved) OR Toolbox (optionally interleaved)</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The application</param>
		/// ------------------------------------------------------------------------------------
		public ExportUsfmDialog(FdoCache cache, FilteredScrBooks filter, RegistryKey appKey,
			MarkupType markup, IHelpTopicProvider helpTopicProvider, IApp app) : this()
		{
			m_cache = cache;
			m_helpTopicProvider = helpTopicProvider;
			m_app = app;
			m_markupType = markup; // let dialog know if this is for Paratext or Toolbox
			if (appKey != null) // might be null in tests - in this case derived class has to provide a m_regGroup
				m_regGroup = new RegistryGroup(appKey, "ExportUsfmSettings");

			// Display books and markup labels
			string filtered = (filter.AllBooks ? TeResourceHelper.GetResourceString("kstidExportDlgUnfiltered") :
				TeResourceHelper.GetResourceString("kstidExportDlgFiltered"));
			string booksToExport = GetExportedBooksStr(filter);
			if (filter.BookCount == 1)
			{
				lblBooks.Text = string.Format(TeResourceHelper.GetResourceString("kstidBooksToExportSingularForm"),
					filtered, booksToExport);
			}
			else
			{
				lblBooks.Text = string.Format(lblBooks.Text, filter.BookCount, filtered, booksToExport);
			}
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="ParatextSsfFileAccessor"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="filter">book filter indicating which books are being exported</param>
		/// ------------------------------------------------------------------------------------
		public ParatextSsfFileAccessor(FdoCache cache, FilteredScrBooks filter)
		{
			m_cache = cache;
			m_filter = filter;
		}
Beispiel #19
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="UpdateBookFilterAction"/> class.
		/// Instances of this class should be created before the book filter has been updated
		/// with the changed list of books because the passed-in book filter is used as the
		/// base for the change. (i.e. when inserting a book, the newFilterList will contain
		/// the new book when the passed-in book filter does not yet contain the new book)
		/// </summary>
		/// <param name="bookFilter">The book filter.</param>
		/// <param name="newFilterList">The list of books that will be the filter when the
		/// action is complete.</param>
		/// ------------------------------------------------------------------------------------
		public UpdateBookFilterAction(FilteredScrBooks bookFilter, IScrBook[] newFilterList)
		{
			m_bookFilter = bookFilter;
			m_filteredBooks = new List<IScrBook>(m_bookFilter.FilteredBooks);
			m_newFilterList = newFilterList;
		}
Beispiel #20
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			//Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
			// Must not be run more than once.
			if (IsDisposed || Disposing)
				return;

			if (disposing)
			{
				if (m_scr != null)
					m_scr.BooksChanged -= BooksChanged;

				// Dispose managed resources here.
				Application.RemoveMessageFilter(this);
				// KeyTermsViewWrapper gets disposed when base class disposes m_rgClientViews
				if (m_gotoRefCtrl != null && m_gotoRefCtrl.Parent == null)
					m_gotoRefCtrl.Dispose();

				if (m_syncHandler != null)
				{
					m_syncHandler.ReferenceChanged -= ScrollToReference;
					m_syncHandler.AnnotationChanged -= ScrollToCitedText;
					m_syncHandler.Dispose();
				}

				if (m_bookFilter != null)
					m_bookFilter.FilterChanged -= BookFilterChanged;

				if (m_draftViewZoomSettingAlternate != null)
					m_draftViewZoomSettingAlternate.Dispose();

				if (m_footnoteViewZoomSettingAlternate != null)
					m_footnoteViewZoomSettingAlternate.Dispose();
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_gotoRefCtrl = null;
			m_syncHandler = null;
			m_viewThatLostFocus = null;
			m_bookFilter = null;
			m_lp = null;
			m_scr = null;
			m_draftViewZoomSettingAlternate = null;
			m_footnoteViewZoomSettingAlternate = null;

			base.Dispose(disposing);
		}
Beispiel #21
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructs a new instance of the <see cref="T:ExportXml"/> class.
		/// </summary>
		/// <param name="fileName">pathname of the XML file to create</param>
		/// <param name="cache">data source</param>
		/// <param name="filter">lists the books to export</param>
		/// <param name="app">The application</param>
		/// <param name="what">tells what to export: everything, filtered list, or single book</param>
		/// <param name="nBook">if single book, number of the book to export</param>
		/// <param name="iFirstSection">if single book, index of first section to export</param>
		/// <param name="iLastSection">if single book, index of last section to export</param>
		/// <param name="sDescription">The s description.</param>
		/// ------------------------------------------------------------------------------------
		public ExportXml(string fileName, FdoCache cache, FilteredScrBooks filter, IApp app,
			ExportWhat what, int nBook, int iFirstSection, int iLastSection, string sDescription)
		{
			m_fileName = fileName;
			m_cache = cache;
			m_bookFilter = filter;
			m_app = app;
			m_what = what;
			m_nBookSingle = nBook;
			m_iFirstSection = iFirstSection;
			m_iLastSection = iLastSection;
			m_sDescription = sDescription;
			m_scr = cache.LangProject.TranslatedScriptureOA;
		}
Beispiel #22
0
		/// <summary>
		/// Executes in two distinct scenarios.
		///
		/// 1. If disposing is true, the method has been called directly
		/// or indirectly by a user's code via the Dispose method.
		/// Both managed and unmanaged resources can be disposed.
		///
		/// 2. If disposing is false, the method has been called by the
		/// runtime from inside the finalizer and you should not reference (access)
		/// other managed objects, as they already have been garbage collected.
		/// Only unmanaged resources can be disposed.
		/// </summary>
		/// <param name="disposing"></param>
		/// <remarks>
		/// If any exceptions are thrown, that is fine.
		/// If the method is being done in a finalizer, it will be ignored.
		/// If it is thrown by client code calling Dispose,
		/// it needs to be handled by fixing the bug.
		///
		/// If subclasses override this method, they should call the base implementation.
		/// </remarks>
		protected override void Dispose(bool disposing)
		{
			// Must not be run more than once.
			if (IsDisposed)
				return;

			if (disposing)
			{
				// Dispose managed resources here.
			}

			// Dispose unmanaged resources here, whether disposing is true or false.
			m_bookFilter = null;
			m_footnoteVc = null;

			base.Dispose(disposing);
		}
Beispiel #23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Applies the book filter and creates divisions.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void ApplyBookFilterAndCreateDivisions()
		{
			m_bookFilter = m_cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterInstance);
			AddDivisionsForBooks();
		}
Beispiel #24
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="UpdateBookFilterAction"/> class.
 /// Instances of this class should be created before the book filter has been updated
 /// with the changed list of books because the passed-in book filter is used as the
 /// base for the change. (i.e. when inserting a book, the newFilterList will contain
 /// the new book when the passed-in book filter does not yet contain the new book)
 /// </summary>
 /// <param name="bookFilter">The book filter.</param>
 /// <param name="newFilterList">The list of books that will be the filter when the
 /// action is complete.</param>
 /// ------------------------------------------------------------------------------------
 public UpdateBookFilterAction(FilteredScrBooks bookFilter, IScrBook[] newFilterList)
 {
     m_bookFilter    = bookFilter;
     m_filteredBooks = new List <IScrBook>(m_bookFilter.FilteredBooks);
     m_newFilterList = newFilterList;
 }
Beispiel #25
0
		/// --------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:ImportedBooks"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="importVersion">The ScrDraft containing the imported books.</param>
		/// <param name="zoomPercentageDraft">The zoom percentage of the draft view.</param>
		/// <param name="zoomPercentageFootnote">The zoom percentage of the footnote view.</param>
		/// <param name="backupVersion">where to store stuff overwritten or merged.</param>
		/// <param name="bookFilter">bookFilter to which to add new books</param>
		/// <param name="booksImported">The canonical numbers of the books which were
		/// imported (unordered).</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// <param name="app">The application.</param>
		/// --------------------------------------------------------------------------------
		public ImportedBooks(FdoCache cache, FwStyleSheet styleSheet,
			IScrDraft importVersion, float zoomPercentageDraft, float zoomPercentageFootnote,
			IScrDraft backupVersion, FilteredScrBooks bookFilter, IEnumerable<int> booksImported,
			IHelpTopicProvider helpTopicProvider, IApp app) :
			this(cache, importVersion, backupVersion, helpTopicProvider, app)
		{
			m_styleSheet = styleSheet;
			m_zoomPercentageDraft = zoomPercentageDraft;
			m_zoomPercentageFootnote = zoomPercentageFootnote;
			m_bookFilter = bookFilter;

			foreach (int bookId in booksImported)
			{
				IScrBook rev = importVersion.FindBook(bookId);

				ListViewItem item = new ListViewItem(
					new string[] {rev.Name.UserDefaultWritingSystem.Text, GetBookInfo(rev)});
				item.SubItems.Add(DlgResources.ResourceString("kstidUnknown"));

				IScrBook curBook = m_scr.FindBook(rev.CanonicalNum);
				if (curBook == null)
				{
					SetItemStatus(item, ImportedBookStatus.New);
					// User should not see this undo task so we don't need to localize the strings.
					UndoableUnitOfWorkHelper.Do("Add book", "Add book",
						m_cache.ServiceLocator.GetInstance<IActionHandler>(), () =>
					{
						m_newBooks.Add(m_scr.CopyBookToCurrent(rev));
					});
				}
				else
					item.Tag = new BookMerger(m_cache, styleSheet, rev);
				lstImportedBooks.Items.Add(item);
			}
			lstImportedBooks.Items[0].Selected = true;
		}
Beispiel #26
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a string of book names in the filter.
		/// </summary>
		/// <param name="filter">book filter</param>
		/// <returns>string with comma-delimited list of books in the filter</returns>
		/// ------------------------------------------------------------------------------------
		private string GetExportedBooksStr(FilteredScrBooks filter)
		{
			StringBuilder filteredBooks = new StringBuilder();
			if (filter.BookCount > 3)
				return string.Empty;

			// Append all scripture books in filter to string
			for (int bookIndex = 0; bookIndex < filter.BookCount; bookIndex++)
			{
				if (bookIndex > 0)
					filteredBooks.Append(", ");
				filteredBooks.Append(filter.GetBook(bookIndex).BookIdRA.UIBookName);
			}

			return string.Format(TeResourceHelper.GetResourceString("kstidExportDlgMultipleBooks"),
				filteredBooks);
		}
Beispiel #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Do required initializations
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void Init()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			if (m_cache != null)
			{
				m_lp = m_cache.LangProject;
				m_scr = m_lp.TranslatedScriptureOA;
				m_scr.BooksChanged += BooksChanged;

				m_bookFilter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(Handle.ToInt32());
				m_bookFilter.FilterChanged += BookFilterChanged;
				m_bookFilter.SetSavedFilterFromString(TeProjectSettings.BookFilterBooks);

				ILgWritingSystemFactory lgwsf = Cache.LanguageWritingSystemFactoryAccessor;
				m_defaultBackTranslationWs = -1;
				using (RegistryStringSetting regDefBtWs = GetBtWsRegistrySetting(String.Empty))
				{
					if (!String.IsNullOrEmpty(regDefBtWs.Value))
						m_defaultBackTranslationWs = lgwsf.GetWsFromStr(regDefBtWs.Value);
					if (m_defaultBackTranslationWs <= 0)
						m_defaultBackTranslationWs = Cache.DefaultAnalWs;
				}
			}
			Application.AddMessageFilter(this);

			if (TMAdapter != null)
				InitializeInsertBookMenus(); // must do after menus are created in InitializeComponent()

			if (DesignMode)
				return;
			SetupSideBarInfoBar();

			Debug.Assert(m_scr != null);
			// Initialize the scripture passage control object.
			GotoReferenceControl.Initialize(ScrReference.StartOfBible(m_scr.Versification));

			UpdateCaptionBar();

			MaxStyleLevel = ToolsOptionsDialog.MaxStyleLevel;

			m_syncHandler = new FocusMessageHandling(this);
			m_draftViewZoomSettingAlternate = new RegistryFloatSetting(MainWndSettingsKey,
				"ZoomFactor" + kDraftViewName, 1.5f);
			m_footnoteViewZoomSettingAlternate = new RegistryFloatSetting(MainWndSettingsKey,
				"ZoomFactor" + kDraftFootnoteViewName, 1.5f);
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:EditorialChecksRenderingsControl"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="bookFilter">The book filter.</param>
		/// <param name="mainWnd">The FwMainWnd that owns this control.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public EditorialChecksRenderingsControl(FdoCache cache, FilteredScrBooks bookFilter,
			FwMainWnd mainWnd, IHelpTopicProvider helpTopicProvider) : base(cache, mainWnd)
		{
			InitializeComponent();
			DataGridView = m_dataGridView;
			m_BookFilter = bookFilter;
			m_helpTopicProvider = helpTopicProvider;

			if (m_cache == null)
				return;

			m_Details.Cache = m_cache;
			m_Details.WritingSystemCode = m_cache.DefaultVernWs;

			if (mainWnd != null)
			{
				m_Details.Font = mainWnd.StyleSheet.GetUiFontForWritingSystem(m_cache.DefaultVernWs,
					FontInfo.kDefaultFontSize);
			}

			m_list = new List<ICheckGridRowObject>();
			m_gridSorter = new CheckGridListSorter(m_list);
			m_gridSorter.AddComparer(m_TypeOfCheck.DataPropertyName, StringComparer.CurrentCulture);
			m_gridSorter.AddComparer(m_Message.DataPropertyName, StringComparer.CurrentCulture);
			m_gridSorter.AddComparer(m_Details.DataPropertyName, m_tsStrComparer);
			m_gridSorter.AddComparer(m_Status.DataPropertyName, new CheckingStatusComparer());
			m_gridSorter.AddComparer(m_Reference.DataPropertyName,
				new ScrReferencePositionComparer(m_cache.LangProject.TranslatedScriptureOA.ScrProjMetaDataProvider, false));

			m_dataGridView.Cache = m_cache;
		}
Beispiel #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make one.
		/// </summary>
		/// <param name="filter">The filter.</param>
		/// <param name="m_newBooks">The new books.</param>
		/// <param name="overwrittenBooksToRestore">The books to put back in the filter if the
		/// user performs an undo of imported books that overwrote existing books.</param>
		/// ------------------------------------------------------------------------------------
		public UndoChangeFilter(FilteredScrBooks filter, List<IScrBook> m_newBooks,
			List<IScrBook> overwrittenBooksToRestore) : this(filter, m_newBooks)
		{
			m_overwrittenBooksToRestore = overwrittenBooksToRestore;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public override void TestSetup()
		{
			base.TestSetup();

			m_filter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(m_filterNum++);
		}
Beispiel #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Make one.
		/// </summary>
		/// <param name="filter">The filter.</param>
		/// <param name="newBooks">The new books.</param>
		/// ------------------------------------------------------------------------------------
		public UndoChangeFilter(FilteredScrBooks filter, List<IScrBook> newBooks)
		{
			m_newBooks = newBooks;
			m_filter = filter;
			m_originalBookList = filter.SavedFilter;
		}