mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Added shared UI library and finished the ColorPicker
This commit is contained in:
1 parent
515348241a
commit
cec6fb45dc
30 files changed
+875
-321
No files matched your search
@@ -164,6 +164,7 @@
|
||||
<Compile Include="Extensions\RgbDeviceExtensions.cs" />
|
||||
<Compile Include="Extensions\RgbRectangleExtensions.cs" />
|
||||
<Compile Include="Extensions\TypeExtensions.cs" />
|
||||
<Compile Include="JsonConverters\SKColorConverter.cs" />
|
||||
<Compile Include="Models\DataModelDescription.cs" />
|
||||
<Compile Include="Models\Surface\ArtemisLed.cs" />
|
||||
<Compile Include="Models\Surface\ArtemisSurface.cs" />
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.JsonConverters
|
||||
{
|
||||
public class SKColorConverter : JsonConverter<SKColor>
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, SKColor value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue(value.ToString());
|
||||
}
|
||||
|
||||
public override SKColor ReadJson(JsonReader reader, Type objectType, SKColor existingValue, bool hasExistingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.Value is string value && !string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
return SKColor.Parse(value);
|
||||
}
|
||||
|
||||
return SKColor.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,11 @@ using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Exceptions;
|
||||
using Artemis.Core.JsonConverters;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
using RGB.NET.Core;
|
||||
using Serilog;
|
||||
using SkiaSharp;
|
||||
@@ -36,9 +38,18 @@ namespace Artemis.Core.Services
|
||||
_pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
||||
_pluginService.PluginDisabled += (sender, args) => _modules = _pluginService.GetPluginsOfType<Module>();
|
||||
|
||||
ConfigureJsonConvert();
|
||||
Task.Run(Initialize);
|
||||
}
|
||||
|
||||
private void ConfigureJsonConvert()
|
||||
{
|
||||
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
|
||||
{
|
||||
Converters = new List<JsonConverter> { new SKColorConverter() }
|
||||
};
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Dispose services
|
||||
|
||||
@@ -8,16 +8,19 @@ using Artemis.Core.Services.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.Core.Services
|
||||
{
|
||||
public class LayerService : ILayerService
|
||||
{
|
||||
private readonly IKernel _kernel;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public LayerService(IKernel kernel)
|
||||
public LayerService(IKernel kernel, ILogger logger)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public LayerElement InstantiateLayerElement(Layer layer, LayerElementDescriptor layerElementDescriptor, string settings, Guid? guid)
|
||||
@@ -42,7 +45,19 @@ namespace Artemis.Core.Services
|
||||
$"Settings where provided but layer element of type {layerElementDescriptor.LayerElementType.Name} has no Settings property."
|
||||
);
|
||||
}
|
||||
settingsInstance = JsonConvert.DeserializeObject(settings, settingsType);
|
||||
|
||||
try
|
||||
{
|
||||
settingsInstance = JsonConvert.DeserializeObject(settings, settingsType);
|
||||
}
|
||||
catch (JsonSerializationException e)
|
||||
{
|
||||
_logger.Warning(e, "Failed to deserialize settings for layer type {type}, resetting element settings - Plugin info: {pluginInfo}",
|
||||
layerElementDescriptor.LayerElementType.Name,
|
||||
layerElementDescriptor.LayerElementProvider.PluginInfo);
|
||||
|
||||
settingsInstance = Activator.CreateInstance(settingsType);
|
||||
}
|
||||
}
|
||||
// If no settings found, provide a fresh instance of the settings type
|
||||
else if (settingsType != null)
|
||||
|
||||
Reference in new issue
Block a user