/// <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(); } }
/// <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(); } }