From cf3bbd547cbe304b524b77b5132723c2d194f60f Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 11 Feb 2017 10:24:15 +0100 Subject: [PATCH] Added custom shapes for leds --- RGB.NET.Core/Devices/Layout/LedLayout.cs | 27 +++++++++++++++-- RGB.NET.Core/Leds/Led.cs | 10 +++++++ RGB.NET.Core/Positioning/Shape.cs | 9 ++++-- .../Generic/CorsairRGBDevice.cs | 1 + RGB.NET.WPF/Styles/LedVisualizer.xaml | 30 +++++++++++++++++++ 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/RGB.NET.Core/Devices/Layout/LedLayout.cs b/RGB.NET.Core/Devices/Layout/LedLayout.cs index 1b71e5b..deee551 100644 --- a/RGB.NET.Core/Devices/Layout/LedLayout.cs +++ b/RGB.NET.Core/Devices/Layout/LedLayout.cs @@ -21,11 +21,12 @@ namespace RGB.NET.Core.Layout public string Id { get; set; } /// - /// Gets or sets the of the . + /// Gets or sets the descriptive of the . + /// This property is for XML-serialization only and should not be directly accessed. /// [XmlElement("Shape")] - [DefaultValue(Shape.Rectangle)] - public Shape Shape { get; set; } = Shape.Rectangle; + [DefaultValue("Rectangle")] + public string DescriptiveShape { get; set; } = "Rectangle"; /// /// Gets or sets the descriptive x-position of the . @@ -59,6 +60,18 @@ namespace RGB.NET.Core.Layout [DefaultValue("1.0")] public string DescriptiveHeight { get; set; } = "1.0"; + /// + /// Gets or sets the of the . + /// + [XmlIgnore] + public Shape Shape { get; set; } + + /// + /// Gets or sets the vecor-data representing a custom-shape of the . + /// + [XmlIgnore] + public string ShapeData { get; set; } + /// /// Gets or sets the x-position of the . /// @@ -94,6 +107,14 @@ namespace RGB.NET.Core.Layout /// The previously calculated. public void CalculateValues(DeviceLayout device, LedLayout lastLed) { + Shape shape; + if (!Enum.TryParse(DescriptiveShape, true, out shape)) + { + shape = Shape.Custom; + ShapeData = DescriptiveShape; + } + Shape = shape; + Width = GetSizeValue(DescriptiveWidth, device.LedUnitWidth); Height = GetSizeValue(DescriptiveHeight, device.LedUnitHeight); diff --git a/RGB.NET.Core/Leds/Led.cs b/RGB.NET.Core/Leds/Led.cs index d4bac50..79c4681 100644 --- a/RGB.NET.Core/Leds/Led.cs +++ b/RGB.NET.Core/Leds/Led.cs @@ -33,6 +33,16 @@ namespace RGB.NET.Core set { SetProperty(ref _shape, value); } } + private string _shapeData; + /// + /// Gets or sets the data used for by the -. + /// + public string ShapeData + { + get { return _shapeData; } + set { SetProperty(ref _shapeData, value); } + } + /// /// Gets a rectangle representing the physical location of the relative to the . /// diff --git a/RGB.NET.Core/Positioning/Shape.cs b/RGB.NET.Core/Positioning/Shape.cs index 1d7384d..f4cdfe0 100644 --- a/RGB.NET.Core/Positioning/Shape.cs +++ b/RGB.NET.Core/Positioning/Shape.cs @@ -9,14 +9,19 @@ namespace RGB.NET.Core [Serializable] public enum Shape { + /// + /// A custom shape defined by vector-data. + /// + Custom = 0, + /// /// A simple rectangle. /// - Rectangle = 0, + Rectangle = 1, /// /// A simple circle. /// - Circle = 1 + Circle = 2, } } diff --git a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs index 11c6cf3..5c312e4 100644 --- a/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs +++ b/RGB.NET.Devices.Corsair/Generic/CorsairRGBDevice.cs @@ -87,6 +87,7 @@ namespace RGB.NET.Devices.Corsair led.LedRectangle.Size.Height = layoutLed.Height; led.Shape = layoutLed.Shape; + led.ShapeData = layoutLed.ShapeData; LedImage image = ledImageLayout?.LedImages.FirstOrDefault(x => x.Id == layoutLed.Id); led.Image = (!string.IsNullOrEmpty(image?.Image)) diff --git a/RGB.NET.WPF/Styles/LedVisualizer.xaml b/RGB.NET.WPF/Styles/LedVisualizer.xaml index ea212ee..05692ed 100644 --- a/RGB.NET.WPF/Styles/LedVisualizer.xaml +++ b/RGB.NET.WPF/Styles/LedVisualizer.xaml @@ -41,6 +41,32 @@ + + + + + + + + + + + + + + + + + +