/// <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>non-undoable task because setting up an StText must be done in a Unit of Work</summary> private void DoSetupFixture() { m_application = new MockFwXApp(new MockFwManager { Cache = Cache }, null, null); var configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname); m_window = new MockFwXWindow(m_application, configFilePath); ((MockFwXWindow)m_window).Init(Cache); // initializes Mediator values m_mediator = m_window.Mediator; // set up default vernacular ws. m_wsDefaultVern = Cache.ServiceLocator.WritingSystemManager.Get("fr"); m_wsOtherVern = Cache.ServiceLocator.WritingSystemManager.Get("es"); m_wsEn = Cache.ServiceLocator.WritingSystemManager.Get("en"); Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Add(m_wsOtherVern); Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Add(m_wsOtherVern); Cache.ServiceLocator.WritingSystems.VernacularWritingSystems.Add(m_wsDefaultVern); Cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems.Insert(0, m_wsDefaultVern); // set up an StText with an empty paragraph with default Contents (empty English TsString) m_sttNoExplicitWs = Cache.ServiceLocator.GetInstance <IStTextFactory>().Create(); Cache.ServiceLocator.GetInstance <ITextFactory>().Create().ContentsOA = m_sttNoExplicitWs; m_sttNoExplicitWs.AddNewTextPara(null); Assert.AreEqual(m_wsEn.Handle, m_sttNoExplicitWs.MainWritingSystem, "Our code counts on English being the defualt WS for very empty texts"); // set up an StText with an empty paragraph with an empty TsString in a non-default vernacular m_sttEmptyButWithWs = Cache.ServiceLocator.GetInstance <IStTextFactory>().Create(); Cache.ServiceLocator.GetInstance <ITextFactory>().Create().ContentsOA = m_sttEmptyButWithWs; m_sttEmptyButWithWs.AddNewTextPara(null); ((IStTxtPara)m_sttEmptyButWithWs.ParagraphsOS[0]).Contents = TsStringUtils.MakeTss(string.Empty, m_wsOtherVern.Handle); }
/// <summary> /// This implements the "Synchronize with LiftShare..." menu command. /// </summary> /// <param name="sender"></param> /// <returns></returns> /// <remarks>Until LiftShare is fully implemented, this is irrelevant.</remarks> public bool OnSynchronize(object sender) { FdoCache cache = null; Form formActive = ActiveForm; foreach (FwXWindow wnd in m_rgMainWindows) { if ((object)wnd == (object)formActive) { cache = wnd.Cache; break; } } if (cache != null) { FwXWindow wndActive = formActive as FwXWindow; LiftSynchronizeDlg dlg = new LiftSynchronizeDlg(cache, wndActive.Mediator); dlg.ShowDialog(formActive); return(true); } else { return(false); } }
public override void FixtureSetup() { base.FixtureSetup(); FwRegistrySettings.Init(); m_application = new MockFwXApp(new MockFwManager { Cache = Cache }, null, null); var configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname); m_window = new MockFwXWindow(m_application, configFilePath); ((MockFwXWindow)m_window).Init(Cache); // initializes Mediator values m_mediator = m_window.Mediator; m_mediator.AddColleague(new StubContentControlProvider()); m_window.LoadUI(configFilePath); // set up clerk to allow DictionaryPublicationDecorator to be created during the UploadToWebonaryController driven export const string reversalIndexClerk = @"<?xml version='1.0' encoding='UTF-8'?> <root> <clerks> <clerk id='entries'> <recordList owner='LexDb' property='Entries'/> </clerk> </clerks> <tools> <tool label='Dictionary' value='lexiconDictionary' icon='DocumentView'> <control> <dynamicloaderinfo assemblyPath='xWorks.dll' class='SIL.FieldWorks.XWorks.XhtmlDocView'/> <parameters area='lexicon' clerk='entries' layout='Bartholomew' layoutProperty='DictionaryPublicationLayout' editable='false' configureObjectName='Dictionary'/> </control> </tool> </tools> </root>" ; var doc = new XmlDocument(); doc.LoadXml(reversalIndexClerk); XmlNode clerkNode = doc.SelectSingleNode("//tools/tool[@label='Dictionary']//parameters[@area='lexicon']"); m_Clerk = RecordClerkFactory.CreateClerk(m_mediator, clerkNode, false); m_mediator.PropertyTable.SetProperty("ActiveClerk", m_Clerk); m_mediator.PropertyTable.SetProperty("ToolForAreaNamed_lexicon", "lexiconDictionary"); Cache.ProjectId.Path = Path.Combine(FwDirectoryFinder.SourceDirectory, "xWorks/xWorksTests/TestData/"); // setup style sheet and style to allow the css to generate during the UploadToWebonaryController driven export m_styleSheet = FontHeightAdjuster.StyleSheetFromMediator(m_mediator); m_owningTable = new StyleInfoTable("AbbySomebody", (IWritingSystemManager)Cache.WritingSystemFactory); var fontInfo = new FontInfo(); var letHeadStyle = new TestStyle(fontInfo, Cache) { Name = CssGenerator.LetterHeadingStyleName, IsParagraphStyle = false }; var dictNormStyle = new TestStyle(fontInfo, Cache) { Name = CssGenerator.DictionaryNormal, IsParagraphStyle = true }; m_styleSheet.Styles.Add(letHeadStyle); m_styleSheet.Styles.Add(dictNormStyle); m_owningTable.Add(CssGenerator.LetterHeadingStyleName, letHeadStyle); m_owningTable.Add(CssGenerator.DictionaryNormal, dictNormStyle); }
/// <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; 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); 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) { ReplaceMainWindow(wndActive); } } 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); }
/// <summary> /// Display the import commands only while in the appropriate area. /// </summary> public bool OnDisplayLaunchConnectedDialog(object parameters, ref UIItemDisplayProperties display) { display.Enabled = false; display.Visible = false; XCore.Command command = parameters as XCore.Command; if (command == null) { return(true); } Form formActive = ActiveForm; FwXWindow wndActive = formActive as FwXWindow; if (wndActive == null) { return(true); } Mediator mediator = wndActive.Mediator; if (mediator == null) { return(true); } string area = wndActive.PropTable.GetValue <string>("areaChoice"); bool fEnabled = true; switch (command.Id) { case "CmdImportSFMLexicon": fEnabled = area == "lexicon"; break; case "CmdImportLinguaLinksData": fEnabled = area == "lexicon"; break; case "CmdImportLiftData": fEnabled = area == "lexicon"; break; case "CmdImportInterlinearSfm": case "CmdImportWordsAndGlossesSfm": case "CmdImportInterlinearData": // LT-11998: importing texts in the Concordance tool can crash fEnabled = area == "textsWords" && wndActive.PropTable.GetStringProperty("currentContentControl", null) != "concordance"; break; case "CmdImportSFMNotebook": fEnabled = area == "notebook"; break; default: break; } display.Enabled = fEnabled; display.Visible = fEnabled; return(true); }
void CloseOldWindow(object sender, EventArgs e) { Application.Idle -= CloseOldWindow; if (m_windowToCloseOnIdle != null) { m_windowToCloseOnIdle.Close(); } m_windowToCloseOnIdle = null; }
public bool OnSFMImport(object parameters) { Form formActive = ActiveForm; FwXWindow wndActive = formActive as FwXWindow; var importWizard = new LexImportWizard(); ((IFwExtension)importWizard).Init(Cache, wndActive.Mediator); importWizard.ShowDialog(formActive); return(true); }
/// <summary> /// Call RefreshDisplay for every child control (recursively) which implements it. /// </summary> public void RefreshDisplay(FdoCache cache) { foreach (IFwMainWnd window in m_rgMainWindows) { FwXWindow xwnd = window as FwXWindow; if (xwnd != null && xwnd.Cache == cache) { xwnd.RefreshDisplay(); } } }
protected override void ShowRecord() { //todo: add the document view name to the task label //todo: fast machine, this doesn't really seem to do any good. I think maybe the parts that //are taking a longtime are not getting Breath(). //todo: test on a machine that is slow enough to see if this is helpful or not! using (ProgressState progress = FwXWindow.CreatePredictiveProgressState(m_mediator, this.m_vectorName)) { progress.Breath(); Debug.Assert(m_rootSite != null); progress.Breath(); base.ShowRecord(); Clerk.SaveOnChangeRecord(); progress.Breath(); if (Clerk.CurrentObject == null) { m_rootSite.Hide(); return; } try { progress.SetMilestone(); m_rootSite.Show(); using (new WaitCursor(this)) { IChangeRootObject root = m_rootSite as IChangeRootObject; if (root != null && !Clerk.SuspendLoadingRecordUntilOnJumpToRecord) { root.SetRoot(Clerk.CurrentObject.Hvo); } } } catch (Exception error) { if (m_mediator.PropertyTable.GetBoolProperty("DoingAutomatedTest", false)) { throw; } else //don't really need to make the program stop just because we could not show this record. { IApp app = (IApp)m_mediator.PropertyTable.GetValue("App"); ErrorReporter.ReportException(error, app.SettingsKey, m_mediator.FeedbackInfoProvider.SupportEmailAddress, null, false); } } } }
public void FixtureCleanUp() { m_application.Dispose(); if (m_window != null) { m_window.Dispose(); m_window = null; } m_application = null; FwRegistrySettings.Release(); }
public void HandleIncomingLink(FwLink link) { CheckDisposed(); FwXWindow fwxwnd = null; string server = link.Server.Replace(".", Environment.MachineName); // = FwLink.RestoreServerFromURL(link.Server).Replace(".", Environment.MachineName); Debug.Assert(server != null && server != String.Empty); string database = link.Database; Debug.Assert(database != null && database != String.Empty); string key = MakeKey(server, database); if (!m_caches.ContainsKey(key)) { // Add command line info. Dictionary <string, List <String> > oldTable = m_commandLineArgs; // Save original args. m_commandLineArgs = new Dictionary <string, List <String> >(); List <String> list = new List <String>(); list.Add(server); m_commandLineArgs.Add("c", list); list = new List <String>(); list.Add(database); m_commandLineArgs.Add("db", list); list = new List <String>(); list.Add(link.ToString()); m_commandLineArgs.Add("link", list); Form frm = ActiveForm; fwxwnd = (FwXWindow)NewMainWindow(null, false); AdjustNewWindowPosition(fwxwnd, frm); m_commandLineArgs = oldTable; // Restore oringinal args. } else { FdoCache cache = m_caches[key]; // Get window that uses the given DB. foreach (FwXWindow wnd in m_rgMainWindows) { if (wnd.Cache == cache) { fwxwnd = wnd; break; } } } fwxwnd.Mediator.SendMessage("FollowLink", link); bool topmost = fwxwnd.TopMost; fwxwnd.TopMost = true; fwxwnd.TopMost = topmost; fwxwnd.Activate(); }
public bool OnSFMImport(object parameters) { Form formActive = ActiveForm; FwXWindow wndActive = (FwXWindow)formActive; using (var importWizard = new LexImportWizard()) { ((IFwExtension)importWizard).Init(Cache, wndActive.Mediator, wndActive.PropTable); importWizard.ShowDialog(formActive); } return(true); }
public void FixtureCleanUp() { TearDown(); m_application.Dispose(); if (m_window != null) { m_window.Dispose(); // also disposes mediator m_window = null; } m_application = null; FwRegistrySettings.Release(); }
/// <summary> /// This is the one (and should be only) handler for the user Refresh command. /// Refresh wants to first clean up the cache, then give things like Clerks a /// chance to reload stuff (calling the old OnRefresh methods), then give /// windows a chance to redisplay themselves. /// </summary> public void OnMasterRefresh(object sender) { CheckDisposed(); // Susanna asked that refresh affect only the currently active project, which is // what the string and List variables below attempt to handle. See LT-6444. string sDatabase = null; string sServer = null; FwXWindow activeWnd = ActiveForm as FwXWindow; if (activeWnd != null) { sDatabase = activeWnd.Cache.DatabaseName.ToLowerInvariant(); sServer = activeWnd.Cache.ServerName.ToLowerInvariant(); } List <FwXWindow> rgxw = new List <FwXWindow>(); foreach (IFwMainWnd wnd in MainWindows) { FwXWindow xwnd = wnd as FwXWindow; if (xwnd != null) { if (sDatabase == null || (xwnd.Cache.DatabaseName.ToLowerInvariant() == sDatabase && xwnd.Cache.ServerName.ToLowerInvariant() == sServer)) { xwnd.PrepareToRefresh(); rgxw.Add(xwnd); } } } FwApp.App.ClearAllCaches(sDatabase, sServer); foreach (FwXWindow xwnd in rgxw) { if (activeWnd != xwnd) { xwnd.FinishRefresh(); } } // LT-3963: active window changes as a result of a refresh. // Make sure focus doesn't switch to another FLEx application / window also // make sure the application focus isn't lost all together. // ALSO, after doing a refresh with just a single application / window, // the application would loose focus and you'd have to click into it to // get that back, this will reset that too. if (activeWnd != null) { // Refresh it last, so its saved settings get restored. activeWnd.FinishRefresh(); activeWnd.Activate(); } }
public void OnIncomingLink(FwLink link) { CheckDisposed(); if (m_rgMainWindows.Count == 0) { return; } FwXWindow wnd = m_rgMainWindows[0] as FwXWindow; Debug.Assert(wnd != null); wnd.Invoke(wnd.IncomingLinkHandler, new Object[] { link }); }
protected virtual void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); if (disposing) { m_application?.Dispose(); m_application = null; m_window?.Dispose(); m_window = null; m_mediator?.Dispose(); m_mediator = null; m_propertyTable?.Dispose(); m_propertyTable = null; } }
public TryAWordRootSite(FdoCache cache, XCore.Mediator mediator) { m_fdoCache = cache; m_mediator = mediator; VisibleChanged += new EventHandler(OnVisibleChanged); FwXWindow window = mediator.PropertyTable.GetValue("window") as FwXWindow; if (window != null) { m_styleSheet = window.StyleSheet; } IWritingSystem wsObj = m_fdoCache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(m_fdoCache.DefaultVernWs); RightToLeft = wsObj.RightToLeft ? RightToLeft.Yes : RightToLeft.No; AutoScroll = true; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Handles the incoming link, after the right window of the right application on the right /// project has been activated. /// See the class comment on FwLinkArgs for details on how all the parts of hyperlinking work. /// </summary> /// <param name="link">The link.</param> /// ------------------------------------------------------------------------------------ public override void HandleIncomingLink(FwLinkArgs link) { CheckDisposed(); // Get window that uses the given DB. FwXWindow fwxwnd = m_rgMainWindows.Count > 0 ? (FwXWindow)m_rgMainWindows[0] : null; if (fwxwnd != null) { fwxwnd.Mediator.SendMessage("FollowLink", link); bool topmost = fwxwnd.TopMost; fwxwnd.TopMost = true; fwxwnd.TopMost = topmost; fwxwnd.Activate(); } }
/// <summary> /// This is the one (and should be only) handler for the user Refresh command. /// Refresh wants to first clean up the cache, then give things like Clerks a /// chance to reload stuff (calling the old OnRefresh methods), then give /// windows a chance to redisplay themselves. /// </summary> public void OnMasterRefresh(object sender) { // TODO: This is no longer called by the Mediator, since this class // is no longer an xcore colleague. But, it can't be removed either, // since it is used by another method on this clsss. :-( CheckDisposed(); // Susanna asked that refresh affect only the currently active project, which is // what the string and List variables below attempt to handle. See LT-6444. FwXWindow activeWnd = ActiveForm as FwXWindow; List <FwXWindow> rgxw = new List <FwXWindow>(); foreach (IFwMainWnd wnd in MainWindows) { FwXWindow xwnd = wnd as FwXWindow; if (xwnd != null) { xwnd.PrepareToRefresh(); rgxw.Add(xwnd); } } if (activeWnd != null) { rgxw.Remove(activeWnd); } foreach (FwXWindow xwnd in rgxw) { xwnd.FinishRefresh(); xwnd.Refresh(); } // LT-3963: active window changes as a result of a refresh. // Make sure focus doesn't switch to another FLEx application / window also // make sure the application focus isn't lost all together. // ALSO, after doing a refresh with just a single application / window, // the application would loose focus and you'd have to click into it to // get that back, this will reset that too. if (activeWnd != null) { // Refresh it last, so its saved settings get restored. activeWnd.FinishRefresh(); activeWnd.Refresh(); activeWnd.Activate(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a main FLEx window. /// </summary> /// <param name="progressDlg">The progress DLG.</param> /// <param name="isNewCache">if set to <c>true</c> [is new cache].</param> /// <param name="wndCopyFrom">The WND copy from.</param> /// <param name="fOpeningNewProject">if set to <c>true</c> [f opening new project].</param> /// ------------------------------------------------------------------------------------ public override Form NewMainAppWnd(IProgress progressDlg, bool isNewCache, Form wndCopyFrom, bool fOpeningNewProject) { if (progressDlg != null) { progressDlg.Message = String.Format("Creating window for MockFwXApp {0}", Cache.ProjectId.Name); } Form form = base.NewMainAppWnd(progressDlg, isNewCache, wndCopyFrom, fOpeningNewProject); if (form is FwXWindow) { FwXWindow wnd = (FwXWindow)form; m_activeMainWindow = form; } return(form); }
/// <summary> /// Try to find a WfiWordform object corresponding the the focus selection. /// If successful return its guid, otherwise, return Guid.Empty. /// </summary> /// <returns></returns> internal static Guid ActiveWordform(FdoCache cache) { if (!(FwApp.App is FwXApp)) { return(Guid.Empty); } FwXWindow window = (FwApp.App as FwXApp).ActiveMainWindow as FwXWindow; if (window == null) { return(Guid.Empty); } IRootSite activeView = window.ActiveView; if (activeView == null) { return(Guid.Empty); } List <IVwRootBox> roots = activeView.AllRootBoxes(); if (roots.Count < 1) { return(Guid.Empty); } SelectionHelper helper = SelectionHelper.Create(roots[0].Site); if (helper == null) { return(Guid.Empty); } ITsString word = helper.SelectedWord; if (word == null || word.Length == 0) { return(Guid.Empty); } int hvoWordform = cache.LangProject.WordformInventoryOA.GetWordformId(word); if (hvoWordform == 0 || cache.IsDummyObject(hvoWordform)) { return(Guid.Empty); } return(cache.GetGuidFromId(hvoWordform)); }
/// <summary> /// This implements the "Synchronize with LiftShare..." menu command. /// </summary> /// <param name="sender"></param> /// <returns></returns> /// <remarks>Until LiftShare is fully implemented, this is irrelevant.</remarks> public bool OnSynchronize(object sender) { #if WANTPORT // FWR-2845; this was not enabled in 6.0 and may be superseded by Randy's LiftBridge. Form formActive = ActiveForm; if (cache != null) { FwXWindow wndActive = formActive as FwXWindow; LiftSynchronizeDlg dlg = new LiftSynchronizeDlg(Cache, wndActive.Mediator); dlg.ShowDialog(formActive); return(true); } else { return(false); } #else return(false); #endif }
public bool OnRestoreDefaultLayouts(object commandObject) { CheckDisposed(); Form formActive = ActiveForm; FwXWindow wndActive = formActive as FwXWindow; if (wndActive != null) { bool fRestore; using (RestoreDefaultsDlg dlg = new RestoreDefaultsDlg(this)) fRestore = (dlg.ShowDialog(formActive) == DialogResult.Yes); if (fRestore) { InitializePartInventories(null, false); ReplaceMainWindow(wndActive); } } return(true); }
public override void FixtureSetup() { base.FixtureSetup(); FwRegistrySettings.Init(); m_application = new MockFwXApp(new MockFwManager { Cache = Cache }, null, null); var m_configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname); m_window = new MockFwXWindow(m_application, m_configFilePath); ((MockFwXWindow)m_window).Init(Cache); // initializes Mediator values m_mediator = m_window.Mediator; // Set up the mediator to look as if we are working in the Reversal Index area m_mediator.PropertyTable.SetProperty("ToolForAreaNamed_lexicon", "reversalEditComplete"); Cache.ProjectId.Path = Path.Combine(FwDirectoryFinder.SourceDirectory, "xWorks/xWorksTests/TestData/"); m_wsEn = Cache.WritingSystemFactory.GetWsFromStr("en"); m_wsFr = Cache.WritingSystemFactory.GetWsFromStr("fr"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates a new instance of the main X window /// </summary> /// <param name="progressDlg">The progress dialog to use, if needed (can be null).</param> /// <param name="isNewCache">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></returns> /// ------------------------------------------------------------------------------------ public override Form NewMainAppWnd(IProgress progressDlg, bool isNewCache, Form wndCopyFrom, bool fOpeningNewProject) { if (isNewCache) { // TODO: Do any needed initialization here. } Stream iconStream = ApplicationIconStream; Debug.Assert(iconStream != null, "Couldn't find the specified application icon as a resource."); string configFile; if (m_appArgs.ConfigFile != string.Empty) { configFile = m_appArgs.ConfigFile; } else { configFile = DirectoryFinder.GetFWCodeFile(DefaultConfigurationPathname); // configFile = (string)SettingsKey.GetValue("LatestConfigurationFile", // Path.Combine(DirectoryFinder.FWCodeDirectory, // DefaultConfigurationPathname)); if (!File.Exists(configFile)) { configFile = null; } } if (configFile == null) // try to load from stream { return(new FwXWindow(this, wndCopyFrom, iconStream, ConfigurationStream)); } // We pass a copy of the link information because it doesn't get used until after the following line // removes the information we need. FwXWindow result = new FwXWindow(this, wndCopyFrom, iconStream, configFile, m_appArgs.HasLinkInformation ? m_appArgs.CopyLinkArgs() : null, false); m_appArgs.ClearLinkInformation(); // Make sure the next window that is opened doesn't default to the same place return(result); }
/// <summary> /// Parse (if necessary...ParseIsCurrent will be checked to see) the texts we want in the concordance. /// </summary> private void ParseInterestingTexts() { // Also it should be forced to be empty if FwUtils.IsTEInstalled returns false. IEnumerable <IStText> scriptureTexts = Cache.LangProject.TranslatedScriptureOA == null ? new IStText[0] : from aText in Cache.LangProject.TranslatedScriptureOA.StTexts where IsInterestingScripture(aText) select aText; // Enhance JohnT: might eventually want to be more selective here, perhaps a genre filter. IEnumerable <IStText> vernacularTexts = from st in Cache.LangProject.Texts select st.ContentsOA; // Filtered list that excludes IScrBookAnnotations. var texts = vernacularTexts.Concat(scriptureTexts).Where(x => x != null).ToList(); int count = (from text in texts from para in text.ParagraphsOS select para).Count(); int done = 0; using (var progress = FwXWindow.CreateSimpleProgressState(m_mediator)) { progress.SetMilestone(ITextStrings.ksParsing); foreach (var text in texts) { foreach (IStTxtPara para in text.ParagraphsOS) { done++; int newPercentDone = done * 100 / count; if (newPercentDone != progress.PercentDone) { progress.PercentDone = newPercentDone; progress.Breath(); } if (para.ParseIsCurrent) { continue; } ParagraphParser.ParseParagraph(para); } } } }
/* * public bool OnImportSFMLexicon(object sender) * { * CheckDisposed(); * * FdoCache cache = null; * Form formActive = ActiveForm; * foreach (FwXWindow wnd in m_rgMainWindows) * { * if ((object)wnd == (object)formActive) * { * cache = wnd.Cache; * break; * } * } * * if (cache != null) * { * FwXWindow wndActive = formActive as FwXWindow; * //SIL.FieldWorks.LexText.Controls.ImportLexiconDlg dlg = * // new SIL.FieldWorks.LexText.Controls.ImportLexiconDlg(cache, "", ""); * SIL.FieldWorks.LexText.Controls.LexImportWizard dlg = * new SIL.FieldWorks.LexText.Controls.LexImportWizard(cache, wndActive.Mediator ); * if(dlg.ShowDialog(ActiveForm) == DialogResult.OK) * * { * // Make everything we've imported visible. Note that this needs to happen regardless of what the return value of ShowDialog is. * // An exception during processing may cause the result to not be OK, but entries will still have been added. * wndActive.Mediator.BroadcastMessage("MasterRefresh", null); * } * } * return true; * } * * /// <summary> * /// Launch a dialog that will allow the user to import LinguaLinks data. * /// </summary> * /// <param name="sender"></param> * /// <returns>true, to indicate it was handled here.</returns> * public bool OnImportLinguaLinksData(object sender) * { * FdoCache cache = null; * Form formActive = ActiveForm; * foreach (FwXWindow wnd in m_rgMainWindows) * { * if ((object)wnd == (object)formActive) * { * cache = wnd.Cache; * break; * } * } * if (cache != null) * { * FwXWindow wndActive = formActive as FwXWindow; * using (LinguaLinksImportDlg dlg = * new LinguaLinksImportDlg(cache, wndActive.Mediator)) * { * if (dlg.ShowDialog(ActiveForm) == DialogResult.OK) * { * // Make everything we've imported visible. * wndActive.Mediator.SendMessage("MasterRefresh", wndActive); * } * * } * } * return true; * } */ public bool OnRestoreDefaultLayouts(object commandObject) { CheckDisposed(); Form formActive = ActiveForm; FdoCache cache = GetActiveCache(formActive); FwXWindow wndActive = formActive as FwXWindow; if (cache != null && wndActive != null) { bool fRestore = false; using (RestoreDefaultsDlg dlg = new RestoreDefaultsDlg()) { fRestore = (dlg.ShowDialog(formActive) == DialogResult.Yes); } if (fRestore) { InitializePartInventories(cache, false); wndActive.Mediator.BroadcastMessage("MasterRefresh", wndActive); } } return(true); }
public bool OnConfigureHomographs(object commandObject) { CheckDisposed(); var configDlg = commandObject as XmlDocConfigureDlg; Form formActive = ActiveForm; FwXWindow wndActive = formActive as FwXWindow; if (wndActive == null && configDlg != null) { wndActive = configDlg.Owner as FwXWindow; } if (wndActive != null) { var hc = wndActive.Cache.ServiceLocator.GetInstance <HomographConfiguration>(); using (var dlg = new ConfigureHomographDlg()) { dlg.SetupDialog(hc, wndActive.Cache, wndActive.ActiveStyleSheet, this, this); dlg.StartPosition = FormStartPosition.CenterScreen; if (dlg.ShowDialog(wndActive) != DialogResult.OK) { return(true); } dlg.GetResults(hc); // If called from config dlg, it will do its own refresh when it closes. if (configDlg == null) { OnMasterRefresh(null); } else { configDlg.MasterRefreshRequired = true; } } } return(true); }
public virtual void FixtureInit() { TestManager.ApproveFixture("WW", "UI"); //TestManager.ApproveFixture ("WW", "5Min"); Init(); //FwXApp app = MakeApplication(); string configPath = System.IO.Path.Combine(SIL.FieldWorks.Common.Utils.DirectoryFinder.FWCodeDirectory, m_application.DefaultConfigurationPathname); FwApp.App = m_application; //review: this seems weird to me (JH); one would think that the application would deliver the window //instead, here, we are passing the application to the new window. m_window = new FwXWindow(LoadCache("TestLangProj"), null, null, configPath, true); // (FwXApp)app.MockInstance); /* note that someday, when we write a test to test the persistence function, * set "TestRestoringFromTestSettings" the second time the application has run in order to pick up * the settings from the first run. The code for this is already in xWindow. */ m_window.Show(); Application.DoEvents(); //without this, tests may fail non-deterministically }