Working profile comparisons

This commit is contained in:
Terry MacDonald 2021-08-24 20:37:32 +12:00
parent 0b864f09ca
commit 90c13c7426
5 changed files with 53 additions and 245 deletions

View File

@ -111,69 +111,6 @@ namespace DisplayMagicianShared.AMD
} }
} }
/*[JsonRequired]
public override List<ScreenPosition> 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 #endregion
public override bool IsValid() public override bool IsValid()

View File

@ -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<string> ProfileDisplayIdentifiers public override List<string> ProfileDisplayIdentifiers
{ {
get get
@ -132,64 +111,6 @@ namespace DisplayMagicianShared.NVIDIA
} }
} }
/*[JsonRequired]
public override List<ScreenPosition> 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 #endregion
public override bool IsValid() public override bool IsValid()

View File

@ -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) public override bool Equals(object obj)
{ {
return this.Equals(obj as ProfileItem); return this.Equals(obj as ProfileItem);
@ -432,7 +432,7 @@ namespace DisplayMagicianShared
int foundPathsCount = 0; int foundPathsCount = 0;
int foundOtherPathsCount = 0; int foundOtherPathsCount = 0;
/*foreach (Topology.Path profilePath in Paths) *//*foreach (Topology.Path profilePath in Paths)
{ {
if (other.Paths.Contains(profilePath)) if (other.Paths.Contains(profilePath))
{ {
@ -448,14 +448,14 @@ namespace DisplayMagicianShared
foundOtherPathsCount++; foundOtherPathsCount++;
continue; continue;
} }
}*/ }*//*
if (foundPathsCount == foundOtherPathsCount) if (foundPathsCount == foundOtherPathsCount)
return true; return true;
else else
return false; return false;
} }*/
// If Equals() returns true for this object compared to another // If Equals() returns true for this object compared to another
// then GetHashCode() must return the same value for these objects. // 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' // Allows us to use 'Contains'
class ProfileComparer : IEqualityComparer<ProfileItem> class ProfileComparer : IEqualityComparer<ProfileItem>
{ {
// Products are equal if their names and product numbers are equal. // 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. //Check whether the compared objects reference the same data.
@ -632,7 +632,7 @@ namespace DisplayMagicianShared
return true; return true;
else else
return false; return false;
}*/ }*//*
public bool Equals(ProfileItem x, ProfileItem y) 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 // Two profiles are equal only when they have the same viewport data
int foundPathsCount = 0; int foundPathsCount = 0;
int foundOtherPathsCount = 0; int foundOtherPathsCount = 0;
/*foreach (Topology.Path profilePath in x.Paths) *//*foreach (Topology.Path profilePath in x.Paths)
{ {
if (y.Paths.Contains(profilePath)) if (y.Paths.Contains(profilePath))
{ {
@ -697,7 +697,7 @@ namespace DisplayMagicianShared
foundOtherPathsCount++; foundOtherPathsCount++;
continue; continue;
} }
}*/ }*//*
if (foundPathsCount == foundOtherPathsCount) if (foundPathsCount == foundOtherPathsCount)
@ -708,7 +708,7 @@ namespace DisplayMagicianShared
// If Equals() returns true for a pair of objects // If Equals() returns true for a pair of objects
// then GetHashCode() must return the same value for these 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 // Check whether the object is null
@ -720,7 +720,7 @@ namespace DisplayMagicianShared
//Calculate the hash code for the product. //Calculate the hash code for the product.
return hashPaths; return hashPaths;
}*/ }*//*
// Modified the GetHashCode to compare the displayidentifier // Modified the GetHashCode to compare the displayidentifier
public int GetHashCode(ProfileItem profile) public int GetHashCode(ProfileItem profile)
{ {
@ -739,5 +739,5 @@ namespace DisplayMagicianShared
return (hashIds,hashPaths).GetHashCode(); return (hashIds,hashPaths).GetHashCode();
} }
} }*/
} }

View File

@ -591,7 +591,7 @@ 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."); 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 AMDProfileItem amdProfile = new AMDProfileItem
{ {
Name = "Current AMD Display Profile" , Name = "Current AMD Display Profile",
//ProfileData = amdLibrary.GetActiveProfile(), //ProfileData = amdLibrary.GetActiveProfile(),
//Screens = amdLibrary.GenerateScreenPositions() //Screens = amdLibrary.GenerateScreenPositions()
//ProfileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers() //ProfileDisplayIdentifiers = ProfileRepository.GenerateProfileDisplayIdentifiers()
@ -653,15 +653,27 @@ namespace DisplayMagicianShared
SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: Checking whether the profile {profile.Name} is the currently active profile."); 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; return true;
} }
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."); SharedLogger.logger.Debug($"ProfileRepository/IsActiveProfile: The profile {profile.Name} is not the currently active profile.");
return false; return false;
} }
}
private static bool LoadProfiles() private static bool LoadProfiles()

View File

@ -96,68 +96,6 @@ namespace DisplayMagicianShared.Windows
} }
} }
/*[JsonRequired]
public override List<ScreenPosition> 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 #endregion