///------------------------------------------------------------------------------- /// <summary> /// Constructor for import dialog, requiring a language project. /// Use this constructor at run time. /// </summary> ///------------------------------------------------------------------------------- public ImportDialog(FwStyleSheet styleSheet, FdoCache cache, IScrImportSet settings, IHelpTopicProvider helpTopicProvider, IApp app) : this() { m_StyleSheet = styleSheet; m_helpTopicProvider = helpTopicProvider; m_app = app; m_scr = cache.LangProject.TranslatedScriptureOA; m_importSettings = settings; //InitBookNameList(); // Set the initial values for the controls from the static variables. radImportEntire.Checked = ImportEntire; radImportRange.Checked = !ImportEntire; chkTranslation.Checked = ImportTranslation; chkBackTranslation.Checked = ImportBackTranslation; chkBookIntros.Checked = ImportBookIntros; chkOther.Checked = ImportAnnotations; // Restore any saved settings. if (s_StartRef != null) StartRef = s_StartRef; else SetStartRefToFirstImportableBook(); if (s_EndRef != null) EndRef = s_EndRef; else SetEndRefToLastImportableBook(); // Finish constructing the ScrBookControl objects. InitializeStartAndEndRefControls(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Insert a book /// </summary> /// <returns>The new book</returns> /// ------------------------------------------------------------------------------------ public IScrBook Do() { IScripture scr = m_cache.LangProject.TranslatedScriptureOA; int hvoTitle; IScrBook newBook = ScrBook.CreateNewScrBook(m_bookID, scr, out hvoTitle); m_bookHvo = newBook.Hvo; // Insert the new book title and set the book names newBook.InitTitlePara(); newBook.Name.CopyAlternatives(newBook.BookIdRA.BookName); newBook.Abbrev.CopyAlternatives(newBook.BookIdRA.BookAbbrev); // Now insert the first section for the new book. ITsTextProps textProps = StyleUtils.CharStyleTextProps(ScrStyleNames.ChapterNumber, m_cache.DefaultVernWs); ScrSection.CreateScrSection(newBook, 0, scr.ConvertToString(1), textProps, false); // Do synchronize stuff if (FwApp.App != null) { FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncReloadScriptureControl, 0, 0), m_cache); } // Use Redo for rest of sync'ing and updating book filter Redo(false); return(newBook); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the scripture note import manager. /// </summary> /// ------------------------------------------------------------------------------------ public static void Initialize(IScripture scr, int bookNum, string alternateRfcWsDir) { s_scr = scr; if (!string.IsNullOrEmpty(alternateRfcWsDir)) { s_alternateRfcWsDir = alternateRfcWsDir; } CacheCheckIds(); if (s_rfcWs == null) { s_rfcWs = new RfcWritingSystem(s_scr.Cache, false); } if (bookNum != s_prevBookNum) { s_prevBookNum = bookNum; s_annotationList = (ScrBookAnnotations)scr.BookAnnotationsOS[bookNum - 1]; s_existingAnnotations = new Dictionary <ScrScriptureNote.ScrNoteKey, ScrScriptureNote>(); foreach (ScrScriptureNote ann in s_annotationList.NotesOS) { s_existingAnnotations[ann.Key] = ann; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ExportRtfDialog"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public ExportRtfDialog(FdoCache cache, IHelpTopicProvider helpTopicProvider) { // // Required for Windows Form Designer support // InitializeComponent(); // If the current settings are for arabic digits then don't show the option // to export them as arabic. m_scr = cache.LangProject.TranslatedScriptureOA; m_helpTopicProvider = helpTopicProvider; // Set default export folder. m_rtfFolder = new RegistryStringSetting( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "ExportFolderForRTF", FwSubKey.TE); string fileName = m_rtfFolder.Value; m_fileDialog = new TeImportExportFileDialog(cache.ProjectId.Name, FileType.RTF); // 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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:MultipleFilterDlg"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public MultipleFilterDlg(FdoCache cache, IHelpTopicProvider helpTopicProviderp, ICmFilter filter) : this() { m_helpTopicProvider = helpTopicProviderp; m_cache = cache; m_cellFactory = m_cache.ServiceLocator.GetInstance <ICmCellFactory>(); m_scr = m_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 = BCVRef.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)); scrBookTo.Initialize(new ScrReference(lastBook, 1, 0, m_scr.Versification).LastReferenceForBook); // Update the controls from the filter in the database. InitializeFromFilter(); chkCategory.Checked = tvCatagories.Load(m_cache, m_filter, null); chkCategory_CheckedChanged(null, null); }
public virtual void Initialize() { CheckDisposed(); Debug.Assert(m_fdoCache == null, "m_fdoCache is not null."); //if (m_fdoCache != null) // m_fdoCache.Dispose(); m_fdoCache = GetCache(); FwStyleSheet styleSheet = new FwStyleSheet(); ILangProject lgproj = m_fdoCache.LangProject; IScripture scripture = lgproj.TranslatedScriptureOA; styleSheet.Init(m_fdoCache, scripture.Hvo, (int)Scripture.ScriptureTags.kflidStyles); Debug.Assert(m_basicView == null, "m_basicView is not null."); //if (m_basicView != null) // m_basicView.Dispose(); m_basicView = new DummyBasicView(); m_basicView.Cache = m_fdoCache; m_basicView.Visible = false; m_basicView.StyleSheet = styleSheet; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { if (components != null) { components.Dispose(); } if (m_styleListHelper != null) { m_styleListHelper.Dispose(); } } m_styleListHelper = null; m_StyleSheet = null; m_mapping = null; m_cache = null; m_scr = null; base.Dispose(disposing); }
/// <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) { return; } if (disposing) { // Dispose managed resources here. UndoResult ures = 0; if (m_fdoCache != null) { while (m_fdoCache.CanUndo) { m_fdoCache.Undo(out ures); } m_fdoCache.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_fdoCache = null; m_styleSheet = null; m_scr = null; if (m_wsf != null) { Marshal.ReleaseComObject(m_wsf); m_wsf = null; } base.Dispose(disposing); }
public void GetBookHvoWithFootnotes() { IScripture scr = Cache.LangProject.TranslatedScriptureOA; IScrBook genesis = scr.ScriptureBooksOS[0]; // Add a footnote in the first book, first section, first paragraph IScrSection section = genesis.SectionsOS[0]; IStFootnote footnote = AddFootnote(genesis, (IStTxtPara)section.ContentOA.ParagraphsOS[0], 2, "A footnote"); m_ScrPubCtrl.CallRefreshDisplay(); m_ScrPubCtrl.CreatePages(); m_ScrPubCtrl.PrepareToDrawPages(0, m_ScrPubCtrl.AutoScrollMinSize.Height * 2); // Simulate setting the IP at the beginning of the footnote bool fFoundPageWithFootnotes = false; foreach (DummyPage page in m_ScrPubCtrl.Pages) { if (page.DependentObjectsRootStream != null) { fFoundPageWithFootnotes = true; ((IVwRootBox)page.DependentObjectsRootStream).MakeSimpleSel(true, true, false, true); m_ScrPubCtrl.FocusedStream = page.DependentObjectsRootStream; break; } } Assert.IsTrue(fFoundPageWithFootnotes, "Can't run this test without finding any footnotes"); SelectionHelper selHelper = SelectionHelper.Create(m_ScrPubCtrl); IScrBook book = m_ScrPubCtrl.GetBook(selHelper, SelectionHelper.SelLimitType.Anchor); Assert.AreEqual(genesis, book); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up for a test. /// </summary> /// ------------------------------------------------------------------------------------ public override void FixtureSetup() { base.FixtureSetup(); // set up our cache m_cache = FdoCache.Create("TestLangProj"); m_scr = m_cache.LangProject.TranslatedScriptureOA; }
/// ------------------------------------------------------------------------------------- /// <summary> /// Create factory note categories from the TE ScrNoteCategories XML file. /// </summary> /// <param name="progressDlg">Progress dialog so the user can cancel</param> /// <param name="scr">The Scripture</param> /// ------------------------------------------------------------------------------------- public static void CreateFactoryScrNoteCategories(IAdvInd4 progressDlg, IScripture scr) { TeScrNoteCategoriesInit noteCategoriesInitializer = new TeScrNoteCategoriesInit(progressDlg, scr, LoadScrNoteCategoriesDoc()); noteCategoriesInitializer.CreateScrNoteCategories(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeKeyTermsInit"/> class. /// </summary> /// ------------------------------------------------------------------------------------ protected TeKeyTermsInit(IScripture scr, IApp app) { m_scr = scr; m_app = app; m_wsf = scr.Cache.LanguageWritingSystemFactoryAccessor; m_servLoc = scr.Cache.ServiceLocator; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the texts for each Scripture book title, section, footnote, etc. /// </summary> /// ------------------------------------------------------------------------------------ public void LoadScriptureTexts(FdoCache cache, IBookImporter bookImporter) { m_bookImporter = bookImporter; m_associatedPtText = bookImporter != null?ParatextHelper.GetAssociatedProject(cache.ProjectId) : null; m_scr = cache.LanguageProject.TranslatedScriptureOA; if (m_scr == null) { return; } List <TreeNode> otBooks = new List <TreeNode>(); List <TreeNode> ntBooks = new List <TreeNode>(); for (int bookNum = 1; bookNum <= BCVRef.LastBook; bookNum++) { var bookName = cache.ServiceLocator.GetInstance <IScrRefSystemRepository>().Singleton.BooksOS[bookNum - 1].UIBookName; object book = m_scr.FindBook(bookNum); if (book == null) { if (m_associatedPtText != null && m_associatedPtText.BookPresent(bookNum)) { book = bookNum; } else { continue; } } TreeNode node = new TreeNode(bookName); node.Tag = book; node.Name = "Book"; // help us query for books. if (bookNum < ScriptureTags.kiNtMin) { otBooks.Add(node); } else { ntBooks.Add(node); } } TreeNode bibleNode = new TreeNode(FwControls.kstidBibleNode); bibleNode.Name = "Bible"; if (otBooks.Count > 0) { TreeNode testamentNode = new TreeNode(FwControls.kstidOtNode, otBooks.ToArray()); testamentNode.Name = "Testament"; // help us query for Testaments bibleNode.Nodes.Add(testamentNode); } if (ntBooks.Count > 0) { TreeNode testamentNode = new TreeNode(FwControls.kstidNtNode, ntBooks.ToArray()); testamentNode.Name = "Testament"; // help us query for Testaments bibleNode.Nodes.Add(testamentNode); } Nodes.Add(bibleNode); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Ensures the specified localization is up-to-date with respect to the localization /// file. /// </summary> /// <param name="locale">The ICU locale for the localization to check/update.</param> /// <param name="scr">Scripture object (which owns the resources that store the version /// info.</param> /// <param name="app">The application (needed for error reporting info).</param> /// <param name="caller">The form that is calling this method (to be used as the owner /// of the progress dialog box).</param> /// ------------------------------------------------------------------------------------ public static void EnsureCurrentLocalization(string locale, IScripture scr, FwApp app, Form caller) { TeKeyTermsInit keyTermsInit = new TeKeyTermsInit(scr, app); keyTermsInit.EnsureCurrentLocalization(locale, caller, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ScrCheckingTokenizer"/> class. /// </summary> /// <param name="book">The book being parsed.</param> /// <param name="chapterNum">The 1-basede canonical chapter number being parse, or 0 to /// parse the whole book</param> /// ------------------------------------------------------------------------------------ public ScrCheckingTokenizer(IScrBook book, int chapterNum) { m_book = book; m_scr = (IScripture)book.Owner; m_chapterNum = chapterNum; Reset(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a blank dummy footnote. Used when a footnote object is missing. /// Note: This does not insert an ORC into the paragraph. The caller is fixing the ORC /// with a missing object. /// </summary> /// <param name="owner">The owner to which we will add a footnote.</param> /// <param name="iFootnote">The 0-based index where the footnote will be inserted in the /// owner.</param> /// <param name="paraContents">The paragraph string where the ORC is being fixed.</param> /// <param name="iRun">The 0-based index of the run from which we will get the writing /// system used in the footnote.</param> /// <returns>a blank general footnote</returns> /// ------------------------------------------------------------------------------------ protected override StFootnote CreateBlankDummyFootnoteNoRecursion(ICmObject owner, int iFootnote, ITsString paraContents, int iRun) { if (!(owner is IScrBook)) { return(base.CreateBlankDummyFootnoteNoRecursion(owner, iFootnote, paraContents, iRun)); } // get the writing system of the existing ORC run int nDummy; int ws = paraContents.get_Properties(iRun).GetIntPropValues( (int)FwTextPropType.ktptWs, out nDummy); // Make a dummy blank footnote IScripture scr = m_cache.LangProject.TranslatedScriptureOA; string sMarker = scr.GeneralFootnoteMarker; StFootnote newFootnote = ScrFootnote.CreateFootnoteInScrBook((IScrBook)owner, iFootnote, ref sMarker, m_cache, ws); // Create an empty footnote paragraph with properties with default style and writing system. StTxtPara footnotePara = new StTxtPara(); newFootnote.ParagraphsOS.Append(footnotePara); footnotePara.StyleRules = StyleUtils.ParaStyleTextProps(ScrStyleNames.NormalFootnoteParagraph); // Insert an empty run into the footnote paragraph in order to set the // default writing system. ITsStrFactory strFactory = TsStrFactoryClass.Create(); footnotePara.Contents.UnderlyingTsString = strFactory.MakeString(string.Empty, m_cache.DefaultVernWs); return(newFootnote); }
public void UndoRedoInsertBook() { CheckDisposed(); FdoCache cache = m_firstMainWnd.Cache; IScripture scripture = cache.LangProject.TranslatedScriptureOA; // Need to have an IP m_firstDraftView.RootBox.MakeSimpleSel(true, true, false, true); // When we start up we shouldn't be able to Undo Assert.IsFalse(cache.CanUndo, "Undo possible after startup"); Assert.IsFalse(cache.CanRedo, "Redo possible after startup"); int nBooks = scripture.ScriptureBooksOS.Count; m_firstDraftView.InsertBook(33); Assert.AreEqual(nBooks + 1, scripture.ScriptureBooksOS.Count); Assert.IsTrue(cache.CanUndo, "Undo not possible after inserting book"); Assert.IsFalse(cache.CanRedo, "Redo possible after inserting book"); m_firstMainWnd.SimulateEditUndoClick(); Assert.AreEqual(nBooks, scripture.ScriptureBooksOS.Count); Assert.IsFalse(cache.CanUndo, "Undo possible after undo"); Assert.IsTrue(cache.CanRedo, "Redo not possible after undo"); m_firstMainWnd.SimulateEditRedoClick(); Assert.AreEqual(nBooks + 1, scripture.ScriptureBooksOS.Count); Assert.IsTrue(cache.CanUndo, "Undo not possible after redo"); Assert.IsFalse(cache.CanRedo, "Redo possible after redo"); m_firstMainWnd.SimulateEditUndoClick(); Assert.AreEqual(nBooks, scripture.ScriptureBooksOS.Count); Assert.IsFalse(cache.CanUndo, "Undo possible after undo"); Assert.IsTrue(cache.CanRedo, "Redo not possible after undo"); }
public void PageElementsDontOverlap_TwoFootnotes() { IScripture scr = Cache.LangProject.TranslatedScriptureOA; ScrBook genesis = (ScrBook)scr.ScriptureBooksOS[0]; // Add a footnote in the first book, first section, first paragraph IScrSection section = (IScrSection)genesis.SectionsOS[0]; StFootnote footnote = m_scrInMemoryCache.AddFootnote(genesis, (StTxtPara)section.ContentOA.ParagraphsOS[0], 2); StTxtPara para = m_scrInMemoryCache.AddParaToMockedText(footnote.Hvo, ScrStyleNames.NormalFootnoteParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "Another footnote", 0); // Add a footnote in the first book, last section, 6th paragraph section = (IScrSection)genesis.SectionsOS[genesis.SectionsOS.Count - 1]; footnote = m_scrInMemoryCache.AddFootnote(genesis, (StTxtPara)section.ContentOA.ParagraphsOS[5], 10); para = m_scrInMemoryCache.AddParaToMockedText(footnote.Hvo, ScrStyleNames.NormalFootnoteParagraph); m_scrInMemoryCache.AddRunToMockedPara(para, "This is the footnote", 0); m_pub.CreatePages(); m_pub.PrepareToDrawPages(0, m_pub.AutoScrollMinSize.Height * 2); Page firstPage = m_pub.Pages[0]; int cFoonotesOnThisPage = (int)m_division.m_testPageFootnoteInfo[firstPage.Handle]; Assert.AreEqual(2, cFoonotesOnThisPage, "Should display two footnotes on first page"); // None of the page elements on the first page should intersect CheckThatPageElementsDontOverlap(firstPage); }
/// ------------------------------------------------------------------------------------ /// <summary> /// If the current Scripture Note categories list version in the Db doesn't match that of /// the current XML file, update the DB. /// </summary> /// <param name="lp">The language project</param> /// <param name="existingProgressDlg">The existing progress dialog, if any.</param> /// ------------------------------------------------------------------------------------ public static void EnsureCurrentScrNoteCategories(ILangProject lp, IAdvInd4 existingProgressDlg) { XmlNode scrNoteCategories = LoadScrNoteCategoriesDoc(); IScripture scr = lp.TranslatedScriptureOA; Guid newVersion = Guid.Empty; try { XmlNode version = scrNoteCategories.Attributes.GetNamedItem("version"); newVersion = new Guid(version.Value); } catch (Exception e) { ReportInvalidInstallation("List version attribute invalid in TeScrNoteCategories.xml", e); } if (scr.NoteCategoriesOA == null || newVersion != scr.NoteCategoriesOA.ListVersion) { using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(Form.ActiveForm)) { dlg.RunTask(existingProgressDlg, true, new BackgroundTaskInvoker(CreateScrNoteCategories), scrNoteCategories, scr); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ExportRtfDialog"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public ExportRtfDialog(FdoCache cache) { // // Required for Windows Form Designer support // InitializeComponent(); // If the current settings are for arabic digits then don't show the option // to export them as arabic. m_scr = cache.LangProject.TranslatedScriptureOA; // Set default export folder. m_rtfFolder = new RegistryStringSetting(FwSubKey.TE, cache.ServerName, cache.DatabaseName, "ExportFolderForRTF", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); string fileName = m_rtfFolder.Value; m_fileDialog = new TeImportExportFileDialog(cache, FileType.RTF); // 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; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Creates and opens a <see cref="DummyFootnoteView"/> in a form. Loads scripture /// footnotes from the DB. /// </summary> /// ----------------------------------------------------------------------------------- public void CreateFootnoteView(FdoCache cache) { CheckDisposed(); Cache = cache; FwStyleSheet styleSheet = new FwStyleSheet(); ILangProject lgproj = Cache.LangProject; IScripture scripture = lgproj.TranslatedScriptureOA; styleSheet.Init(Cache, scripture.Hvo, (int)Scripture.ScriptureTags.kflidStyles); m_footnoteView = new DummyFootnoteView(Cache); m_footnoteView.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; m_footnoteView.Dock = DockStyle.Fill; m_footnoteView.Name = "footnoteView"; // make sure book filter is created before view constructor is created. int nbook = m_footnoteView.BookFilter.BookCount; m_footnoteView.MakeRoot(); m_footnoteView.Visible = true; m_footnoteView.StyleSheet = styleSheet; Controls.Add(m_footnoteView); m_footnoteView.ActivateView(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Clean up any resources being used. /// </summary> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } base.Dispose(disposing); if (disposing) { if (components != null) { components.Dispose(); } if (m_FootnoteVc != null) { m_FootnoteVc.Dispose(); } } m_FootnoteVc = null; m_Scripture = null; m_persistence = null; m_draftView = null; m_bookFilter = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Clean up any resources being used. /// </summary> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) ScriptureObject.BooksChanged -= BooksChanged; ScriptureObject = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:MultipleFilterDlg"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public MultipleFilterDlg(FdoCache cache, IHelpTopicProvider helpTopicProviderp, ICmFilter filter) : this() { m_helpTopicProvider = helpTopicProviderp; m_cache = cache; m_cellFactory = m_cache.ServiceLocator.GetInstance<ICmCellFactory>(); m_scr = m_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 = BCVRef.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)); scrBookTo.Initialize(new ScrReference(lastBook, 1, 0, m_scr.Versification).LastReferenceForBook); // Update the controls from the filter in the database. InitializeFromFilter(); chkCategory.Checked = tvCatagories.Load(m_cache, m_filter, null); chkCategory_CheckedChanged(null, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Attaches the annotated objects to the specifed annotation. /// </summary> /// ------------------------------------------------------------------------------------ private static void AttachAnnotatedObjects(IScripture scr, int bookNum, IScrScriptureNote scrNote) { int iSection, iPara, ichStart, ichEnd; ScrReference scrRef = new ScrReference(scrNote.BeginRef, scr.Versification); if (TeEditingHelper.FindTextInVerse(scr, scrNote.CitedTextTss, scrRef, true, out iSection, out iPara, out ichStart, out ichEnd)) { IScrBook book = scr.FindBook(bookNum); Debug.Assert(book != null); scrNote.BeginOffset = ichStart; scrNote.EndOffset = ichEnd; if (iSection == -1) { scrNote.BeginObjectRA = scrNote.EndObjectRA = book.TitleOA.ParagraphsOS[iPara]; } else { scrNote.BeginObjectRA = scrNote.EndObjectRA = book.SectionsOS[iSection].ContentOA.ParagraphsOS[iPara]; } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Call the base class method /// </summary> /// ------------------------------------------------------------------------------------ public static void CallCreateScrNoteCategories(IScripture scr, XmlDocument doc) { DummyTeScrNoteCategoriesInit noteCategoriesInitializer = new DummyTeScrNoteCategoriesInit(null, scr, doc.SelectSingleNode("TEScrNoteCategories")); noteCategoriesInitializer.CreateScrNoteCategories(); }
public void DeleteFootnoteSelection() { m_ScrPubCtrl.PageHeight = 432000; // 6 inches m_ScrPubCtrl.PageWidth = 288000; // 4 inches m_division.TopMargin = 18000; // Half inch m_division.BottomMargin = 18000; m_division.InsideMargin = 18000; m_division.OutsideMargin = 18000; m_ScrPubCtrl.Width = 4 * 96; // represents a window that is 4" wide at 96 DPI m_ScrPubCtrl.CreatePages(); List <Page> pagesToBeDrawn = m_ScrPubCtrl.PrepareToDrawPages(0, 2000); IVwLayoutStream layoutStream = m_division.MainLayoutStream; IVwRootBox rootbox = layoutStream as IVwRootBox; // Get number of footnotes in book. IScripture scr = m_fdoCache.LangProject.TranslatedScriptureOA; Assert.AreEqual(3, scr.ScriptureBooksOS.Count); ScrBook james = (ScrBook)m_fdoCache.LangProject.TranslatedScriptureOA.ScriptureBooksOS[1]; int numFootnotes = james.FootnotesOS.Count; // Select the first footnote in James. SelectionHelper selHelper = SelectRangeOfChars(rootbox, 2, 2, 3); // Delete the footnote marker selection. //m_footnoteView.OnKeyDown(new KeyEventArgs(Keys.Delete)); m_ScrPubCtrl.PressKey(new KeyEventArgs(Keys.Delete)); // Confirm that there is one less footnote in the book. Assert.AreEqual(numFootnotes - 1, james.FootnotesOS.Count); }
public void FindOrCreateStyles_SucceedsAfterStylesMovedFromScripture() { IScripture scr = Cache.ServiceLocator.GetInstance <IScriptureFactory>().Create(); var scriptureStyle = Cache.ServiceLocator.GetInstance <IStStyleFactory>().Create(); scr.StylesOC.Add(scriptureStyle); string styleName = "Scripture Style"; scriptureStyle.Name = styleName; scriptureStyle.Type = StyleType.kstParagraph; scriptureStyle.Context = ContextValues.Text; scriptureStyle.Structure = StructureValues.Body; scriptureStyle.Function = FunctionValues.Prose; scriptureStyle.IsBuiltIn = true; scriptureStyle.IsModified = true; scriptureStyle.NextRA = scriptureStyle; var props1 = TsStringUtils.MakeProps("mystyle", Cache.DefaultAnalWs); scriptureStyle.Rules = props1; scriptureStyle.UserLevel = 5; Guid scrStyleGuid = scriptureStyle.Guid; var sut = new TestAccessorForFindOrCreateStyle(Cache); Assert.That(scr.StylesOC.Count, Is.EqualTo(0), "Style should have been removed from Scripture."); Assert.That(Cache.LangProject.StylesOC.Count, Is.EqualTo(1), "Style should have been added to language project."); Assert.That(Cache.LangProject.StylesOC.First().Name, Is.EqualTo(styleName), "Style name should not have changed."); var movedStyle = sut.FindOrCreateStyle(styleName, StyleType.kstParagraph, ContextValues.Text, StructureValues.Body, FunctionValues.Prose, scrStyleGuid); Assert.That(movedStyle, Is.EqualTo(scriptureStyle)); Assert.That(movedStyle.Name, Is.EqualTo(styleName), "Style name should not have changed."); Assert.That(movedStyle.Owner, Is.EqualTo(Cache.LangProject), "The style owner should be the language project."); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Make one for converting the specified paragraph. /// </summary> /// <param name="para">The paragraph.</param> /// <param name="wsBt">The writing system for which to do the conversion.</param> /// ------------------------------------------------------------------------------------ private BtConverter(IStTxtPara para, int wsBt) { m_para = para; m_cache = para.Cache; m_cpe = m_cache.ServiceLocator.UnicodeCharProps; m_scr = para.Cache.LangProject.TranslatedScriptureOA; m_wsBt = wsBt; }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ScrChecksDataSource"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="punctWhitespaceChar"></param> /// <param name="legacyOverridesFile"></param> /// <param name="styleSheetFileName">Path to the stylesheet definition XML file</param> /// ------------------------------------------------------------------------------------ public ScrChecksDataSource(FdoCache cache, string punctWhitespaceChar, string legacyOverridesFile, string styleSheetFileName) { m_cache = cache; m_scr = cache.LangProject.TranslatedScriptureOA; m_punctWhitespaceChar = punctWhitespaceChar; m_styleSheetFileName = styleSheetFileName; m_legacyOverridesFile = legacyOverridesFile; }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Cleanups the scripture note import manager. /// </summary> /// ------------------------------------------------------------------------------------ public static void Cleanup() { s_existingAnnotations = null; s_checkNamesToGuids = null; s_annotationList = null; s_prevBookNum = 0; s_scr = null; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="NotesDataEntryView"/> class. /// </summary> /// <param name="cache">Duh</param> /// <param name="userView">The UserView that this view displays</param> /// <param name="notesWnd">The notes window.</param> /// ------------------------------------------------------------------------------------ public NotesDataEntryView(FdoCache cache, IUserView userView, FwMainWnd notesWnd) : base(cache) { m_scr = Cache.LangProject.TranslatedScriptureOA; m_UserView = userView; m_notesMainWnd = notesWnd; BaseInfoBarCaption = userView.ViewNameShort; ReadOnlyView = true; }
/// ------------------------------------------------------------------------------------ /// <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> /// <param name="sectionsTag">The sections tag.</param> /// ------------------------------------------------------------------------------------ public TeHeaderFooterVc(FdoCache cache, IPageInfo page, int wsDefault, DateTime printDateTime, int filterInstance, int sectionsTag) : base(page, wsDefault, printDateTime, cache) { m_scr = m_cache.LangProject.TranslatedScriptureOA; m_bookFilter = FilteredScrBooks.GetFilterInstance(m_cache, filterInstance); m_autoAdjustColumns = true; m_sectionsTag = sectionsTag; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:TeScrNoteCategoriesInit"/> class. /// </summary> /// <param name="progressDlg">The progress dialog.</param> /// <param name="scr">The scripture object.</param> /// <param name="categories">The categories.</param> /// ------------------------------------------------------------------------------------ protected TeScrNoteCategoriesInit(IAdvInd4 progressDlg, IScripture scr, XmlNode categories) { m_scr = scr; m_progressDlg = progressDlg; m_categories = categories; m_userLocale = scr.Cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(scr.Cache.DefaultUserWs); m_fallbackUserLocale = scr.Cache.FallbackUserLocale; }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="NotesDataEntryView"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="infoBarCaption">The info bar caption.</param> /// <param name="notesWnd">The notes window.</param> /// ------------------------------------------------------------------------------------ public NotesDataEntryView(FdoCache cache, IHelpTopicProvider helpTopicProvider, string infoBarCaption, FwMainWnd notesWnd) : base(cache) { m_helpTopicProvider = helpTopicProvider; m_scr = cache.LangProject.TranslatedScriptureOA; m_notesMainWnd = notesWnd; BaseInfoBarCaption = infoBarCaption; ReadOnlyView = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Exposes the CreateScrStyles method /// </summary> /// ------------------------------------------------------------------------------------ static public void CallCreateScrStyles(IScripture scr, XmlNode teStyles) { using (ProgressDialogWithTask progressDlg = new ProgressDialogWithTask(Form.ActiveForm)) { DummyTeStylesXmlAccessor acc = new DummyTeStylesXmlAccessor(scr, teStyles); acc.InitLoading(progressDlg, scr, teStyles); } }
/// <summary> /// Make one for converting the specified paragraph. /// </summary> /// <param name="para"></param> public BtConverter(IStTxtPara para) { m_para = para; m_cache = para.Cache; kflidFT = StTxtPara.SegmentFreeTranslationFlid(m_cache); kflidSegments = StTxtPara.SegmentsFlid(m_cache); m_cpe = m_cache.LanguageWritingSystemFactoryAccessor.UnicodeCharProps; m_scr = para.Cache.LangProject.TranslatedScriptureOA; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeScrNoteCategoriesInit"/> class. /// </summary> /// <param name="progressDlg">The progress dialog.</param> /// <param name="scr">The scripture object.</param> /// <param name="categories">The categories.</param> /// ------------------------------------------------------------------------------------ protected TeScrNoteCategoriesInit(IProgress progressDlg, IScripture scr, XmlNode categories) { m_scr = scr; m_servLoc = scr.Cache.ServiceLocator; m_progressDlg = progressDlg; m_categories = categories; m_defUserWs = m_servLoc.WritingSystemManager.UserWs; m_wsId = m_servLoc.WritingSystemManager.UserWritingSystem.Id; m_fallbackUserWsId = WritingSystemServices.FallbackUserWsId; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:TePageSetupDlg"/> class. /// </summary> /// <param name="wsUser">The user writing system.</param> /// <param name="pgLayout">The page layout.</param> /// <param name="scr">The Scripture object (which owns the publications).</param> /// <param name="publication">The publication.</param> /// <param name="division">The division. The NumberOfColumns in the division should be /// set before calling this dialog.</param> /// <param name="teMainWnd">TE main window (provides callbacks).</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="units">The user's prefered measurement units.</param> /// <param name="fIsTrialPub">if set to <c>true</c> view from which this dialog /// was brought up is Trial Publication view.</param> /// <param name="pubPageSizes">The page sizes available for publication.</param> /// ------------------------------------------------------------------------------------ public TePageSetupDlg(int wsUser, IPubPageLayout pgLayout, IScripture scr, IPublication publication, IPubDivision division, IPageSetupCallbacks teMainWnd, IHelpTopicProvider helpTopicProvider, MsrSysType units, bool fIsTrialPub, List<PubPageInfo> pubPageSizes) : base(wsUser, pgLayout, scr, publication, division, teMainWnd, helpTopicProvider, units, pubPageSizes) { m_fIsTrialPublication = fIsTrialPub; if (!m_chkNonStdChoices.Checked) // following the standard m_standardLeadingFactor = m_nudLineSpacing.Value / m_nudBaseCharSize.Value; }
public override void FixtureSetup() { CheckDisposed(); base.FixtureSetup(); m_fdoCache = FdoCache.Create("TestLangProj"); m_scr = m_fdoCache.LangProject.TranslatedScriptureOA; // For these tests we don't need to run InstallLanguage. m_wsf = m_fdoCache.LanguageWritingSystemFactoryAccessor; m_wsf.BypassInstall = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="FilteredScrBooks"/> class. /// </summary> /// <param name="cache"></param> /// <param name="filterInstance"></param> /// ------------------------------------------------------------------------------------ public FilteredScrBooks(FdoCache cache, int filterInstance) { m_cache = cache; m_scr = m_cache.LangProject.TranslatedScriptureOA; ClassName = kFilteredClass; FieldName = kFilteredField + "_" + filterInstance; Type = (int) CellarModuleDefns.kcptReferenceSequence; // Due to the possibility of a book being deleted from the database by an // undo request after an insert of a book, we cannot store the filtered books // in the cache. Instead, we use the ComputeEveryTime flag so that the load // method will be called every time that the filtered books sequence is accessed. ComputeEveryTime = true; cache.InstallVirtualProperty(this); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="SaveVersionDialog"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public SaveVersionDialog(FdoCache cache, IHelpTopicProvider helpTopicProvider) { m_cache = cache; m_scr = m_cache.LangProject.TranslatedScriptureOA; m_helpTopicProvider = helpTopicProvider; // // Required for Windows Form Designer support // InitializeComponent(); if (m_cache == null) return; m_BooksToSave = new List<IScrBook>(); m_treeView.BeginUpdate(); List<TreeNode> otBooks = new List<TreeNode>(); List<TreeNode> ntBooks = new List<TreeNode>(); foreach (IScrBook book in m_scr.ScriptureBooksOS) { TreeNode node = new TreeNode(book.BestUIName); node.Tag = book; if (book.CanonicalNum < ScriptureTags.kiNtMin) otBooks.Add(node); // OT book else ntBooks.Add(node); // NT book } TreeNode bibleNode = new TreeNode(TeResourceHelper.GetResourceString("kstidBibleNode")); if (otBooks.Count > 0) { bibleNode.Nodes.Add(new TreeNode(TeResourceHelper.GetResourceString("kstidOtNode"), otBooks.ToArray())); } if (ntBooks.Count > 0) { bibleNode.Nodes.Add(new TreeNode(TeResourceHelper.GetResourceString("kstidNtNode"), ntBooks.ToArray())); } m_treeView.Nodes.Add(bibleNode); // REVIEW: once we have sections we probably don't want to expand below book level m_treeView.ExpandAll(); m_treeView.EndUpdate(); // update the ok button enabled state m_treeView_NodeCheckChanged(null, EventArgs.Empty); }
/// <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) return; if (disposing) { // Dispose managed resources here. } // Dispose unmanaged resources here, whether disposing is true or false. m_scr = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:UndoImportInfo"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="bookFilter">The book filter.</param> /// ------------------------------------------------------------------------------------ public UndoImportManager(FdoCache cache, FilteredScrBooks bookFilter) { m_cache = cache; m_bookFilter = bookFilter; m_scr = m_cache.LangProject.TranslatedScriptureOA; Debug.Assert(m_cache.ActionHandlerAccessor != null); Debug.Assert(m_cache.ActionHandlerAccessor.CurrentDepth == 0); m_hMark = m_cache.ActionHandlerAccessor.Mark(); IActionHandler actionHandler = m_cache.ActionHandlerAccessor; m_suppressor = new SuppressSubTasks(m_cache); // don't need to undo setting properties. // Create new archive for saving backup versions of imported book m_savedVersion = new ScrDraft(); m_scr.ArchivedDraftsOC.Add(m_savedVersion); actionHandler.AddAction(new UndoImportObjectAction(m_savedVersion)); m_savedVersion.Description = TeResourceHelper.GetResourceString("kstidSavedVersionDescriptionOriginal"); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="NotesMainWnd"/> class. /// </summary> /// <param name="app">The app</param> /// <param name="stylesheet">The stylesheet</param> /// <param name="zoomPercent">The zoom percentage</param> /// ----------------------------------------------------------------------------------- public NotesMainWnd(FwApp app, FwStyleSheet stylesheet, float zoomPercent) : base(app, null) { // // Required for Windows Form Designer support // InitializeComponent(); Name = "NotesMainWnd"; m_zoomPercent = zoomPercent; m_scr = m_app.Cache.LangProject.TranslatedScriptureOA; m_StyleSheet = stylesheet; SetupSideBarInfoBar(); AddFilters(); // Save the max. width for the sidebar and set it to the default width. // m_maxSideBarWidth = m_sideBarContainer.Width; m_sideBarContainer.Width = kDefaultSideBarWidth; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the scripture note import manager. /// </summary> /// ------------------------------------------------------------------------------------ public static void Initialize(IScripture scr, int bookNum, string alternateRfcWsDir) { s_scr = scr; if (!string.IsNullOrEmpty(alternateRfcWsDir)) s_alternateRfcWsDir = alternateRfcWsDir; CacheCheckIds(); if (bookNum != s_prevBookNum) { s_prevBookNum = bookNum; s_annotationList = scr.BookAnnotationsOS[bookNum - 1]; s_existingAnnotations = new Dictionary<ScrNoteKey, IScrScriptureNote>(); foreach (IScrScriptureNote ann in s_annotationList.NotesOS) s_existingAnnotations[ann.Key] = ann; } }
/// ------------------------------------------------------------------------------------ /// <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; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose( bool disposing ) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) return; if (disposing) { if (m_messageFilterInstalled) { Application.RemoveMessageFilter(this); m_messageFilterInstalled = false; } // We don't want to call Controls.Clear() here, because that causes the controls // to change size (and fire the events for it...). It causes CreateMenuAndToolbars() // to be called, so we end up with two toolbar adapters, but we dispose only one, // so eventually it tries to access the already disposed mediator. //Controls.Clear(); // No, since m_bookMerger owns it. // if (m_differences != null) // m_differences.Dispose(); if (m_viewHelper != null) m_viewHelper.Dispose(); if (m_msgMediator != null) { m_msgMediator.RemoveColleague(this); // m_msgMediator gets disposed from calling components.Dispose() below } if (m_undoTaskHelper != null) m_undoTaskHelper.Dispose(); if(components != null) { components.Dispose(); } } // Deal with unmanaged stuff here. m_viewHelper = null; m_differences = null; // Just null it, since m_bookMerger owns it and will dispose it. m_msgMediator = null; m_bookMerger = null; // Client gave it, so it has to dispose it. m_cache = null; m_scr = null; m_stylesheet = null; m_undoTaskHelper = null; base.Dispose( disposing ); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DiffDialog"/> class. /// </summary> /// <param name="bookMerger"></param> /// <param name="cache"></param> /// <param name="stylesheet"></param> /// <param name="zoomFactorDraft">The zoom percentage to be used for the "draft" (i.e., /// main Scripture) view</param> /// <param name="zoomFactorFootnote">The zoom percentage to be used for the "footnote" /// view</param> /// <param name="fDoCollapseUndo">true if we want to collapse to a single Undo item on close.</param> /// ----------------------------------------------------------------------------------- public DiffDialog(BookMerger bookMerger, FdoCache cache, IVwStylesheet stylesheet, float zoomFactorDraft, float zoomFactorFootnote, bool fDoCollapseUndo) { Debug.Assert(cache != null); m_viewHelper = new ActiveViewHelper(this); m_fDoCollapseUndo = fDoCollapseUndo; // Required for Windows Form Designer support InitializeComponent(); // just as fallback in case the Designer replaced FwContainer with Container // in InitializeComponent()... if (!(components is FwContainer)) components = new FwContainer(components); // the last column of the table layout manager in the last row should have the // width of the scroll bar TableLayoutPanel tablePanel = tableLayoutPanel.GetControlFromPosition(0, 3) as TableLayoutPanel; tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth - SystemInformation.FixedFrameBorderSize.Width; tablePanel = tableLayoutPanel.GetControlFromPosition(1, 3) as TableLayoutPanel; tablePanel.ColumnStyles[3].Width = SystemInformation.VerticalScrollBarWidth - SystemInformation.FixedFrameBorderSize.Width; m_msgMediator = new Mediator(); m_msgMediator.AddColleague(this); components.Add(m_msgMediator); m_bookMerger = bookMerger; m_differences = bookMerger.Differences; m_cache = cache; m_scr = m_cache.LangProject.TranslatedScriptureOA; m_stylesheet = stylesheet; m_zoomFactorDraft = zoomFactorDraft; m_zoomFactorFootnote = zoomFactorFootnote; // Don't start out in edit mode m_editMode = false; // If the diff is a comparison of the current against a normal saved version, then // change the label text. ScrDraft draft = new ScrDraft(m_cache, m_bookMerger.BookRev.OwnerHVO); if (draft.Type == ScrDraftType.SavedVersion) { lblSavedVersion.Text = string.Format(TeDiffViewResources.kstidSavedVersion, draft.Description); } else lblSavedVersion.Text = string.Format(lblSavedVersion.Text, draft.Description); CreateUndoMark(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DummyTeKeyTermsInit"/> class. /// </summary> /// <param name="scr">The Scripture object.</param> /// ------------------------------------------------------------------------------------ public DummyTeKeyTermsInit(IScripture scr) : base(scr) { }
/// ------------------------------------------------------------------------------------ /// <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="helpTopicProvider">The help topic provider.</param> /// <param name="app">The app.</param> /// ------------------------------------------------------------------------------------ public ImportWizard(string langProjName, IScripture scr, FwStyleSheet styleSheet, IHelpTopicProvider helpTopicProvider, IApp app) : this() { m_LangProjName = langProjName; m_scr = scr; m_helpTopicProvider = helpTopicProvider; m_app = app; m_StyleSheet = styleSheet; m_resolver = new ConfirmOverlappingFileReplaceDialog(helpTopicProvider); m_cache = scr.Cache; // Attempt to get the default import settings. m_settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Unknown); if (m_settings.ImportTypeEnum == TypeOfImport.Unknown) 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; } if (m_helpTopicProvider == null) m_btnHelp.Visible = false; if (m_app != null) { m_LatestImportFolder = new RegistryStringSetting(FwSubKey.TE, m_scr.Cache.ProjectId.Name, "LatestImportDirectory", string.Empty); sfFileListBuilder.LatestImportFolder = m_LatestImportFolder.Value; } sfFileListBuilder.Initialize(m_helpTopicProvider, m_app); if (m_StyleSheet != null) { m_scrViewHelper = new StyleListViewHelper(lvScrMappings, 1); m_scrViewHelper.AddStyles(m_StyleSheet, MappingDetailsCtrl.AllPseudoStyles); m_annotationViewHelper = new StyleListViewHelper(lvAnnotationMappings, 1); m_annotationViewHelper.AddStyles(m_StyleSheet, MappingDetailsCtrl.AllPseudoStyles); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="FilteredScrBooks"/> class. /// </summary> /// <param name="cache"></param> /// ------------------------------------------------------------------------------------ internal FilteredScrBooks(FdoCache cache) { m_cache = cache; m_scr = m_cache.LangProject.TranslatedScriptureOA; m_filteredBooks = new List<IScrBook>(m_scr.ScriptureBooksOS); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize the FDO cache and open database /// </summary> /// <remarks>This method is called before each test</remarks> /// ------------------------------------------------------------------------------------ public override void Initialize() { base.Initialize(); m_scr = m_fdoCache.LangProject.TranslatedScriptureOA; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="NotesEditingHelper"/> class. /// </summary> /// <param name="cache">The DB connection</param> /// <param name="callbacks">implementation of <see cref="IEditingCallbacks"/></param> /// <param name="filterInstance"></param> /// ------------------------------------------------------------------------------------ public NotesEditingHelper(FdoCache cache, IEditingCallbacks callbacks, int filterInstance) : base(cache, callbacks) { m_scr = m_cache.LangProject.TranslatedScriptureOA; }