From fef3dbf1e0adecb81f1dbd62f40c058224ccd670 Mon Sep 17 00:00:00 2001 From: Terry MacDonald Date: Tue, 7 Sep 2021 22:08:54 +1200 Subject: [PATCH] Part 2 of the move to a single ProfileItem Mostly works now! Only bit still needing work is the Avtive profile detection to detect the non-surround profile when we return from surround. I think it's to do with the windows display number changing :(. I need to check that. --- DisplayMagician/UIForms/DisplayProfileForm.cs | 2 +- DisplayMagicianShared/ProfileItem.cs | 11 ++++-- DisplayMagicianShared/ProfileRepository.cs | 39 +++---------------- 3 files changed, 14 insertions(+), 38 deletions(-) diff --git a/DisplayMagician/UIForms/DisplayProfileForm.cs b/DisplayMagician/UIForms/DisplayProfileForm.cs index 4792983..f5cd025 100644 --- a/DisplayMagician/UIForms/DisplayProfileForm.cs +++ b/DisplayMagician/UIForms/DisplayProfileForm.cs @@ -202,7 +202,7 @@ namespace DisplayMagician.UIForms // if the item was removed from the list during this // list refresh, then we select this profile only if it // is the currently used Profile - if (ProfileRepository.IsActiveProfile(_selectedProfile)) + if (profile.Equals(_selectedProfile)) newItem.Selected = true; // Add it to the list! diff --git a/DisplayMagicianShared/ProfileItem.cs b/DisplayMagicianShared/ProfileItem.cs index 00bba14..eff3deb 100644 --- a/DisplayMagicianShared/ProfileItem.cs +++ b/DisplayMagicianShared/ProfileItem.cs @@ -522,10 +522,13 @@ namespace DisplayMagicianShared } } - public virtual bool PerformPostLoadingTasks() + /*public bool PerformPostLoadingTasks() { - return false; - } + // First thing we do is to set up the Screens + //_screens = GetScreenPositions(); + + return true; + }*/ // ReSharper disable once FunctionComplexityOverflow @@ -1474,7 +1477,6 @@ namespace DisplayMagicianShared // Check the object fields // ProfileDisplayIdentifiers may be the same but in different order within the array, so we need to handle // that fact. - int ourMatchedIds = 0; return NVIDIADisplayConfig.Equals(other.NVIDIADisplayConfig) && //AMDDisplayConfig.Equals(other.AMDDisplayConfig) && WindowsDisplayConfig.Equals(other.WindowsDisplayConfig) && @@ -1489,6 +1491,7 @@ namespace DisplayMagicianShared if (ReferenceEquals(this, obj)) return true; // If different types then can't be true if (obj.GetType() == this.GetType()) return false; + if (!(obj is ProfileItem)) return false; // Check the object fields as this must the same object as obj, and we need to test in more detail return Equals((ProfileItem) obj); } diff --git a/DisplayMagicianShared/ProfileRepository.cs b/DisplayMagicianShared/ProfileRepository.cs index 1601da3..2ec1e54 100644 --- a/DisplayMagicianShared/ProfileRepository.cs +++ b/DisplayMagicianShared/ProfileRepository.cs @@ -706,41 +706,14 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Finding the current profile in the Profile Repository"); - /*// Go through all the profiles and set up the needed structures (such as the Screens list) + // Go through all the profiles and set up the needed structures (such as the Screens list) // and check if the current profile is used - foreach (ProfileItem loadedProfile in _allProfiles) + /*foreach (ProfileItem loadedProfile in _allProfiles) { - if (loadedProfile.VideoMode == VIDEO_MODE.NVIDIA) - { - // NVIDIA config! - SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Profile {loadedProfile.Name} is a NVIDIA Profile"); - NVIDIAProfileItem nvidiaLoadedProfile = (NVIDIAProfileItem)loadedProfile; - nvidiaLoadedProfile.PerformPostLoadingTasks(); - if (ProfileRepository.IsActiveProfile(nvidiaLoadedProfile)) - _currentProfile = nvidiaLoadedProfile; - } - else if (loadedProfile is AMDProfileItem) - { - // AMD config! - SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Profile {loadedProfile.Name} is an AMD Profile"); - AMDProfileItem amdLoadedProfile = (AMDProfileItem) loadedProfile; - amdLoadedProfile.PerformPostLoadingTasks(); - if (ProfileRepository.IsActiveProfile(amdLoadedProfile)) - _currentProfile = amdLoadedProfile; - } - else if (loadedProfile is WinProfileItem) - { - // Windows CCD config! - SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Profile {loadedProfile.Name} is a Windows Profile"); - WinProfileItem winLoadedProfile = (WinProfileItem)loadedProfile; - winLoadedProfile.PerformPostLoadingTasks(); - if (ProfileRepository.IsActiveProfile(winLoadedProfile)) - _currentProfile = winLoadedProfile; - } - else - { - SharedLogger.logger.Error($"ProfileRepository/LoadProfiles: ERROR - Profile {loadedProfile.Name} is not a recognised profile!"); - } + SharedLogger.logger.Debug($"ProfileRepository/LoadProfiles: Profile {loadedProfile.Name} is a NVIDIA Profile"); + loadedProfile.PerformPostLoadingTasks(); + *//*if (ProfileRepository.IsActiveProfile(loadedProfile)) + _currentProfile = loadedProfile;*//* }*/ // Sort the profiles alphabetically