/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the progress on the splash screen's progress bar. /// </summary> /// <param name="splashScreen">The splash screen.</param> /// ------------------------------------------------------------------------------------ private static void UpdateProgress(IFwSplashScreen splashScreen) { if (splashScreen != null) { splashScreen.ProgressBar.Step(1); } }
/// ------------------------------------------------------------------------------------- /// <summary> /// Perform one-time initialization of a new Scripture project /// </summary> /// <returns>true if data loaded successfully; false, otherwise</returns> /// ------------------------------------------------------------------------------------- protected bool Initialize(IFwSplashScreen splashScreen) { ILangProject lp = m_cache.LangProject; if (m_scr != null) { // Preload all book, section and paragraphs if we already have Scripture PreloadData(m_cache, splashScreen); if (m_scr.BookAnnotationsOS.Count != 0 && m_cache.ScriptureReferenceSystem.BooksOS.Count != 0 && m_scr.PublicationsOC.Count != 0 && lp.KeyTermsList.PossibilitiesOS.Count >= 1 && m_scr.NoteCategoriesOA != null && m_scr.NoteCategoriesOA.PossibilitiesOS.Count > 0) { return(true); } } IAdvInd4 existingProgressDlg = null; if (splashScreen != null) { existingProgressDlg = splashScreen.ProgressBar as IAdvInd4; } using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(Form.ActiveForm)) { try { dlg.RunTask(existingProgressDlg, true, new BackgroundTaskInvoker(InitializeScriptureProject)); } catch (WorkerThreadException e) { UndoResult ures; while (m_cache.Undo(out ures)) { ; // Enhance JohnT: make use of ures? } MessageBox.Show(Form.ActiveForm, e.InnerException.Message, TeResourceHelper.GetResourceString("kstidApplicationName"), MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } return(true); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Perform one-time initialization of a new Scripture project /// </summary> /// <param name="cache">The database cache</param> /// <param name="splashScreen">The splash screen (can be null).</param> /// <returns> /// true if data loaded successfully; false, otherwise /// </returns> /// ------------------------------------------------------------------------------------ public static bool Initialize(FdoCache cache, IFwSplashScreen splashScreen) { TeScrInitializer scrInitializer = new TeScrInitializer(cache); return scrInitializer.Initialize(splashScreen); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Updates the progress on the splash screen's progress bar. /// </summary> /// <param name="splashScreen">The splash screen.</param> /// ------------------------------------------------------------------------------------ private static void UpdateProgress(IFwSplashScreen splashScreen) { if (splashScreen != null) splashScreen.ProgressBar.Step(1); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Preloads the data used by TE. /// </summary> /// <param name="cache">The cache.</param> /// <param name="splashScreen">The splash screen (can be null).</param> /// ------------------------------------------------------------------------------------ public static void PreloadData(FdoCache cache, IFwSplashScreen splashScreen) { if (splashScreen != null) { splashScreen.ProgressBar.SetRange(0, 21); // we call 21 x UpdateProgress() below splashScreen.ProgressBar.StepSize = 1; splashScreen.ProgressBar.Position = 0; } // Preload all vectors for scripture // NOTE: splitting up the loading of flids off of the same object type (e.g. StText) // lets us create a smoother progress bar and doesn't seem to produce any noticable // performance hit! cache.PreloadIfMissing(cache.LangProject.TranslatedScriptureOAHvo, (int)Scripture.ScriptureTags.kflidScriptureBooks, 0); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)ScrBook.ScrBookTags.kflidSections, "ScrBook"); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)Scripture.ScriptureTags.kflidStyles, "Scripture"); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningAtomicProp((int)ScrSection.ScrSectionTags.kflidHeading, "ScrSection"); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningAtomicProp((int)ScrSection.ScrSectionTags.kflidContent, "ScrSection"); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText", new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText", new int[] { (int)ScrBook.ScrBookTags.kflidTitle }); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText", new int[] { (int)ScrSection.ScrSectionTags.kflidHeading }); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)StText.StTextTags.kflidParagraphs, "StText", new int[] { (int)ScrSection.ScrSectionTags.kflidContent }); UpdateProgress(splashScreen); cache.LoadAllOfAnOwningVectorProp((int)StTxtPara.StTxtParaTags.kflidTranslations, "StTxtPara"); UpdateProgress(splashScreen); // also preload all scripture, sections, paragraphs and footnotes CmObject.LoadDataForFlids(typeof(Scripture), cache, null, LangProject.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(StStyle), cache, new int[] { (int)LangProject.LangProjectTags.kflidTranslatedScripture }, Scripture.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(ScrSection), cache, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, ScrBook.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(StFootnote), cache, new int[] { (int)Scripture.ScriptureTags.kflidScriptureBooks }, ScrBook.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(StTxtPara), cache, new int[] { (int)ScrBook.ScrBookTags.kflidFootnotes }, StText.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(StTxtPara), cache, new int[] { (int)ScrBook.ScrBookTags.kflidTitle }, StText.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(StTxtPara), cache, new int[] { (int)ScrSection.ScrSectionTags.kflidHeading }, StText.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(StTxtPara), cache, new int[] { (int)ScrSection.ScrSectionTags.kflidContent }, StText.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(CmTranslation), cache, new int[] { (int)CmTranslation.CmTranslationTags.kflidStatus }, CmTranslation.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(CmTranslation), cache, new int[] { (int)CmTranslation.CmTranslationTags.kflidTranslation }, CmTranslation.FullViewName); UpdateProgress(splashScreen); CmObject.LoadDataForFlids(typeof(CmTranslation), cache, new int[] { (int)CmTranslation.CmTranslationTags.kflidType }, CmTranslation.FullViewName); UpdateProgress(splashScreen); }
/// ------------------------------------------------------------------------------------- /// <summary> /// Perform one-time initialization of a new Scripture project /// </summary> /// <returns>true if data loaded successfully; false, otherwise</returns> /// ------------------------------------------------------------------------------------- protected bool Initialize(IFwSplashScreen splashScreen) { ILangProject lp = m_cache.LangProject; if (m_scr != null) { // Preload all book, section and paragraphs if we already have Scripture PreloadData(m_cache, splashScreen); if (m_scr.BookAnnotationsOS.Count != 0 && m_cache.ScriptureReferenceSystem.BooksOS.Count != 0 && m_scr.PublicationsOC.Count != 0 && lp.KeyTermsList.PossibilitiesOS.Count >= 1 && m_scr.NoteCategoriesOA != null && m_scr.NoteCategoriesOA.PossibilitiesOS.Count > 0) { return true; } } IAdvInd4 existingProgressDlg = null; if (splashScreen != null) existingProgressDlg = splashScreen.ProgressBar as IAdvInd4; using (ProgressDialogWithTask dlg = new ProgressDialogWithTask(Form.ActiveForm)) { try { dlg.RunTask(existingProgressDlg, true, new BackgroundTaskInvoker(InitializeScriptureProject)); } catch (WorkerThreadException e) { UndoResult ures; while (m_cache.Undo(out ures)) ; // Enhance JohnT: make use of ures? MessageBox.Show(Form.ActiveForm, e.InnerException.Message, TeResourceHelper.GetResourceString("kstidApplicationName"), MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } } return true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Closes the splash screen /// </summary> /// ------------------------------------------------------------------------------------ public virtual void CloseSplashScreen() { CheckDisposed(); // Close the splash screen if (m_SplashScreenWnd != null) { // We have to clear out the reference to the progress bar on the splash screen // before we close the splash screen otherwise we're in trouble foreach (FdoCache cache in m_caches.Values) { if (cache.ProgressBar == m_SplashScreenWnd.ProgressBar) cache.ProgressBar = null; } m_SplashScreenWnd.Close(); m_SplashScreenWnd = null; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Displays the splash screen /// </summary> /// ------------------------------------------------------------------------------------ public virtual void ShowSplashScreen() { CheckDisposed(); m_SplashScreenWnd = new FwSplashScreen(); m_SplashScreenWnd.Show(); m_SplashScreenWnd.Refresh(); }
/// <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 virtual void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (m_isDisposed || m_beingDisposed) return; m_beingDisposed = true; UpdateAppRuntimeCounter(); if (disposing) { FwRegistrySettings.FirstTimeAppHasBeenRun = false; // Dispose managed resources here. Logger.ShutDown(); Application.ThreadException -= new ThreadExceptionEventHandler(HandleTopLevelError); List<IFwMainWnd> mainWnds = new List<IFwMainWnd>(m_rgMainWindows); // Use another array, since m_rgMainWindows may change. m_rgMainWindows.Clear(); // In fact, just clear the main array, so the windows won't have to worry so much. foreach (IFwMainWnd mainWnd in mainWnds) { if (mainWnd is Form) { Form wnd = (Form)mainWnd; wnd.Closing -= new CancelEventHandler(OnClosingWindow); wnd.Closed -= new EventHandler(OnWindowClosed); wnd.Activated -= new EventHandler(fwMainWindow_Activated); wnd.HandleDestroyed -= new EventHandler(fwMainWindow_HandleDestroyed); wnd.Dispose(); } else if (mainWnd is IDisposable) ((IDisposable)mainWnd).Dispose(); } if (m_caches != null) { foreach (FdoCache cache in m_caches.Values) cache.Dispose(); m_caches.Clear(); } if (m_findReplaceDlg != null) m_findReplaceDlg.Dispose(); #if DEBUG if (m_debugProcs != null) m_debugProcs.Dispose(); #endif // Close the splash screen if, for some reason, it's still hanging around. It // really shouldn't still be around by this time, except when some testing code // instantiates FwApp objects. This will make sure the splash screen goes away // when the FwApp object goes out of scope. CloseSplashScreen(); ResourceHelper.ShutdownHelper(); if (m_rgMainWindows != null) m_rgMainWindows.Clear(); if (m_commandLineArgs != null) m_commandLineArgs.Clear(); if (m_suppressedCaches != null) m_suppressedCaches.Clear(); if (m_refreshViewCaches != null) m_refreshViewCaches.Clear(); if (m_findPatterns != null) m_findPatterns.Clear(); Application.RemoveMessageFilter(this); } // Dispose unmanaged resources here, whether disposing is true or false. m_rgMainWindows = null; m_activeMainWindow = null; m_commandLineArgs = null; m_SplashScreenWnd = null; m_findPatterns = null; m_findReplaceDlg = null; m_suppressedCaches = null; m_refreshViewCaches = null; #if DEBUG m_debugProcs = null; #endif m_caches = null; s_app = null; m_isDisposed = true; m_beingDisposed = false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Perform one-time initialization of a new Scripture project /// </summary> /// <param name="cache">The database cache</param> /// <param name="splashScreen">The splash screen (can be null).</param> /// <returns> /// true if data loaded successfully; false, otherwise /// </returns> /// ------------------------------------------------------------------------------------ public static bool Initialize(FdoCache cache, IFwSplashScreen splashScreen) { TeScrInitializer scrInitializer = new TeScrInitializer(cache); return(scrInitializer.Initialize(splashScreen)); }