1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Updated Layouts to contain device-image infos

This commit is contained in:
Darth Affe 2018-01-17 21:56:01 +01:00
parent 6fe54bd3ec
commit 739fbf8733
64 changed files with 143 additions and 185 deletions

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -16,7 +16,7 @@ namespace RGB.NET.Core
/// Represents a generic RGB-device /// Represents a generic RGB-device
/// </summary> /// </summary>
public abstract class AbstractRGBDevice<TDeviceInfo> : AbstractBindable, IRGBDevice<TDeviceInfo> public abstract class AbstractRGBDevice<TDeviceInfo> : AbstractBindable, IRGBDevice<TDeviceInfo>
where TDeviceInfo : IRGBDeviceInfo where TDeviceInfo : class, IRGBDeviceInfo
{ {
#region Properties & Fields #region Properties & Fields
@ -130,13 +130,16 @@ namespace RGB.NET.Core
/// </summary> /// </summary>
/// <param name="layoutPath">The file containing the layout.</param> /// <param name="layoutPath">The file containing the layout.</param>
/// <param name="imageLayout">The name of the layout used to get the images of the leds.</param> /// <param name="imageLayout">The name of the layout used to get the images of the leds.</param>
/// <param name="imageBasePath">The path images for this device are collected in.</param>
/// <param name="createMissingLeds">If set to true a new led is initialized for every id in the layout if it doesn't already exist.</param> /// <param name="createMissingLeds">If set to true a new led is initialized for every id in the layout if it doesn't already exist.</param>
protected virtual void ApplyLayoutFromFile(string layoutPath, string imageLayout, string imageBasePath, bool createMissingLeds = false) protected virtual DeviceLayout ApplyLayoutFromFile(string layoutPath, string imageLayout, bool createMissingLeds = false)
{ {
DeviceLayout layout = DeviceLayout.Load(layoutPath); DeviceLayout layout = DeviceLayout.Load(layoutPath);
if (layout != null) if (layout != null)
{ {
string imageBasePath = string.IsNullOrWhiteSpace(layout.ImageBasePath) ? null : PathHelper.GetAbsolutePath(layout.ImageBasePath);
if ((imageBasePath != null) && !string.IsNullOrWhiteSpace(layout.DeviceImage) && (DeviceInfo != null))
DeviceInfo.Image = new Uri(Path.Combine(imageBasePath, layout.DeviceImage), UriKind.Absolute);
LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase)); LedImageLayout ledImageLayout = layout.LedImageLayouts.FirstOrDefault(x => string.Equals(x.Layout, imageLayout, StringComparison.OrdinalIgnoreCase));
Size = new Size(layout.Width, layout.Height); Size = new Size(layout.Width, layout.Height);
@ -158,13 +161,14 @@ namespace RGB.NET.Core
led.ShapeData = layoutLed.ShapeData; led.ShapeData = layoutLed.ShapeData;
LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id);
led.Image = (!string.IsNullOrEmpty(image?.Image)) if ((imageBasePath != null) && !string.IsNullOrEmpty(image?.Image))
? new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute) led.Image = new Uri(Path.Combine(imageBasePath, image.Image), UriKind.Absolute);
: new Uri(Path.Combine(imageBasePath, "Missing.png"), UriKind.Absolute);
} }
} }
} }
} }
return layout;
} }
/// <summary> /// <summary>

View File

@ -37,7 +37,7 @@ namespace RGB.NET.Core
/// <summary> /// <summary>
/// Gets the URI of an image of the <see cref="IRGBDevice"/> or null if there is no image. /// Gets the URI of an image of the <see cref="IRGBDevice"/> or null if there is no image.
/// </summary> /// </summary>
Uri Image { get; } Uri Image { get; set; }
#endregion #endregion
} }

View File

@ -84,6 +84,18 @@ namespace RGB.NET.Core.Layout
[DefaultValue(19.0)] [DefaultValue(19.0)]
public double LedUnitHeight { get; set; } = 19.0; public double LedUnitHeight { get; set; } = 19.0;
/// <summary>
/// The path images for this device are collected in.
/// </summary>
[XmlElement("ImageBasePath")]
public string ImageBasePath { get; set; }
/// <summary>
/// The image file for this device.
/// </summary>
[XmlElement("DeviceImage")]
public string DeviceImage { get; set; }
/// <summary> /// <summary>
/// Gets or sets a list of <see cref="LedLayout"/> representing all the <see cref="Led"/> of the <see cref="DeviceLayout"/>. /// Gets or sets a list of <see cref="LedLayout"/> representing all the <see cref="Led"/> of the <see cref="DeviceLayout"/>.
/// </summary> /// </summary>

View File

@ -26,9 +26,7 @@ namespace RGB.NET.Devices.Asus
/// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param> /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
internal AsusDramRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) internal AsusDramRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle)
: base(deviceType, handle) : base(deviceType, handle)
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Asus\Drams\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -21,7 +21,7 @@ namespace RGB.NET.Devices.Asus
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;

View File

