/// ------------------------------------------------------------------------------------ /// <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> /// ------------------------------------------------------------------------------------ public ExportUsfmDialog(FdoCache cache, FilteredScrBooks filter, RegistryKey appKey, MarkupType markup) : this() { m_cache = cache; 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> /// 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_regGroup != null) { m_regGroup.Dispose(); } } m_regGroup = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <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_regGroup != null) m_regGroup.Dispose(); } m_regGroup = null; base.Dispose( disposing ); }
/// ------------------------------------------------------------------------------------ /// <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> /// Toggles side bar, status bar and toolbar's visibility /// </summary> /// <param name="args"></param> /// <returns><c>true</c> because we handled the message.</returns> /// ------------------------------------------------------------------------------------ protected bool OnViewFullWindow(object args) { // If this registry key exists then we know we're in full window mode. m_fFullWindow = RegistryHelper.KeyExists(m_app.ProjectSpecificSettingsKey, "FullWindowSettings"); using (RegistryGroup regGroup = new RegistryGroup(m_app.ProjectSpecificSettingsKey, "FullWindowSettings")) { if (!m_fFullWindow) { m_fFullWindow = true; regGroup.SetBoolValue("SideBarVisible", SIBAdapter.SideBarVisible); regGroup.SetBoolValue("StatusBarVisible", statusStrip.Visible); SIBAdapter.SideBarVisible = false; splitContainer.Panel1Collapsed = true; statusStrip.Visible = false; TMBarProperties[] toolbars = m_tmAdapter.BarInfoForViewMenu; foreach (TMBarProperties barProps in toolbars) { regGroup.SetBoolValue(barProps.Name, barProps.Visible); m_tmAdapter.HideToolBar(barProps.Name); } } else { m_fFullWindow = false; // If side bar was already not visible, then it was also collapsed. // there's nothing we need to do for the side bar. if (regGroup.GetBoolValue("SideBarVisible", true)) { // SideBar must be uncollapsed before being made visible splitContainer.Panel1Collapsed = false; SIBAdapter.SideBarVisible = true; } statusStrip.Visible = regGroup.GetBoolValue("StatusBarVisible", true); TMBarProperties[] toolbars = m_tmAdapter.BarInfoForViewMenu; foreach (TMBarProperties barProps in toolbars) { if (regGroup.GetBoolValue(barProps.Name, true)) m_tmAdapter.ShowToolBar(barProps.Name); } try { regGroup.Delete(); } catch { } } } 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; }