Devices - Implemented switching between layout providers

This commit is contained in:
RobertBeekman committed 2024-01-13 11:59:12 +01:00
1 parent e8590abd61
commit dad6a56238
25 files changed
+178 -80

No files matched your search

@@ -1,11 +1,18 @@
using RGB.NET.Layout;
using Artemis.Core.Services;
using RGB.NET.Layout;
namespace Artemis.Core.Providers;
public class CustomPathLayoutProvider : ILayoutProvider
{
public static string LayoutType = "CustomPath";
private readonly IDeviceService _deviceService;
public CustomPathLayoutProvider(IDeviceService deviceService)
{
_deviceService = deviceService;
}
/// <inheritdoc />
public ArtemisLayout? GetDeviceLayout(ArtemisDevice device)
{
@@ -19,10 +26,23 @@ public class CustomPathLayoutProvider : ILayoutProvider
{
device.ApplyLayout(layout, device.DeviceProvider.CreateMissingLedsSupported, device.DeviceProvider.RemoveExcessiveLedsSupported);
}
/// <inheritdoc />
public bool IsMatch(ArtemisDevice device)
{
return device.LayoutSelection.Type == LayoutType;
}
/// <summary>
/// Configures the provided device to use this layout provider.
/// </summary>
/// <param name="device">The device to apply the provider to.</param>
/// <param name="path">The path to the custom layout.</param>
public void ConfigureDevice(ArtemisDevice device, string? path)
{
device.LayoutSelection.Type = LayoutType;
device.LayoutSelection.Parameter = path;
_deviceService.SaveDevice(device);
_deviceService.LoadDeviceLayout(device);
}
}
@@ -1,8 +1,16 @@
namespace Artemis.Core.Providers;
using Artemis.Core.Services;
namespace Artemis.Core.Providers;
public class DefaultLayoutProvider : ILayoutProvider
{
public static string LayoutType = "Default";
private readonly IDeviceService _deviceService;
public DefaultLayoutProvider(IDeviceService deviceService)
{
_deviceService = deviceService;
}
/// <inheritdoc />
public ArtemisLayout? GetDeviceLayout(ArtemisDevice device)
@@ -28,4 +36,16 @@ public class DefaultLayoutProvider : ILayoutProvider
{
return device.LayoutSelection.Type == LayoutType;
}
/// <summary>
/// Configures the provided device to use this layout provider.
/// </summary>
/// <param name="device">The device to apply the provider to.</param>
public void ConfigureDevice(ArtemisDevice device)
{
device.LayoutSelection.Type = LayoutType;
device.LayoutSelection.Parameter = null;
_deviceService.SaveDevice(device);
_deviceService.LoadDeviceLayout(device);
}
}
@@ -1,9 +1,17 @@
namespace Artemis.Core.Providers;
using Artemis.Core.Services;
namespace Artemis.Core.Providers;
public class NoneLayoutProvider : ILayoutProvider
{
private readonly IDeviceService _deviceService;
public static string LayoutType = "None";
public NoneLayoutProvider(IDeviceService deviceService)
{
_deviceService = deviceService;
}
/// <inheritdoc />
public ArtemisLayout? GetDeviceLayout(ArtemisDevice device)
{
@@ -21,4 +29,16 @@ public class NoneLayoutProvider : ILayoutProvider
{
return device.LayoutSelection.Type == LayoutType;
}
/// <summary>
/// Configures the provided device to use this layout provider.
/// </summary>
/// <param name="device">The device to apply the provider to.</param>
public void ConfigureDevice(ArtemisDevice device)
{
device.LayoutSelection.Type = LayoutType;
device.LayoutSelection.Parameter = null;
_deviceService.SaveDevice(device);
_deviceService.LoadDeviceLayout(device);
}
}