mirror of
https://github.com/DarthAffe/RGBSyncPlus
synced 2026-11-11 13:06:28 +00:00
Initial implementation
This commit is contained in:
1 parent
278e22020e
commit
fd662dcf34
63 files changed
+4881
No files matched your search
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGBSyncPlus.Configuration
|
||||
{
|
||||
public class AbstractConfiguration : AbstractBindable, IConfiguration, INotifyPropertyChanged
|
||||
{
|
||||
#region Methods
|
||||
|
||||
protected override bool SetProperty<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
if ((typeof(T) == typeof(double)) || (typeof(T) == typeof(float)))
|
||||
{
|
||||
if (Math.Abs((double)(object)storage - (double)(object)value) < 0.000001) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Equals(storage, value)) return false;
|
||||
}
|
||||
|
||||
storage = value;
|
||||
// ReSharper disable once ExplicitCallerInfoArgument
|
||||
OnPropertyChanged(propertyName);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RGB.NET.Core;
|
||||
|
||||
namespace RGBSyncPlus.Configuration
|
||||
{
|
||||
public class ColorSerializer : JsonConverter
|
||||
{
|
||||
#region Methods
|
||||
|
||||
public override bool CanConvert(Type objectType) => objectType == typeof(Color);
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (!(value is Color color)) return;
|
||||
|
||||
writer.WriteStartObject();
|
||||
writer.WritePropertyName("A");
|
||||
writer.WriteValue(color.A);
|
||||
writer.WritePropertyName("R");
|
||||
writer.WriteValue(color.R);
|
||||
writer.WritePropertyName("G");
|
||||
writer.WriteValue(color.G);
|
||||
writer.WritePropertyName("B");
|
||||
writer.WriteValue(color.B);
|
||||
writer.WriteEndObject();
|
||||
}
|
||||
|
||||
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>());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace RGBSyncPlus.Configuration
|
||||
{
|
||||
public interface IConfiguration : INotifyPropertyChanged
|
||||
{ }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace RGBSyncPlus.Configuration.Legacy
|
||||
{
|
||||
public static class ConfigurationUpdates
|
||||
{
|
||||
#region Methods
|
||||
|
||||
public static void PerformOn(Settings settings)
|
||||
{ }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using RGBSyncPlus.Model;
|
||||
|
||||
namespace RGBSyncPlus.Configuration
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
#region Constants
|
||||
|
||||
public const int CURRENT_VERSION = 1;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties & Fields
|
||||
|
||||
public int Version { get; set; } = 0;
|
||||
|
||||
public double UpdateRate { get; set; } = 30.0;
|
||||
|
||||
public List<SyncGroup> SyncGroups { get; set; } = new List<SyncGroup>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user