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).
This commit is contained in:
Terry MacDonald 2021-10-31 10:00:57 +13:00
parent 340e1a6db0
commit 613283da41
4 changed files with 44 additions and 20 deletions

View File

@ -317,7 +317,8 @@ namespace DisplayMagician {
app.Command(DisplayMagicianStartupAction.RunShortcut.ToString(), (runShortcutCmd) => app.Command(DisplayMagicianStartupAction.RunShortcut.ToString(), (runShortcutCmd) =>
{ {
// Try to load all the games in parallel to this process // 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 // Set the --trace or --debug options if supplied
if (trace.HasValue()) if (trace.HasValue())
@ -591,16 +592,17 @@ namespace DisplayMagician {
} }
} }
logger.Info("Starting Normally..."); logger.Info("Starting Normally...");
// Try to load all the games in parallel to this process // 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(); StartUpApplication();
return 0; return 0;
}); });
logger.Debug($"Try to load all the Games in the background to avoid locking the UI");
if (AppProgramSettings.ShowSplashScreen) if (AppProgramSettings.ShowSplashScreen)
{ {
//Show Splash Form //Show Splash Form
@ -609,7 +611,6 @@ namespace DisplayMagician {
() => Application.Run(AppSplashScreen))); () => Application.Run(AppSplashScreen)));
splashThread.SetApartmentState(ApartmentState.STA); splashThread.SetApartmentState(ApartmentState.STA);
splashThread.Start(); splashThread.Start();
} }
try try
@ -662,6 +663,7 @@ namespace DisplayMagician {
IPCService.GetInstance().Status = InstanceStatus.User; IPCService.GetInstance().Status = InstanceStatus.User;
// Close the splash screen
if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed) if (ProgramSettings.LoadSettings().ShowSplashScreen && AppSplashScreen != null && !AppSplashScreen.Disposing && !AppSplashScreen.IsDisposed)
AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close())); AppSplashScreen.Invoke(new Action(() => AppSplashScreen.Close()));
@ -735,7 +737,7 @@ namespace DisplayMagician {
// Run the program with normal startup // Run the program with normal startup
AppMainForm = new MainForm(); AppMainForm = new MainForm();
//AppMainForm.Load += MainForm_LoadCompleted; AppMainForm.Load += MainForm_LoadCompleted;
Application.Run(AppMainForm); Application.Run(AppMainForm);
} }
@ -768,6 +770,10 @@ namespace DisplayMagician {
ShortcutItem shortcutToRun = null; 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 // Check there is only one version of this application so we won't
// mess with another monitoring session // mess with another monitoring session
if ( if (
@ -795,9 +801,6 @@ namespace DisplayMagician {
throw new Exception(Language.Cannot_find_shortcut_in_library); 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) if (shortcutToRun is ShortcutItem)
{ {
ShortcutRepository.RunShortcut(shortcutToRun); ShortcutRepository.RunShortcut(shortcutToRun);
@ -821,13 +824,14 @@ namespace DisplayMagician {
{ {
logger.Trace($"Program/RunProfile: Starting"); 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 // Lookup the profile
ProfileItem profileToUse = ProfileRepository.AllProfiles.Where(p => p.UUID.Equals(profileName)).First(); 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"); 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); ProfileRepository.ApplyProfile(profileToUse);
} }

View File

@ -629,6 +629,7 @@ namespace DisplayMagician
@"Cannot run the Shortcut", @"Cannot run the Shortcut",
MessageBoxButtons.OK, MessageBoxButtons.OK,
MessageBoxIcon.Exclamation); MessageBoxIcon.Exclamation);
return; return;
} }

View File

@ -15,6 +15,7 @@ namespace DisplayMagician.UIForms
public LoadingForm() public LoadingForm()
{ {
InitializeComponent(); InitializeComponent();
this.TopMost = false;
} }
} }
} }

View File

@ -69,6 +69,12 @@ namespace DisplayMagician.UIForms
{ {
logger.Warn($"DisplayProfileForm/Apply_Click: Error applying the Profile {_selectedProfile.Name}. Unable to change the display layout."); 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) 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); 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 // Restart updating the saved_profiles listview
ilv_saved_profiles.ResumeLayout(); ilv_saved_profiles.ResumeLayout();
} }
@ -332,6 +338,12 @@ namespace DisplayMagician.UIForms
// Refresh the image list view // Refresh the image list view
//RefreshImageListView(profile); //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 // And finally refresh the profile in the display view
dv_profile.Profile = profile; dv_profile.Profile = profile;
dv_profile.Refresh(); dv_profile.Refresh();
@ -432,6 +444,12 @@ namespace DisplayMagician.UIForms
// now update the profiles image listview // now update the profiles image listview
RefreshDisplayProfileUI(); 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) private void ilv_saved_profiles_ItemClick(object sender, ItemClickEventArgs e)