using System;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair
{
///
///
/// Represents a generic information for a Corsair-.
///
public class CorsairRGBDeviceInfo : IRGBDeviceInfo
{
#region Properties & Fields
///
/// Gets the corsair specific device type.
///
public CorsairDeviceType CorsairDeviceType { get; }
///
/// Gets the index of the .
///
public int CorsairDeviceIndex { get; }
///
public RGBDeviceType DeviceType { get; }
///
public string DeviceName { get; }
///
public string Manufacturer => "Corsair";
///
public string Model { get; }
///
public object? LayoutMetadata { get; set; }
///
/// Gets a flag that describes device capabilities. ()
///
public CorsairDeviceCaps CapsMask { get; }
#endregion
#region Constructors
///
/// Internal constructor of managed .
///
/// The index of the .
/// The type of the .
/// The native -struct
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo)
{
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type;
this.Model = nativeInfo.model == IntPtr.Zero ? string.Empty : Regex.Replace(Marshal.PtrToStringAnsi(nativeInfo.model) ?? string.Empty, " ?DEMO", string.Empty, RegexOptions.IgnoreCase);
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}
///
/// Internal constructor of managed .
///
/// The index of the .
/// The type of the .
/// The native -struct
/// The name of the device-model (overwrites the one provided with the device info).
internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo, string modelName)
{
this.CorsairDeviceIndex = deviceIndex;
this.DeviceType = deviceType;
this.CorsairDeviceType = nativeInfo.type;
this.Model = modelName;
this.CapsMask = (CorsairDeviceCaps)nativeInfo.capsMask;
DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model);
}
#endregion
}
}