diff --git a/src/Artemis.Core/Models/Profile/Layer.cs b/src/Artemis.Core/Models/Profile/Layer.cs
index f4f403100..9199aa021 100644
--- a/src/Artemis.Core/Models/Profile/Layer.cs
+++ b/src/Artemis.Core/Models/Profile/Layer.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
-using System.Diagnostics;
using System.Linq;
using Artemis.Core.LayerBrushes;
using Artemis.Core.LayerEffects;
diff --git a/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs b/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs
index 22b15e662..f4103388e 100644
--- a/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs
+++ b/src/Artemis.Core/Models/ProfileConfiguration/ProfileConfiguration.cs
@@ -107,6 +107,11 @@ namespace Artemis.Core
///
public ProfileConfigurationHotkey? DisableHotkey { get; set; }
+ ///
+ /// Gets the ID of the profile of this profile configuration
+ ///
+ public Guid ProfileId => Entity.ProfileId;
+
///
/// Gets the profile of this profile configuration
///
diff --git a/src/Artemis.Core/Models/Surface/ArtemisLed.cs b/src/Artemis.Core/Models/Surface/ArtemisLed.cs
index cec97bd94..b8b81ec5b 100644
--- a/src/Artemis.Core/Models/Surface/ArtemisLed.cs
+++ b/src/Artemis.Core/Models/Surface/ArtemisLed.cs
@@ -8,8 +8,8 @@ namespace Artemis.Core
///
public class ArtemisLed : CorePropertyChanged
{
- private SKRectI _absoluteRectangle;
- private SKRectI _rectangle;
+ private SKRect _absoluteRectangle;
+ private SKRect _rectangle;
internal ArtemisLed(Led led, ArtemisDevice device)
{
@@ -31,7 +31,7 @@ namespace Artemis.Core
///
/// Gets the rectangle covering the LED positioned relative to the
///
- public SKRectI Rectangle
+ public SKRect Rectangle
{
get => _rectangle;
private set => SetAndNotify(ref _rectangle, value);
@@ -40,7 +40,7 @@ namespace Artemis.Core
///
/// Gets the rectangle covering the LED
///
- public SKRectI AbsoluteRectangle
+ public SKRect AbsoluteRectangle
{
get => _absoluteRectangle;
private set => SetAndNotify(ref _absoluteRectangle, value);
@@ -59,8 +59,8 @@ namespace Artemis.Core
internal void CalculateRectangles()
{
- Rectangle = RgbLed.Boundary.ToSKRectI();
- AbsoluteRectangle = RgbLed.AbsoluteBoundary.ToSKRectI();
+ Rectangle = RgbLed.Boundary.ToSKRect();
+ AbsoluteRectangle = RgbLed.AbsoluteBoundary.ToSKRect();
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs
index e2f51547d..8d46099e0 100644
--- a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs
+++ b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs
@@ -87,8 +87,8 @@ namespace Artemis.Core
if (led != null)
{
- led.Location = new Point(MathF.Round(layoutLed.X), MathF.Round(layoutLed.Y));
- led.Size = new Size(MathF.Round(layoutLed.Width), MathF.Round(layoutLed.Height));
+ led.Location = new Point(layoutLed.X, layoutLed.Y);
+ led.Size = new Size(layoutLed.Width, layoutLed.Height);
led.Shape = layoutLed.Shape;
led.ShapeData = layoutLed.ShapeData;
led.LayoutMetadata = layoutLed.CustomData;
diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
index 053fd0fdb..5c9ea5812 100644
--- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
+++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
@@ -157,7 +157,7 @@ namespace Artemis.UI.Shared
///
protected virtual void Dispose(bool disposing)
{
- if (disposing)
+ if (disposing)
_timer.Dispose();
}
@@ -215,7 +215,7 @@ namespace Artemis.UI.Shared
double y = position.Y / RenderSize.Height;
Point scaledPosition = new(x * Device.Rectangle.Width, y * Device.Rectangle.Height);
- DeviceVisualizerLed? deviceVisualizerLed = _deviceVisualizerLeds.FirstOrDefault(l => l.DisplayGeometry != null && l.LedRect.Contains(scaledPosition));
+ DeviceVisualizerLed? deviceVisualizerLed = _deviceVisualizerLeds.FirstOrDefault(l => l.HitTest(scaledPosition));
if (deviceVisualizerLed != null)
OnLedClicked(new LedClickedEventArgs(deviceVisualizerLed.Led.Device, deviceVisualizerLed.Led));
}
diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs
index cf0699306..b6cdae397 100644
--- a/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs
+++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs
@@ -6,6 +6,7 @@ using System.Windows.Media.Imaging;
using Artemis.Core;
using RGB.NET.Core;
using Color = System.Windows.Media.Color;
+using Point = System.Windows.Point;
using SolidColorBrush = System.Windows.Media.SolidColorBrush;
namespace Artemis.UI.Shared
@@ -14,10 +15,10 @@ namespace Artemis.UI.Shared
{
private const byte Dimmed = 100;
private const byte NonDimmed = 255;
- private Color _renderColor;
private GeometryDrawing? _geometryDrawing;
- private SolidColorBrush? _renderColorBrush;
private DrawingGroup? _lastBackingStore;
+ private Color _renderColor;
+ private SolidColorBrush? _renderColorBrush;
public DeviceVisualizerLed(ArtemisLed led)
{
@@ -48,7 +49,7 @@ namespace Artemis.UI.Shared
_renderColorBrush ??= new SolidColorBrush();
_geometryDrawing ??= new GeometryDrawing(_renderColorBrush, null, new RectangleGeometry(LedRect));
-
+
byte r = Led.RgbLed.Color.GetR();
byte g = Led.RgbLed.Color.GetG();
byte b = Led.RgbLed.Color.GetB();
@@ -64,7 +65,6 @@ namespace Artemis.UI.Shared
backingStore.Children.Add(_geometryDrawing);
_lastBackingStore = backingStore;
}
-
}
public void RenderImage(DrawingContext drawingContext)
@@ -95,6 +95,20 @@ namespace Artemis.UI.Shared
drawingContext.Pop();
}
+ public bool HitTest(Point position)
+ {
+ if (DisplayGeometry == null)
+ return false;
+
+ PathGeometry translatedGeometry = Geometry.Combine(
+ Geometry.Empty,
+ DisplayGeometry,
+ GeometryCombineMode.Union,
+ new TranslateTransform(Led.RgbLed.Location.X, Led.RgbLed.Location.Y)
+ );
+ return translatedGeometry.FillContains(position);
+ }
+
private void CreateLedGeometry()
{
// The minimum required size for geometry to be created