mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile configurations - Publicly expose profile ID
Device visualizer - Hit test on LED geometry Layouts - Reverted layout rounding change
This commit is contained in:
parent
18ae7b70b0
commit
d749ab5bbd
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Artemis.Core.LayerBrushes;
|
using Artemis.Core.LayerBrushes;
|
||||||
using Artemis.Core.LayerEffects;
|
using Artemis.Core.LayerEffects;
|
||||||
|
|||||||
@ -107,6 +107,11 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ProfileConfigurationHotkey? DisableHotkey { get; set; }
|
public ProfileConfigurationHotkey? DisableHotkey { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ID of the profile of this profile configuration
|
||||||
|
/// </summary>
|
||||||
|
public Guid ProfileId => Entity.ProfileId;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the profile of this profile configuration
|
/// Gets the profile of this profile configuration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -8,8 +8,8 @@ namespace Artemis.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class ArtemisLed : CorePropertyChanged
|
public class ArtemisLed : CorePropertyChanged
|
||||||
{
|
{
|
||||||
private SKRectI _absoluteRectangle;
|
private SKRect _absoluteRectangle;
|
||||||
private SKRectI _rectangle;
|
private SKRect _rectangle;
|
||||||
|
|
||||||
internal ArtemisLed(Led led, ArtemisDevice device)
|
internal ArtemisLed(Led led, ArtemisDevice device)
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ namespace Artemis.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the rectangle covering the LED positioned relative to the<see cref="Device" />
|
/// Gets the rectangle covering the LED positioned relative to the<see cref="Device" />
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKRectI Rectangle
|
public SKRect Rectangle
|
||||||
{
|
{
|
||||||
get => _rectangle;
|
get => _rectangle;
|
||||||
private set => SetAndNotify(ref _rectangle, value);
|
private set => SetAndNotify(ref _rectangle, value);
|
||||||
@ -40,7 +40,7 @@ namespace Artemis.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the rectangle covering the LED
|
/// Gets the rectangle covering the LED
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public SKRectI AbsoluteRectangle
|
public SKRect AbsoluteRectangle
|
||||||
{
|
{
|
||||||
get => _absoluteRectangle;
|
get => _absoluteRectangle;
|
||||||
private set => SetAndNotify(ref _absoluteRectangle, value);
|
private set => SetAndNotify(ref _absoluteRectangle, value);
|
||||||
@ -59,8 +59,8 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
internal void CalculateRectangles()
|
internal void CalculateRectangles()
|
||||||
{
|
{
|
||||||
Rectangle = RgbLed.Boundary.ToSKRectI();
|
Rectangle = RgbLed.Boundary.ToSKRect();
|
||||||
AbsoluteRectangle = RgbLed.AbsoluteBoundary.ToSKRectI();
|
AbsoluteRectangle = RgbLed.AbsoluteBoundary.ToSKRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,8 +87,8 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
if (led != null)
|
if (led != null)
|
||||||
{
|
{
|
||||||
led.Location = new Point(MathF.Round(layoutLed.X), MathF.Round(layoutLed.Y));
|
led.Location = new Point(layoutLed.X, layoutLed.Y);
|
||||||
led.Size = new Size(MathF.Round(layoutLed.Width), MathF.Round(layoutLed.Height));
|
led.Size = new Size(layoutLed.Width, layoutLed.Height);
|
||||||
led.Shape = layoutLed.Shape;
|
led.Shape = layoutLed.Shape;
|
||||||
led.ShapeData = layoutLed.ShapeData;
|
led.ShapeData = layoutLed.ShapeData;
|
||||||
led.LayoutMetadata = layoutLed.CustomData;
|
led.LayoutMetadata = layoutLed.CustomData;
|
||||||
|
|||||||
@ -157,7 +157,7 @@ namespace Artemis.UI.Shared
|
|||||||
/// </param>
|
/// </param>
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
_timer.Dispose();
|
_timer.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ namespace Artemis.UI.Shared
|
|||||||
double y = position.Y / RenderSize.Height;
|
double y = position.Y / RenderSize.Height;
|
||||||
|
|
||||||
Point scaledPosition = new(x * Device.Rectangle.Width, y * Device.Rectangle.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)
|
if (deviceVisualizerLed != null)
|
||||||
OnLedClicked(new LedClickedEventArgs(deviceVisualizerLed.Led.Device, deviceVisualizerLed.Led));
|
OnLedClicked(new LedClickedEventArgs(deviceVisualizerLed.Led.Device, deviceVisualizerLed.Led));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Windows.Media.Imaging;
|
|||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using Color = System.Windows.Media.Color;
|
using Color = System.Windows.Media.Color;
|
||||||
|
using Point = System.Windows.Point;
|
||||||
using SolidColorBrush = System.Windows.Media.SolidColorBrush;
|
using SolidColorBrush = System.Windows.Media.SolidColorBrush;
|
||||||
|
|
||||||
namespace Artemis.UI.Shared
|
namespace Artemis.UI.Shared
|
||||||
@ -14,10 +15,10 @@ namespace Artemis.UI.Shared
|
|||||||
{
|
{
|
||||||
private const byte Dimmed = 100;
|
private const byte Dimmed = 100;
|
||||||
private const byte NonDimmed = 255;
|
private const byte NonDimmed = 255;
|
||||||
private Color _renderColor;
|
|
||||||
private GeometryDrawing? _geometryDrawing;
|
private GeometryDrawing? _geometryDrawing;
|
||||||
private SolidColorBrush? _renderColorBrush;
|
|
||||||
private DrawingGroup? _lastBackingStore;
|
private DrawingGroup? _lastBackingStore;
|
||||||
|
private Color _renderColor;
|
||||||
|
private SolidColorBrush? _renderColorBrush;
|
||||||
|
|
||||||
public DeviceVisualizerLed(ArtemisLed led)
|
public DeviceVisualizerLed(ArtemisLed led)
|
||||||
{
|
{
|
||||||
@ -48,7 +49,7 @@ namespace Artemis.UI.Shared
|
|||||||
|
|
||||||
_renderColorBrush ??= new SolidColorBrush();
|
_renderColorBrush ??= new SolidColorBrush();
|
||||||
_geometryDrawing ??= new GeometryDrawing(_renderColorBrush, null, new RectangleGeometry(LedRect));
|
_geometryDrawing ??= new GeometryDrawing(_renderColorBrush, null, new RectangleGeometry(LedRect));
|
||||||
|
|
||||||
byte r = Led.RgbLed.Color.GetR();
|
byte r = Led.RgbLed.Color.GetR();
|
||||||
byte g = Led.RgbLed.Color.GetG();
|
byte g = Led.RgbLed.Color.GetG();
|
||||||
byte b = Led.RgbLed.Color.GetB();
|
byte b = Led.RgbLed.Color.GetB();
|
||||||
@ -64,7 +65,6 @@ namespace Artemis.UI.Shared
|
|||||||
backingStore.Children.Add(_geometryDrawing);
|
backingStore.Children.Add(_geometryDrawing);
|
||||||
_lastBackingStore = backingStore;
|
_lastBackingStore = backingStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderImage(DrawingContext drawingContext)
|
public void RenderImage(DrawingContext drawingContext)
|
||||||
@ -95,6 +95,20 @@ namespace Artemis.UI.Shared
|
|||||||
drawingContext.Pop();
|
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()
|
private void CreateLedGeometry()
|
||||||
{
|
{
|
||||||
// The minimum required size for geometry to be created
|
// The minimum required size for geometry to be created
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user