UI - Many misc fixes I can't remember

Profile editor - Removed layer outline, increasing performance by a lot
Device visualizer - Streamlined custom
Device providers - Added debug device provider
ASUS - Added Maximus X Hero thanks @copystring
Plugin core - Added PerLedLayerBrush
Noise layer - Converted to PerLedLayerBrush, increasing performance and quality
This commit is contained in:
SpoinkyNL committed 2020-08-02 00:20:25 +02:00
1 parent 3000d4607a
commit aa7c914b92
29 files changed
+767 -277

No files matched your search

@@ -65,13 +65,28 @@ namespace Artemis.UI.Shared.Controls
_timer.Stop();
}
public static Size ResizeKeepAspect(Size src, double maxWidth, double maxHeight)
{
double scale;
if (maxWidth == double.PositiveInfinity && maxHeight != double.PositiveInfinity)
scale = maxHeight / src.Height;
else if (maxWidth != double.PositiveInfinity && maxHeight == double.PositiveInfinity)
scale = maxWidth / src.Width;
else if (maxWidth == double.PositiveInfinity && maxHeight == double.PositiveInfinity)
return src;
scale = Math.Min(maxWidth / src.Width, maxHeight / src.Height);
return new Size(src.Width * scale, src.Height * scale);
}
protected override void OnRender(DrawingContext drawingContext)
{
if (Device == null)
return;
// Determine the scale required to fit the desired size of the control
var measureSize = MeasureOverride(Size.Empty);
var measureSize = MeasureDevice();
var scale = Math.Min(DesiredSize.Width / measureSize.Width, DesiredSize.Height / measureSize.Height);
var scaledRect = new Rect(0, 0, measureSize.Width * scale, measureSize.Height * scale);
@@ -103,16 +118,24 @@ namespace Artemis.UI.Shared.Controls
drawingContext.DrawDrawing(_backingStore);
}
private Size MeasureDevice()
{
if (Device == null)
return Size.Empty;
var rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
rotationRect.Transform(new RotateTransform(Device.Rotation).Value);
return rotationRect.Size;
}
protected override Size MeasureOverride(Size availableSize)
{
if (Device == null)
return Size.Empty;
var rotationRect = new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
rotationRect.Transform(new RotateTransform(Device.Rotation).Value);
// TODO: If availableSize exceeds what we need, scale up
return rotationRect.Size;
var deviceSize = MeasureDevice();
return ResizeKeepAspect(deviceSize, availableSize.Width, availableSize.Height);
}
private void OnUnloaded(object sender, RoutedEventArgs e)
@@ -69,7 +69,7 @@ namespace Artemis.UI.Shared.Controls
// Create transparent pixels covering the entire LedRect so the image size matched the LedRect size
drawingContext.DrawRectangle(new SolidColorBrush(Colors.Transparent), null, LedRect);
// Translate to the top-left of the LedRect
drawingContext.PushTransform(new TranslateTransform(LedRect.X, LedRect.Y));
drawingContext.PushTransform(new TranslateTransform(LedRect.X , LedRect.Y));
// Render the LED geometry
drawingContext.DrawGeometry(fillBrush, new Pen(penBrush, 1) {LineJoin = PenLineJoin.Round}, DisplayGeometry.GetOutlinedPathGeometry());
// Restore the drawing context
@@ -88,7 +88,7 @@ namespace Artemis.UI.Shared.Controls
if (Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
CreateCustomGeometry(2.0);
else
CreateCustomGeometry(0);
CreateCustomGeometry(1.0);
break;
case Shape.Rectangle:
if (Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keyboard || Led.RgbLed.Device.DeviceInfo.DeviceType == RGBDeviceType.Keypad)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Plugins.Abstract;
@@ -125,7 +126,7 @@ namespace Artemis.UI.Shared.Services
{
if (SelectedProfile == null)
return;
// Stick to the main segment for any element that is not currently selected
foreach (var folder in SelectedProfile.GetAllFolders())
folder.OverrideProgress(CurrentTime, folder != SelectedProfileElement);