Profile configurations - Publicly expose profile ID

Device visualizer - Hit test on LED geometry
Layouts - Reverted layout rounding change
This commit is contained in:
Robert committed 2021-06-16 22:25:10 +02:00
1 parent 18ae7b70b0
commit d749ab5bbd
6 files changed
+33 -15

No files matched your search

@@ -157,7 +157,7 @@ namespace Artemis.UI.Shared
/// </param>
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));
}
@@ -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