@ -33,8 +33,7 @@ namespace RGB.NET.Devices.Asus
InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10)); InitializeLed(LedId.GraphicsCard1 + i, new Rectangle(i * 10, 0, 10, 10));
//TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images? //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Asus\GraphicsCards"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -26,9 +26,7 @@ namespace RGB.NET.Devices.Asus
/// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param> /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
internal AsusGraphicsCardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) internal AsusGraphicsCardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle)
: base(deviceType, handle) : base(deviceType, handle)
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Asus\GraphicsCards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -33,8 +33,7 @@ namespace RGB.NET.Devices.Asus
InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19)); InitializeLed(LedId.Keyboard_Escape + i, new Rectangle(i * 19, 0, 19, 19));
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString());
DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Asus\Keyboards"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -37,11 +37,9 @@ namespace RGB.NET.Devices.Asus
/// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param> /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
/// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using.</param> /// <param name="culture">The <see cref="T:System.Globalization.CultureInfo" /> of the layout this keyboard is using.</param>
internal AsusKeyboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, CultureInfo culture) internal AsusKeyboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle, CultureInfo culture)
: base(deviceType, handle, "Asus", "Claymore") : base(deviceType, handle, "Claymore")
{ {
SetLayouts(culture.KeyboardLayoutId); SetLayouts(culture.KeyboardLayoutId);
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Asus\Keyboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
} }
#endregion #endregion

View File

@ -9,6 +9,8 @@
<Model>Prime X370-PRO</Model> <Model>Prime X370-PRO</Model>
<Width>252</Width> <Width>252</Width>
<Height>305</Height> <Height>305</Height>
<ImageBasePath>Images\Asus\Mainboards</ImageBasePath>
<DeviceImage>PRIMEX370-PRO.png</DeviceImage>
<Leds> <Leds>
<Led Id="Mainboard1"> <Led Id="Mainboard1">
<X>0</X> <X>0</X>

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -32,9 +32,8 @@ namespace RGB.NET.Devices.Asus
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8)); InitializeLed(LedId.Mainboard1 + i, new Rectangle(i * 40, 0, 40, 8));
//TODO DarthAffe 07.10.2017: We don'T know the model, how to save layouts and images? //TODO DarthAffe 07.10.2017: We don't know the model, how to save layouts and images?
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Asus\Mainboards"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -26,9 +26,7 @@ namespace RGB.NET.Devices.Asus
/// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param> /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
internal AsusMainboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) internal AsusMainboardRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle)
: base(deviceType, handle, WMIHelper.GetMainboardInfo()?.model ?? "Generic Asus-Device") : base(deviceType, handle, WMIHelper.GetMainboardInfo()?.model ?? "Generic Asus-Device")
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Asus\Mainboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -32,8 +32,7 @@ namespace RGB.NET.Devices.Asus
for (int i = 0; i < ledCount; i++) for (int i = 0; i < ledCount; i++)
InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10)); InitializeLed(LedId.Mouse1 + i, new Rectangle(i * 10, 0, 10, 10));
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Asus\Mouses"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -25,10 +25,8 @@ namespace RGB.NET.Devices.Asus
/// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param> /// <param name="deviceType">The type of the <see cref="IRGBDevice"/>.</param>
/// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param> /// <param name="handle">The handle of the <see cref="IRGBDevice"/>.</param>
internal AsusMouseRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle) internal AsusMouseRGBDeviceInfo(RGBDeviceType deviceType, IntPtr handle)
: base(deviceType, handle, "Asus", "Rog") : base(deviceType, handle, "Rog")
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Asus\Mouses\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -121,11 +121,11 @@ namespace RGB.NET.Devices.Asus.Native
private static SetRogMouseModePointer _setRogMouseModePointer; private static SetRogMouseModePointer _setRogMouseModePointer;
private static SetRogMouseColorPointer _setRogMouseColorPointer; private static SetRogMouseColorPointer _setRogMouseColorPointer;
private static EnumerateDramPointer _enumerateDramPointer; //private static EnumerateDramPointer _enumerateDramPointer;
private static SetDramModePointer _setDramModePointer; //private static SetDramModePointer _setDramModePointer;
private static GetDramLedCountPointer _getDramLedCountPointer; //private static GetDramLedCountPointer _getDramLedCountPointer;
private static SetDramColorPointer _setDramColorPointer; //private static SetDramColorPointer _setDramColorPointer;
private static GetDramColorPointer _getDramColorPointer; //private static GetDramColorPointer _getDramColorPointer;
#endregion #endregion
@ -169,16 +169,16 @@ namespace RGB.NET.Devices.Asus.Native
[UnmanagedFunctionPointer(CallingConvention.StdCall)] [UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void SetRogMouseColorPointer(IntPtr handle, byte[] colors, int size); private delegate void SetRogMouseColorPointer(IntPtr handle, byte[] colors, int size);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] //[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int EnumerateDramPointer(IntPtr handles, int size); //private delegate int EnumerateDramPointer(IntPtr handles, int size);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] //[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int GetDramLedCountPointer(IntPtr handle); //private delegate int GetDramLedCountPointer(IntPtr handle);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] //[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void SetDramModePointer(IntPtr handle, int mode); //private delegate void SetDramModePointer(IntPtr handle, int mode);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] //[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void SetDramColorPointer(IntPtr handle, byte[] colors, int size); //private delegate void SetDramColorPointer(IntPtr handle, byte[] colors, int size);
[UnmanagedFunctionPointer(CallingConvention.StdCall)] //[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate int GetDramColorPointer(IntPtr handle, IntPtr colors, int size); //private delegate int GetDramColorPointer(IntPtr handle, IntPtr colors, int size);
#endregion #endregion

