From bdf446581e4725ac5cc23782521ed4567c8f6295 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 4 Feb 2017 08:29:11 +0100 Subject: [PATCH] Added shape to led and improved layout-loading --- RGB.NET.Core/Devices/Layout/DeviceLayout.cs | 4 ++-- RGB.NET.Core/Devices/Layout/LedLayout.cs | 4 ++-- RGB.NET.Core/Leds/Led.cs | 10 ++++++++++ .../Layout/LayoutShape.cs => Positioning/Shape.cs} | 12 +++++++++--- RGB.NET.Core/RGB.NET.Core.csproj | 2 +- RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs | 4 ++-- .../Generic/CorsairRGBDeviceInfo.cs | 3 +++ .../Headset/CorsairHeadsetRGBDevice.cs | 2 -- .../Keyboard/CorsairKeyboardRGBDevice.cs | 2 +- 9 files changed, 30 insertions(+), 13 deletions(-) rename RGB.NET.Core/{Devices/Layout/LayoutShape.cs => Positioning/Shape.cs} (56%) diff --git a/RGB.NET.Core/Devices/Layout/DeviceLayout.cs b/RGB.NET.Core/Devices/Layout/DeviceLayout.cs index eceb38d..e522209 100644 --- a/RGB.NET.Core/Devices/Layout/DeviceLayout.cs +++ b/RGB.NET.Core/Devices/Layout/DeviceLayout.cs @@ -51,10 +51,10 @@ namespace RGB.NET.Core.Layout public string Model { get; set; } /// - /// Gets or sets the of the . + /// Gets or sets the of the . /// [XmlElement("Shape")] - public LayoutShape Shape { get; set; } + public Shape Shape { get; set; } /// /// Gets or sets the width of the . diff --git a/RGB.NET.Core/Devices/Layout/LedLayout.cs b/RGB.NET.Core/Devices/Layout/LedLayout.cs index 9224240..5f46dcc 100644 --- a/RGB.NET.Core/Devices/Layout/LedLayout.cs +++ b/RGB.NET.Core/Devices/Layout/LedLayout.cs @@ -19,10 +19,10 @@ namespace RGB.NET.Core.Layout public string Id { get; set; } /// - /// Gets or sets the of the . + /// Gets or sets the of the . /// [XmlElement("Shape")] - public LayoutShape Shape { get; set; } + public Shape Shape { get; set; } /// /// Gets or sets the x-position of the . diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index 42479e1..020cf5e 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -22,6 +22,16 @@ namespace RGB.NET.Core /// public ILedId Id { get; } + private Shape _shape = Shape.Rectangle; + /// + /// Gets or sets the of the . + /// + public Shape Shape + { + get { return _shape; } + set { SetProperty(ref _shape, value); } + } + /// /// Gets a rectangle representing the physical location of the relative to the . /// diff --git a/RGB.NET.Core/Devices/Layout/LayoutShape.cs b/RGB.NET.Core/Positioning/Shape.cs similarity index 56% rename from RGB.NET.Core/Devices/Layout/LayoutShape.cs rename to RGB.NET.Core/Positioning/Shape.cs index db6b081..1d7384d 100644 --- a/RGB.NET.Core/Devices/Layout/LayoutShape.cs +++ b/RGB.NET.Core/Positioning/Shape.cs @@ -1,16 +1,22 @@ using System; +using RGB.NET.Core.Layout; -namespace RGB.NET.Core.Layout +namespace RGB.NET.Core { /// /// Contains a list of different shapes used by . /// [Serializable] - public enum LayoutShape + public enum Shape { /// /// A simple rectangle. /// - Rectangle = 0 + Rectangle = 0, + + /// + /// A simple circle. + /// + Circle = 1 } } diff --git a/RGB.NET.Core/RGB.NET.Core.csproj b/RGB.NET.Core/RGB.NET.Core.csproj index 4cb9e54..eef0e49 100644 --- a/RGB.NET.Core/RGB.NET.Core.csproj +++ b/RGB.NET.Core/RGB.NET.Core.csproj @@ -49,7 +49,7 @@ - + diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index 1eaf65d..3c63407 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.InteropServices; using RGB.NET.Core; using RGB.NET.Core.Layout; @@ -82,6 +80,8 @@ namespace RGB.NET.Devices.Corsair led.LedRectangle.Location.Y = layoutLed.Y; led.LedRectangle.Size.Width = layoutLed.Width; led.LedRectangle.Size.Height = layoutLed.Height; + + led.Shape = layoutLed.Shape; } } } diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs index b8d9a84..ab528bf 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDeviceInfo.cs @@ -34,6 +34,9 @@ namespace RGB.NET.Devices.Corsair /// public Uri Image { get; protected set; } + /// + public RGBDeviceLighting Lighting => RGBDeviceLighting.Key; + /// /// Gets a flag that describes device capabilities. () /// diff --git a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs index 626193d..a6d8ca5 100644 --- a/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Headset/CorsairHeadsetRGBDevice.cs @@ -1,11 +1,9 @@ // ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global -using System; using System.IO; using System.Reflection; using RGB.NET.Core; -using RGB.NET.Core.Layout; namespace RGB.NET.Devices.Corsair { diff --git a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs index 3e1203b..b62192a 100644 --- a/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Keyboard/CorsairKeyboardRGBDevice.cs @@ -59,7 +59,7 @@ namespace RGB.NET.Devices.Corsair } ApplyLayoutFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), - $@"Layouts\Corsair\Keyboards\{KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}\{KeyboardDeviceInfo.LogicalLayout.ToString().ToUpper()}.xml")); + $@"Layouts\Corsair\Keyboards\{KeyboardDeviceInfo.Model.Replace(" ", string.Empty).ToUpper()}\{KeyboardDeviceInfo.PhysicalLayout.ToString().ToUpper()}.xml")); } #endregion