mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Core - Allow device providers to opt out of layout LED creation/removal
Device properties UI - Highlight selected LEDs in white
This commit is contained in:
1 parent
7000110dcb
commit
7a3be83bf6
11 files changed
+206
-101
No files matched your search
@@ -329,6 +329,13 @@ namespace Artemis.Core
|
||||
/// <param name="removeExcessiveLeds">A boolean indicating whether to remove excess LEDs present in the device but missing in the layout</param>
|
||||
internal void ApplyLayout(ArtemisLayout layout, bool createMissingLeds, bool removeExcessiveLeds)
|
||||
{
|
||||
if (createMissingLeds && !DeviceProvider.CreateMissingLedsSupported)
|
||||
throw new ArtemisCoreException($"Cannot apply layout with {nameof(createMissingLeds)} " +
|
||||
"set to true because the device provider does not support it");
|
||||
if (removeExcessiveLeds && !DeviceProvider.RemoveExcessiveLedsSupported)
|
||||
throw new ArtemisCoreException($"Cannot apply layout with {nameof(removeExcessiveLeds)} " +
|
||||
"set to true because the device provider does not support it");
|
||||
|
||||
if (layout.IsValid)
|
||||
layout.RgbLayout!.ApplyTo(RgbDevice, createMissingLeds, removeExcessiveLeds);
|
||||
|
||||
|
||||
@@ -51,6 +51,18 @@ namespace Artemis.Core.DeviceProviders
|
||||
/// </summary>
|
||||
public bool CanDetectLogicalLayout { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether adding missing LEDs defined in a layout but missing on the device is supported
|
||||
/// <para>Note: Defaults to <see langword="true" />.</para>
|
||||
/// </summary>
|
||||
public bool CreateMissingLedsSupported { get; protected set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether removing excess LEDs present in the device but missing in the layout is supported
|
||||
/// <para>Note: Defaults to <see langword="true" />.</para>
|
||||
/// </summary>
|
||||
public bool RemoveExcessiveLedsSupported { get; protected set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Loads a layout for the specified device and wraps it in an <see cref="ArtemisLayout" />
|
||||
/// </summary>
|
||||
|
||||
@@ -90,9 +90,7 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="device"></param>
|
||||
/// <param name="layout"></param>
|
||||
/// <param name="createMissingLeds"></param>
|
||||
/// <param name="removeExessiveLeds"></param>
|
||||
void ApplyDeviceLayout(ArtemisDevice device, ArtemisLayout layout, bool createMissingLeds, bool removeExessiveLeds);
|
||||
void ApplyDeviceLayout(ArtemisDevice device, ArtemisLayout layout);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to retrieve the <see cref="ArtemisDevice" /> that corresponds the provided RGB.NET
|
||||
|
||||
@@ -312,7 +312,7 @@ namespace Artemis.Core.Services
|
||||
layout = new ArtemisLayout(device.CustomLayoutPath, LayoutSource.Configured);
|
||||
if (layout.IsValid)
|
||||
{
|
||||
ApplyDeviceLayout(device, layout, true, true);
|
||||
ApplyDeviceLayout(device, layout);
|
||||
return layout;
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ namespace Artemis.Core.Services
|
||||
layout = device.DeviceProvider.LoadUserLayout(device);
|
||||
if (layout.IsValid)
|
||||
{
|
||||
ApplyDeviceLayout(device, layout, true, true);
|
||||
ApplyDeviceLayout(device, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -329,13 +329,13 @@ namespace Artemis.Core.Services
|
||||
layout = device.DeviceProvider.LoadLayout(device);
|
||||
if (layout.IsValid)
|
||||
{
|
||||
ApplyDeviceLayout(device, layout, true, true);
|
||||
ApplyDeviceLayout(device, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
// Finally fall back to a default layout
|
||||
layout = LoadDefaultLayout(device);
|
||||
ApplyDeviceLayout(device, layout, true, true);
|
||||
ApplyDeviceLayout(device, layout);
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -344,9 +344,9 @@ namespace Artemis.Core.Services
|
||||
return new("NYI", LayoutSource.Default);
|
||||
}
|
||||
|
||||
public void ApplyDeviceLayout(ArtemisDevice device, ArtemisLayout layout, bool createMissingLeds, bool removeExessiveLeds)
|
||||
public void ApplyDeviceLayout(ArtemisDevice device, ArtemisLayout layout)
|
||||
{
|
||||
device.ApplyLayout(layout, createMissingLeds, removeExessiveLeds);
|
||||
device.ApplyLayout(layout, device.DeviceProvider.CreateMissingLedsSupported, device.DeviceProvider.RemoveExcessiveLedsSupported);
|
||||
UpdateLedGroup();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user