View File

@ -22,7 +22,7 @@ namespace RGB.NET.Devices.CoolerMaster
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;

View File

@ -57,8 +57,7 @@ namespace RGB.NET.Devices.CoolerMaster
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
$@"Layouts\CoolerMaster\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), $@"Layouts\CoolerMaster\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString());
DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\CoolerMaster\Keyboards"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,4 @@
using System; using System.Globalization;
using System.Globalization;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.CoolerMaster namespace RGB.NET.Devices.CoolerMaster
@ -39,8 +38,6 @@ namespace RGB.NET.Devices.CoolerMaster
this.PhysicalLayout = physicalKeyboardLayout; this.PhysicalLayout = physicalKeyboardLayout;
SetLayouts(culture.KeyboardLayoutId); SetLayouts(culture.KeyboardLayoutId);
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\CoolerMaster\Keyboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
} }
private void SetLayouts(int keyboardLayoutId) private void SetLayouts(int keyboardLayoutId)

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -33,7 +33,7 @@ namespace RGB.NET.Devices.Corsair
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public bool SupportsSyncBack => true; public bool SupportsSyncBack => true;

View File

@ -32,8 +32,7 @@ namespace RGB.NET.Devices.Corsair
InitializeLed(LedId.Headset1, new Rectangle(0, 0, 10, 10)); InitializeLed(LedId.Headset1, new Rectangle(0, 0, 10, 10));
InitializeLed(LedId.Headset2, new Rectangle(10, 0, 10, 10)); InitializeLed(LedId.Headset2, new Rectangle(10, 0, 10, 10));
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Corsair\Headsets"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,4 @@
using System; using RGB.NET.Core;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native; using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair namespace RGB.NET.Devices.Corsair
@ -20,9 +19,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param> /// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, RGBDeviceType.Headset, nativeInfo) : base(deviceIndex, RGBDeviceType.Headset, nativeInfo)
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Corsair\Headsets\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -51,8 +51,7 @@ namespace RGB.NET.Devices.Corsair
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId))
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\HeadsetStands\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Corsair\HeadsetStands"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,4 @@
using System; using RGB.NET.Core;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native; using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair namespace RGB.NET.Devices.Corsair
@ -20,9 +19,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param> /// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
internal CorsairHeadsetStandRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) internal CorsairHeadsetStandRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, RGBDeviceType.HeadsetStand, nativeInfo) : base(deviceIndex, RGBDeviceType.HeadsetStand, nativeInfo)
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Corsair\HeadsetStands\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -50,8 +50,7 @@ namespace RGB.NET.Devices.Corsair
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath(
$@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), $@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), DeviceInfo.LogicalLayout.ToString());
DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,7 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core; using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native; using RGB.NET.Devices.Corsair.Native;
@ -40,9 +39,6 @@ namespace RGB.NET.Devices.Corsair
{ {
this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout; this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout;
this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout; this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout;
string model = Model.Replace(" ", string.Empty).ToUpper();
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Corsair\Keyboards\{model}.png"), UriKind.Absolute);
} }
#endregion #endregion

View File

@ -9,6 +9,8 @@
<Model>K70 RGB</Model> <Model>K70 RGB</Model>
<Width>436</Width> <Width>436</Width>
<Height>165</Height> <Height>165</Height>
<ImageBasePath>Images\Corsair\Keyboards</ImageBasePath>
<DeviceImage>K70RGB.png</DeviceImage>
<Leds> <Leds>
<!-- Extra-Keys: Brightness -> Mute --> <!-- Extra-Keys: Brightness -> Mute -->
<Led Id="Keyboard_Brightness"> <Led Id="Keyboard_Brightness">

View File

@ -9,6 +9,8 @@
<Model>K95 RGB</Model> <Model>K95 RGB</Model>
<Width>500</Width> <Width>500</Width>
<Height>165</Height> <Height>165</Height>
<ImageBasePath>Images\Corsair\Keyboards</ImageBasePath>
<DeviceImage>K95RGB.png</DeviceImage>
<Leds> <Leds>
<!-- Extra-Keys: MR -> Mute --> <!-- Extra-Keys: MR -> Mute -->
<Led Id="Keyboard_MacroRecording"> <Led Id="Keyboard_MacroRecording">

View File

