diff --git a/DisplayMagicianShared/AMD/AMDProfileItem.cs b/DisplayMagicianShared/AMD/AMDProfileItem.cs index 439b6d4..367dba1 100644 --- a/DisplayMagicianShared/AMD/AMDProfileItem.cs +++ b/DisplayMagicianShared/AMD/AMDProfileItem.cs @@ -111,69 +111,6 @@ namespace DisplayMagicianShared.AMD } } - /*[JsonRequired] - public override List Screens - { - get - { - if (_screens.Count == 0) - { - _screens = GetScreenPositions(); - } - return _screens; - } - set - { - _screens = value; - } - } - - - - [JsonConverter(typeof(CustomBitmapConverter))] - public override Bitmap ProfileBitmap - { - get - { - *//*if (!ProfileRepository.ProfilesLoaded) - return null;*//* - - if (_profileBitmap != null) - return _profileBitmap; - else - { - _profileBitmap = this.ProfileIcon.ToBitmap(256, 256); - return _profileBitmap; - } - } - set - { - _profileBitmap = value; - } - - } - - - [JsonConverter(typeof(CustomBitmapConverter))] - public override Bitmap ProfileTightestBitmap - { - get - { - if (_profileShortcutBitmap != null) - return _profileShortcutBitmap; - else - { - _profileShortcutBitmap = this.ProfileIcon.ToTightestBitmap(); - return _profileShortcutBitmap; - } - } - set - { - _profileShortcutBitmap = value; - } - - } */ - #endregion public override bool IsValid() diff --git a/DisplayMagicianShared/NVIDIA/NVIDIAProfileItem.cs b/DisplayMagicianShared/NVIDIA/NVIDIAProfileItem.cs index f5e7b6a..b9e31e9 100644 --- a/DisplayMagicianShared/NVIDIA/NVIDIAProfileItem.cs +++ b/DisplayMagicianShared/NVIDIA/NVIDIAProfileItem.cs @@ -94,27 +94,6 @@ namespace DisplayMagicianShared.NVIDIA } } - - /*[JsonIgnore] - public override ProfileIcon ProfileIcon - { - get - { - if (_profileIcon != null) - return _profileIcon; - else - { - _profileIcon = new ProfileIcon(this); - return _profileIcon; - } - } - set - { - _profileIcon = value; - } - - }*/ - public override List ProfileDisplayIdentifiers { get @@ -132,64 +111,6 @@ namespace DisplayMagicianShared.NVIDIA } } - /*[JsonRequired] - public override List Screens - { - get - { - if (_screens.Count == 0) - { - _screens = GetScreenPositions(); - } - return _screens; - } - set - { - _screens = value; - } - } - - - [JsonConverter(typeof(CustomBitmapConverter))] - public override Bitmap ProfileBitmap - { - get - { - if (_profileBitmap != null) - return _profileBitmap; - else - { - _profileBitmap = this.ProfileIcon.ToBitmap(256, 256); - return _profileBitmap; - } - } - set - { - _profileBitmap = value; - } - - } - - [JsonConverter(typeof(CustomBitmapConverter))] - public override Bitmap ProfileTightestBitmap - { - get - { - if (_profileShortcutBitmap != null) - return _profileShortcutBitmap; - else - { - _profileShortcutBitmap = this.ProfileIcon.ToTightestBitmap(); - return _profileShortcutBitmap; - } - } - set - { - _profileShortcutBitmap = value; - } - - }*/ - #endregion public override bool IsValid() diff --git a/DisplayMagicianShared/ProfileItem.cs b/DisplayMagicianShared/ProfileItem.cs index caae129..69e3346 100644 --- a/DisplayMagicianShared/ProfileItem.cs +++ b/DisplayMagicianShared/ProfileItem.cs @@ -368,7 +368,7 @@ namespace DisplayMagicianShared } - // The public override for the Object.Equals + /* // The public override for the Object.Equals public override bool Equals(object obj) { return this.Equals(obj as ProfileItem); @@ -432,7 +432,7 @@ namespace DisplayMagicianShared int foundPathsCount = 0; int foundOtherPathsCount = 0; - /*foreach (Topology.Path profilePath in Paths) + *//*foreach (Topology.Path profilePath in Paths) { if (other.Paths.Contains(profilePath)) { @@ -448,14 +448,14 @@ namespace DisplayMagicianShared foundOtherPathsCount++; continue; } - }*/ + }*//* if (foundPathsCount == foundOtherPathsCount) return true; else return false; - } + }*/ // If Equals() returns true for this object compared to another // then GetHashCode() must return the same value for these objects. @@ -609,12 +609,12 @@ namespace DisplayMagicianShared } } - // Custom Equality comparer for the Profile class + /*// Custom Equality comparer for the Profile class // Allows us to use 'Contains' class ProfileComparer : IEqualityComparer { // Products are equal if their names and product numbers are equal. - /*public bool Equals(ProfileItem x, ProfileItem y) + *//*public bool Equals(ProfileItem x, ProfileItem y) { //Check whether the compared objects reference the same data. @@ -632,7 +632,7 @@ namespace DisplayMagicianShared return true; else return false; - }*/ + }*//* public bool Equals(ProfileItem x, ProfileItem y) { @@ -681,7 +681,7 @@ namespace DisplayMagicianShared // Two profiles are equal only when they have the same viewport data int foundPathsCount = 0; int foundOtherPathsCount = 0; - /*foreach (Topology.Path profilePath in x.Paths) + *//*foreach (Topology.Path profilePath in x.Paths) { if (y.Paths.Contains(profilePath)) { @@ -697,7 +697,7 @@ namespace DisplayMagicianShared foundOtherPathsCount++; continue; } - }*/ + }*//* if (foundPathsCount == foundOtherPathsCount) @@ -708,7 +708,7 @@ namespace DisplayMagicianShared // If Equals() returns true for a pair of objects // then GetHashCode() must return the same value for these objects. - /*public int GetHashCode(ProfileItem profile) + *//*public int GetHashCode(ProfileItem profile) { // Check whether the object is null @@ -720,7 +720,7 @@ namespace DisplayMagicianShared //Calculate the hash code for the product. return hashPaths; - }*/ + }*//* // Modified the GetHashCode to compare the displayidentifier public int GetHashCode(ProfileItem profile) { @@ -739,5 +739,5 @@ namespace DisplayMagicianShared return (hashIds,hashPaths).GetHashCode(); } - } + }*/ } \ No newline at end of file diff --git a/DisplayMagicianShared/ProfileRepository.cs b/DisplayMagicianShared/ProfileRepository.cs index d76159b..fcee3cb 100644 --- a/DisplayMagicianShared/ProfileRepository.cs +++ b/DisplayMagicianShared/ProfileRepository.cs @@ -88,7 +88,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Warn(ex, $"ProfileRepository/ProfileRepository: Initialising AMD ADL caused an exception."); } } - + try { // Create the Profile Storage Path if it doesn't exist so that it's avilable for all the program @@ -149,7 +149,7 @@ namespace DisplayMagicianShared public static ProfileItem CurrentProfile { - get + get { if (_currentProfile == null) UpdateActiveProfile(); @@ -183,7 +183,7 @@ namespace DisplayMagicianShared public static VIDEO_MODE CurrentVideoMode { get - { + { return _currentVideoMode; } set @@ -192,7 +192,7 @@ namespace DisplayMagicianShared } } - + public static List ConnectedDisplayIdentifiers { get @@ -211,15 +211,15 @@ namespace DisplayMagicianShared } - public static bool ProfilesLoaded { - get + public static bool ProfilesLoaded { + get { return _profilesLoaded; - } - set + } + set { _profilesLoaded = value; - } + } } #endregion @@ -314,7 +314,7 @@ namespace DisplayMagicianShared public static bool RemoveProfile(string profileName) { - + if (String.IsNullOrWhiteSpace(profileName)) return false; @@ -403,7 +403,7 @@ namespace DisplayMagicianShared SaveProfiles(); IsPossibleRefresh(); return true; - } + } else if (numRemoved == 0) return false; else @@ -425,7 +425,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/ContainsProfile: Our profile repository does contain a profile called {Profile.Name}"); return true; } - + } SharedLogger.logger.Debug($"ProfileRepository/ContainsProfile: Our profile repository doesn't contain a profile called {Profile.Name}"); return false; @@ -446,7 +446,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/ContainsProfile2: Our profile repository does contain a profile with UUID {ProfileNameOrId}"); return true; } - + } else foreach (ProfileItem testProfile in _allProfiles) @@ -456,7 +456,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/ContainsProfile2: Our profile repository does contain a profile with Name {ProfileNameOrId}"); return true; } - + } SharedLogger.logger.Debug($"ProfileRepository/ContainsProfile2: Our profile repository doesn't contain a profile with a UUID or Name {ProfileNameOrId}"); @@ -479,7 +479,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/ContainsCurrentProfile: Our profile repository does contain the display profile currently in use"); return true; } - + } SharedLogger.logger.Debug($"ProfileRepository/ContainsCurrentProfile: Our profile repository doesn't contain the display profile currently in use"); @@ -496,7 +496,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Error($"ProfileRepository/GetProfile: Profile to get was empty or only whitespace"); return null; } - + if (ProfileItem.IsValidUUID(ProfileNameOrId)) foreach (ProfileItem testProfile in _allProfiles) @@ -506,7 +506,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/GetProfile: Returning profile with UUID {ProfileNameOrId}"); return testProfile; } - + } else foreach (ProfileItem testProfile in _allProfiles) @@ -516,7 +516,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/GetProfile: Returning profile with Name {ProfileNameOrId}"); return testProfile; } - + } SharedLogger.logger.Debug($"ProfileRepository/GetProfile: Didn't match any profiles with UUD or Name {ProfileNameOrId}"); @@ -530,7 +530,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Error($"ProfileRepository/RenameProfile: Profile to rename was empty or only whitespace"); return false; } - + SharedLogger.logger.Debug($"ProfileRepository/RenameProfile: Attempting to rename profile {profile.Name} to {renamedName}"); @@ -539,7 +539,7 @@ namespace DisplayMagicianShared SharedLogger.logger.Error($"ProfileRepository/RenameProfile: The name the user wanted to renamed to profile to is not a valid filename"); return false; } - + profile.Name = GetValidFilename(renamedName); IsPossibleRefresh(); @@ -560,7 +560,7 @@ namespace DisplayMagicianShared } - } + } public static void UpdateActiveProfile() { @@ -591,10 +591,10 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/UpdateActiveProfile: NVIDIA is not installed but the AMD ADL Driver IS installed, so using that for this display profile."); AMDProfileItem amdProfile = new AMDProfileItem { - Name = "Current AMD Display Profile" , + Name = "Current AMD Display Profile", //ProfileData = amdLibrary.GetActiveProfile(), //Screens = amdLibrary.GenerateScreenPositions() - //ProfileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers() + //ProfileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers() }; //activeProfile.ProfileIcon = new ProfileIcon(activeProfile); //activeProfile.ProfileBitmap = activeProfile.ProfileIcon.ToBitmap(256, 256); @@ -653,14 +653,26 @@ namespace DisplayMagicianShared SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: Checking whether the profile {profile.Name} is the currently active profile."); - if (profile.Equals(_currentProfile)) + if (profile is NVIDIAProfileItem && profile.Equals((NVIDIAProfileItem)_currentProfile)) { - SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The profile {profile.Name} is the currently active profile."); + SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The NVIDIA profile {profile.Name} is the currently active profile."); return true; } - - SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The profile {profile.Name} is not the currently active profile."); - return false; + else if (profile is AMDProfileItem && profile.Equals((AMDProfileItem)_currentProfile)) + { + SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The AMD profile {profile.Name} is the currently active profile."); + return true; + } + else if (profile is WinProfileItem && profile.Equals((WinProfileItem)_currentProfile)) + { + SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The Windows CCD profile {profile.Name} is the currently active profile."); + return true; + } + else + { + SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The profile {profile.Name} is not the currently active profile."); + return false; + } } diff --git a/DisplayMagicianShared/Windows/WinProfileItem.cs b/DisplayMagicianShared/Windows/WinProfileItem.cs index 255b6fe..99a8739 100644 --- a/DisplayMagicianShared/Windows/WinProfileItem.cs +++ b/DisplayMagicianShared/Windows/WinProfileItem.cs @@ -96,69 +96,7 @@ namespace DisplayMagicianShared.Windows } } - /*[JsonRequired] - public override List Screens - { - get - { - if (_screens.Count == 0) - { - _screens = GetScreenPositions(); - } - return _screens; - } - set - { - _screens = value; - } - } - - - - [JsonConverter(typeof(CustomBitmapConverter))] - public override Bitmap ProfileBitmap - { - get - { - *//*if (!ProfileRepository.ProfilesLoaded) - return null;*//* - - if (_profileBitmap != null) - return _profileBitmap; - else - { - _profileBitmap = this.ProfileIcon.ToBitmap(256, 256); - return _profileBitmap; - } - } - set - { - _profileBitmap = value; - } - - } -*/ - - /*[JsonConverter(typeof(CustomBitmapConverter))] - public override Bitmap ProfileTightestBitmap - { - get - { - if (_profileShortcutBitmap != null) - return _profileShortcutBitmap; - else - { - _profileShortcutBitmap = this.ProfileIcon.ToTightestBitmap(); - return _profileShortcutBitmap; - } - } - set - { - _profileShortcutBitmap = value; - } - - } */ - + #endregion public override bool IsValid()