using System.Collections.Generic;
using RGB.NET.Core;
namespace RGB.NET.Devices.CoolerMaster
{
///
///
/// Represents a CoolerMaster keyboard.
///
public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice, IKeyboard
{
#region Properties & Fields
IKeyboardDeviceInfo IKeyboard.DeviceInfo => DeviceInfo;
#endregion
#region Constructors
///
///
/// Initializes a new instance of the class.
///
/// The specific information provided by CoolerMaster for the keyboard
internal CoolerMasterKeyboardRGBDevice(CoolerMasterKeyboardRGBDeviceInfo info)
: base(info)
{ }
#endregion
#region Methods
///
protected override void InitializeLayout()
{
if (!CoolerMasterKeyboardLedMappings.Mapping.TryGetValue(DeviceInfo.DeviceIndex, out Dictionary>? deviceMappings))
throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex}");
if (!deviceMappings.TryGetValue(DeviceInfo.PhysicalLayout, out Dictionary? mapping))
throw new RGBDeviceException($"Failed to find a CoolerMasterKeyboardLedMapping for device index {DeviceInfo.DeviceIndex} with physical layout {DeviceInfo.PhysicalLayout}");
foreach ((LedId ledId, (int row, int column)) in mapping)
AddLed(ledId, new Point(column * 19, row * 19), new Size(19, 19));
}
///
protected override object GetLedCustomData(LedId ledId) => CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout][ledId];
#endregion
}
}