@ -9,6 +9,8 @@
<Model>K95 RGB Platinum</Model> <Model>K95 RGB Platinum</Model>
<Width>465</Width> <Width>465</Width>
<Height>169</Height> <Height>169</Height>
<ImageBasePath>Images\Corsair\Keyboards</ImageBasePath>
<DeviceImage>K95RGBPLATINUM.png</DeviceImage>
<Leds> <Leds>
<!-- Extra-Keys: ? -> Mute --> <!-- Extra-Keys: ? -> Mute -->
<Led Id="Keyboard_Brightness"> <Led Id="Keyboard_Brightness">

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -54,8 +54,7 @@ namespace RGB.NET.Devices.Corsair
throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'"); throw new RGBDeviceException($"Can't initialize mouse with layout '{DeviceInfo.PhysicalLayout}'");
} }
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mice"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,4 @@
using System; using RGB.NET.Core;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native; using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair namespace RGB.NET.Devices.Corsair
@ -31,8 +30,6 @@ namespace RGB.NET.Devices.Corsair
: base(deviceIndex, RGBDeviceType.Mouse, nativeInfo) : base(deviceIndex, RGBDeviceType.Mouse, nativeInfo)
{ {
this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout; this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout;
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Corsair\Mice\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
} }
#endregion #endregion

View File

@ -51,8 +51,7 @@ namespace RGB.NET.Devices.Corsair
foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId)) foreach (_CorsairLedPosition ledPosition in positions.OrderBy(p => p.LedId))
InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); InitializeLed(mapping.TryGetValue(ledPosition.LedId, out LedId ledId) ? ledId : LedId.Invalid, new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height));
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null);
null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mousepads"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,4 @@
using System; using RGB.NET.Core;
using RGB.NET.Core;
using RGB.NET.Devices.Corsair.Native; using RGB.NET.Devices.Corsair.Native;
namespace RGB.NET.Devices.Corsair namespace RGB.NET.Devices.Corsair
@ -20,9 +19,7 @@ namespace RGB.NET.Devices.Corsair
/// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param> /// <param name="nativeInfo">The native <see cref="T:RGB.NET.Devices.Corsair.Native._CorsairDeviceInfo" />-struct</param>
internal CorsairMousepadRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) internal CorsairMousepadRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo)
: base(deviceIndex, RGBDeviceType.Mousepad, nativeInfo) : base(deviceIndex, RGBDeviceType.Mousepad, nativeInfo)
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Corsair\Mousepad\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -56,10 +56,9 @@ namespace RGB.NET.Devices.Logitech
protected virtual void InitializeLayout() protected virtual void InitializeLayout()
{ {
if (!(DeviceInfo is LogitechRGBDeviceInfo info)) return; if (!(DeviceInfo is LogitechRGBDeviceInfo info)) return;
string basePath = info.ImageBasePath;
string layout = info.ImageLayout; string layout = info.ImageLayout;
string layoutPath = info.LayoutPath; string layoutPath = info.LayoutPath;
ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, PathHelper.GetAbsolutePath($@"Images\Logitech\{basePath}"), true); ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Logitech\{layoutPath}.xml"), layout, true);
} }
#endregion #endregion

View File

@ -21,7 +21,7 @@ namespace RGB.NET.Devices.Logitech
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting public RGBDeviceLighting Lighting
@ -46,11 +46,6 @@ namespace RGB.NET.Devices.Logitech
/// </summary> /// </summary>
public LogitechDeviceCaps DeviceCaps { get; } public LogitechDeviceCaps DeviceCaps { get; }
/// <summary>
/// Gets the base of the image path used to load device-images.
/// </summary>
internal string ImageBasePath { get; }
/// <summary> /// <summary>
/// Gets the layout used to decide which images to load. /// Gets the layout used to decide which images to load.
/// </summary> /// </summary>
@ -75,16 +70,13 @@ namespace RGB.NET.Devices.Logitech
/// <param name="imageLayout">The layout used to decide which images to load.</param> /// <param name="imageLayout">The layout used to decide which images to load.</param>
/// <param name="layoutPath">The path/name of the layout-file.</param> /// <param name="layoutPath">The path/name of the layout-file.</param>
internal LogitechRGBDeviceInfo(RGBDeviceType deviceType, string model, LogitechDeviceCaps deviceCaps, internal LogitechRGBDeviceInfo(RGBDeviceType deviceType, string model, LogitechDeviceCaps deviceCaps,
string imageBasePath, string imageLayout, string layoutPath) string imageLayout, string layoutPath)
{ {
this.DeviceType = deviceType; this.DeviceType = deviceType;
this.Model = model; this.Model = model;
this.DeviceCaps = deviceCaps; this.DeviceCaps = deviceCaps;
this.ImageBasePath = imageBasePath;
this.ImageLayout = imageLayout; this.ImageLayout = imageLayout;
this.LayoutPath = layoutPath; this.LayoutPath = layoutPath;
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Logitech\{LayoutPath}.png"), UriKind.Absolute);
} }
#endregion #endregion

View File

