diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 701788f..7415ba2 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -12,12 +12,16 @@ namespace RGB.NET.Core /// /// Represents a generic RGB-device /// - public abstract class AbstractRGBDevice : AbstractBindable, IRGBDevice + public abstract class AbstractRGBDevice : AbstractBindable, IRGBDevice + where TDeviceInfo : IRGBDeviceInfo { #region Properties & Fields /// - public abstract IRGBDeviceInfo DeviceInfo { get; } + public abstract TDeviceInfo DeviceInfo { get; } + + /// + IRGBDeviceInfo IRGBDevice.DeviceInfo => DeviceInfo; /// public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0); @@ -137,20 +141,14 @@ namespace RGB.NET.Core /// Returns an enumerator that iterates over all of the . /// /// An enumerator for all of the . - public IEnumerator GetEnumerator() - { - return LedMapping.Values.GetEnumerator(); - } + public IEnumerator GetEnumerator() => LedMapping.Values.GetEnumerator(); /// /// /// Returns an enumerator that iterates over all of the . /// /// An enumerator for all of the . - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } + IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); #endregion diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs index 216dc4e..30777f6 100644 --- a/RGB.NET.Core/Devices/IRGBDevice.cs +++ b/RGB.NET.Core/Devices/IRGBDevice.cs @@ -5,7 +5,7 @@ namespace RGB.NET.Core { /// /// - /// Represents a generic RGB-device + /// Represents a generic RGB-device. /// public interface IRGBDevice : IEnumerable, IBindable, IDisposable { @@ -79,4 +79,17 @@ namespace RGB.NET.Core #endregion } + + /// + /// + /// Represents a generic RGB-device with an known device-info type. + /// + public interface IRGBDevice : IRGBDevice + where TDeviceInfo : IRGBDeviceInfo + { + /// + /// Gets generic information about the . + /// + new TDeviceInfo DeviceInfo { get; } + } } diff --git a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs index b764395..550e803 100644 --- a/RGB.NET.Devices.Asus/AsusDeviceProvider.cs +++ b/RGB.NET.Devices.Asus/AsusDeviceProvider.cs @@ -109,8 +109,7 @@ namespace RGB.NET.Devices.Asus { IntPtr handle = Marshal.ReadIntPtr(mainboardHandles, i); _AsusSDK.SetMbMode(handle, 1); - AsusMainboardRGBDevice device = - new AsusMainboardRGBDevice(new AsusMainboardRGBDeviceInfo(RGBDeviceType.Mainboard, handle)); + AsusMainboardRGBDevice device = new AsusMainboardRGBDevice(new AsusMainboardRGBDeviceInfo(RGBDeviceType.Mainboard, handle)); device.Initialize(); devices.Add(device); } diff --git a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs index 6ca6546..fcc1138 100644 --- a/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Generic/AsusRGBDevice.cs @@ -12,7 +12,8 @@ namespace RGB.NET.Devices.Asus /// /// Represents a generic Asus-device. (keyboard, mouse, headset, mousepad). /// - public abstract class AsusRGBDevice : AbstractRGBDevice + public abstract class AsusRGBDevice : AbstractRGBDevice, IAsusRGBDevice + where TDeviceInfo : AsusRGBDeviceInfo { #region Properties & Fields @@ -25,17 +26,17 @@ namespace RGB.NET.Devices.Asus /// /// Gets information about the . /// - public override IRGBDeviceInfo DeviceInfo { get; } + public override TDeviceInfo DeviceInfo { get; } #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The generic information provided by Asus for the device. - protected AsusRGBDevice(IRGBDeviceInfo info) + protected AsusRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } @@ -43,11 +44,11 @@ namespace RGB.NET.Devices.Asus #endregion #region Methods - + /// /// Initializes the device. /// - internal void Initialize() + public void Initialize() { InitializeLayout(); diff --git a/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs b/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs new file mode 100644 index 0000000..ea31b62 --- /dev/null +++ b/RGB.NET.Devices.Asus/Generic/IAsusRGBDevice.cs @@ -0,0 +1,12 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.Asus +{ + /// + /// Represents a asus RGB-device. + /// + internal interface IAsusRGBDevice : IRGBDevice + { + void Initialize(); + } +} diff --git a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs index c15301f..bf77de2 100644 --- a/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/GraphicsCard/AsusGraphicsCardRGBDevice.cs @@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus /// /// Represents a Asus graphicsCard. /// - public class AsusGraphicsCardRGBDevice : AsusRGBDevice + public class AsusGraphicsCardRGBDevice : AsusRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public AsusGraphicsCardRGBDeviceInfo GraphicsCardDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus /// The specific information provided by Asus for the graphics card. internal AsusGraphicsCardRGBDevice(AsusGraphicsCardRGBDeviceInfo info) : base(info) - { - this.GraphicsCardDeviceInfo = info; - } + { } #endregion @@ -39,17 +28,17 @@ namespace RGB.NET.Devices.Asus protected override void InitializeLayout() { //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetGPULedCount(GraphicsCardDeviceInfo.Handle); + int ledCount = _AsusSDK.GetGPULedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) InitializeLed(new AsusLedId(this, AsusLedIds.GraphicsCardLed1 + i, 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? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{GraphicsCardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\GraphicsCards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Asus\GraphicsCards")); } /// - protected override void ApplyColorData() => _AsusSDK.SetGPUColor(GraphicsCardDeviceInfo.Handle, ColorData); + protected override void ApplyColorData() => _AsusSDK.SetGPUColor(DeviceInfo.Handle, ColorData); #endregion } diff --git a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs index dc92567..5a17dff 100644 --- a/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Keyboard/AsusKeyboardRGBDevice.cs @@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus /// /// Represents a Asus keyboard. /// - public class AsusKeyboardRGBDevice : AsusRGBDevice + public class AsusKeyboardRGBDevice : AsusRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public AsusKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus /// The specific information provided by Asus for the keyboard. internal AsusKeyboardRGBDevice(AsusKeyboardRGBDeviceInfo info) : base(info) - { - this.KeyboardDeviceInfo = info; - } + { } #endregion @@ -39,17 +28,17 @@ namespace RGB.NET.Devices.Asus protected override void InitializeLayout() { //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetClaymoreKeyboardLedCount(KeyboardDeviceInfo.Handle); + int ledCount = _AsusSDK.GetClaymoreKeyboardLedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) InitializeLed(new AsusLedId(this, AsusLedIds.KeyboardLed1 + i, i), new Rectangle(i * 19, 0, 19, 19)); - string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), - KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Asus\Keyboards")); + string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), + DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Asus\Keyboards")); } /// - protected override void ApplyColorData() => _AsusSDK.SetClaymoreKeyboardColor(KeyboardDeviceInfo.Handle, ColorData); + protected override void ApplyColorData() => _AsusSDK.SetClaymoreKeyboardColor(DeviceInfo.Handle, ColorData); #endregion } diff --git a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs index ca3a6ed..67d0423 100644 --- a/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mainboard/AsusMainboardRGBDevice.cs @@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus /// /// Represents a Asus mainboard. /// - public class AsusMainboardRGBDevice : AsusRGBDevice + public class AsusMainboardRGBDevice : AsusRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public AsusMainboardRGBDeviceInfo MainboardDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus /// The specific information provided by Asus for the mainboard. internal AsusMainboardRGBDevice(AsusMainboardRGBDeviceInfo info) : base(info) - { - this.MainboardDeviceInfo = info; - } + { } #endregion @@ -39,17 +28,17 @@ namespace RGB.NET.Devices.Asus protected override void InitializeLayout() { //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetMbLedCount(MainboardDeviceInfo.Handle); + int ledCount = _AsusSDK.GetMbLedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) InitializeLed(new AsusLedId(this, AsusLedIds.MainboardAudio1 + i, 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? - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{MainboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mainboards\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Asus\Mainboards")); } /// - protected override void ApplyColorData() => _AsusSDK.SetMbColor(MainboardDeviceInfo.Handle, ColorData); + protected override void ApplyColorData() => _AsusSDK.SetMbColor(DeviceInfo.Handle, ColorData); #endregion } diff --git a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs index 369d267..d83963e 100644 --- a/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs +++ b/RGB.NET.Devices.Asus/Mouse/AsusMouseRGBDevice.cs @@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Asus /// /// Represents a Asus mouse. /// - public class AsusMouseRGBDevice : AsusRGBDevice + public class AsusMouseRGBDevice : AsusRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public AsusMouseRGBDeviceInfo MouseDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Asus /// The specific information provided by Asus for the mouse. internal AsusMouseRGBDevice(AsusMouseRGBDeviceInfo info) : base(info) - { - this.MouseDeviceInfo = info; - } + { } #endregion @@ -39,16 +28,16 @@ namespace RGB.NET.Devices.Asus protected override void InitializeLayout() { //TODO DarthAffe 07.10.2017: Look for a good default layout - int ledCount = _AsusSDK.GetRogMouseLedCount(MouseDeviceInfo.Handle); + int ledCount = _AsusSDK.GetRogMouseLedCount(DeviceInfo.Handle); for (int i = 0; i < ledCount; i++) InitializeLed(new AsusLedId(this, AsusLedIds.MouseLed1 + i, i), new Rectangle(i * 10, 0, 10, 10)); - - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{MouseDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Asus\Mouses\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Asus\Mouses")); } /// - protected override void ApplyColorData() => _AsusSDK.SetRogMouseColor(MouseDeviceInfo.Handle, ColorData); + protected override void ApplyColorData() => _AsusSDK.SetRogMouseColor(DeviceInfo.Handle, ColorData); #endregion } diff --git a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj index c5c8c5e..cde110d 100644 --- a/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj +++ b/RGB.NET.Devices.Asus/RGB.NET.Devices.Asus.csproj @@ -54,6 +54,7 @@ + diff --git a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs index 3e70d53..b6151c1 100644 --- a/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs +++ b/RGB.NET.Devices.CoolerMaster/CoolerMasterDeviceProvider.cs @@ -101,7 +101,7 @@ namespace RGB.NET.Devices.CoolerMaster _CoolerMasterSDK.SetControlDevice(index); if (_CoolerMasterSDK.IsDevicePlugged()) { - CoolerMasterRGBDevice device; + ICoolerMasterRGBDevice device; switch (index.GetDeviceType()) { case RGBDeviceType.Keyboard: diff --git a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs index e6ba06b..8a5415a 100644 --- a/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Generic/CoolerMasterRGBDevice.cs @@ -12,24 +12,25 @@ namespace RGB.NET.Devices.CoolerMaster /// /// Represents a generic CoolerMaster-device. (keyboard, mouse, headset, mousepad). /// - public abstract class CoolerMasterRGBDevice : AbstractRGBDevice + public abstract class CoolerMasterRGBDevice : AbstractRGBDevice, ICoolerMasterRGBDevice + where TDeviceInfo : CoolerMasterRGBDeviceInfo { #region Properties & Fields /// /// /// Gets information about the . /// - public override IRGBDeviceInfo DeviceInfo { get; } + public override TDeviceInfo DeviceInfo { get; } #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The generic information provided by CoolerMaster for the device. - protected CoolerMasterRGBDevice(IRGBDeviceInfo info) + protected CoolerMasterRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } @@ -42,7 +43,7 @@ namespace RGB.NET.Devices.CoolerMaster /// /// Initializes the device. /// - internal void Initialize() + public void Initialize() { InitializeLayout(); @@ -105,7 +106,7 @@ namespace RGB.NET.Devices.CoolerMaster if (leds.Count > 0) { - _CoolerMasterSDK.SetControlDevice(((CoolerMasterRGBDeviceInfo)DeviceInfo).DeviceIndex); + _CoolerMasterSDK.SetControlDevice(DeviceInfo.DeviceIndex); foreach (Led led in leds) { @@ -120,7 +121,7 @@ namespace RGB.NET.Devices.CoolerMaster /// public override void Dispose() { - _CoolerMasterSDK.SetControlDevice(((CoolerMasterRGBDeviceInfo)DeviceInfo).DeviceIndex); + _CoolerMasterSDK.SetControlDevice(DeviceInfo.DeviceIndex); _CoolerMasterSDK.EnableLedControl(false); base.Dispose(); diff --git a/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs new file mode 100644 index 0000000..cf33e57 --- /dev/null +++ b/RGB.NET.Devices.CoolerMaster/Generic/ICoolerMasterRGBDevice.cs @@ -0,0 +1,12 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.CoolerMaster +{ + /// + /// Represents a CoolerMaster RGB-device. + /// + internal interface ICoolerMasterRGBDevice : IRGBDevice + { + void Initialize(); + } +} diff --git a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs index 6280689..423486c 100644 --- a/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.CoolerMaster/Keyboard/CoolerMasterKeyboardRGBDevice.cs @@ -8,17 +8,8 @@ namespace RGB.NET.Devices.CoolerMaster /// /// Represents a CoolerMaster keyboard. /// - public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice + public class CoolerMasterKeyboardRGBDevice : CoolerMasterRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public CoolerMasterKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -28,9 +19,7 @@ namespace RGB.NET.Devices.CoolerMaster /// The specific information provided by CoolerMaster for the keyboard internal CoolerMasterKeyboardRGBDevice(CoolerMasterKeyboardRGBDeviceInfo info) : base(info) - { - this.KeyboardDeviceInfo = info; - } + { } #endregion @@ -39,16 +28,16 @@ namespace RGB.NET.Devices.CoolerMaster /// protected override void InitializeLayout() { - Dictionary> mapping = CoolerMasterKeyboardLedMappings.Mapping[KeyboardDeviceInfo.DeviceIndex][KeyboardDeviceInfo.PhysicalLayout]; + Dictionary> mapping = CoolerMasterKeyboardLedMappings.Mapping[DeviceInfo.DeviceIndex][DeviceInfo.PhysicalLayout]; foreach (KeyValuePair> led in mapping) InitializeLed(new CoolerMasterLedId(this, led.Key, led.Value.Item1, led.Value.Item2), new Rectangle(led.Value.Item2 * 19, led.Value.Item1 * 19, 19, 19)); - string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); + string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( - $@"Layouts\CoolerMaster\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), - KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\CoolerMaster\Keyboards")); + $@"Layouts\CoolerMaster\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), + DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\CoolerMaster\Keyboards")); } #endregion diff --git a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj index 0220975..eb43d97 100644 --- a/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj +++ b/RGB.NET.Devices.CoolerMaster/RGB.NET.Devices.CoolerMaster.csproj @@ -56,6 +56,7 @@ + diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 6307d47..b0670fb 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -129,7 +129,7 @@ namespace RGB.NET.Devices.Corsair if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting)) continue; // Everything that doesn't support lighting control is useless - CorsairRGBDevice device; + ICorsairRGBDevice device; switch (info.CorsairDeviceType) { case CorsairDeviceType.Keyboard: @@ -178,7 +178,7 @@ namespace RGB.NET.Devices.Corsair return true; } - private void AddSpecialParts(CorsairRGBDevice device) + private void AddSpecialParts(ICorsairRGBDevice device) { if (device.DeviceInfo.Model.Equals("K95 RGB Platinum", StringComparison.OrdinalIgnoreCase)) device.AddSpecialDevicePart(new LightbarSpecialPart(device)); diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index 8724c6a..3f35dac 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -13,7 +13,8 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a generic CUE-device. (keyboard, mouse, headset, mousepad). /// - public abstract class CorsairRGBDevice : AbstractRGBDevice + public abstract class CorsairRGBDevice : AbstractRGBDevice, ICorsairRGBDevice + where TDeviceInfo : CorsairRGBDeviceInfo { #region Properties & Fields @@ -21,17 +22,17 @@ namespace RGB.NET.Devices.Corsair /// /// Gets information about the . /// - public override IRGBDeviceInfo DeviceInfo { get; } + public override TDeviceInfo DeviceInfo { get; } #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The generic information provided by CUE for the device. - protected CorsairRGBDevice(IRGBDeviceInfo info) + protected CorsairRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } @@ -43,7 +44,7 @@ namespace RGB.NET.Devices.Corsair /// /// Initializes the device. /// - internal void Initialize() + public void Initialize() { InitializeLayout(); diff --git a/RGB.NET.Devices.Corsair/Generic/ICorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/ICorsairRGBDevice.cs new file mode 100644 index 0000000..fbc9254 --- /dev/null +++ b/RGB.NET.Devices.Corsair/Generic/ICorsairRGBDevice.cs @@ -0,0 +1,12 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.Corsair +{ + /// + /// Represents a corsair RGB-device. + /// + internal interface ICorsairRGBDevice : IRGBDevice + { + void Initialize(); + } +} diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index 7578f31..da46ae5 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -9,17 +9,8 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a corsair headset. /// - public class CorsairHeadsetRGBDevice : CorsairRGBDevice + public class CorsairHeadsetRGBDevice : CorsairRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public CorsairHeadsetRGBDeviceInfo HeadsetDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -29,9 +20,7 @@ namespace RGB.NET.Devices.Corsair /// The specific information provided by CUE for the headset internal CorsairHeadsetRGBDevice(CorsairHeadsetRGBDeviceInfo info) : base(info) - { - this.HeadsetDeviceInfo = info; - } + { } #endregion @@ -43,7 +32,7 @@ namespace RGB.NET.Devices.Corsair InitializeLed(new CorsairLedId(this, CorsairLedIds.LeftLogo), new Rectangle(0, 0, 10, 10)); InitializeLed(new CorsairLedId(this, CorsairLedIds.RightLogo), new Rectangle(10, 0, 10, 10)); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{HeadsetDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Headsets\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\Headsets")); } diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index c7daaeb..0fcafa5 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -12,17 +12,8 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a corsair keyboard. /// - public class CorsairKeyboardRGBDevice : CorsairRGBDevice + public class CorsairKeyboardRGBDevice : CorsairRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public CorsairKeyboardRGBDeviceInfo KeyboardDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -32,9 +23,7 @@ namespace RGB.NET.Devices.Corsair /// The specific information provided by CUE for the keyboard internal CorsairKeyboardRGBDevice(CorsairKeyboardRGBDeviceInfo info) : base(info) - { - this.KeyboardDeviceInfo = info; - } + { } #endregion @@ -58,10 +47,10 @@ namespace RGB.NET.Devices.Corsair ptr = new IntPtr(ptr.ToInt64() + structSize); } - string model = KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); + string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( - $@"Layouts\Corsair\Keyboards\{model}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), - KeyboardDeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards")); + $@"Layouts\Corsair\Keyboards\{model}\{DeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml"), + DeviceInfo.LogicalLayout.ToString(), PathHelper.GetAbsolutePath(@"Images\Corsair\Keyboards")); } #endregion diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index f6aedd4..a56af7d 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -10,17 +10,8 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a corsair mouse. /// - public class CorsairMouseRGBDevice : CorsairRGBDevice + public class CorsairMouseRGBDevice : CorsairRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public CorsairMouseRGBDeviceInfo MouseDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -30,9 +21,7 @@ namespace RGB.NET.Devices.Corsair /// The specific information provided by CUE for the mouse internal CorsairMouseRGBDevice(CorsairMouseRGBDeviceInfo info) : base(info) - { - this.MouseDeviceInfo = info; - } + { } #endregion @@ -41,7 +30,7 @@ namespace RGB.NET.Devices.Corsair /// protected override void InitializeLayout() { - switch (MouseDeviceInfo.PhysicalLayout) + switch (DeviceInfo.PhysicalLayout) { case CorsairPhysicalMouseLayout.Zones1: InitializeLed(new CorsairLedId(this, CorsairLedIds.B1), new Rectangle(0, 0, 10, 10)); @@ -62,10 +51,10 @@ namespace RGB.NET.Devices.Corsair InitializeLed(new CorsairLedId(this, CorsairLedIds.B4), new Rectangle(30, 0, 10, 10)); break; default: - throw new RGBDeviceException($"Can't initial mouse with layout '{MouseDeviceInfo.PhysicalLayout}'"); + throw new RGBDeviceException($"Can't initial mouse with layout '{DeviceInfo.PhysicalLayout}'"); } - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{MouseDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mice\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mice")); } diff --git a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs index 6c4cf59..f6474f0 100644 --- a/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousepad/CorsairMousepadRGBDevice.cs @@ -14,17 +14,8 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a corsair mousepad. /// - public class CorsairMousepadRGBDevice : CorsairRGBDevice + public class CorsairMousepadRGBDevice : CorsairRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public CorsairMousepadRGBDeviceInfo MousepadDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -34,9 +25,7 @@ namespace RGB.NET.Devices.Corsair /// The specific information provided by CUE for the mousepad internal CorsairMousepadRGBDevice(CorsairMousepadRGBDeviceInfo info) : base(info) - { - this.MousepadDeviceInfo = info; - } + { } #endregion @@ -47,7 +36,7 @@ namespace RGB.NET.Devices.Corsair { _CorsairLedPositions nativeLedPositions = (_CorsairLedPositions) - Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(MousepadDeviceInfo.CorsairDeviceIndex), + Marshal.PtrToStructure(_CUESDK.CorsairGetLedPositionsByDeviceIndex(DeviceInfo.CorsairDeviceIndex), typeof(_CorsairLedPositions)); int structSize = Marshal.SizeOf(typeof(_CorsairLedPosition)); @@ -65,7 +54,7 @@ namespace RGB.NET.Devices.Corsair InitializeLed(new CorsairLedId(this, ledPosition.ledId), new Rectangle(ledPosition.left, ledPosition.top, ledPosition.width, ledPosition.height)); - ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{MousepadDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), + ApplyLayoutFromFile(PathHelper.GetAbsolutePath($@"Layouts\Corsair\Mousepads\{DeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}.xml"), null, PathHelper.GetAbsolutePath(@"Images\Corsair\Mousepads")); } diff --git a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj index 558c4a5..6f48b40 100644 --- a/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj +++ b/RGB.NET.Devices.Corsair/RGB.NET.Devices.Corsair.csproj @@ -59,6 +59,7 @@ + diff --git a/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs b/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs new file mode 100644 index 0000000..d8f3154 --- /dev/null +++ b/RGB.NET.Devices.Logitech/Generic/ILogitechRGBDevice.cs @@ -0,0 +1,12 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.Logitech +{ + /// + /// Represents a logitech RGB-device. + /// + internal interface ILogitechRGBDevice : IRGBDevice + { + void Initialize(); + } +} diff --git a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs index d548a0b..a93b0b3 100644 --- a/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/Generic/LogitechRGBDevice.cs @@ -10,7 +10,8 @@ namespace RGB.NET.Devices.Logitech /// /// Represents a generic Logitech-device. (keyboard, mouse, headset, mousepad). /// - public abstract class LogitechRGBDevice : AbstractRGBDevice + public abstract class LogitechRGBDevice : AbstractRGBDevice, ILogitechRGBDevice + where TDeviceInfo : LogitechRGBDeviceInfo { #region Properties & Fields @@ -18,17 +19,17 @@ namespace RGB.NET.Devices.Logitech /// /// Gets information about the . /// - public override IRGBDeviceInfo DeviceInfo { get; } + public override TDeviceInfo DeviceInfo { get; } #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The generic information provided by Logitech for the device. - protected LogitechRGBDevice(IRGBDeviceInfo info) + protected LogitechRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } @@ -40,7 +41,7 @@ namespace RGB.NET.Devices.Logitech /// /// Initializes the device. /// - internal void Initialize() + public void Initialize() { InitializeLayout(); diff --git a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs index 2240ad1..295f2c9 100644 --- a/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs +++ b/RGB.NET.Devices.Logitech/LogitechDeviceProvider.cs @@ -101,7 +101,7 @@ namespace RGB.NET.Devices.Logitech if (DeviceChecker.IsPerKeyDeviceConnected) { (string model, RGBDeviceType deviceType, int _, string imageBasePath, string imageLayout, string layoutPath) = DeviceChecker.PerKeyDeviceData; - LogitechRGBDevice device = new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.PerKeyRGB, imageBasePath, imageLayout, layoutPath)); + ILogitechRGBDevice device = new LogitechPerKeyRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.PerKeyRGB, imageBasePath, imageLayout, layoutPath)); device.Initialize(); devices.Add(device); } @@ -113,7 +113,7 @@ namespace RGB.NET.Devices.Logitech if (DeviceChecker.IsPerDeviceDeviceConnected) { (string model, RGBDeviceType deviceType, int _, string imageBasePath, string imageLayout, string layoutPath) = DeviceChecker.PerDeviceDeviceData; - LogitechRGBDevice device = new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.DeviceRGB, imageBasePath, imageLayout, layoutPath)); + ILogitechRGBDevice device = new LogitechPerDeviceRGBDevice(new LogitechRGBDeviceInfo(deviceType, model, LogitechDeviceCaps.DeviceRGB, imageBasePath, imageLayout, layoutPath)); device.Initialize(); devices.Add(device); } diff --git a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs index 4f132ae..7dea9df 100644 --- a/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerDevice/LogitechPerDeviceRGBDevice.cs @@ -10,17 +10,8 @@ namespace RGB.NET.Devices.Logitech /// /// Represents a logitech per-device-lightable device. /// - public class LogitechPerDeviceRGBDevice : LogitechRGBDevice + public class LogitechPerDeviceRGBDevice : LogitechRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public LogitechRGBDeviceInfo PerDeviceDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -30,9 +21,7 @@ namespace RGB.NET.Devices.Logitech /// The specific information provided by logitech for the per-device-lightable device internal LogitechPerDeviceRGBDevice(LogitechRGBDeviceInfo info) : base(info) - { - this.PerDeviceDeviceInfo = info; - } + { } #endregion diff --git a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs index ffbdc72..256c6ed 100644 --- a/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs +++ b/RGB.NET.Devices.Logitech/PerKey/LogitechPerKeyRGBDevice.cs @@ -10,17 +10,8 @@ namespace RGB.NET.Devices.Logitech /// /// Represents a logitech per-key-lightable device. /// - public class LogitechPerKeyRGBDevice : LogitechRGBDevice + public class LogitechPerKeyRGBDevice : LogitechRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public LogitechRGBDeviceInfo PerKeyDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -30,9 +21,7 @@ namespace RGB.NET.Devices.Logitech /// The specific information provided by logitech for the per-key-lightable device internal LogitechPerKeyRGBDevice(LogitechRGBDeviceInfo info) : base(info) - { - this.PerKeyDeviceInfo = info; - } + { } #endregion diff --git a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj index aeeca58..3f81a26 100644 --- a/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj +++ b/RGB.NET.Devices.Logitech/RGB.NET.Devices.Logitech.csproj @@ -53,6 +53,7 @@ + diff --git a/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs new file mode 100644 index 0000000..f8b35a8 --- /dev/null +++ b/RGB.NET.Devices.Msi/Generic/IMsiRGBDevice.cs @@ -0,0 +1,12 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.Msi +{ + /// + /// Represents a msi RGB-device. + /// + internal interface IMsiRGBDevice : IRGBDevice + { + void Initialize(); + } +} diff --git a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs index ad8a25f..4ec4ad2 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiRGBDevice.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Core.Layout; using RGB.NET.Devices.Msi.Native; @@ -13,7 +12,8 @@ namespace RGB.NET.Devices.Msi /// /// Represents a generic Msi-device. (keyboard, mouse, headset, mousepad). /// - public abstract class MsiRGBDevice : AbstractRGBDevice + public abstract class MsiRGBDevice : AbstractRGBDevice, IMsiRGBDevice + where TDeviceInfo : MsiRGBDeviceInfo { #region Properties & Fields @@ -21,17 +21,17 @@ namespace RGB.NET.Devices.Msi /// /// Gets information about the . /// - public override IRGBDeviceInfo DeviceInfo { get; } + public override TDeviceInfo DeviceInfo { get; } #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The generic information provided by Msi for the device. - protected MsiRGBDevice(IRGBDeviceInfo info) + protected MsiRGBDevice(TDeviceInfo info) { this.DeviceInfo = info; } @@ -43,7 +43,7 @@ namespace RGB.NET.Devices.Msi /// /// Initializes the device. /// - internal void Initialize() + public void Initialize() { InitializeLayout(); @@ -106,7 +106,7 @@ namespace RGB.NET.Devices.Msi if (leds.Count > 0) { - string deviceType = ((MsiRGBDeviceInfo)DeviceInfo).MsiDeviceType; + string deviceType = DeviceInfo.MsiDeviceType; foreach (Led led in leds) _MsiSDK.SetLedColor(deviceType, ((MsiLedId)led.Id).Index, led.Color.R, led.Color.G, led.Color.B); } diff --git a/RGB.NET.Devices.Msi/Generic/MsiRGBDeviceInfo.cs b/RGB.NET.Devices.Msi/Generic/MsiRGBDeviceInfo.cs index 7ce90fc..89b12e0 100644 --- a/RGB.NET.Devices.Msi/Generic/MsiRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Msi/Generic/MsiRGBDeviceInfo.cs @@ -14,6 +14,9 @@ namespace RGB.NET.Devices.Msi /// public RGBDeviceType DeviceType { get; } + /// + /// Gets the internal type of the . + /// public string MsiDeviceType { get; } /// diff --git a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj index 1cca868..b94243b 100644 --- a/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj +++ b/RGB.NET.Devices.Msi/RGB.NET.Devices.Msi.csproj @@ -47,6 +47,7 @@ + diff --git a/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs new file mode 100644 index 0000000..cde5132 --- /dev/null +++ b/RGB.NET.Devices.Novation/Generic/INovationRGBDevice.cs @@ -0,0 +1,12 @@ +using RGB.NET.Core; + +namespace RGB.NET.Devices.Novation +{ + /// + /// Represents a novation RGB-device. + /// + internal interface INovationRGBDevice : IRGBDevice + { + void Initialize(); + } +} diff --git a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs index 2185923..11f3ef9 100644 --- a/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Generic/NovationRGBDevice.cs @@ -12,30 +12,31 @@ namespace RGB.NET.Devices.Novation /// /// Represents a generic Novation-device. (launchpad). /// - public abstract class NovationRGBDevice : AbstractRGBDevice + public abstract class NovationRGBDevice : AbstractRGBDevice, INovationRGBDevice + where TDeviceInfo : NovationRGBDeviceInfo { #region Properties & Fields private readonly OutputDevice _outputDevice; - private readonly NovationRGBDeviceInfo _deviceInfo; + private readonly TDeviceInfo _deviceInfo; /// /// /// Gets information about the . /// - public override IRGBDeviceInfo DeviceInfo => _deviceInfo; + public override TDeviceInfo DeviceInfo => _deviceInfo; #endregion #region Constructors /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// The generic information provided by Novation for the device. - protected NovationRGBDevice(NovationRGBDeviceInfo info) + protected NovationRGBDevice(TDeviceInfo info) { - _deviceInfo = info; + this._deviceInfo = info; _outputDevice = new OutputDevice(info.DeviceId); } @@ -48,7 +49,7 @@ namespace RGB.NET.Devices.Novation /// /// Initializes the device. /// - internal void Initialize() + public void Initialize() { InitializeLayout(); @@ -123,12 +124,12 @@ namespace RGB.NET.Devices.Novation } /// - /// Resets the back top default. + /// Resets the back top default. /// public virtual void Reset() => SendMessage(0xB0, 0, 0); /// - /// Convert a to its novation-representation depending on the of the . + /// Convert a to its novation-representation depending on the of the . /// /// The to convert. /// The novation-representation of the . @@ -146,7 +147,7 @@ namespace RGB.NET.Devices.Novation } /// - /// Convert a to its novation-representation depending on the of the . + /// Convert a to its novation-representation depending on the of the . /// The conversion uses the full rgb-range. /// /// The to convert. @@ -158,7 +159,7 @@ namespace RGB.NET.Devices.Novation } /// - /// Convert a to its novation-representation depending on the of the . + /// Convert a to its novation-representation depending on the of the . /// The conversion uses only a limited amount of colors (3 red, 3 yellow, 3 green). /// /// The to convert. @@ -178,7 +179,7 @@ namespace RGB.NET.Devices.Novation } /// - /// Sends a message to the . + /// Sends a message to the . /// /// The status-code of the message. /// The first data-package of the message. diff --git a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs index fd4d576..e17c4ba 100644 --- a/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs +++ b/RGB.NET.Devices.Novation/Launchpad/NovationLaunchpadRGBDevice.cs @@ -7,17 +7,8 @@ namespace RGB.NET.Devices.Novation /// /// Represents a Novation launchpad. /// - public class NovationLaunchpadRGBDevice : NovationRGBDevice + public class NovationLaunchpadRGBDevice : NovationRGBDevice { - #region Properties & Fields - - /// - /// Gets information about the . - /// - public NovationLaunchpadRGBDeviceInfo LaunchpadDeviceInfo { get; } - - #endregion - #region Constructors /// @@ -27,9 +18,7 @@ namespace RGB.NET.Devices.Novation /// The specific information provided by Novation for the launchpad internal NovationLaunchpadRGBDevice(NovationLaunchpadRGBDeviceInfo info) : base(info) - { - this.LaunchpadDeviceInfo = info; - } + { } #endregion @@ -54,7 +43,7 @@ namespace RGB.NET.Devices.Novation InitializeLed(new NovationLedId(this, ledId), rectangle); } - string model = LaunchpadDeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); + string model = DeviceInfo.Model.Replace(" ", string.Empty).ToUpper(); ApplyLayoutFromFile(PathHelper.GetAbsolutePath( $@"Layouts\Novation\Launchpads\{model.ToUpper()}.xml"), "Default", PathHelper.GetAbsolutePath(@"Images\Novation\Launchpads")); } diff --git a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs index c1297ff..b560056 100644 --- a/RGB.NET.Devices.Novation/NovationDeviceProvider.cs +++ b/RGB.NET.Devices.Novation/NovationDeviceProvider.cs @@ -79,7 +79,7 @@ namespace RGB.NET.Devices.Novation if (deviceId == null) continue; - NovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability())); + INovationRGBDevice device = new NovationLaunchpadRGBDevice(new NovationLaunchpadRGBDeviceInfo(outCaps.name, index, deviceId.GetColorCapability())); device.Initialize(); devices.Add(device); } diff --git a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj index 92a372d..b137d3f 100644 --- a/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj +++ b/RGB.NET.Devices.Novation/RGB.NET.Devices.Novation.csproj @@ -59,6 +59,7 @@ +