Patch Profiles that are missing GDI settings

This will ensure that existing display profiles will at least load. Anyone with refresh settings changes or BPC or other device context settings will need to recreate their display profiles.
This commit is contained in:
Terry MacDonald 2021-10-16 09:37:52 +13:00
parent b5e84cf6a8
commit d98372bf39
2 changed files with 34 additions and 2 deletions

View File

@ -26,8 +26,8 @@ using System.Resources;
[assembly: Guid("e4ceaf5e-ad01-4695-b179-31168eb74c48")]
// Version information
[assembly: AssemblyVersion("2.0.1.127")]
[assembly: AssemblyFileVersion("2.0.1.127")]
[assembly: AssemblyVersion("2.0.1.129")]
[assembly: AssemblyFileVersion("2.0.1.129")]
[assembly: NeutralResourcesLanguageAttribute( "en" )]
[assembly: CLSCompliant(true)]

View File

@ -818,6 +818,38 @@ namespace DisplayMagicianShared
JObject NVIDIADisplayConfig = (JObject)profile.SelectToken("NVIDIADisplayConfig");
NVIDIADisplayConfig.Add("ColorConfig",defaultColorConfig);
changedJson = true;
SharedLogger.logger.Trace($"ProfileRepository/MigrateJsonToLatestVersion: Patched missing NVIDIA Color Config in profile {profile.SelectToken("Name")} (index {i}).");
}
}
}
catch (JsonReaderException ex)
{
SharedLogger.logger.Error($"ProfileRepository/MigrateJsonToLatestVersion: JSONReaderException while trying to process the Profiles json data to migrate any older feature to the latest version.");
}
catch (Exception ex)
{
SharedLogger.logger.Error($"ProfileRepository/MigrateJsonToLatestVersion: Exception while trying to process the Profiles json data to migrate any older feature to the latest version.");
}
// Now we try and add a default Windows GDI Device Context if there isn't one
try
{
SharedLogger.logger.Trace($"ProfileRepository/MigrateJsonToLatestVersion: Looking for missing Windows GDI Device Context.");
// Create a default object
Dictionary<string, GDI_DISPLAY_SETTING> GdiDisplaySettings = new Dictionary<string, GDI_DISPLAY_SETTING>();
JObject defaultGdiDisplaySettings = (JObject)JToken.FromObject(GdiDisplaySettings);
for (int i = 0; i < root.Count; i++)
{
JObject profile = (JObject)root[i];
JObject result = (JObject)profile.SelectToken("WindowsDisplayConfig.GdiDisplaySettings");
if (result == null)
{
JObject WindowsDisplayConfig = (JObject)profile.SelectToken("WindowsDisplayConfig");
WindowsDisplayConfig.Add("GdiDisplaySettings", defaultGdiDisplaySettings);
changedJson = true;
SharedLogger.logger.Trace($"ProfileRepository/MigrateJsonToLatestVersion: Patched missing Windows GDI Device Context in profile {profile.SelectToken("Name")} (index {i}).");
}
}
}