From 086f2fc1f991e6da63d3636158a5840055727c25 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Thu, 21 Nov 2019 08:45:38 +0100 Subject: [PATCH] Updated for RGB.NET's changes regarding rotation --- src/Artemis.Core/Artemis.Core.csproj | 2 +- .../Extensions/RgbRectangleExtensions.cs | 8 ++-- src/Artemis.Core/Models/Profile/Layer.cs | 47 ++++++++++++++++++- src/Artemis.Core/Models/Profile/Profile.cs | 6 +++ src/Artemis.Core/Models/Surface/Device.cs | 9 ++-- src/Artemis.Core/Models/Surface/DeviceLed.cs | 38 +++++++++++++++ src/Artemis.Core/Models/Surface/Led.cs | 38 --------------- src/Artemis.Core/Models/Surface/Surface.cs | 2 +- src/Artemis.Core/RGB.NET/GraphicsDecorator.cs | 4 +- src/Artemis.Core/Services/CoreService.cs | 26 ++++++---- .../Storage/Interfaces/ISurfaceService.cs | 5 ++ .../Services/Storage/ProfileService.cs | 33 ++++++++++++- .../GeneralModule.cs | 4 +- .../Entities/Profile/LayerEntity.cs | 2 +- .../Entities/Profile/LedEntity.cs | 2 +- src/Artemis.UI/Artemis.UI.csproj | 1 - .../Extensions/RgbRectangleExtensions.cs | 12 ----- .../Visualization/ProfileLedViewModel.cs | 16 +++---- .../Visualization/SurfaceLedViewModel.cs | 8 ++-- 19 files changed, 175 insertions(+), 88 deletions(-) create mode 100644 src/Artemis.Core/Models/Surface/DeviceLed.cs delete mode 100644 src/Artemis.Core/Models/Surface/Led.cs delete mode 100644 src/Artemis.UI/Extensions/RgbRectangleExtensions.cs diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index 451d434f7..47f0e3e75 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -157,7 +157,7 @@ - + diff --git a/src/Artemis.Core/Extensions/RgbRectangleExtensions.cs b/src/Artemis.Core/Extensions/RgbRectangleExtensions.cs index 2e94514bd..bbc3c21e1 100644 --- a/src/Artemis.Core/Extensions/RgbRectangleExtensions.cs +++ b/src/Artemis.Core/Extensions/RgbRectangleExtensions.cs @@ -7,10 +7,10 @@ namespace Artemis.Core.Extensions public static Rectangle ToDrawingRectangle(this global::RGB.NET.Core.Rectangle rectangle, double scale) { return new Rectangle( - (int) (rectangle.X * scale), - (int) (rectangle.Y * scale), - (int) (rectangle.Width * scale), - (int) (rectangle.Height * scale) + (int) (rectangle.Location.X * scale), + (int) (rectangle.Location.Y * scale), + (int) (rectangle.Size.Width * scale), + (int) (rectangle.Size.Height * scale) ); } } diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs index 15b2c3082..74a07932a 100644 --- a/src/Artemis.Core/Models/Profile/Layer.cs +++ b/src/Artemis.Core/Models/Profile/Layer.cs @@ -1,10 +1,16 @@ using System; +using System.Collections.Generic; using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using Artemis.Core.Extensions; using Artemis.Core.Models.Profile.Abstract; +using Artemis.Core.Models.Surface; using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Interfaces; using Artemis.Core.Services.Interfaces; using Artemis.Storage.Entities.Profile; +using Device = Artemis.Core.Models.Surface.Device; namespace Artemis.Core.Models.Profile { @@ -18,6 +24,7 @@ namespace Artemis.Core.Models.Profile Profile = profile; ParentFolder = folder; Name = name; + Leds = new List(); } internal Layer(Profile profile, Folder folder, LayerEntity layerEntity, IPluginService pluginService) @@ -28,6 +35,7 @@ namespace Artemis.Core.Models.Profile Profile = profile; ParentFolder = folder; LayerType = pluginService.GetLayerTypeByGuid(layerEntity.LayerTypeGuid); + Leds = new List(); } internal LayerEntity LayerEntity { get; set; } @@ -36,9 +44,13 @@ namespace Artemis.Core.Models.Profile public Profile Profile { get; } public Folder ParentFolder { get; } + public List Leds { get; private set; } public LayerType LayerType { get; private set; } public ILayerTypeConfiguration LayerTypeConfiguration { get; set; } + public Rectangle RenderRectangle { get; set; } + public GraphicsPath RenderPath { get; set; } + public override void Update(double deltaTime) { if (LayerType == null) @@ -71,10 +83,22 @@ namespace Artemis.Core.Models.Profile LayerEntity.Name = Name; LayerEntity.ProfileId = Profile.EntityId; - // TODO: LEDs, conditions, elements } + public void ApplySurface(Surface.Surface surface) + { + var leds = new List(); + foreach (var surfaceDevice in surface.Devices) + { + var deviceHash = surfaceDevice.RgbDevice.GetDeviceHashCode(); + leds.AddRange(surfaceDevice.Leds.Where(dl => LayerEntity.Leds.Any(l => l.DeviceHash == deviceHash && l.LedName == dl.RgbLed.ToString()))); + } + + Leds = leds; + CalculateRenderProperties(); + } + public void UpdateLayerType(LayerType layerType) { if (LayerType != null) @@ -88,6 +112,27 @@ namespace Artemis.Core.Models.Profile LayerType = layerType; } + internal void CalculateRenderProperties() + { + if (!Leds.Any()) + { + // TODO: Create an empty rectangle and path + return; + } + + // Determine to top-left and bottom-right + var minX = Leds.Min(l => l.AbsoluteRenderRectangle.X); + var minY = Leds.Min(l => l.AbsoluteRenderRectangle.Y); + var maxX = Leds.Max(l => l.AbsoluteRenderRectangle.X); + var maxY = Leds.Max(l => l.AbsoluteRenderRectangle.Y); + + RenderRectangle = new Rectangle(minX, minY, maxX - minX, maxY - minY); + + var path = new GraphicsPath(); + path.AddRectangles(Leds.Select(l => l.AbsoluteRenderRectangle).ToArray()); + RenderPath = path; + } + public override string ToString() { return $"{nameof(Profile)}: {Profile}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}"; diff --git a/src/Artemis.Core/Models/Profile/Profile.cs b/src/Artemis.Core/Models/Profile/Profile.cs index f85a88f3d..8be810229 100644 --- a/src/Artemis.Core/Models/Profile/Profile.cs +++ b/src/Artemis.Core/Models/Profile/Profile.cs @@ -139,5 +139,11 @@ namespace Artemis.Core.Models.Profile } #endregion + + public void ApplySurface(Surface.Surface surface) + { + foreach (var layer in GetAllLayers()) + layer.ApplySurface(surface); + } } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Surface/Device.cs b/src/Artemis.Core/Models/Surface/Device.cs index f52589e34..79e3d2691 100644 --- a/src/Artemis.Core/Models/Surface/Device.cs +++ b/src/Artemis.Core/Models/Surface/Device.cs @@ -24,7 +24,7 @@ namespace Artemis.Core.Models.Surface ZIndex = 1; ApplyToEntity(); - CalculateRenderRectangle(); + CalculateRenderProperties(); } internal Device(IRGBDevice rgbDevice, Plugin plugin, Surface surface, DeviceEntity deviceEntity) @@ -78,10 +78,12 @@ namespace Artemis.Core.Models.Surface internal void ApplyToRgbDevice() { RgbDevice.Location = new Point(DeviceEntity.X, DeviceEntity.Y); - CalculateRenderRectangle(); + RgbDevice.Rotation = DeviceEntity.Rotation; + + CalculateRenderProperties(); } - internal void CalculateRenderRectangle() + internal void CalculateRenderProperties() { RenderRectangle = new Rectangle( (int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero), @@ -98,6 +100,7 @@ namespace Artemis.Core.Models.Surface var path = new GraphicsPath(); path.AddRectangles(Leds.Select(l => l.AbsoluteRenderRectangle).ToArray()); + path.FillMode = FillMode.Winding; RenderPath = path; } diff --git a/src/Artemis.Core/Models/Surface/DeviceLed.cs b/src/Artemis.Core/Models/Surface/DeviceLed.cs new file mode 100644 index 000000000..13b367b1b --- /dev/null +++ b/src/Artemis.Core/Models/Surface/DeviceLed.cs @@ -0,0 +1,38 @@ +using System; +using RGB.NET.Core; +using Rectangle = System.Drawing.Rectangle; + +namespace Artemis.Core.Models.Surface +{ + public class DeviceLed + { + public DeviceLed(Led led, Device device) + { + RgbLed = led; + Device = device; + CalculateRenderRectangle(); + } + + public Led RgbLed { get; } + public Device Device { get; } + + public Rectangle RenderRectangle { get; private set; } + public Rectangle AbsoluteRenderRectangle { get; private set; } + + public void CalculateRenderRectangle() + { + RenderRectangle = new Rectangle( + (int) Math.Round(RgbLed.LedRectangle.Location.X * Device.Surface.Scale, MidpointRounding.AwayFromZero), + (int) Math.Round(RgbLed.LedRectangle.Location.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero), + (int) Math.Round(RgbLed.LedRectangle.Size.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero), + (int) Math.Round(RgbLed.LedRectangle.Size.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero) + ); + AbsoluteRenderRectangle = new Rectangle( + (int) Math.Round(RgbLed.AbsoluteLedRectangle.Location.X * Device.Surface.Scale, MidpointRounding.AwayFromZero), + (int) Math.Round(RgbLed.AbsoluteLedRectangle.Location.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero), + (int) Math.Round(RgbLed.AbsoluteLedRectangle.Size.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero), + (int) Math.Round(RgbLed.AbsoluteLedRectangle.Size.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero) + ); + } + } +} \ No newline at end of file diff --git a/src/Artemis.Core/Models/Surface/Led.cs b/src/Artemis.Core/Models/Surface/Led.cs deleted file mode 100644 index d34022fd9..000000000 --- a/src/Artemis.Core/Models/Surface/Led.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using RGB.NET.Core; -using Rectangle = System.Drawing.Rectangle; - -namespace Artemis.Core.Models.Surface -{ - public class DeviceLed - { - public DeviceLed(Led led, Device device) - { - RgbLed = led; - Device = device; - CalculateRenderRectangle(); - } - - public Led RgbLed { get; } - public Device Device { get; } - - public Rectangle RenderRectangle { get; private set; } - public Rectangle AbsoluteRenderRectangle { get; private set; } - - public void CalculateRenderRectangle() - { - RenderRectangle = new Rectangle( - (int) Math.Round(RgbLed.LedRectangle.X * Device.Surface.Scale, MidpointRounding.AwayFromZero), - (int) Math.Round(RgbLed.LedRectangle.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero), - (int) Math.Round(RgbLed.LedRectangle.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero), - (int) Math.Round(RgbLed.LedRectangle.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero) - ); - AbsoluteRenderRectangle = new Rectangle( - (int) Math.Round(RgbLed.AbsoluteLedRectangle.X * Device.Surface.Scale, MidpointRounding.AwayFromZero), - (int) Math.Round(RgbLed.AbsoluteLedRectangle.Y * Device.Surface.Scale, MidpointRounding.AwayFromZero), - (int) Math.Round(RgbLed.AbsoluteLedRectangle.Width * Device.Surface.Scale, MidpointRounding.AwayFromZero), - (int) Math.Round(RgbLed.AbsoluteLedRectangle.Height * Device.Surface.Scale, MidpointRounding.AwayFromZero) - ); - } - } -} \ No newline at end of file diff --git a/src/Artemis.Core/Models/Surface/Surface.cs b/src/Artemis.Core/Models/Surface/Surface.cs index 22ae9fc7a..b54f6a306 100644 --- a/src/Artemis.Core/Models/Surface/Surface.cs +++ b/src/Artemis.Core/Models/Surface/Surface.cs @@ -65,7 +65,7 @@ namespace Artemis.Core.Models.Surface { Scale = value; foreach (var device in Devices) - device.CalculateRenderRectangle(); + device.CalculateRenderProperties(); OnScaleChanged(); } diff --git a/src/Artemis.Core/RGB.NET/GraphicsDecorator.cs b/src/Artemis.Core/RGB.NET/GraphicsDecorator.cs index 5326910ed..c9433f1ec 100644 --- a/src/Artemis.Core/RGB.NET/GraphicsDecorator.cs +++ b/src/Artemis.Core/RGB.NET/GraphicsDecorator.cs @@ -21,8 +21,8 @@ namespace Artemis.Core.RGB.NET _bitmap = null; else { - var width = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.X + l.AbsoluteLedRectangle.Width) * scale, 4096); - var height = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Y + l.AbsoluteLedRectangle.Height) * scale, 4096); + var width = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Location.X + l.AbsoluteLedRectangle.Size.Width) * scale, 4096); + var height = Math.Min(leds.Max(l => l.AbsoluteLedRectangle.Location.Y + l.AbsoluteLedRectangle.Size.Height) * scale, 4096); _bitmap = new DirectBitmap((int) width, (int) height); } diff --git a/src/Artemis.Core/Services/CoreService.cs b/src/Artemis.Core/Services/CoreService.cs index 6094f49d2..a1fae6776 100644 --- a/src/Artemis.Core/Services/CoreService.cs +++ b/src/Artemis.Core/Services/CoreService.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading.Tasks; using Artemis.Core.Events; using Artemis.Core.Exceptions; @@ -21,6 +22,7 @@ namespace Artemis.Core.Services private readonly IPluginService _pluginService; private readonly IRgbService _rgbService; private readonly ISurfaceService _surfaceService; + private List _modules; internal CoreService(ILogger logger, IPluginService pluginService, IRgbService rgbService, ISurfaceService surfaceService) { @@ -31,6 +33,10 @@ namespace Artemis.Core.Services _rgbService.Surface.Updating += SurfaceOnUpdating; _rgbService.Surface.Updated += SurfaceOnUpdated; + _modules = _pluginService.GetPluginsOfType(); + _pluginService.PluginEnabled += (sender, args) => _modules = _pluginService.GetPluginsOfType(); + _pluginService.PluginDisabled += (sender, args) => _modules = _pluginService.GetPluginsOfType(); + Task.Run(Initialize); } @@ -66,11 +72,12 @@ namespace Artemis.Core.Services { try { - var modules = _pluginService.GetPluginsOfType(); - - // Update all active modules - foreach (var module in modules) - module.Update(args.DeltaTime); + lock (_modules) + { + // Update all active modules + foreach (var module in _modules) + module.Update(args.DeltaTime); + } // If there is no graphics decorator, skip the frame if (_rgbService.GraphicsDecorator == null) @@ -84,11 +91,14 @@ namespace Artemis.Core.Services return; g.Clear(Color.Black); - foreach (var module in modules) - module.Render(args.DeltaTime, _surfaceService.ActiveSurface, g); + lock (_modules) + { + foreach (var module in _modules) + module.Render(args.DeltaTime, _surfaceService.ActiveSurface, g); + } } - OnFrameRendering(new FrameRenderingEventArgs(modules, _rgbService.GraphicsDecorator.GetBitmap(), args.DeltaTime, _rgbService.Surface)); + OnFrameRendering(new FrameRenderingEventArgs(_modules, _rgbService.GraphicsDecorator.GetBitmap(), args.DeltaTime, _rgbService.Surface)); } catch (Exception e) { diff --git a/src/Artemis.Core/Services/Storage/Interfaces/ISurfaceService.cs b/src/Artemis.Core/Services/Storage/Interfaces/ISurfaceService.cs index 440a228a4..64cc44d3c 100644 --- a/src/Artemis.Core/Services/Storage/Interfaces/ISurfaceService.cs +++ b/src/Artemis.Core/Services/Storage/Interfaces/ISurfaceService.cs @@ -48,5 +48,10 @@ namespace Artemis.Core.Services.Storage.Interfaces /// Occurs when the active device entity has been changed /// event EventHandler ActiveSurfaceConfigurationChanged; + + /// + /// Occurs when a surface configuration has been updated + /// + event EventHandler SurfaceConfigurationUpdated; } } \ No newline at end of file diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index 582e284ed..9eeee057b 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.Linq; +using Artemis.Core.Events; using Artemis.Core.Models.Profile; +using Artemis.Core.Models.Surface; using Artemis.Core.Plugins.Abstract; using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Storage.Interfaces; @@ -14,12 +16,36 @@ namespace Artemis.Core.Services.Storage public class ProfileService : IProfileService { private readonly IPluginService _pluginService; + private readonly ISurfaceService _surfaceService; private readonly IProfileRepository _profileRepository; - internal ProfileService(IPluginService pluginService, IProfileRepository profileRepository) + internal ProfileService(IPluginService pluginService, ISurfaceService surfaceService, IProfileRepository profileRepository) { _pluginService = pluginService; + _surfaceService = surfaceService; _profileRepository = profileRepository; + + _surfaceService.ActiveSurfaceConfigurationChanged += SurfaceServiceOnActiveSurfaceConfigurationChanged; + _surfaceService.SurfaceConfigurationUpdated += SurfaceServiceOnSurfaceConfigurationUpdated; + } + + private void SurfaceServiceOnActiveSurfaceConfigurationChanged(object sender, SurfaceConfigurationEventArgs e) + { + ApplySurfaceToProfiles(e.Surface); + } + + private void SurfaceServiceOnSurfaceConfigurationUpdated(object sender, SurfaceConfigurationEventArgs e) + { + if (!e.Surface.IsActive) + return; + ApplySurfaceToProfiles(e.Surface); + } + + private void ApplySurfaceToProfiles(Surface surface) + { + var profileModules = _pluginService.GetPluginsOfType(); + foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList()) + profileModule.ActiveProfile.ApplySurface(surface); } public List GetProfiles(ProfileModule module) @@ -55,6 +81,8 @@ namespace Artemis.Core.Services.Storage var profile = new Profile(module.PluginInfo, name); _profileRepository.Add(profile.ProfileEntity); + if (_surfaceService.ActiveSurface != null) + profile.ApplySurface(_surfaceService.ActiveSurface); return profile; } @@ -70,6 +98,9 @@ namespace Artemis.Core.Services.Storage { foreach (var profileElement in profile.Children) profileElement.ApplyToEntity(); + + if (_surfaceService.ActiveSurface != null) + profile.ApplySurface(_surfaceService.ActiveSurface); } _profileRepository.Save(profile.ProfileEntity); diff --git a/src/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Artemis.Plugins.Modules.General/GeneralModule.cs index 54fd49f59..fc6db290a 100644 --- a/src/Artemis.Plugins.Modules.General/GeneralModule.cs +++ b/src/Artemis.Plugins.Modules.General/GeneralModule.cs @@ -21,7 +21,7 @@ namespace Artemis.Plugins.Modules.General _settings = settings; DisplayName = "General"; ExpandsMainDataModel = true; - DeviceBrushes= new Dictionary(); + DeviceBrushes = new Dictionary(); var testSetting = _settings.GetSetting("TestSetting", DateTime.Now); @@ -89,7 +89,7 @@ namespace Artemis.Plugins.Modules.General var brush = DeviceBrushes[device]; brush.TranslateTransform((int) Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage), 0); graphics.FillPath(brush, device.RenderPath); - brush.TranslateTransform((int)Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage) * -1, 0); + brush.TranslateTransform((int) Math.Round(device.RenderRectangle.Width / 100.0 * MovePercentage) * -1, 0); } } diff --git a/src/Artemis.Storage/Entities/Profile/LayerEntity.cs b/src/Artemis.Storage/Entities/Profile/LayerEntity.cs index 337c7c4d5..28016388c 100644 --- a/src/Artemis.Storage/Entities/Profile/LayerEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LayerEntity.cs @@ -12,7 +12,7 @@ namespace Artemis.Storage.Entities.Profile public int Order { get; set; } public string Name { get; set; } - + public List Leds { get; set; } public List Condition { get; set; } public List Elements { get; set; } diff --git a/src/Artemis.Storage/Entities/Profile/LedEntity.cs b/src/Artemis.Storage/Entities/Profile/LedEntity.cs index ad2238511..358648b10 100644 --- a/src/Artemis.Storage/Entities/Profile/LedEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LedEntity.cs @@ -7,6 +7,6 @@ namespace Artemis.Storage.Entities.Profile public Guid Id { get; set; } public string LedName { get; set; } - public string LimitedToDevice { get; set; } + public int DeviceHash { get; set; } } } \ No newline at end of file diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index c9b70d8d9..54f064410 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -150,7 +150,6 @@ - diff --git a/src/Artemis.UI/Extensions/RgbRectangleExtensions.cs b/src/Artemis.UI/Extensions/RgbRectangleExtensions.cs deleted file mode 100644 index 7d2443a91..000000000 --- a/src/Artemis.UI/Extensions/RgbRectangleExtensions.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Drawing; - -namespace Artemis.UI.Extensions -{ - public static class RgbRectangleExtensions - { - public static Rectangle ToDrawingRectangle(this RGB.NET.Core.Rectangle rectangle) - { - return new Rectangle((int) rectangle.X, (int) rectangle.Y, (int) rectangle.Width, (int) rectangle.Height); - } - } -} \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedViewModel.cs index 59265975c..a9c54d356 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedViewModel.cs @@ -13,10 +13,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization public ProfileLedViewModel(Led led) { Led = led; - X = Led.LedRectangle.X; - Y = Led.LedRectangle.Y; - Width = Led.LedRectangle.Width; - Height = Led.LedRectangle.Height; + X = Led.Location.X; + Y = Led.Location.Y; + Width = Led.Size.Width; + Height = Led.Size.Height; Execute.OnUIThread(CreateLedGeometry); } @@ -63,17 +63,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization private void CreateRectangleGeometry() { - DisplayGeometry = new RectangleGeometry(new Rect(0.5, 0.5, Led.LedRectangle.Width - 1, Led.LedRectangle.Height - 1)); + DisplayGeometry = new RectangleGeometry(new Rect(0.5, 0.5, Led.Size.Width - 1, Led.Size.Height - 1)); } private void CreateCircleGeometry() { - DisplayGeometry = new EllipseGeometry(new Rect(0.5, 0.5, Led.LedRectangle.Width - 1, Led.LedRectangle.Height - 1)); + DisplayGeometry = new EllipseGeometry(new Rect(0.5, 0.5, Led.Size.Width - 1, Led.Size.Height - 1)); } private void CreateKeyCapGeometry() { - DisplayGeometry = new RectangleGeometry(new Rect(1, 1, Led.LedRectangle.Width - 2, Led.LedRectangle.Height - 2), 1.6, 1.6); + DisplayGeometry = new RectangleGeometry(new Rect(1, 1, Led.Size.Width - 2, Led.Size.Height - 2), 1.6, 1.6); } private void CreateCustomGeometry(double deflateAmount) @@ -88,7 +88,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization { Children = new TransformCollection { - new ScaleTransform(Led.LedRectangle.Width - deflateAmount, Led.LedRectangle.Height - deflateAmount), + new ScaleTransform(Led.Size.Width - deflateAmount, Led.Size.Height - deflateAmount), new TranslateTransform(deflateAmount / 2, deflateAmount / 2) } } diff --git a/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceLedViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceLedViewModel.cs index 802ebe5b2..19269b7f5 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceLedViewModel.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/Visualization/SurfaceLedViewModel.cs @@ -20,10 +20,10 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization public void ApplyLedToViewModel() { - X = Led.LedRectangle.X; - Y = Led.LedRectangle.Y; - Width = Led.LedRectangle.Width; - Height = Led.LedRectangle.Height; + X = Led.Location.X; + Y = Led.Location.Y; + Width = Led.Size.Width; + Height = Led.Size.Height; } } } \ No newline at end of file