using System.Linq;
using RGB.NET.Core;
namespace RGB.NET.Devices.Logitech
{
///
///
///
/// Represents a generic Logitech-device. (keyboard, mouse, headset, mousepad).
///
public abstract class LogitechRGBDevice : AbstractRGBDevice, ILogitechRGBDevice
where TDeviceInfo : LogitechRGBDeviceInfo
{
#region Properties & Fields
///
///
/// Gets information about the .
///
public override TDeviceInfo DeviceInfo { get; }
///
/// Gets or sets the update queue performing updates for this device.
///
// ReSharper disable once MemberCanBePrivate.Global
protected UpdateQueue UpdateQueue { get; set; }
#endregion
#region Constructors
///
/// Initializes a new instance of the class.
///
/// The generic information provided by Logitech for the device.
protected LogitechRGBDevice(TDeviceInfo info)
{
this.DeviceInfo = info;
}
#endregion
#region Methods
///
/// Initializes the device.
///
public void Initialize(UpdateQueue updateQueue)
{
InitializeLayout();
if (Size == Size.Invalid)
{
Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle));
Size = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y);
}
UpdateQueue = updateQueue;
}
///
/// Initializes the and of the device.
///
protected virtual void InitializeLayout()
{
if (!(DeviceInfo is LogitechRGBDeviceInfo info)) return;
string layout = info.ImageLayout;
string layoutPath = info.LayoutPath;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, true);
}
#endregion
}
}