From 613283da41543dd6367529ba2b7fee28fbe24c4c Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Sun, 31 Oct 2021 10:00:57 +1300 Subject: [PATCH] Temporarily force DisplayMagician to wait for games to load This is a test to see if this fixes the missing Steam games in large Steam libraries issue (#49). --- DisplayMagician/Program.cs | 30 +++++++++-------- DisplayMagician/ShortcutRepository.cs | 1 + DisplayMagician/UIForms/LoadingForm.cs | 1 + displaymagician/uiforms/displayprofileform.cs | 32 +++++++++++++++---- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/DisplayMagician/Program.cs b/DisplayMagician/Program.cs index ae7362e..eac76c5 100644 --- a/DisplayMagician/Program.cs +++ b/DisplayMagician/Program.cs @@ -317,7 +317,8 @@ namespace DisplayMagician { app.Command(DisplayMagicianStartupAction.RunShortcut.ToString(), (runShortcutCmd) => { // Try to load all the games in parallel to this process - Task.Run(() => LoadGamesInBackground()); + //Task.Run(() => LoadGamesInBackground()); + LoadGamesInBackground(); // Set the --trace or --debug options if supplied if (trace.HasValue()) @@ -591,16 +592,17 @@ namespace DisplayMagician { } } logger.Info("Starting Normally..."); - + // Try to load all the games in parallel to this process - Task.Run(() => LoadGamesInBackground()); + //Task.Run(() => LoadGamesInBackground()); + logger.Debug($"Try to load all the Games in the background to avoid locking the UI"); + LoadGamesInBackground(); StartUpApplication(); return 0; }); - logger.Debug($"Try to load all the Games in the background to avoid locking the UI"); - + if (AppProgramSettings.ShowSplashScreen) { //Show Splash Form @@ -609,7 +611,6 @@ namespace DisplayMagician { () => Application.Run(AppSplashScreen))); splashThread.SetApartmentState(ApartmentState.STA); splashThread.Start(); - } try @@ -662,6 +663,7 @@ namespace DisplayMagician { IPCService.GetInstance().Status = InstanceStatus.User; + // Close the splash screen if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed) AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close())); @@ -735,7 +737,7 @@ namespace DisplayMagician { // Run the program with normal startup AppMainForm = new MainForm(); - //AppMainForm.Load += MainForm_LoadCompleted; + AppMainForm.Load += MainForm_LoadCompleted; Application.Run(AppMainForm); } @@ -768,6 +770,10 @@ namespace DisplayMagician { ShortcutItem shortcutToRun = null; + // Close the splash screen + if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed) + AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close())); + // Check there is only one version of this application so we won't // mess with another monitoring session if ( @@ -795,9 +801,6 @@ namespace DisplayMagician { throw new Exception(Language.Cannot_find_shortcut_in_library); } - if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed) - AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close())); - if (shortcutToRun is ShortcutItem) { ShortcutRepository.RunShortcut(shortcutToRun); @@ -821,13 +824,14 @@ namespace DisplayMagician { { logger.Trace($"Program/RunProfile: Starting"); + // Close the splash screen + if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed) + AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close())); + // Lookup the profile ProfileItem profileToUse = ProfileRepository.AllProfiles.Where(p => p.UUID.Equals(profileName)).First(); logger.Trace($"Program/RunProfile: Found profile called {profileName} and now starting to apply the profile"); - if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed) - AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close())); - ProfileRepository.ApplyProfile(profileToUse); } diff --git a/DisplayMagician/ShortcutRepository.cs b/DisplayMagician/ShortcutRepository.cs index 0c18f3c..f87fceb 100644 --- a/DisplayMagician/ShortcutRepository.cs +++ b/DisplayMagician/ShortcutRepository.cs @@ -629,6 +629,7 @@ namespace DisplayMagician @"Cannot run the Shortcut", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + return; } diff --git a/DisplayMagician/UIForms/LoadingForm.cs b/DisplayMagician/UIForms/LoadingForm.cs index f371717..a67e226 100644 --- a/DisplayMagician/UIForms/LoadingForm.cs +++ b/DisplayMagician/UIForms/LoadingForm.cs @@ -15,6 +15,7 @@ namespace DisplayMagician.UIForms public LoadingForm() { InitializeComponent(); + this.TopMost = false; } } } diff --git a/displaymagician/uiforms/displayprofileform.cs b/displaymagician/uiforms/displayprofileform.cs index 2d64d8b..b828068 100644 --- a/displaymagician/uiforms/displayprofileform.cs +++ b/displaymagician/uiforms/displayprofileform.cs @@ -69,6 +69,12 @@ namespace DisplayMagician.UIForms { logger.Warn($"DisplayProfileForm/Apply_Click: Error applying the Profile {_selectedProfile.Name}. Unable to change the display layout."); } + + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } } @@ -124,6 +130,12 @@ namespace DisplayMagician.UIForms } + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } + } private void Save_Click(object sender, EventArgs e) @@ -178,6 +190,7 @@ namespace DisplayMagician.UIForms { MessageBox.Show(ex.Message, Language.Shortcut, MessageBoxButtons.OK, MessageBoxIcon.Warning); } + } } @@ -223,13 +236,6 @@ namespace DisplayMagician.UIForms } - // Also refresh the right-click menu (if we have a main form loaded) - if (Program.AppMainForm is Form) - { - Program.AppMainForm.RefreshNotifyIconMenus(); - } - - // Restart updating the saved_profiles listview ilv_saved_profiles.ResumeLayout(); } @@ -332,6 +338,12 @@ namespace DisplayMagician.UIForms // Refresh the image list view //RefreshImageListView(profile); + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } + // And finally refresh the profile in the display view dv_profile.Profile = profile; dv_profile.Refresh(); @@ -432,6 +444,12 @@ namespace DisplayMagician.UIForms // now update the profiles image listview RefreshDisplayProfileUI(); + // Also refresh the right-click menu (if we have a main form loaded) + if (Program.AppMainForm is Form) + { + Program.AppMainForm.RefreshNotifyIconMenus(); + } + } private void ilv_saved_profiles_ItemClick(object sender, ItemClickEventArgs e)