-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathOpenRGBDeviceInfo.cs
More file actions
62 lines (49 loc) · 1.85 KB
/
OpenRGBDeviceInfo.cs
File metadata and controls
62 lines (49 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using RGB.NET.Core;
using OpenRGBDevice = OpenRGB.NET.Device;
namespace RGB.NET.Devices.OpenRGB;
/// <summary>
/// Represents generic information for an OpenRGB Device
/// </summary>
public class OpenRGBDeviceInfo : IRGBDeviceInfo
{
#region Properties & Fields
/// <inheritdoc />
public RGBDeviceType DeviceType { get; }
/// <inheritdoc />
public string DeviceName { get; }
/// <inheritdoc />
public string Manufacturer { get; }
/// <inheritdoc />
public string Model { get; }
/// <inheritdoc />
public object? LayoutMetadata { get; set; }
/// <summary>
/// Gets the OpenRGB device.
/// </summary>
public OpenRGBDevice OpenRGBDevice { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of <see cref="OpenRGBDeviceInfo"/>.
/// </summary>
/// <param name="openRGBDevice">The OpenRGB device to extract information from.</param>
/// <param name="splitId">If this is a zone or segment, specify the name</param>
internal OpenRGBDeviceInfo(OpenRGBDevice openRGBDevice, string? splitId = null)
{
this.OpenRGBDevice = openRGBDevice;
DeviceType = Helper.GetRgbNetDeviceType(openRGBDevice.Type);
Manufacturer = Helper.GetVendorName(openRGBDevice);
Model = Helper.GetModelName(openRGBDevice);
string model = Manufacturer + " " + Model;
string id = string.IsNullOrWhiteSpace(openRGBDevice.Serial) ? openRGBDevice.Location : openRGBDevice.Serial;
if (string.IsNullOrWhiteSpace(id)) // this device is 99% unpluggable
{
DeviceName = IdGenerator.MakeUnique(typeof(OpenRGBDeviceProvider), Manufacturer + " " + Model);
}
else
{
DeviceName = model + " #" + Helper.HashAndShorten(id) + (splitId != null ? $" {splitId}" : null);
}
}
#endregion
}