/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:MultipleFilterDlg"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public MultipleFilterDlg(FdoCache cache, ICmFilter filter) : this() { m_cache = cache; m_scr = (Scripture)cache.LangProject.TranslatedScriptureOA; m_filter = filter; // Initialize the enabled status of the group boxes. chkStatus_CheckedChanged(null, null); chkType_CheckedChanged(null, null); chkScrRange_CheckedChanged(null, null); // Initialize the beginning and ending default Scripture references. int firstBook = 1; int lastBook = ScrReference.LastBook; if (m_scr.ScriptureBooksOS.Count > 0) { firstBook = m_scr.ScriptureBooksOS[0].CanonicalNum; lastBook = m_scr.ScriptureBooksOS[m_scr.ScriptureBooksOS.Count - 1].CanonicalNum; } scrBookFrom.Initialize(new ScrReference(firstBook, 1, 1, m_scr.Versification), m_scr, false); scrBookTo.Initialize(new ScrReference(lastBook, 1, 0, m_scr.Versification).LastReferenceForBook, m_scr, false); // Update the controls from the filter in the database. InitializeFromFilter(); chkCategory.Checked = tvCatagories.Load(m_cache, m_filter, null); chkCategory_CheckedChanged(null, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DummyImportWizard"/> class. /// </summary> /// <param name="cache">The database cache.</param> /// <param name="scr">The Scripture object.</param> /// <param name="styleSheet">The style sheet.</param> /// ------------------------------------------------------------------------------------ public DummyImportWizard(FdoCache cache, Scripture scr, FwStyleSheet styleSheet) : base("LANG. PROJ. TEST NAME.", scr, styleSheet, cache) { m_lvCurrentMappingList = lvScrMappings; m_btnCurrentModifyButton = m_btnModifyScrMapping; m_btnCurrentDeleteButton = m_btnDeleteScrMapping; }
public override void FixtureSetup() { base.FixtureSetup(); Unpacker.UnPackParatextTestProjects(); m_regData = Unpacker.PrepareRegistryForPTData(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; ScrReferenceTests.InitializeScrReferenceForTests(); }
public void Init() { m_inMemoryCache = ScrInMemoryFdoCache.Create(this); m_inMemoryCache.InitializeLangProject(); m_inMemoryCache.InitializeScripture(); m_inMemoryCache.AddBookToMockedScripture(1, "Genesis"); m_inMemoryCache.AddBookToMockedScripture(2, "Exodus"); m_inMemoryCache.AddBookToMockedScripture(5, "Deuteronomy"); m_James = m_inMemoryCache.AddBookToMockedScripture(59, "James"); m_inMemoryCache.AddBookToMockedScripture(66, "Revelation"); m_fdoCache = m_inMemoryCache.Cache; m_scr = (Scripture)m_fdoCache.LangProject.TranslatedScriptureOA; m_ctrlOwner = new Form(); ILgWritingSystemFactory wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor; m_scp = new DummyScrPassageControl(null, m_scr, false); m_dbScp = new DummyScrPassageControl(null, m_scr, true); m_ctrlOwner.Controls.Add(m_scp); m_ctrlOwner.Controls.Add(m_dbScp); m_ctrlOwner.CreateControl(); if (m_scp.DropDownWindow != null) m_scp.DropDownWindow.Close(); if (m_dbScp.DropDownWindow != null) m_dbScp.DropDownWindow.Close(); // Forcing the reference to this should reset the ScrReference object for us // which, we hope will cause some strange errors to occur when running in // console mode. The tests seem to always work in gui mode but not console mode. m_scp.ScReference = new ScrReference(01001001, m_scr.Versification); m_dbScp.ScReference = new ScrReference(01001001, m_scr.Versification); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ImportedBooks"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="booksImported">The books that have been imported.</param> /// <param name="backupVersion">where to store stuff overwritten or merged.</param> /// ------------------------------------------------------------------------------------ protected ImportedBooks(FdoCache cache, IScrDraft booksImported, IScrDraft backupVersion) { InitializeComponent(); m_cache = cache; m_scr = m_cache.LangProject.TranslatedScriptureOA as Scripture; m_backupVersion = backupVersion; m_booksImported = booksImported; }
public void HardLineBreak() { CheckDisposed(); // Set IP in the middle of the second Scripture section head in James. // Then press Shift-Enter. This should put a hard line break in the middle of this // section head and the IP should be at the beginning of the second line. DummyDraftView draftView = m_draftForm.DraftView; draftView.RootBox.Activate(VwSelectionState.vssEnabled); draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4); KeyEventArgs e = new KeyEventArgs(Keys.Right); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); draftView.CallRootSiteOnKeyDown(e); // We should be between the 'a' and 'n' of the word "and" in the section head // containing "Faith and Wisdom". SelectionHelper selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); int ihvoPara = selHelper.LevelInfo[0].ihvo; Assert.AreEqual(7, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Now send the Shift-Enter draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); // We should have split the line between the 'a' and 'n' of the word "and". selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(8, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // To make sure we're on the next line down, send an up-arrow draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); // We should be at the beginning of the section head. selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Finally, make sure the hard line break character is in the right place in the // string in the data cache. Scripture scr = new Scripture(m_draftForm.Cache, draftView.HvoScripture); ScrBook james = (ScrBook)scr.ScriptureBooksOS[1]; ScrSection modifiedScrSection = (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo]; Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count); Assert.AreEqual(0x2028, ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[7]); // Second test: // Set IP at the beginning of the second Scripture section head in James. // Then press Shift-Enter. This should put an empty line at the beginning of this // section head and the IP should be at the beginning of the second line. draftView.SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, 1, 4); selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); ihvoPara = selHelper.LevelInfo[0].ihvo; Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Now send the Shift-Enter draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Shift | Keys.Enter)); // We should have an blank line before Faith and Wisdom. selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(2, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // To make sure we're on the next line down, send an up-arrow draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); draftView.CallRootSiteOnKeyDown(new KeyEventArgs(Keys.Up)); // We should be at the beginning of the section head containing "Faith and Wisdom". selHelper = SelectionHelper.Create(draftView); Assert.AreEqual(4, selHelper.NumberOfLevels); Assert.AreEqual((int)ScrSection.ScrSectionTags.kflidHeading, selHelper.LevelInfo[1].tag); // Make sure we're still in the same para Assert.AreEqual(ihvoPara, selHelper.LevelInfo[0].ihvo); Assert.AreEqual(0, selHelper.IchAnchor); Assert.AreEqual(selHelper.IchAnchor, selHelper.IchEnd); // Finally, make sure the hard line break character is in the right place in the // string in the data cache. scr = new Scripture(m_draftForm.Cache, draftView.HvoScripture); james = (ScrBook)scr.ScriptureBooksOS[1]; modifiedScrSection = (ScrSection)james.SectionsOS[selHelper.LevelInfo[2].ihvo]; Assert.AreEqual(1, modifiedScrSection.HeadingOA.ParagraphsOS.Count); Assert.AreEqual(0x2028, ((StTxtPara)modifiedScrSection.HeadingOA.ParagraphsOS[0]).Contents.Text[0]); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Exposes the <see cref="TeScrInitializer.CreateScrBookAnnotations"/> method /// </summary> /// <param name="scr">The Scripture object in the DB</param> /// ------------------------------------------------------------------------------------ public void CallCreateScrBookAnnotations(Scripture scr) { CreateScrBookAnnotations(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public DBMultilingScrBooks(Scripture scr) : base(scr) { m_scripture = scr; }
protected DummyTeScrNoteCategoriesInit(IAdvInd4 progressDlg, Scripture scr, XmlNode categories) : base(progressDlg, scr, categories) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Allows subclasses to do other stuff to initialize the cache before it gets used /// </summary> /// ------------------------------------------------------------------------------------ protected override void InitializeCache() { m_scrInMemoryCache.InitializeScripture(); m_scr = Cache.LangProject.TranslatedScriptureOA as Scripture; base.InitializeCache(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for runtime. No help file. /// </summary> /// <param name="langProjName">Name of the lang proj.</param> /// <param name="scr">The Scripture object which contains import settings.</param> /// <param name="styleSheet">The styleSheet</param> /// <param name="cache">The cache</param> /// ------------------------------------------------------------------------------------ public ImportWizard(string langProjName, Scripture scr, FwStyleSheet styleSheet, FdoCache cache) : this(langProjName, scr, styleSheet, cache, null) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Exposes the LoadTeStylesDoc method /// </summary> /// <returns>An XmlNode representing the Styles in TeStyles.xml /// </returns> /// ------------------------------------------------------------------------------------ static public XmlNode CallLoadTeStylesDoc(Scripture scr) { DummyTeStylesXmlAccessor acc = new DummyTeStylesXmlAccessor(scr); return acc.LoadDoc(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Init the base class TePublicationsInit for testing. /// </summary> /// <param name="cache"></param> /// ------------------------------------------------------------------------------------ internal TestTePublicationsInit(Scripture scr) : base(scr) { m_fUnderTest = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor /// </summary> /// <param name="scr">The Scripture object.</param> /// <param name="styleSheet">The styleSheet</param> /// <param name="cache">The cache</param> /// ------------------------------------------------------------------------------------ public ImportWizardWrapper(Scripture scr, FwStyleSheet styleSheet, FdoCache cache) : base("Test", scr, styleSheet, cache) { m_lvCurrentMappingList = lvScrMappings; m_btnCurrentModifyButton = m_btnModifyScrMapping; m_btnCurrentDeleteButton = m_btnDeleteScrMapping; m_btnCurrentAddButton = m_btnAddScrMapping; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Non-default constructor /// </summary> /// <param name="reference">Initial reference</param> /// <param name="scr">Scripture project</param> /// <param name="useBooksFromDB">Flag indicating whether to display the list of books /// available in the database or show all books in the Canon of Scripture.</param> /// ------------------------------------------------------------------------------------ public ScrPassageControl(ScrReference reference, Scripture scr, bool useBooksFromDB) { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.ResizeRedraw, true); // This call is required by the Windows.Forms Form Designer. InitializeComponent(); if (DesignMode) return; if (scr != null) Initialize(reference, scr, useBooksFromDB); // TODO: Add any initialization after the InitForm call m_dropdownForm = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialization, either from constructor or elsewhere following the default /// constructor. /// </summary> /// <param name="reference">Initial reference</param> /// <param name="scr">Scripture project</param> /// <param name="availableBooks">array of book numbers indicating those books available /// in the control.</param> /// ------------------------------------------------------------------------------------ public void Initialize(ScrReference reference, Scripture scr, int[] availableBooks) { m_rgnAvailableBooks = availableBooks; Initialize(reference, scr, false); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialization, either from constructor or elsewhere following the default constructor. /// </summary> /// <param name="reference">Initial reference</param> /// <param name="scr">Scripture project</param> /// <param name="useBooksFromDB">Flag indicating whether to display the list of books /// available in the database or show all books in the Canon of Scripture.</param> /// ------------------------------------------------------------------------------------ public void Initialize(ScrReference reference, Scripture scr, bool useBooksFromDB) { Debug.Assert(scr != null); m_scripture = scr; m_wsf = scr.Cache.LanguageWritingSystemFactoryAccessor; if (useBooksFromDB) m_mulScrBooks = new DBMultilingScrBooks(scr); else m_mulScrBooks = new MultilingScrBooks(scr); m_mulScrBooks.InitializeWritingSystems(m_wsf); if (m_rgnAvailableBooks != null) InitializeBookLabels(); else { BookLabels = m_mulScrBooks.GetBookNames(true); m_rgnAvailableBooks = new int[m_mulScrBooks.ScriptureBooksLim]; } if (reference != null && !reference.IsEmpty) ScReference = reference; else if (m_rgblBookNames != null && m_rgblBookNames.Length > 0) ScReference = new ScrReference(m_rgblBookNames[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); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for runtime. /// </summary> /// <param name="langProjName">Name of the lang proj.</param> /// <param name="scr">The Scripture object.</param> /// <param name="styleSheet">The styleSheet</param> /// <param name="cache">The cache</param> /// <param name="sHelpFile">If null, the help button will be hidden</param> /// ------------------------------------------------------------------------------------ public ImportWizard(string langProjName, Scripture scr, FwStyleSheet styleSheet, FdoCache cache, string sHelpFile) : this() { m_LangProjName = langProjName; m_scr = scr; m_StyleSheet = styleSheet; m_resolver = new ConfirmOverlappingFileReplaceDialog(); m_settings = (ScrImportSet)m_scr.DefaultImportSettings; if (m_settings == null) { m_settings = new ScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Paratext6; } InitializeScrImportSettings(); // Initialize controls based on settings provided switch (m_settings.ImportTypeEnum) { case TypeOfImport.Paratext6: rbParatext6.Checked = true; break; case TypeOfImport.Other: rbOther.Checked = true; break; case TypeOfImport.Paratext5: rbParatext5.Checked = true; break; } m_cache = cache; m_helpFile = sHelpFile; if (m_helpFile == null) m_btnHelp.Visible = false; if (FwApp.App != null) { m_LatestImportFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName, cache.DatabaseName, "LatestImportDirectory", string.Empty); sfFileListBuilder.LatestImportFolder = m_LatestImportFolder.Value; } if (m_StyleSheet != null) { m_scrViewHelper = new StyleListViewHelper(lvScrMappings, 1); m_scrViewHelper.AddStyles(m_StyleSheet as FwStyleSheet, MappingDetailsCtrl.AllPseudoStyles); m_annotationViewHelper = new StyleListViewHelper(lvAnnotationMappings, 1); m_annotationViewHelper.AddStyles(m_StyleSheet as FwStyleSheet, MappingDetailsCtrl.AllPseudoStyles); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DummyScrPassageControl"/> class. /// </summary> /// <param name="reference">Initial reference</param> /// <param name="scr">Scripture project</param> /// <param name="useBooksFromDB">Flag indicating whether to display the list of books /// available in the database or show all books in the Canon of Scripture.</param> /// ------------------------------------------------------------------------------------ public DummyScrPassageControl(ScrReference reference, Scripture scr, bool useBooksFromDB) : base(reference, scr, useBooksFromDB) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <param name="vernVerseChapterText">Verse or chapter number text. This may be /// <c>null</c>.</param> /// <param name="scr"></param> /// <returns>The converted verse or chapter number, or empty string if /// <paramref name="vernVerseChapterText"/> is <c>null</c>.</returns> /// ------------------------------------------------------------------------------------ public static string ConvertVerseChapterNumForBT(string vernVerseChapterText, Scripture scr) { if (vernVerseChapterText == null) return string.Empty; // empty verse/chapter number run. StringBuilder btVerseChapterText = new StringBuilder(vernVerseChapterText.Length); char baseChar = scr.UseScriptDigits ? (char)scr.ScriptDigitZero : '0'; for (int i = 0; i < vernVerseChapterText.Length; i++) { if (char.IsDigit(vernVerseChapterText[i])) { btVerseChapterText.Append((char)('0' + (vernVerseChapterText[i] - baseChar))); } else { btVerseChapterText.Append(vernVerseChapterText[i]); } } return btVerseChapterText.ToString(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attempt to set the selection immediately following the last character of the closest /// verse number to the requested verse. If no section exists within one chapter of the /// requested verse, the selection will not be changed. /// </summary> /// <param name="targetRef">Reference to seek</param> /// <returns>true if the selected is changed (to the requested verse or one nearby); /// false otherwise</returns> /// ------------------------------------------------------------------------------------ public bool GotoVerse(ScrReference targetRef) { CheckDisposed(); Scripture scr = new Scripture(m_fdoCache, HvoScripture); int iBook = 0; foreach (ScrBook book in scr.ScriptureBooksOS) { if (book.BookIdRA.OwnOrd == targetRef.Book) { // found the book ScrSection prevSection; int iSection = 0; foreach (ScrSection section in book.SectionsOS) { if (section.VerseRefStart <= targetRef) { if (section.VerseRefEnd >= targetRef) { int ihvoPara; // index of paragraph containing the verse int ichPosition; //place to put IP. FindVerseNumber(section, targetRef, out ihvoPara, out ichPosition); SetInsertionPoint(iBook, iSection, ihvoPara, ichPosition, false); return true; } prevSection = section; } else { // try finding a close enough verse ref in previous section } iSection++; } } iBook++; } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Call the base class method /// </summary> /// ------------------------------------------------------------------------------------ public static void CallCreateScrNoteCategories(Scripture scr, XmlDocument doc) { DummyTeScrNoteCategoriesInit noteCategoriesInitializer = new DummyTeScrNoteCategoriesInit(null, scr, doc.SelectSingleNode("TEScrNoteCategories")); noteCategoriesInitializer.CreateScrNoteCategories(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Shuts down the cache. /// </summary> /// <remarks>This method is called after each test</remarks> /// ------------------------------------------------------------------------------------ public override void Exit() { m_scr = null; base.Exit(); }