/// ------------------------------------------------------------------------------------ /// <summary> /// Launches the proj properties DLG. /// </summary> /// <param name="startOnWSPage">if set to <c>true</c> [start on WS page].</param> /// ------------------------------------------------------------------------------------ private void LaunchProjPropertiesDlg(bool startOnWSPage) { if (!ClientServerServicesHelper.WarnOnOpeningSingleUserDialog(Cache)) return; if (!SharedBackendServicesHelper.WarnOnOpeningSingleUserDialog(Cache)) return; FdoCache cache = Cache; bool fDbRenamed = false; string sProject = cache.ProjectId.Name; string sProjectOrig = sProject; string sLinkedFilesRootDir = cache.LangProject.LinkedFilesRootDir; using (var dlg = new FwProjPropertiesDlg(cache, m_app, m_app, FontHeightAdjuster.StyleSheetFromMediator(Mediator))) { dlg.ProjectPropertiesChanged += OnProjectPropertiesChanged; if (startOnWSPage) dlg.StartWithWSPage(); if (dlg.ShowDialog(this) != DialogResult.Abort) { fDbRenamed = dlg.ProjectNameChanged(); if (fDbRenamed) { sProject = dlg.ProjectName; } bool fFilesMoved = false; if (dlg.LinkedFilesChanged()) { fFilesMoved = m_app.UpdateExternalLinks(sLinkedFilesRootDir); } // no need for any of these refreshes if entire window has been/will be // destroyed and recreated. if (!fDbRenamed && !fFilesMoved) { Mediator.PropertyTable.SetProperty("DocumentName", cache.ProjectId.UiName); Mediator.PropertyTable.SetPropertyPersistence("DocumentName", false); } } } if (fDbRenamed) m_app.FwManager.RenameProject(sProject, m_app); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Display the project properties dialog /// </summary> /// <param name="args"></param> /// ------------------------------------------------------------------------------------ protected virtual bool OnFileProjectProperties(object args) { // Disabling the main window circumvents the usual mechanisms for switching keyboards, // so we manually switch to the default keyboard here so that the Project Properties // dialog displays the default keyboard. When we're all done we switch back to the // keyboard we had recently. (TE-4683) var oldWsd = Keyboard.Controller.ActiveKeyboard; Keyboard.Controller.ActivateDefaultKeyboard(); // Disable windows on cache to prevent painting when fonts for writing system are changed m_app.EnableMainWindows(false); bool fDbRenamed = false; bool fFilesMoved = false; string sProject = m_cache.ProjectId.Name; string sOrigLinkedFilesRootDir = m_cache.LangProject.LinkedFilesRootDir; try { using (var dlg = new FwProjPropertiesDlg(m_cache, m_app, m_app, m_StyleSheet)) { if (dlg.ShowDialog(this) != DialogResult.OK) return true; using (new WaitCursor(this)) { fDbRenamed = dlg.ProjectNameChanged(); if (fDbRenamed) sProject = dlg.ProjectName; if (dlg.LinkedFilesChanged()) fFilesMoved = m_app.UpdateExternalLinks(sOrigLinkedFilesRootDir); if (!fDbRenamed) { // rename works only if other programs (like Flex) are not // running. In which case, the Sync operation isn't needed. // Note: We handle this here since Flex does full refresh and we don't want // this happening first. if (dlg.WritingSystemsChanged()) { using (var undoHelper = new UndoTaskHelper(m_cache.ActionHandlerAccessor, null, "kstidUndoRedoProjectProperties")) { var undoAction = new SyncUndoAction(m_app, SyncMsg.ksyncWs); undoAction.Do(); m_cache.DomainDataByFlid.GetActionHandler().AddAction(undoAction); undoHelper.RollBack = false; } } } } } } finally { m_app.EnableMainWindows(true); if (!fDbRenamed && !fFilesMoved) // no need for refresh when total shutdown & reopen { // Make sure windows for this cache are now enabled. // if the dialog merged two writing systems it will close/dispose this FwMainWnd. // if so, don't try to access any properties like EditingHelper or we'll crash (TE-7297). if (!IsDisposed) { // Restore the previous keyboard if (oldWsd != null) oldWsd.Activate(); } } } if (fDbRenamed) m_app.FwManager.RenameProject(sProject, m_app); return true; }