@ -13,18 +13,18 @@ namespace RGB.NET.Devices.Logitech.HID
private const int VENDOR_ID = 0x046D; private const int VENDOR_ID = 0x046D;
//TODO DarthAffe 14.11.2017: Add devices //TODO DarthAffe 14.11.2017: Add devices
private static readonly List<(string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath)> PER_KEY_DEVICES private static readonly List<(string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath)> PER_KEY_DEVICES
= new List<(string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath)> = new List<(string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath)>
{ {
("G910", RGBDeviceType.Keyboard, 0xC32B, "Keyboards", "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout ("G910", RGBDeviceType.Keyboard, 0xC32B, "DE", @"Keyboards\G910\UK"), //TODO DarthAffe 15.11.2017: Somehow detect the current layout
("G610", RGBDeviceType.Keyboard, 0xC333, "Keyboards", "DE", @"Keyboards\G610\UK"), ("G610", RGBDeviceType.Keyboard, 0xC333, "DE", @"Keyboards\G610\UK"),
}; };
private static readonly List<(string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath)> PER_DEVICE_DEVICES private static readonly List<(string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath)> PER_DEVICE_DEVICES
= new List<(string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath)> = new List<(string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath)>
{ {
("G403", RGBDeviceType.Mouse, 0xC083, "Mice", "default", @"Mice\G403"), ("G403", RGBDeviceType.Mouse, 0xC083, "default", @"Mice\G403"),
("G502", RGBDeviceType.Mouse, 0xC332, "Mice", "default", @"Mice\G502"), ("G502", RGBDeviceType.Mouse, 0xC332, "default", @"Mice\G502"),
}; };
#endregion #endregion
@ -32,10 +32,10 @@ namespace RGB.NET.Devices.Logitech.HID
#region Properties & Fields #region Properties & Fields
public static bool IsPerKeyDeviceConnected { get; private set; } public static bool IsPerKeyDeviceConnected { get; private set; }
public static (string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath) PerKeyDeviceData { get; private set; } public static (string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath) PerKeyDeviceData { get; private set; }
public static bool IsPerDeviceDeviceConnected { get; private set; } public static bool IsPerDeviceDeviceConnected { get; private set; }
public static (string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath) PerDeviceDeviceData { get; private set; } public static (string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath) PerDeviceDeviceData { get; private set; }
#endregion #endregion
@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Logitech.HID
HidDeviceLoader loader = new HidDeviceLoader(); HidDeviceLoader loader = new HidDeviceLoader();
List<int> ids = loader.GetDevices(VENDOR_ID).Select(x => x.ProductID).Distinct().ToList(); List<int> ids = loader.GetDevices(VENDOR_ID).Select(x => x.ProductID).Distinct().ToList();
foreach ((string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath) deviceData in PER_KEY_DEVICES) foreach ((string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath) deviceData in PER_KEY_DEVICES)
if (ids.Contains(deviceData.id)) if (ids.Contains(deviceData.id))
{ {
IsPerKeyDeviceConnected = true; IsPerKeyDeviceConnected = true;
@ -54,7 +54,7 @@ namespace RGB.NET.Devices.Logitech.HID
break; break;
} }
foreach ((string model, RGBDeviceType deviceType, int id, string imageBasePath, string imageLayout, string layoutPath) deviceData in PER_DEVICE_DEVICES) foreach ((string model, RGBDeviceType deviceType, int id, string imageLayout, string layoutPath) deviceData in PER_DEVICE_DEVICES)
if (ids.Contains(deviceData.id)) if (ids.Contains(deviceData.id))
{ {
IsPerDeviceDeviceConnected = true; IsPerDeviceDeviceConnected = true;

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -9,6 +9,8 @@
<Model>G610</Model> <Model>G610</Model>
<Width>442</Width> <Width>442</Width>
<Height>152</Height> <Height>152</Height>
<ImageBasePath>Images\Logitech\Keyboards</ImageBasePath>
<DeviceImage></DeviceImage>
<Leds> <Leds>
<!-- Esc -> Pause --> <!-- Esc -> Pause -->
<Led Id="Keyboard_Escape"> <Led Id="Keyboard_Escape">

View File

@ -9,6 +9,8 @@
<Model>G910</Model> <Model>G910</Model>
<Width>491</Width> <Width>491</Width>
<Height>238</Height> <Height>238</Height>
<ImageBasePath>Images\Logitech\Keyboards</ImageBasePath>
<DeviceImage>G910.png</DeviceImage>
<Leds> <Leds>
<!-- Esc -> Pause --> <!-- Esc -> Pause -->
<Led Id="Keyboard_Escape"> <Led Id="Keyboard_Escape">
@ -367,7 +369,7 @@
<LedImage Id="Keyboard_RightGui" Image="Raptor_Keys\Windows.png" /> <LedImage Id="Keyboard_RightGui" Image="Raptor_Keys\Windows.png" />
<LedImage Id="Keyboard_Application" Image="Raptor_Keys\Menu.png" /> <LedImage Id="Keyboard_Application" Image="Raptor_Keys\Menu.png" />
<LedImage Id="Keyboard_RightCtrl" Image="Raptor_Keys\Strg.png" /> <LedImage Id="Keyboard_RightCtrl" Image="Raptor_Keys\Strg.png" />
<LedImage Id="Keyboard_ArrowLef" Image="Raptor_Keys\CaretLeft.png" /> <LedImage Id="Keyboard_ArrowLeft" Image="Raptor_Keys\CaretLeft.png" />
<LedImage Id="Keyboard_ArrowDown" Image="Raptor_Keys\CaretDown.png" /> <LedImage Id="Keyboard_ArrowDown" Image="Raptor_Keys\CaretDown.png" />
<LedImage Id="Keyboard_ArrowRight" Image="Raptor_Keys\CaretRight.png" /> <LedImage Id="Keyboard_ArrowRight" Image="Raptor_Keys\CaretRight.png" />
<LedImage Id="Keyboard_Num0" Image="Raptor_Keys\Num0_Einfg.png" /> <LedImage Id="Keyboard_Num0" Image="Raptor_Keys\Num0_Einfg.png" />

View File

@ -9,6 +9,8 @@
<Model>G403</Model> <Model>G403</Model>
<Width>67</Width> <Width>67</Width>
<Height>125</Height> <Height>125</Height>
<ImageBasePath>Images\Logitech\Mice</ImageBasePath>
<DeviceImage>G403.png</DeviceImage>
<Leds> <Leds>
<Led Id="Custom1"> <Led Id="Custom1">
<Shape>m 0.7025,0.00275 -0.15,0 -0,0.26 h 0.15 z m -0.16732,0.7925 c -0.7,0.0159 -0.55,0.19383 -0.006236,0.19067 l 0.001707,-0.0416 c -0.425,-0.0115 -0.225,-0.11 0.005116,-0.10 z m 0.410,0.0779 -0.435,0 0,0.0401 0.225,0 0,0.0437 0.21,0 z</Shape> <Shape>m 0.7025,0.00275 -0.15,0 -0,0.26 h 0.15 z m -0.16732,0.7925 c -0.7,0.0159 -0.55,0.19383 -0.006236,0.19067 l 0.001707,-0.0416 c -0.425,-0.0115 -0.225,-0.11 0.005116,-0.10 z m 0.410,0.0779 -0.435,0 0,0.0401 0.225,0 0,0.0437 0.21,0 z</Shape>

View File

@ -100,10 +100,10 @@ namespace RGB.NET.Devices.Logitech
{ {
if (DeviceChecker.IsPerKeyDeviceConnected) if (DeviceChecker.IsPerKeyDeviceConnected)
{ {
(string model, RGBDeviceType deviceType, int _, string imageBasePath, string imageLayout, string layoutPath) = DeviceChecker.PerKeyDeviceData; (string model, RGBDeviceType deviceType, int _, string imageLayout, string layoutPath) = DeviceChecker.PerKeyDeviceData;
if (loadFilter.HasFlag(deviceType)) //TODO DarthAffe 07.12.2017: Check if it's worth to try another device if the one returned doesn't match the filter if (loadFilter.HasFlag(deviceType)) //TODO DarthAffe 07.12.2017: Check if it's worth to try another device if the one returned doesn't match the filter
{ {
ILogitechRGBDevice device = new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.PerKeyRGB, imageBasePath, imageLayout, layoutPath)); ILogitechRGBDevice device = new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.PerKeyRGB, imageLayout, layoutPath));
device.Initialize(); device.Initialize();
devices.Add(device); devices.Add(device);
} }
@ -115,10 +115,10 @@ namespace RGB.NET.Devices.Logitech
{ {
if (DeviceChecker.IsPerDeviceDeviceConnected) if (DeviceChecker.IsPerDeviceDeviceConnected)
{ {
(string model, RGBDeviceType deviceType, int _, string imageBasePath, string imageLayout, string layoutPath) = DeviceChecker.PerDeviceDeviceData; (string model, RGBDeviceType deviceType, int _, string imageLayout, string layoutPath) = DeviceChecker.PerDeviceDeviceData;
if (loadFilter.HasFlag(deviceType)) //TODO DarthAffe 07.12.2017: Check if it's worth to try another device if the one returned doesn't match the filter if (loadFilter.HasFlag(deviceType)) //TODO DarthAffe 07.12.2017: Check if it's worth to try another device if the one returned doesn't match the filter
{ {
ILogitechRGBDevice device = new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.DeviceRGB, imageBasePath, imageLayout, layoutPath)); ILogitechRGBDevice device = new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.DeviceRGB, imageLayout, layoutPath));
device.Initialize(); device.Initialize();
devices.Add(device); devices.Add(device);
} }

View File

@ -26,7 +26,7 @@ namespace RGB.NET.Devices.Msi
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public bool SupportsSyncBack => false; public bool SupportsSyncBack => false;

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -21,7 +21,7 @@ namespace RGB.NET.Devices.Novation
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; public RGBDeviceLighting Lighting => RGBDeviceLighting.Key;

View File

@ -47,8 +47,7 @@ namespace RGB.NET.Devices.Novation
} }
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default");
$@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default", PathHelper.GetAbsolutePath(@"Images\Novation\Launchpads"));
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,4 @@
using System; using RGB.NET.Core;
using RGB.NET.Core;
namespace RGB.NET.Devices.Novation namespace RGB.NET.Devices.Novation
{ {
@ -20,9 +19,7 @@ namespace RGB.NET.Devices.Novation
/// <param name="colorCapabilities">The <see cref="T:RGB.NET.Devices.Novation.NovationColorCapabilities" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.</param> /// <param name="colorCapabilities">The <see cref="T:RGB.NET.Devices.Novation.NovationColorCapabilities" /> of the <see cref="T:RGB.NET.Core.IRGBDevice" />.</param>
internal NovationLaunchpadRGBDeviceInfo(string model, int deviceId, NovationColorCapabilities colorCapabilities) internal NovationLaunchpadRGBDeviceInfo(string model, int deviceId, NovationColorCapabilities colorCapabilities)
: base(RGBDeviceType.LedMatrix, model, deviceId, colorCapabilities) : base(RGBDeviceType.LedMatrix, model, deviceId, colorCapabilities)
{ { }
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Novation\Launchpads\{Model.Replace(" ", string.Empty).ToUpper()}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -11,6 +11,8 @@
<Height>240</Height> <Height>240</Height>
<LedUnitWidth>20</LedUnitWidth> <LedUnitWidth>20</LedUnitWidth>
<LedUnitHeight>20</LedUnitHeight> <LedUnitHeight>20</LedUnitHeight>
<ImageBasePath>Images\Novation\Launchpads</ImageBasePath>
<DeviceImage>LaunchpadS.png</DeviceImage>
<Leds> <Leds>
<!-- Custom-buttons --> <!-- Custom-buttons -->
<Led Id="Custom1"> <Led Id="Custom1">

View File

@ -34,8 +34,7 @@ namespace RGB.NET.Devices.Razer
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\ChromaLink\{model}.xml"), null);
$@"Layouts\Razer\ChromaLink\{model}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Razer\ChromaLink"));
if (LedMapping.Count == 0) if (LedMapping.Count == 0)
for (int i = 0; i < _Defines.CHROMALINK_MAX_LEDS; i++) for (int i = 0; i < _Defines.CHROMALINK_MAX_LEDS; i++)

View File

@ -1,7 +1,4 @@
// ReSharper disable MemberCanBePrivate.Global using System;
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.Razer namespace RGB.NET.Devices.Razer
@ -22,10 +19,7 @@ namespace RGB.NET.Devices.Razer
/// <param name="model">The model of the <see cref="IRGBDevice"/>.</param> /// <param name="model">The model of the <see cref="IRGBDevice"/>.</param>
internal RazerChromaLinkRGBDeviceInfo(Guid deviceId, string model) internal RazerChromaLinkRGBDeviceInfo(Guid deviceId, string model)
: base(deviceId, RGBDeviceType.LedStripe, model) : base(deviceId, RGBDeviceType.LedStripe, model)
{ { }
string modelName = Model.Replace(" ", string.Empty).ToUpper();
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Razer\ChromaLinks\{modelName}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -26,7 +26,7 @@ namespace RGB.NET.Devices.Razer
public string Model { get; } public string Model { get; }
/// <inheritdoc /> /// <inheritdoc />
public Uri Image { get; protected set; } public Uri Image { get; set; }
/// <inheritdoc /> /// <inheritdoc />
public bool SupportsSyncBack => false; public bool SupportsSyncBack => false;

View File

@ -34,8 +34,7 @@ namespace RGB.NET.Devices.Razer
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Headset\{model}.xml"), null);
$@"Layouts\Razer\Headset\{model}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Razer\Headset"));
if (LedMapping.Count == 0) if (LedMapping.Count == 0)
for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++) for (int i = 0; i < _Defines.HEADSET_MAX_LEDS; i++)

