diff --git a/RGB.NET.Core/Devices/AbstractRGBDevice.cs b/RGB.NET.Core/Devices/AbstractRGBDevice.cs index 1d8958e..d983043 100644 --- a/RGB.NET.Core/Devices/AbstractRGBDevice.cs +++ b/RGB.NET.Core/Devices/AbstractRGBDevice.cs @@ -1,4 +1,7 @@ -using System.Collections; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System.Collections; using System.Collections.Generic; using System.Linq; @@ -7,7 +10,7 @@ namespace RGB.NET.Core /// /// Represents a generic RGB-device /// - public abstract class AbstractRGBDevice : IRGBDevice + public abstract class AbstractRGBDevice : AbstractBindable, IRGBDevice { #region Properties & Fields @@ -15,7 +18,20 @@ namespace RGB.NET.Core public abstract IRGBDeviceInfo DeviceInfo { get; } /// - public abstract Rectangle DeviceRectangle { get; } + public Size Size => new Size(InternalSize?.Width ?? 0, InternalSize?.Height ?? 0); + + /// + /// Gets the of the whole . + /// + protected abstract Size InternalSize { get; set; } + + private Point _location = new Point(); + /// + public Point Location + { + get { return _location; } + set { SetProperty(ref _location, value ?? new Point()); } + } /// /// Gets a dictionary containing all of the . @@ -39,8 +55,7 @@ namespace RGB.NET.Core /// IEnumerable IRGBDevice.this[Rectangle referenceRect, double minOverlayPercentage] - => LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.LedRectangle) >= minOverlayPercentage) - ; + => LedMapping.Values.Where(x => referenceRect.CalculateIntersectPercentage(x.LedRectangle) >= minOverlayPercentage); #endregion diff --git a/RGB.NET.Core/Devices/IRGBDevice.cs b/RGB.NET.Core/Devices/IRGBDevice.cs index 7422dc1..a730e2b 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 /// - public interface IRGBDevice : IEnumerable + public interface IRGBDevice : IEnumerable, IBindable { #region Properties @@ -15,9 +15,14 @@ namespace RGB.NET.Core IRGBDeviceInfo DeviceInfo { get; } /// - /// Gets the representing the whole . + /// Gets or sets the location of the . /// - Rectangle DeviceRectangle { get; } + Point Location { get; set; } + + /// + /// Gets a copy of the of the whole . + /// + Size Size { get; } #endregion @@ -48,7 +53,7 @@ namespace RGB.NET.Core #endregion #region Methods - + /// /// Perform an update for all dirty , or all if flushLeds is set to true. /// diff --git a/RGB.NET.Core/Devices/IRGBDeviceInfo.cs b/RGB.NET.Core/Devices/IRGBDeviceInfo.cs index 20f952d..6575570 100644 --- a/RGB.NET.Core/Devices/IRGBDeviceInfo.cs +++ b/RGB.NET.Core/Devices/IRGBDeviceInfo.cs @@ -8,9 +8,9 @@ #region Properties & Fields /// - /// Gets the of the . + /// Gets the of the . /// - DeviceType DeviceType { get; } + RGBDeviceType DeviceType { get; } /// /// Gets the manufacturer-name of the . diff --git a/RGB.NET.Core/Devices/IDeviceProvider.cs b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs similarity index 86% rename from RGB.NET.Core/Devices/IDeviceProvider.cs rename to RGB.NET.Core/Devices/IRGBDeviceProvider.cs index 716f507..cb1f95e 100644 --- a/RGB.NET.Core/Devices/IDeviceProvider.cs +++ b/RGB.NET.Core/Devices/IRGBDeviceProvider.cs @@ -5,7 +5,7 @@ namespace RGB.NET.Core /// /// Represents a generic device provider. /// - public interface IDeviceProvider + public interface IRGBDeviceProvider { #region Properties & Fields @@ -15,7 +15,7 @@ namespace RGB.NET.Core bool IsInitialized { get; } /// - /// Gets a list of loaded by this . + /// Gets a list of loaded by this . /// IEnumerable Devices { get; } @@ -27,9 +27,9 @@ namespace RGB.NET.Core #endregion #region Methods - + /// - /// Initializes the if not already happened or reloads it if it is already initialized. + /// Initializes the if not already happened or reloads it if it is already initialized. /// /// Specifies whether the application should request exclusive access of possible or not. /// Specifies whether exception during the initialization sequence should be thrown or not. diff --git a/RGB.NET.Core/Devices/DeviceType.cs b/RGB.NET.Core/Devices/RGBDeviceType.cs similarity index 96% rename from RGB.NET.Core/Devices/DeviceType.cs rename to RGB.NET.Core/Devices/RGBDeviceType.cs index 83c376f..de234dd 100644 --- a/RGB.NET.Core/Devices/DeviceType.cs +++ b/RGB.NET.Core/Devices/RGBDeviceType.cs @@ -3,7 +3,7 @@ /// /// Contains list of different types of device. /// - public enum DeviceType + public enum RGBDeviceType { /// /// Represents a device where the type is not known or not present in the list. diff --git a/RGB.NET.Core/Events/ExceptionEventArgs.cs b/RGB.NET.Core/Events/ExceptionEventArgs.cs index 0f16e81..baa1e77 100644 --- a/RGB.NET.Core/Events/ExceptionEventArgs.cs +++ b/RGB.NET.Core/Events/ExceptionEventArgs.cs @@ -6,7 +6,7 @@ using System; namespace RGB.NET.Core { /// - /// Represents the information supplied with an -event. + /// Represents the information supplied with an -event. /// public class ExceptionEventArgs : EventArgs { diff --git a/RGB.NET.Core/Events/UpdatedEventArgs.cs b/RGB.NET.Core/Events/UpdatedEventArgs.cs index e9dd193..e8daac7 100644 --- a/RGB.NET.Core/Events/UpdatedEventArgs.cs +++ b/RGB.NET.Core/Events/UpdatedEventArgs.cs @@ -3,7 +3,7 @@ namespace RGB.NET.Core { /// - /// Represents the information supplied with an -event. + /// Represents the information supplied with an -event. /// public class UpdatedEventArgs : EventArgs { } diff --git a/RGB.NET.Core/Events/UpdatingEventArgs.cs b/RGB.NET.Core/Events/UpdatingEventArgs.cs index f0fb5e5..dfc2752 100644 --- a/RGB.NET.Core/Events/UpdatingEventArgs.cs +++ b/RGB.NET.Core/Events/UpdatingEventArgs.cs @@ -6,7 +6,7 @@ using System; namespace RGB.NET.Core { /// - /// Represents the information supplied with an -event. + /// Represents the information supplied with an -event. /// public class UpdatingEventArgs : EventArgs { diff --git a/RGB.NET.Core/MVVM/AbstractBindable.cs b/RGB.NET.Core/MVVM/AbstractBindable.cs index 52a3cf6..2efca52 100644 --- a/RGB.NET.Core/MVVM/AbstractBindable.cs +++ b/RGB.NET.Core/MVVM/AbstractBindable.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Core /// /// Represents a basic bindable class which notifies when a property value changes. /// - public abstract class AbstractBindable : INotifyPropertyChanged + public abstract class AbstractBindable : IBindable { #region Events diff --git a/RGB.NET.Core/MVVM/IBindable.cs b/RGB.NET.Core/MVVM/IBindable.cs new file mode 100644 index 0000000..4191eac --- /dev/null +++ b/RGB.NET.Core/MVVM/IBindable.cs @@ -0,0 +1,11 @@ +using System.ComponentModel; + +namespace RGB.NET.Core +{ + /// + /// Represents a basic bindable class which notifies when a property value changes. + /// + public interface IBindable : INotifyPropertyChanged + { + } +} diff --git a/RGB.NET.Core/Positioning/Rectangle.cs b/RGB.NET.Core/Positioning/Rectangle.cs index e76f5b3..62be5d1 100644 --- a/RGB.NET.Core/Positioning/Rectangle.cs +++ b/RGB.NET.Core/Positioning/Rectangle.cs @@ -105,20 +105,26 @@ namespace RGB.NET.Core /// The list of used to calculate the and public Rectangle(IEnumerable rectangles) { + bool hasPoint = false; double posX = double.MaxValue; double posY = double.MaxValue; double posX2 = double.MinValue; double posY2 = double.MinValue; - foreach (Rectangle rectangle in rectangles) - { - posX = Math.Min(posX, rectangle.Location.X); - posY = Math.Min(posY, rectangle.Location.Y); - posX2 = Math.Max(posX2, rectangle.Location.X + rectangle.Size.Width); - posY2 = Math.Max(posY2, rectangle.Location.Y + rectangle.Size.Height); - } + if (rectangles != null) + foreach (Rectangle rectangle in rectangles) + { + hasPoint = true; + posX = Math.Min(posX, rectangle.Location.X); + posY = Math.Min(posY, rectangle.Location.Y); + posX2 = Math.Max(posX2, rectangle.Location.X + rectangle.Size.Width); + posY2 = Math.Max(posY2, rectangle.Location.Y + rectangle.Size.Height); + } - InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)); + if (hasPoint) + InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)); + else + InitializeFromPoints(new Point(0, 0), new Point(0, 0)); } /// @@ -138,20 +144,26 @@ namespace RGB.NET.Core public Rectangle(IEnumerable points) : this() { + bool hasPoint = false; double posX = double.MaxValue; double posY = double.MaxValue; double posX2 = double.MinValue; double posY2 = double.MinValue; - foreach (Point point in points) + if (points != null) + foreach (Point point in points) { + hasPoint = true; posX = Math.Min(posX, point.X); posY = Math.Min(posY, point.Y); posX2 = Math.Max(posX2, point.X); posY2 = Math.Max(posY2, point.Y); } - InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)); + if (hasPoint) + InitializeFromPoints(new Point(posX, posY), new Point(posX2, posY2)); + else + InitializeFromPoints(new Point(0, 0), new Point(0, 0)); } #endregion diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 7bee7ae..f3dad45 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -47,8 +47,8 @@ - - + + @@ -62,17 +62,19 @@ - + - + + + diff --git a/RGB.NET.Core/Surfaces/RGBSurface.cs b/RGB.NET.Core/RGBSurface.cs similarity index 55% rename from RGB.NET.Core/Surfaces/RGBSurface.cs rename to RGB.NET.Core/RGBSurface.cs index fbbf712..7fe5b67 100644 --- a/RGB.NET.Core/Surfaces/RGBSurface.cs +++ b/RGB.NET.Core/RGBSurface.cs @@ -1,42 +1,42 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; namespace RGB.NET.Core { /// - /// Represents a generic RGB-surface. + /// Represents a RGB-surface containing multiple devices. /// - public class RGBSurface : AbstractLedGroup, IRGBSurface + public static partial class RGBSurface { #region Properties & Fields - private DateTime _lastUpdate; + private static DateTime _lastUpdate; - /// - public Dictionary Devices { get; } = new Dictionary(); + private static IList _deviceProvider = new List(); + private static IList _devices = new List(); + + // ReSharper disable InconsistentNaming - private readonly LinkedList _ledGroups = new LinkedList(); + private static readonly LinkedList _ledGroups = new LinkedList(); - /// - public Rectangle SurfaceRectangle => new Rectangle(Devices.Select(x => x.Key.DeviceRectangle)); + private static readonly Rectangle _surfaceRectangle = new Rectangle(); - #endregion + // ReSharper restore InconsistentNaming - #region Events + /// + /// Gets a readonly list containing all loaded . + /// + public static IEnumerable Devices => new ReadOnlyCollection(_devices); - // ReSharper disable EventNeverSubscribedTo.Global - - /// - public event ExceptionEventHandler Exception; - - /// - public event UpdatingEventHandler Updating; - - /// - public event UpdatedEventHandler Updated; - - // ReSharper restore EventNeverSubscribedTo.Global + /// + /// Gets a copy of the representing this . + /// + public static Rectangle SurfaceRectangle => new Rectangle(_surfaceRectangle); #endregion @@ -45,7 +45,7 @@ namespace RGB.NET.Core /// /// Initializes a new instance of the class. /// - public RGBSurface() + static RGBSurface() { _lastUpdate = DateTime.Now; } @@ -54,8 +54,11 @@ namespace RGB.NET.Core #region Methods - /// - public void Update(bool flushLeds = false) + /// + /// Perform an update for all dirty , or all , if flushLeds is set to true. + /// + /// Specifies whether all , (including clean ones) should be updated. + public static void Update(bool flushLeds = false) { OnUpdating(); @@ -66,12 +69,11 @@ namespace RGB.NET.Core ledGroup.UpdateEffects(); // Render brushes - Render(this); foreach (ILedGroup ledGroup in _ledGroups.OrderBy(x => x.ZIndex)) Render(ledGroup); } - foreach (IRGBDevice device in Devices.Keys) + foreach (IRGBDevice device in Devices) device.Update(flushLeds); OnUpdated(); @@ -81,7 +83,7 @@ namespace RGB.NET.Core /// Renders a ledgroup. /// /// The led group to render. - private void Render(ILedGroup ledGroup) + private static void Render(ILedGroup ledGroup) { IList leds = ledGroup.GetLeds().ToList(); IBrush brush = ledGroup.Brush; @@ -118,24 +120,11 @@ namespace RGB.NET.Core } } - private Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null) + private static Rectangle GetDeviceLedLocation(Led led, Point extraOffset = null) { - Point deviceLocation; - if (!Devices.TryGetValue(led.Device, out deviceLocation)) - deviceLocation = new Point(); - return extraOffset != null - ? new Rectangle(led.LedRectangle.Location + deviceLocation + extraOffset, led.LedRectangle.Size) - : new Rectangle(led.LedRectangle.Location + deviceLocation, led.LedRectangle.Size); - } - - /// - public void PositionDevice(IRGBDevice device, Point location) - { - if (device == null) return; - - lock (Devices) - Devices[device] = location ?? new Point(); + ? new Rectangle(led.LedRectangle.Location + led.Device.Location + extraOffset, led.LedRectangle.Size) + : new Rectangle(led.LedRectangle.Location + led.Device.Location, led.LedRectangle.Size); } /// @@ -143,9 +132,8 @@ namespace RGB.NET.Core /// /// The to attach. /// true if the could be attached; otherwise, false. - public bool AttachLedGroup(ILedGroup ledGroup) + public static bool AttachLedGroup(ILedGroup ledGroup) { - if (ledGroup is IRGBSurface) return false; if (ledGroup == null) return false; lock (_ledGroups) @@ -162,9 +150,8 @@ namespace RGB.NET.Core /// /// The to detached. /// true if the could be detached; otherwise, false. - public bool DetachLedGroup(ILedGroup ledGroup) + public static bool DetachLedGroup(ILedGroup ledGroup) { - if (ledGroup is IRGBSurface) return false; if (ledGroup == null) return false; lock (_ledGroups) @@ -177,64 +164,14 @@ namespace RGB.NET.Core } } - /// - public override IEnumerable GetLeds() + private static void UpdateSurfaceRectangle() { - return Devices.SelectMany(d => d.Key); + Rectangle devicesRectangle = new Rectangle(_devices.Select(d => new Rectangle(d.Location, d.Size))); + + _surfaceRectangle.Size.Width = devicesRectangle.Location.X + devicesRectangle.Size.Width; + _surfaceRectangle.Size.Height = devicesRectangle.Location.Y + devicesRectangle.Size.Height; } - #region EventCaller - - /// - /// Handles the needed event-calls for an exception. - /// - /// The exception previously thrown. - protected virtual void OnException(Exception ex) - { - try - { - Exception?.Invoke(this, new ExceptionEventArgs(ex)); - } - catch - { - // Well ... that's not my fault - } - } - - /// - /// Handles the needed event-calls before updating. - /// - protected virtual void OnUpdating() - { - try - { - long lastUpdateTicks = _lastUpdate.Ticks; - _lastUpdate = DateTime.Now; - Updating?.Invoke(this, new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000.0)); - } - catch - { - // Well ... that's not my fault - } - } - - /// - /// Handles the needed event-calls after an update. - /// - protected virtual void OnUpdated() - { - try - { - Updated?.Invoke(this, new UpdatedEventArgs()); - } - catch - { - // Well ... that's not my fault - } - } - - #endregion - #endregion } } diff --git a/RGB.NET.Core/RGBSurfaceDeviceEvents.cs b/RGB.NET.Core/RGBSurfaceDeviceEvents.cs new file mode 100644 index 0000000..5ef5e2c --- /dev/null +++ b/RGB.NET.Core/RGBSurfaceDeviceEvents.cs @@ -0,0 +1,95 @@ +using System; + +namespace RGB.NET.Core +{ + public static partial class RGBSurface + { + #region EventHandler + + /// + /// Represents the event-handler of the -event. + /// + /// The arguments provided by the event. + public delegate void ExceptionEventHandler(ExceptionEventArgs args); + + /// + /// Represents the event-handler of the -event. + /// + /// The arguments provided by the event. + public delegate void UpdatingEventHandler(UpdatingEventArgs args); + + /// + /// Represents the event-handler of the -event. + /// + /// The arguments provided by the event. + public delegate void UpdatedEventHandler(UpdatedEventArgs args); + + #endregion + + #region Events + + // ReSharper disable EventNeverSubscribedTo.Global + + /// + /// Occurs when a catched exception is thrown inside the . + /// + public static event ExceptionEventHandler Exception; + + /// + /// Occurs when the starts updating. + /// + public static event UpdatingEventHandler Updating; + + /// + /// Occurs when the update is done. + /// + public static event UpdatedEventHandler Updated; + + // ReSharper restore EventNeverSubscribedTo.Global + + #endregion + + #region Methods + + /// + /// Handles the needed event-calls for an exception. + /// + /// The exception previously thrown. + private static void OnException(Exception ex) + { + try + { + Exception?.Invoke(new ExceptionEventArgs(ex)); + } + catch { /* Well ... that's not my fault */ } + } + + /// + /// Handles the needed event-calls before updating. + /// + private static void OnUpdating() + { + try + { + long lastUpdateTicks = _lastUpdate.Ticks; + _lastUpdate = DateTime.Now; + Updating?.Invoke(new UpdatingEventArgs((DateTime.Now.Ticks - lastUpdateTicks) / 10000000.0)); + } + catch { /* Well ... that's not my fault */ } + } + + /// + /// Handles the needed event-calls after an update. + /// + private static void OnUpdated() + { + try + { + Updated?.Invoke(new UpdatedEventArgs()); + } + catch { /* Well ... that's not my fault */ } + } + + #endregion + } +} diff --git a/RGB.NET.Core/RGBSurfaceDeviceLoader.cs b/RGB.NET.Core/RGBSurfaceDeviceLoader.cs new file mode 100644 index 0000000..c67f771 --- /dev/null +++ b/RGB.NET.Core/RGBSurfaceDeviceLoader.cs @@ -0,0 +1,43 @@ +using System.ComponentModel; +using System.Linq; + +namespace RGB.NET.Core +{ + public static partial class RGBSurface + { + #region Methods + + // ReSharper disable once UnusedMember.Global + /// + /// Loads all devices the given is able to provide. + /// + /// + public static void LoadDevices(IRGBDeviceProvider deviceProvider) + { + if (_deviceProvider.Contains(deviceProvider) || _deviceProvider.Any(x => x.GetType() == deviceProvider.GetType())) return; + + if (deviceProvider.IsInitialized || deviceProvider.Initialize()) + { + _deviceProvider.Add(deviceProvider); + + foreach (IRGBDevice device in deviceProvider.Devices) + { + if (_devices.Contains(device)) continue; + + device.PropertyChanged += DeviceOnPropertyChanged; + _devices.Add(device); + } + } + + UpdateSurfaceRectangle(); + } + + private static void DeviceOnPropertyChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) + { + if (string.Equals(propertyChangedEventArgs.PropertyName, nameof(IRGBDevice.Location))) + UpdateSurfaceRectangle(); + } + + #endregion + } +} diff --git a/RGB.NET.Core/Surfaces/IRGBSurface.cs b/RGB.NET.Core/Surfaces/IRGBSurface.cs deleted file mode 100644 index 8810b10..0000000 --- a/RGB.NET.Core/Surfaces/IRGBSurface.cs +++ /dev/null @@ -1,104 +0,0 @@ -using System.Collections.Generic; - -namespace RGB.NET.Core -{ - - #region EventHandler - - /// - /// Represents the event-handler of the -event. - /// - /// The sender of the event. - /// The arguments provided by the event. - public delegate void ExceptionEventHandler(object sender, ExceptionEventArgs args); - - /// - /// Represents the event-handler of the -event. - /// - /// The sender of the event. - /// The arguments provided by the event. - public delegate void UpdatingEventHandler(object sender, UpdatingEventArgs args); - - /// - /// Represents the event-handler of the -event. - /// - /// The sender of the event. - /// The arguments provided by the event. - public delegate void UpdatedEventHandler(object sender, UpdatedEventArgs args); - - #endregion - - /// - /// Represents a generic RGB-surface. - /// - public interface IRGBSurface : ILedGroup - { - #region Properties & Fields - - /// - /// Gets a dictionary containing the locations of all positioned on this . - /// - Dictionary Devices { get; } - - /// - /// Gets a copy of the representing this . - /// - Rectangle SurfaceRectangle { get; } - - #endregion - - #region Methods - - /// - /// Perform an update for all dirty , or all , if flushLeds is set to true. - /// - /// Specifies whether all , (including clean ones) should be updated. - void Update(bool flushLeds = false); - - /// - /// Sets the location of the given to the given . - /// - /// The to move. - /// The target . - void PositionDevice(IRGBDevice device, Point location); - - /// - /// Attaches the given . - /// - /// The to attach. - /// true if the could be attached; otherwise, false. - bool AttachLedGroup(ILedGroup ledGroup); - - /// - /// Detaches the given . - /// - /// The to detached. - /// true if the could be detached; otherwise, false. - bool DetachLedGroup(ILedGroup ledGroup); - - #endregion - - #region Events - - // ReSharper disable EventNeverSubscribedTo.Global - - /// - /// Occurs when a catched exception is thrown inside the . - /// - event ExceptionEventHandler Exception; - - /// - /// Occurs when the starts updating. - /// - event UpdatingEventHandler Updating; - - /// - /// Occurs when the update is done. - /// - event UpdatedEventHandler Updated; - - // ReSharper restore EventNeverSubscribedTo.Global - - #endregion - } -} diff --git a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs index 7f03c45..66ea7f2 100644 --- a/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs +++ b/RGB.NET.Devices.Corsair/CorsairDeviceProvider.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System.Collections.Generic; using System.Collections.ObjectModel; using System.Runtime.InteropServices; using RGB.NET.Core; @@ -10,10 +13,15 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a device provider responsible for corsair (CUE) devices. /// - public class CorsairDeviceProvider : IDeviceProvider + public class CorsairDeviceProvider : IRGBDeviceProvider { #region Properties & Fields + /// + /// Gets the singleton instance. + /// + public static CorsairDeviceProvider Instance { get; } = new CorsairDeviceProvider(); + /// /// Indicates if the SDK is initialized and ready to use. /// @@ -44,6 +52,13 @@ namespace RGB.NET.Devices.Corsair #endregion + #region Constructors + + private CorsairDeviceProvider() + { } + + #endregion + #region Methods /// @@ -109,7 +124,7 @@ namespace RGB.NET.Devices.Corsair { _CorsairDeviceInfo nativeDeviceInfo = (_CorsairDeviceInfo)Marshal.PtrToStructure(_CUESDK.CorsairGetDeviceInfo(i), typeof(_CorsairDeviceInfo)); - CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, DeviceType.Unknown, nativeDeviceInfo); + CorsairRGBDeviceInfo info = new CorsairRGBDeviceInfo(i, RGBDeviceType.Unknown, nativeDeviceInfo); if (!info.CapsMask.HasFlag(CorsairDeviceCaps.Lighting)) continue; // Everything that doesn't support lighting control is useless diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs index 145198f..137fe8a 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairLedId.cs @@ -6,7 +6,7 @@ namespace RGB.NET.Devices.Corsair /// /// Represents a Id of a on a . /// - [DebuggerDisplay("{_ledId}")] + [DebuggerDisplay("{" + nameof(_ledId) + "}")] public class CorsairLedId : ILedId { #region Properties & Fields diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index bd7f584..e0e1055 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -15,9 +15,8 @@ namespace RGB.NET.Devices.Corsair /// public override IRGBDeviceInfo DeviceInfo { get; } - private Rectangle _deviceRectangle; /// - public override Rectangle DeviceRectangle => _deviceRectangle; + protected override Size InternalSize { get; set; } #endregion @@ -43,7 +42,8 @@ namespace RGB.NET.Devices.Corsair { InitializeLeds(); - _deviceRectangle = new Rectangle(this.Select(x => x.LedRectangle)); + Rectangle ledRectangle = new Rectangle(this.Select(x => x.LedRectangle)); + InternalSize = ledRectangle.Size + new Size(ledRectangle.Location.X, ledRectangle.Location.Y); } /// diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs index d4ea7c9..2b3bc68 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs @@ -23,7 +23,7 @@ namespace RGB.NET.Devices.Corsair public int CorsairDeviceIndex { get; } /// - public DeviceType DeviceType { get; } + public RGBDeviceType DeviceType { get; } /// public string Manufacturer => "Corsair"; @@ -46,7 +46,7 @@ namespace RGB.NET.Devices.Corsair /// The index of the . /// The type of the . /// The native -struct - internal CorsairRGBDeviceInfo(int deviceIndex, DeviceType deviceType, _CorsairDeviceInfo nativeInfo) + internal CorsairRGBDeviceInfo(int deviceIndex, RGBDeviceType deviceType, _CorsairDeviceInfo nativeInfo) { this.CorsairDeviceIndex = deviceIndex; this.DeviceType = deviceType; diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index 07c56c5..e1e2195 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -1,4 +1,7 @@ -using RGB.NET.Core; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; namespace RGB.NET.Devices.Corsair { diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs index 161a214..09abf44 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDeviceInfo.cs @@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Corsair /// The index of the . /// The native -struct internal CorsairHeadsetRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, Core.DeviceType.Headset, nativeInfo) + : base(deviceIndex, Core.RGBDeviceType.Headset, nativeInfo) { } #endregion diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index 42bd313..e18fd93 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -1,4 +1,7 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Devices.Corsair.Native; diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs index 3af41ef..25e772c 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDeviceInfo.cs @@ -1,4 +1,7 @@ -using RGB.NET.Devices.Corsair.Native; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Devices.Corsair.Native; namespace RGB.NET.Devices.Corsair { @@ -29,7 +32,7 @@ namespace RGB.NET.Devices.Corsair /// The index of the . /// The native -struct internal CorsairKeyboardRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, Core.DeviceType.Keyboard, nativeInfo) + : base(deviceIndex, Core.RGBDeviceType.Keyboard, nativeInfo) { this.PhysicalLayout = (CorsairPhysicalKeyboardLayout)nativeInfo.physicalLayout; this.LogicalLayout = (CorsairLogicalKeyboardLayout)nativeInfo.logicalLayout; diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs index 5351cce..4af9621 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDevice.cs @@ -1,4 +1,7 @@ -using RGB.NET.Core; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using RGB.NET.Core; using RGB.NET.Core.Exceptions; namespace RGB.NET.Devices.Corsair diff --git a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs index 656053e..00af3dc 100644 --- a/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mouse/CorsairMouseRGBDeviceInfo.cs @@ -24,7 +24,7 @@ namespace RGB.NET.Devices.Corsair /// The index of the . /// The native -struct internal CorsairMouseRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, Core.DeviceType.Mouse, nativeInfo) + : base(deviceIndex, Core.RGBDeviceType.Mouse, nativeInfo) { this.PhysicalLayout = (CorsairPhysicalMouseLayout)nativeInfo.physicalLayout; } diff --git a/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs b/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs index 998c7ef..c12d158 100644 --- a/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDevice.cs @@ -1,4 +1,7 @@ -using System; +// ReSharper disable MemberCanBePrivate.Global +// ReSharper disable UnusedMember.Global + +using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; diff --git a/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDeviceInfo.cs index 83932f7..ea696ce 100644 --- a/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Mousmat/CorsairMousematRGBDeviceInfo.cs @@ -15,7 +15,7 @@ namespace RGB.NET.Devices.Corsair /// The index if the . /// The native -struct internal CorsairMousematRGBDeviceInfo(int deviceIndex, _CorsairDeviceInfo nativeInfo) - : base(deviceIndex, Core.DeviceType.Mousemat, nativeInfo) + : base(deviceIndex, Core.RGBDeviceType.Mousemat, nativeInfo) { } #endregion