Changed Settings-Serialization to work with hte new double-values in colors.

Fixes #50
This commit is contained in:
Darth Affe 2019-06-09 19:25:02 +02:00
parent 967dde1d3d
commit 6ad2e861a0

View File

@ -30,10 +30,16 @@ namespace KeyboardAudioVisualizer.Configuration
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JObject jsonObject = JObject.Load(reader);
return new Color(jsonObject.Property("A").Value.ToObject<byte>(),
jsonObject.Property("R").Value.ToObject<byte>(),
jsonObject.Property("G").Value.ToObject<byte>(),
jsonObject.Property("B").Value.ToObject<byte>());
if (jsonObject.Property("A").Value.ToObject<double>() > 1.0) //DarthAffe 09.06.2019: Convert old Settings
return new Color(jsonObject.Property("A").Value.ToObject<byte>(),
jsonObject.Property("R").Value.ToObject<byte>(),
jsonObject.Property("G").Value.ToObject<byte>(),
jsonObject.Property("B").Value.ToObject<byte>());
else
return new Color(jsonObject.Property("A").Value.ToObject<double>(),
jsonObject.Property("R").Value.ToObject<double>(),
jsonObject.Property("G").Value.ToObject<double>(),
jsonObject.Property("B").Value.ToObject<double>());
}
#endregion