View File

@ -1,7 +1,4 @@
// ReSharper disable MemberCanBePrivate.Global using System;
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.Razer namespace RGB.NET.Devices.Razer
@ -22,10 +19,7 @@ namespace RGB.NET.Devices.Razer
/// <param name="model">The model of the <see cref="IRGBDevice"/>.</param> /// <param name="model">The model of the <see cref="IRGBDevice"/>.</param>
internal RazerHeadsetRGBDeviceInfo(Guid deviceId, string model) internal RazerHeadsetRGBDeviceInfo(Guid deviceId, string model)
: base(deviceId, RGBDeviceType.Headset, model) : base(deviceId, RGBDeviceType.Headset, model)
{ { }
string modelName = Model.Replace(" ", string.Empty).ToUpper();
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Razer\Headsets\{modelName}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -40,9 +40,6 @@ namespace RGB.NET.Devices.Razer
: base(deviceId, RGBDeviceType.Keyboard, model) : base(deviceId, RGBDeviceType.Keyboard, model)
{ {
SetLayouts(culture.KeyboardLayoutId); SetLayouts(culture.KeyboardLayoutId);
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Razer\Keyboards\{Model.Replace(" ", string.Empty).ToUpper()}.png"),
UriKind.Absolute);
} }
#endregion #endregion

