mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profiles - Fixed LEDs of devices that are missing being removed from layers (#733)
This commit is contained in:
parent
3f1eaeda29
commit
b83f1f0102
@ -11,6 +11,7 @@
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PackageId>ArtemisRGB.Core</PackageId>
|
||||
<PluginApiVersion>1</PluginApiVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -19,8 +20,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj"/>
|
||||
<ProjectReference Condition="'$(BuildingNuget)' == 'True'" Update="..\Artemis.Storage\Artemis.Storage.csproj" PrivateAssets="All"/>
|
||||
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj" />
|
||||
<ProjectReference Condition="'$(BuildingNuget)' == 'True'" Update="..\Artemis.Storage\Artemis.Storage.csproj" PrivateAssets="All" />
|
||||
|
||||
<!--
|
||||
Include Artemis.Storage directly in the NuGet package instead of expecting it as an external dependency
|
||||
|
||||
@ -16,12 +16,13 @@ namespace Artemis.Core;
|
||||
/// </summary>
|
||||
public sealed class Layer : RenderProfileElement
|
||||
{
|
||||
private readonly List<Layer> _renderCopies;
|
||||
private LayerGeneralProperties _general;
|
||||
private readonly List<Layer> _renderCopies = new();
|
||||
private LayerGeneralProperties _general = new();
|
||||
private LayerTransformProperties _transform = new();
|
||||
private BaseLayerBrush? _layerBrush;
|
||||
private LayerShape? _layerShape;
|
||||
private List<ArtemisLed> _leds;
|
||||
private LayerTransformProperties _transform;
|
||||
private List<ArtemisLed> _leds = new();
|
||||
private List<LedEntity> _missingLeds = new();
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="Layer" /> class and adds itself to the child collection of the provided
|
||||
@ -37,16 +38,9 @@ public sealed class Layer : RenderProfileElement
|
||||
Profile = Parent.Profile;
|
||||
Name = name;
|
||||
Suspended = false;
|
||||
|
||||
// TODO: move to top
|
||||
_renderCopies = new List<Layer>();
|
||||
_general = new LayerGeneralProperties();
|
||||
_transform = new LayerTransformProperties();
|
||||
|
||||
_leds = new List<ArtemisLed>();
|
||||
Leds = new ReadOnlyCollection<ArtemisLed>(_leds);
|
||||
|
||||
Adapter = new LayerAdapter(this);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@ -63,16 +57,9 @@ public sealed class Layer : RenderProfileElement
|
||||
|
||||
Profile = profile;
|
||||
Parent = parent;
|
||||
|
||||
// TODO: move to top
|
||||
_renderCopies = new List<Layer>();
|
||||
_general = new LayerGeneralProperties();
|
||||
_transform = new LayerTransformProperties();
|
||||
|
||||
_leds = new List<ArtemisLed>();
|
||||
Leds = new ReadOnlyCollection<ArtemisLed>(_leds);
|
||||
|
||||
Adapter = new LayerAdapter(this);
|
||||
|
||||
Load();
|
||||
Initialize();
|
||||
}
|
||||
@ -327,6 +314,7 @@ public sealed class Layer : RenderProfileElement
|
||||
|
||||
// LEDs
|
||||
LayerEntity.Leds.Clear();
|
||||
SaveMissingLeds();
|
||||
foreach (ArtemisLed artemisLed in Leds)
|
||||
{
|
||||
LedEntity ledEntity = new()
|
||||
@ -786,6 +774,8 @@ public sealed class Layer : RenderProfileElement
|
||||
a.RgbLed.Id.ToString() == ledEntity.LedName);
|
||||
if (match != null)
|
||||
leds.Add(match);
|
||||
else
|
||||
_missingLeds.Add(ledEntity);
|
||||
}
|
||||
|
||||
_leds = leds;
|
||||
@ -793,6 +783,11 @@ public sealed class Layer : RenderProfileElement
|
||||
CalculateRenderProperties();
|
||||
}
|
||||
|
||||
private void SaveMissingLeds()
|
||||
{
|
||||
LayerEntity.Leds.AddRange(_missingLeds.Except(LayerEntity.Leds, LedEntity.LedEntityComparer));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Brush management
|
||||
|
||||
@ -1,7 +1,37 @@
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Storage.Entities.Profile;
|
||||
|
||||
public class LedEntity
|
||||
{
|
||||
#region LedEntityEqualityComparer
|
||||
|
||||
private sealed class LedEntityEqualityComparer : IEqualityComparer<LedEntity>
|
||||
{
|
||||
public bool Equals(LedEntity x, LedEntity y)
|
||||
{
|
||||
if (ReferenceEquals(x, y))
|
||||
return true;
|
||||
if (ReferenceEquals(x, null))
|
||||
return false;
|
||||
if (ReferenceEquals(y, null))
|
||||
return false;
|
||||
if (x.GetType() != y.GetType())
|
||||
return false;
|
||||
return x.LedName == y.LedName && x.DeviceIdentifier == y.DeviceIdentifier && x.PhysicalLayout == y.PhysicalLayout;
|
||||
}
|
||||
|
||||
public int GetHashCode(LedEntity obj)
|
||||
{
|
||||
return HashCode.Combine(obj.LedName, obj.DeviceIdentifier, obj.PhysicalLayout);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEqualityComparer<LedEntity> LedEntityComparer { get; } = new LedEntityEqualityComparer();
|
||||
|
||||
#endregion
|
||||
|
||||
public string LedName { get; set; }
|
||||
public string DeviceIdentifier { get; set; }
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user