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:
Robert committed 2021-04-01 19:57:28 +02:00
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);