diff --git a/HeliosPlus/Program.cs b/HeliosPlus/Program.cs index 4ef58d9..6d60d12 100644 --- a/HeliosPlus/Program.cs +++ b/HeliosPlus/Program.cs @@ -301,9 +301,6 @@ namespace HeliosPlus { // ApplyProfile lives here so that the UI works. public static bool ApplyProfile(ProfileItem profile) { - // If we're already on the wanted profile then no need to change! - if (ProfileRepository.IsActiveProfile(profile)) - return true; // We need to check if the profile is valid if (!profile.IsPossible) @@ -384,11 +381,13 @@ namespace HeliosPlus { if (applyTopologyTask.IsFaulted) Console.WriteLine("Program/ApplyProfile : Applying Profile Topology stage failed to complete"); + + if (!applyTopologyTask.IsCompleted) + return false; } // We always want to do the WindowsDisplayAPI PathInfo part pathInfoForm.ShowDialog(); - applyPathInfoTask.Wait(); try { applyPathInfoTask.Wait(); @@ -413,9 +412,7 @@ namespace HeliosPlus { if (applyPathInfoTask.IsFaulted) Console.WriteLine("Program/ApplyProfile : Applying Profile PathInfo stage failed to complete"); - if (applyTopologyTask.IsCompleted && applyPathInfoTask.IsCompleted) - return true; - else + if (!applyPathInfoTask.IsCompleted) return false; } @@ -424,6 +421,8 @@ namespace HeliosPlus { Console.WriteLine($"ProfileRepository/ApplyTopology exception: {ex.Message}: {ex.StackTrace} - {ex.InnerException}"); return false; } + + return true; } public static bool LoadGamesInBackground() diff --git a/HeliosPlus/ShortcutRepository.cs b/HeliosPlus/ShortcutRepository.cs index 25ba8fc..c8dbfd7 100644 --- a/HeliosPlus/ShortcutRepository.cs +++ b/HeliosPlus/ShortcutRepository.cs @@ -484,7 +484,6 @@ namespace HeliosPlus if (needToChangeProfiles) { // Apply the Profile! - //if (!ProfileRepository.ApplyProfile(shortcutToUse.ProfileToUse)) if (!Program.ApplyProfile(shortcutToUse.ProfileToUse)) { throw new Exception(Language.Cannot_change_active_profile); diff --git a/HeliosPlus/UIForms/ApplyingProfileForm.cs b/HeliosPlus/UIForms/ApplyingProfileForm.cs index f9419bd..04c86ce 100644 --- a/HeliosPlus/UIForms/ApplyingProfileForm.cs +++ b/HeliosPlus/UIForms/ApplyingProfileForm.cs @@ -139,7 +139,9 @@ namespace HeliosPlus.UIForms { lock (_progressPositions) { - + // Screen.Allscreens is a static variable and won't be updated while the program is running. + // SO we use reflection to wipe the value and force it to be updated afresh. + typeof(Screen).GetField("screens", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(null, null); Screen[] screens = Screen.AllScreens; Size = screens.Select(screen => screen.Bounds) .Aggregate(Rectangle.Union)