mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Devices - Implemented switching between layout providers
This commit is contained in:
1 parent
e8590abd61
commit
dad6a56238
25 files changed
+178
-80
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Providers;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.WebClient.Workshop.Services;
|
||||
|
||||
namespace Artemis.WebClient.Workshop.Providers;
|
||||
@@ -7,11 +8,13 @@ namespace Artemis.WebClient.Workshop.Providers;
|
||||
public class WorkshopLayoutProvider : ILayoutProvider
|
||||
{
|
||||
public static string LayoutType = "Workshop";
|
||||
|
||||
|
||||
private readonly IDeviceService _deviceService;
|
||||
private readonly IWorkshopService _workshopService;
|
||||
|
||||
public WorkshopLayoutProvider(IWorkshopService workshopService)
|
||||
public WorkshopLayoutProvider(IDeviceService deviceService, IWorkshopService workshopService)
|
||||
{
|
||||
_deviceService = deviceService;
|
||||
_workshopService = workshopService;
|
||||
}
|
||||
|
||||
@@ -45,4 +48,16 @@ public class WorkshopLayoutProvider : ILayoutProvider
|
||||
{
|
||||
return entry.TryGetMetadata("DeviceId", out HashSet<string>? deviceIds) && deviceIds.Contains(device.Identifier);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class InstalledEntry
|
||||
ReleaseVersion = Entity.ReleaseVersion;
|
||||
InstalledAt = Entity.InstalledAt;
|
||||
|
||||
_metadata = new Dictionary<string, object>(Entity.Metadata);
|
||||
_metadata = Entity.Metadata != null ? new Dictionary<string, object>(Entity.Metadata) : new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
internal void Save()
|
||||
|
||||
Reference in new issue
Block a user