/// <summary> /// Closes and re-opens the argument window, in the same place, as a drastic way of applying new settings. /// </summary> internal void ReplaceMainWindow(FwXWindow wndActive) { wndActive.SaveSettings(); FwManager.OpenNewWindowForApp(this, null); m_windowToCloseOnIdle = wndActive; Application.Idle += CloseOldWindow; }
/// <summary> /// Select an existing language project. /// </summary> /// <param name="activeWindow"></param> public void ChooseLangProject(FwXWindow activeWindow) { CheckDisposed(); Debug.Assert(activeWindow != null); FdoCache cache = activeWindow.Cache; Debug.Assert(cache != null); // Results parms for the dlg. bool fHaveProject; int hvoProj; string sProject; Guid guid; bool fHaveSubitem; int hvoSubitem; string sUserWs = cache.LanguageWritingSystemFactoryAccessor.GetStrFromWs(cache.DefaultUserWs); //"en"; string sName; string sServer = (cache != null) ? cache.ServerName : MiscUtils.LocalServerName; string sDatabase; IOpenFWProjectDlg dlg = OpenFWProjectDlgClass.Create(); dlg.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor; uint hwnd = activeWindow == null ? 0 : (uint)activeWindow.Handle.ToInt32(); dlg.Show(Logger.Stream, sServer, MiscUtils.LocalServerName, sUserWs, hwnd, false, 0, FwApp.App.HelpFile + "::/" + FwApp.App.GetHelpString("khtpFWOpenProject", 0)); dlg.GetResults(out fHaveProject, out hvoProj, out sProject, out sDatabase, out sServer, out guid, out fHaveSubitem, out hvoSubitem, out sName); System.Runtime.InteropServices.Marshal.ReleaseComObject(dlg); if (fHaveProject) { // make sure the server ends in "\\SILFW" // Note lowercase of SILFW in Turkish is not silfw. if (sServer != null && sServer.ToLowerInvariant().EndsWith("\\silfw") == false) { sServer += "\\SILFW"; // append it } // The GetCache call will switch the 'cache' var to an extant FdoCache, // if the app already has a connection on open on that server and DB. if (CheckDbVerCompatibility(sServer, sDatabase)) { bool isNewCache = GetCache(sServer, sDatabase, out cache); // save the local and global settings for windows sharing this cache. if (!isNewCache) { foreach (IFwMainWnd mainWindow in m_rgMainWindows) { if (mainWindow.Cache == cache && mainWindow is FwXWindow && mainWindow != activeWindow) { (mainWindow as FwXWindow).SaveSettings(); } } } // save the settings for activeWindow last. activeWindow.SaveSettings(); Form fwMainWindow = NewMainAppWnd(cache, isNewCache, null, false); m_rgMainWindows.Add((IFwMainWnd)fwMainWindow); AdjustNewWindowPosition(fwMainWindow, activeWindow); fwMainWindow.Show(); ((IFwMainWnd)fwMainWindow).InitAndShowClient(); } } }
/// <summary> /// Used to launch various import dialogs, but could do other things /// </summary> /// <param name="commandObject"></param> /// <returns></returns> public bool OnLaunchConnectedDialog(object commandObject) { CheckDisposed(); XCore.Command command = (XCore.Command)commandObject; System.Xml.XmlNode first = command.Parameters[0]; System.Xml.XmlNode classInfo = first.SelectSingleNode("dynamicloaderinfo"); Form formActive = ActiveForm; FwXWindow wndActive = formActive as FwXWindow; IFwExtension dlg = null; if (((classInfo as System.Xml.XmlElement)?.Attributes["class"]?.Value ?? "").Contains( "LinguaLinks")) { // Message is deliberately not localized. We expect this to affect maybe one person every couple of years based on recent // occurrences. Doubt it's worth translating. // The reason for the disabling is that model changes require significant changes to the Import code, // and we don't think it's worth the effort. What few LinguaLinks projects still require import can be handled // by installing a version 7 FieldWorks, importing, and then migrating. // (For example, the currently generated stage 5 XML assumes Senses still reference ReveralEntries, rather than the // current opposite link; and there were problems importing texts even in FLEx 8 (LT-2084)). MessageBox.Show( @"Fieldworks no longer supports import of LinguaLinks data. For any remaining projects that need this, our support staff can help convert your data. Please send a message to [email protected]", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information); return(true); } try { try { dlg = (IFwExtension)DynamicLoader.CreateObject(classInfo); } catch (Exception error) { string message = XmlUtils.GetOptionalAttributeValue(classInfo, "notFoundMessage", null); // Make this localizable! if (message != null) { throw new ApplicationException(message, error); } } var oldWsUser = Cache.WritingSystemFactory.UserWs; dlg.Init(Cache, wndActive.Mediator, wndActive.PropTable); DialogResult dr = ((Form)dlg).ShowDialog(ActiveForm); if (dr == DialogResult.OK) { if (dlg is LexOptionsDlg) { LexOptionsDlg loDlg = dlg as LexOptionsDlg; if (oldWsUser != Cache.WritingSystemFactory.UserWs || loDlg.PluginsUpdated) { wndActive.SaveSettings(); MessageBoxUtils.Show(wndActive, LexTextStrings.LexTextApp_RestartToChangeUI_Content, LexTextStrings.LexTextApp_RestartToChangeUI_Title, MessageBoxButtons.OK); } } else if (dlg is LinguaLinksImportDlg || dlg is InterlinearImportDlg || dlg is LexImportWizard || dlg is NotebookImportWiz || dlg is LiftImportDlg) { // Make everything we've imported visible. wndActive.Mediator.SendMessage("MasterRefresh", wndActive); } } } finally { if (dlg != null && dlg is IDisposable) { (dlg as IDisposable).Dispose(); } } return(true); }