// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using System.Drawing;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Helper;
namespace CUE.NET.Devices.Generic
{
///
/// Represents a single LED of a CUE-device.
///
public class CorsairLed
{
#region Properties & Fields
///
/// Gets the key-ID of the Led.
///
public CorsairLedId Id { get; set; }
///
/// Gets a rectangle representing the physical location of the led.
///
public RectangleF LedRectangle { get; }
///
/// Indicates whether the LED has changed an internal state.
///
public bool IsDirty => RequestedColor != _color;
///
/// Gets the Color the LED should be set to on the next update.
///
public Color RequestedColor { get; private set; } = Color.Transparent;
private Color _color = Color.Transparent;
///
/// Gets the current color of the LED. Sets the for the next update. />.
///
public Color Color
{
get { return _color; }
set
{
if (!IsLocked)
RequestedColor = RequestedColor.Blend(value);
}
}
///
/// Gets or sets if the color of this LED can be changed.
///
public bool IsLocked { get; set; } = false;
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The ID of the LED
/// The rectangle representing the physical location of the LED.
internal CorsairLed(CorsairLedId id, RectangleF ledRectangle)
{
this.Id = id;
this.LedRectangle = ledRectangle;
}
#endregion
#region Methods
///
/// Updates the LED to the requested color.
///
internal void Update()
{
_color = RequestedColor;
}
///
/// Resets the LED back to default
///
internal void Reset()
{
_color = Color.Transparent;
RequestedColor = Color.Transparent;
IsLocked = false;
}
#endregion
}
}