public override bool OnFinishedInit() { CheckDisposed(); if (!base.OnFinishedInit()) return false; EnsureEnglishLdsExists(); ScrText assocProj = ParatextHelper.GetAssociatedProject(m_cache.ProjectId); if (assocProj != null && m_app.MainWindows.Count == 1) { MessageBox.Show(this, string.Format(TeResourceHelper.GetResourceString("kstidNoExportStartupMsg"), assocProj.JoinedNameAndFullName), FwUtils.ksTeAppName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } // If there are books in the project... if (m_cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS.Count > 0) { if (m_startupLink != null) { // This should automatically disabled any problem filters. m_app.HandleIncomingLink(m_startupLink); } else { // When the TE window first opens, check if a book filter was enabled when // the user last closed TE. If so, then show the user the book filter dialog. if (TeProjectSettings.BookFilterEnabled) OnBookFilter(null); } if (!ActiveViewHelper.IsViewVisible(ActiveView) && SIBAdapter != null) { // Attempt to get the last active tab and tab item from the registry. // If no tab and tab item are set, default to the Scripture tab // and the Draft view tab item. string activeTab = (string)MainWndSettingsKey.GetValue("ActiveTab", kScrSBTabName); string activeTabItem = (string)MainWndSettingsKey.GetValue("ActiveTabItem", kScrDraftViewSBItemName); SIBAdapter.SetCurrentTabItem(activeTab, activeTabItem, true); } return true; } // There are no books in the project. Handle things nicely for the user. // switch to Scripture Task - Draft view if (SIBAdapter != null) SIBAdapter.SetCurrentTabItem(kScrSBTabName, kScrDraftViewSBItemName, true); // Open a helpful window //Mediator msgMediator = (m_app != null ? m_app.MessageMediator : null); using (EmptyScripture dlg = new EmptyScripture(m_tmAdapter, m_cache, m_app)) { dlg.ShowDialog(); switch (dlg.OptionChosen) { case EmptyScripture.Option.Book: // insert the book Debug.Assert(ActiveEditingHelper != null); string undo, redo; TeResourceHelper.MakeUndoRedoLabels("kstidInsertBook", out undo, out redo); using (UndoableUnitOfWorkHelper undoHelper = new UndoableUnitOfWorkHelper( m_cache.ServiceLocator.GetInstance<IActionHandler>(), undo, redo)) { ActiveEditingHelper.InsertBook(dlg.BookChosen); undoHelper.RollBack = false; } break; case EmptyScripture.Option.Import: OnImportStandardFormat(null); break; case EmptyScripture.Option.Exit: OnFileClose(null); return true; } } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// When finished initializing, show a helpful window if there are no books yet in the /// project. Handle some of the commands on that dialog box. /// </summary> /// <returns>True if successful; false if user chooses to exit app</returns> /// ------------------------------------------------------------------------------------ public override bool OnFinishedInit() { CheckDisposed(); if (!base.OnFinishedInit()) return false; // From here on out, we assume the cache is preloaded with any data important to // TE, so we set PreloadData false to improve performance. // REVIEW: Until we get inter-app synchronization fully implemented, this will // probably result in accidental misses when attempting to look up words in the // lexicon or wordform inventory (in Key Terms view) that have been added in FLEx. m_cache.PreloadData = false; // If there are books in the project... if (m_cache.LangProject.TranslatedScriptureOA.ScriptureBooksOS.Count > 0) { // When the TE window first opens, check if a book filter was enabled when // the user last closed TE. If so, then show the user the book filter dialog. if (m_bookFilterEnabled != null && m_bookFilterEnabled.Value) OnBookFilter(null); if (!ActiveViewHelper.IsViewVisible(ActiveView) && SIBAdapter != null) { // Attempt to get the last active tab and tab item from the registry. // If no tab and tab item are set, default to the Scripture tab // and the Draft view tab item. RegistryGroup regGroup = new RegistryGroup(SettingsKeyEx, GetType().Name); string activeTab = regGroup.GetStringValue("ActiveTab", kScrSBTabName); string activeTabItem = regGroup.GetStringValue("ActiveTabItem", kScrDraftViewSBItemName); SIBAdapter.SetCurrentTabItem(activeTab, activeTabItem, true); } return true; } // There are no books in the project. Handle things nicely for the user. // switch to Scripture Task - Draft view if (SIBAdapter != null) SIBAdapter.SetCurrentTabItem(kScrSBTabName, kScrDraftViewSBItemName, true); // Open a helpful window //Mediator msgMediator = (FwApp.App != null ? FwApp.App.MessageMediator : null); using (EmptyScripture dlg = new EmptyScripture(m_tmAdapter, m_cache)) { dlg.ShowDialog(); switch (dlg.OptionChosen) { case EmptyScripture.Option.Book: // insert the book Debug.Assert(ActiveEditingHelper != null); ActiveEditingHelper.InsertBook(dlg.BookChosen); break; case EmptyScripture.Option.Import: OnImportStandardFormat(null); break; case EmptyScripture.Option.Exit: OnFileClose(null); return false; } } return true; }