View File

@ -34,8 +34,7 @@ namespace RGB.NET.Devices.Razer
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Keypad\{model}.xml"), null);
$@"Layouts\Razer\Keypad\{model}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Razer\Keypad"));
if (LedMapping.Count == 0) if (LedMapping.Count == 0)
{ {

View File

@ -1,7 +1,4 @@
// ReSharper disable MemberCanBePrivate.Global using System;
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.Razer namespace RGB.NET.Devices.Razer
@ -22,10 +19,7 @@ namespace RGB.NET.Devices.Razer
/// <param name="model">The model of the <see cref="IRGBDevice"/>.</param> /// <param name="model">The model of the <see cref="IRGBDevice"/>.</param>
internal RazerKeypadRGBDeviceInfo(Guid deviceId, string model) internal RazerKeypadRGBDeviceInfo(Guid deviceId, string model)
: base(deviceId, RGBDeviceType.Keypad, model) : base(deviceId, RGBDeviceType.Keypad, model)
{ { }
string modelName = Model.Replace(" ", string.Empty).ToUpper();
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Razer\Keypads\{modelName}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -13,6 +13,8 @@
<xsd:element name="Shape" type="xsd:string" /> <xsd:element name="Shape" type="xsd:string" />
<xsd:element name="Width" type="xsd:double" /> <xsd:element name="Width" type="xsd:double" />
<xsd:element name="Height" type="xsd:double" /> <xsd:element name="Height" type="xsd:double" />
<xsd:element name="ImageBasePath" type="xsd:string" />
<xsd:element name="DeviceImage" type="xsd:string" />
<xsd:element name="LedUnitWidth" type="xsd:double" /> <xsd:element name="LedUnitWidth" type="xsd:double" />
<xsd:element name="LedUnitHeight" type="xsd:double" /> <xsd:element name="LedUnitHeight" type="xsd:double" />
<xsd:element name="Leds"> <xsd:element name="Leds">

View File

@ -34,8 +34,7 @@ namespace RGB.NET.Devices.Razer
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Mice\{model}.xml"), null);
$@"Layouts\Razer\Mice\{model}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Razer\Mice"));
if (LedMapping.Count == 0) if (LedMapping.Count == 0)
{ {

View File

@ -1,7 +1,4 @@
// ReSharper disable MemberCanBePrivate.Global using System;
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.Razer namespace RGB.NET.Devices.Razer
@ -22,10 +19,7 @@ namespace RGB.NET.Devices.Razer
/// <param name="model">The model of the <see cref="IRGBDevice"/>.</param> /// <param name="model">The model of the <see cref="IRGBDevice"/>.</param>
internal RazerMouseRGBDeviceInfo(Guid deviceId, string model) internal RazerMouseRGBDeviceInfo(Guid deviceId, string model)
: base(deviceId, RGBDeviceType.Mouse, model) : base(deviceId, RGBDeviceType.Mouse, model)
{ { }
string modelName = Model.Replace(" ", string.Empty).ToUpper();
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Razer\Mice\{modelName}.png"), UriKind.Absolute);
}
#endregion #endregion
} }

View File

@ -34,8 +34,7 @@ namespace RGB.NET.Devices.Razer
protected override void InitializeLayout() protected override void InitializeLayout()
{ {
string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper();
ApplyLayoutFromFile(PathHelper.GetAbsolutePath( ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Razer\Mousepad\{model}.xml"), null);
$@"Layouts\Razer\Mousepad\{model}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Razer\Mousepad"));
if (LedMapping.Count == 0) if (LedMapping.Count == 0)
for (int i = 0; i < _Defines.MOUSEPAD_MAX_LEDS; i++) for (int i = 0; i < _Defines.MOUSEPAD_MAX_LEDS; i++)

View File

@ -1,7 +1,4 @@
// ReSharper disable MemberCanBePrivate.Global using System;
// ReSharper disable UnusedMember.Global
using System;
using RGB.NET.Core; using RGB.NET.Core;
namespace RGB.NET.Devices.Razer namespace RGB.NET.Devices.Razer
@ -22,10 +19,7 @@ namespace RGB.NET.Devices.Razer
/// <param name="model">The model of the <see cref="IRGBDevice"/>.</param> /// <param name="model">The model of the <see cref="IRGBDevice"/>.</param>
internal RazerMousepadRGBDeviceInfo(Guid deviceId, string model) internal RazerMousepadRGBDeviceInfo(Guid deviceId, string model)
: base(deviceId, RGBDeviceType.Mousepad, model) : base(deviceId, RGBDeviceType.Mousepad, model)
{ { }
string modelName = Model.Replace(" ", string.Empty).ToUpper();
Image = new Uri(PathHelper.GetAbsolutePath($@"Images\Razer\Mousepads\{modelName}.png"), UriKind.Absolute);
}
#endregion #endregion
} }