Esempio n. 1
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Creates a new instance of the main Translation Editor window
        /// </summary>
        ///
        /// <param name="cache">Instance of the FW Data Objects cache that the new main window
        /// will use for accessing the database.</param>
        /// <param name="fNewCache">Flag indicating whether one-time, application-specific
        /// initialization should be done for this cache.</param>
        /// <param name="wndCopyFrom"> Must be null for creating the original app window.
        /// Otherwise, a reference to the main window whose settings we are copying.</param>
        /// <param name="fOpeningNewProject"><c>true</c> if opening a brand spankin' new
        /// project</param>
        /// <returns>New instance of TeMainWnd if Scripture data has been successfully loaded;
        /// null, otherwise</returns>
        /// -----------------------------------------------------------------------------------
        protected override Form NewMainAppWnd(FdoCache cache, bool fNewCache, Form wndCopyFrom,
                                              bool fOpeningNewProject)
        {
            if (!LoadData(cache, fOpeningNewProject))
            {
                return(null);
            }

            if (fNewCache)
            {
                ILangProject lp = cache.LangProject;
                // Loop through the Vernacular WS and initialize them
                foreach (ILgWritingSystem ws in lp.VernWssRC)
                {
                    cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws.Hvo);
                }

                // Loop through the Analysis WS and initialize them
                foreach (ILgWritingSystem ws in lp.AnalysisWssRC)
                {
                    cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(ws.Hvo);
                }

                // Since getting the engine for a WS can actually cause it to get updated from
                // the local XML file, we now need to clear the info about them, so we won't be
                // using stale data from the cache.
                cache.VwCacheDaAccessor.ClearInfoAboutAll(lp.VernWssRC.HvoArray, lp.VernWssRC.Count,
                                                          VwClearInfoAction.kciaRemoveObjectAndOwnedInfo);
                cache.VwCacheDaAccessor.ClearInfoAboutAll(lp.AnalysisWssRC.HvoArray, lp.AnalysisWssRC.Count,
                                                          VwClearInfoAction.kciaRemoveObjectAndOwnedInfo);

                // Make sure this DB uses the current stylesheet version, note categories & and key terms list
                if (!fOpeningNewProject)
                {
                    IAdvInd4 progressDlg = m_SplashScreenWnd != null ? m_SplashScreenWnd.ProgressBar as IAdvInd4 : null;
                    TeScrInitializer.EnsureProjectComponentsValid(cache, progressDlg);
                }
                // Do any other needed initialization here.
            }

            // TE-1913: Prevent user from accessing windows that are open to the same project.
            // Originally this was used for importing.
            foreach (Form wnd in MainWindows)
            {
                if (!wnd.Enabled && (wnd is FwMainWnd && ((FwMainWnd)wnd).Cache == cache))
                {
                    MessageBox.Show("This project is locked by another window. Please try again later.",
                                    "Project Locked", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(null);
                }
            }
            return(NewTeMainWnd(cache, wndCopyFrom));
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        ///	App-specific initialization of the cache.
        /// </summary>
        /// <param name="progressDlg">The progress dialog.</param>
        /// <returns>True if the initialize was successful, false otherwise</returns>
        /// ------------------------------------------------------------------------------------
        public override bool InitCacheForApp(IThreadedProgress progressDlg)
        {
            if (!TeScrInitializer.Initialize(Cache, this, progressDlg))
            {
                return(false);
            }

            // Make sure this DB uses the current stylesheet version, note categories & and key terms list
            IActionHandler actionHandler = Cache.ServiceLocator.GetInstance <IActionHandler>();

            NonUndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW(actionHandler,
                                                               () => TeScrInitializer.EnsureProjectComponentsValid(Cache, this, progressDlg));

            Cache.ServiceLocator.GetInstance <IParagraphCounterRepository>().RegisterViewTypeId <TeParaCounter>((int)TeViewGroup.Scripture);
            Cache.ServiceLocator.GetInstance <IParagraphCounterRepository>().RegisterViewTypeId <TeParaCounter>((int)TeViewGroup.Footnote);
            return(true);
        }