using OpenRGB.NET;
using RGB.NET.Core;
namespace RGB.NET.Devices.OpenRGB;
///
public sealed class OpenRGBSegmentDevice : AbstractOpenRGBDevice
{
#region Properties & Fields
private readonly int _initialLed;
private readonly Segment _segment;
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The information provided by OpenRGB
/// The ledId of the first led in the device that belongs to this zone.
/// The Segment information provided by OpenRGB.
/// The queue used to update this zone.
public OpenRGBSegmentDevice(OpenRGBDeviceInfo info, int initialLed, Segment segment, IUpdateQueue updateQueue)
: base(info, updateQueue)
{
_initialLed = initialLed;
_segment = segment;
InitializeLayout();
}
#endregion
#region Methods
private void InitializeLayout()
{
Size ledSize = new(19);
const int LED_SPACING = 20;
LedId initialId = Helper.GetInitialLedIdForDeviceType(DeviceInfo.DeviceType);
for (int i = 0; i < _segment.LedCount; i++)
{
LedId ledId = initialId++;
// ReSharper disable once HeapView.BoxingAllocation
while (AddLed(ledId, new Point(LED_SPACING * i, 0), ledSize, _initialLed + i) == null)
ledId = initialId++;
}
}
#endregion
}