diff --git a/src/Artemis.Core/Models/Surface/ArtemisDevice.cs b/src/Artemis.Core/Models/Surface/ArtemisDevice.cs
index f347c932a..2f5e618d3 100644
--- a/src/Artemis.Core/Models/Surface/ArtemisDevice.cs
+++ b/src/Artemis.Core/Models/Surface/ArtemisDevice.cs
@@ -27,6 +27,9 @@ namespace Artemis.Core
Rotation = 0;
Scale = 1;
ZIndex = 1;
+ RedScale = 1;
+ GreenScale = 1;
+ BlueScale = 1;
deviceProvider.DeviceLayoutPaths.TryGetValue(rgbDevice, out string? layoutPath);
LayoutPath = layoutPath;
@@ -171,6 +174,36 @@ namespace Artemis.Core
}
}
+ public double RedScale
+ {
+ get => DeviceEntity.RedScale;
+ set
+ {
+ DeviceEntity.RedScale = value;
+ OnPropertyChanged(nameof(RedScale));
+ }
+ }
+
+ public double GreenScale
+ {
+ get => DeviceEntity.GreenScale;
+ set
+ {
+ DeviceEntity.GreenScale = value;
+ OnPropertyChanged(nameof(GreenScale));
+ }
+ }
+
+ public double BlueScale
+ {
+ get => DeviceEntity.BlueScale;
+ set
+ {
+ DeviceEntity.BlueScale = value;
+ OnPropertyChanged(nameof(BlueScale));
+ }
+ }
+
///
/// Gets the path to where the layout of the device was (attempted to be) loaded from
///
diff --git a/src/Artemis.Core/RGB.NET/BitmapBrush.cs b/src/Artemis.Core/RGB.NET/BitmapBrush.cs
index 3f6926c4a..3761cdfd0 100644
--- a/src/Artemis.Core/RGB.NET/BitmapBrush.cs
+++ b/src/Artemis.Core/RGB.NET/BitmapBrush.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using RGB.NET.Core;
using SkiaSharp;
@@ -101,7 +101,13 @@ namespace Artemis.Core
{
Point scaledLocation = renderTarget.Point * Scale;
if (scaledLocation.X < Bitmap.Width && scaledLocation.Y < Bitmap.Height)
- RenderedTargets[renderTarget] = Bitmap.GetPixel(scaledLocation.X.RoundToInt(), scaledLocation.Y.RoundToInt()).ToRgbColor();
+ {
+ var pixel = Bitmap.GetPixel(scaledLocation.X.RoundToInt(), scaledLocation.Y.RoundToInt()).ToRgbColor();
+ var artemisDevice = Surface?.GetArtemisLed(renderTarget.Led)?.Device;
+ if (artemisDevice is not null)
+ pixel = pixel.MultiplyRGB(artemisDevice.RedScale, artemisDevice.GreenScale, artemisDevice.BlueScale);
+ RenderedTargets[renderTarget] = pixel;
+ }
}
}
@@ -148,8 +154,13 @@ namespace Artemis.Core
// Bitmap.SetPixel(x, y, new SKColor(0, 255, 0));
}
}
+ var pixel = new Color(a / sampleSize, r / sampleSize, g / sampleSize, b / sampleSize);
- RenderedTargets[renderTarget] = new Color(a / sampleSize, r / sampleSize, g / sampleSize, b / sampleSize);
+ var artemisDevice = Surface?.GetArtemisLed(renderTarget.Led)?.Device;
+ if (artemisDevice is not null)
+ pixel = pixel.MultiplyRGB(artemisDevice.RedScale, artemisDevice.GreenScale, artemisDevice.BlueScale);
+
+ RenderedTargets[renderTarget] = pixel;
}
}
diff --git a/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs b/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs
index dc2c481d3..b4a5f7665 100644
--- a/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs
+++ b/src/Artemis.Storage/Entities/Surface/DeviceEntity.cs
@@ -15,6 +15,9 @@ namespace Artemis.Storage.Entities.Surface
public double Rotation { get; set; }
public double Scale { get; set; }
public int ZIndex { get; set; }
+ public double RedScale { get; set; }
+ public double GreenScale { get; set; }
+ public double BlueScale { get; set; }
public List InputIdentifiers { get; set; }
}
diff --git a/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigView.xaml b/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigView.xaml
index 8ebca71ee..f19f2c753 100644
--- a/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigView.xaml
+++ b/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigView.xaml
@@ -4,37 +4,115 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
+ xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:surfaceEditor="clr-namespace:Artemis.UI.Screens.SurfaceEditor.Dialogs"
mc:Ignorable="d"
- d:DesignHeight="351.305" d:DesignWidth="262.163"
d:DataContext="{d:DesignInstance {x:Type surfaceEditor:SurfaceDeviceConfigViewModel}}">
+
+
+
-
-
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigViewModel.cs b/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigViewModel.cs
index bd74d1076..efc5be348 100644
--- a/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigViewModel.cs
+++ b/src/Artemis.UI/Screens/SurfaceEditor/Dialogs/SurfaceDeviceConfigViewModel.cs
@@ -2,6 +2,7 @@
using Artemis.Core;
using Artemis.Core.Services;
using Artemis.UI.Shared.Services;
+using SkiaSharp;
using Stylet;
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
@@ -14,6 +15,11 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
private string _title;
private int _x;
private int _y;
+ public double _redScale;
+ public double _greenScale;
+ public double _blueScale;
+ private SKColor _currentColor;
+ private bool _displayOnDevices;
public SurfaceDeviceConfigViewModel(ArtemisDevice device, ICoreService coreService, IModelValidator validator) : base(validator)
{
@@ -22,10 +28,27 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
Device = device;
Title = $"{Device.RgbDevice.DeviceInfo.DeviceName} - Properties";
- X = (int) Device.X;
- Y = (int) Device.Y;
+ X = (int)Device.X;
+ Y = (int)Device.Y;
Scale = Device.Scale;
- Rotation = (int) Device.Rotation;
+ Rotation = (int)Device.Rotation;
+ RedScale = Device.RedScale * 100d;
+ GreenScale = Device.GreenScale * 100d;
+ BlueScale = Device.BlueScale * 100d;
+ CurrentColor = SKColors.White;
+ _coreService.FrameRendering += OnFrameRendering;
+ }
+
+ private void OnFrameRendering(object sender, FrameRenderingEventArgs e)
+ {
+ if (!_displayOnDevices)
+ return;
+
+ using SKPaint overlayPaint = new SKPaint
+ {
+ Color = CurrentColor
+ };
+ e.Canvas.DrawRect(0, 0, e.Canvas.LocalClipBounds.Width, e.Canvas.LocalClipBounds.Height, overlayPaint);
}
public ArtemisDevice Device { get; }
@@ -61,6 +84,36 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
set => SetAndNotify(ref _rotation, value);
}
+ public double RedScale
+ {
+ get => _redScale;
+ set => SetAndNotify(ref _redScale, value);
+ }
+
+ public double GreenScale
+ {
+ get => _greenScale;
+ set => SetAndNotify(ref _greenScale, value);
+ }
+
+ public double BlueScale
+ {
+ get => _blueScale;
+ set => SetAndNotify(ref _blueScale, value);
+ }
+
+ public SKColor CurrentColor
+ {
+ get => _currentColor;
+ set => SetAndNotify(ref _currentColor, value);
+ }
+
+ public bool DisplayOnDevices
+ {
+ get => _displayOnDevices;
+ set => SetAndNotify(ref _displayOnDevices, value);
+ }
+
public async Task Accept()
{
await ValidateAsync();
@@ -74,10 +127,22 @@ namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
Device.Y = Y;
Device.Scale = Scale;
Device.Rotation = Rotation;
+ Device.RedScale = RedScale / 100d;
+ Device.GreenScale = GreenScale / 100d;
+ Device.BlueScale = BlueScale / 100d;
_coreService.ModuleRenderingDisabled = false;
-
+ _coreService.FrameRendering -= OnFrameRendering;
Session.Close(true);
}
+
+ public void ApplyScaling()
+ {
+ //TODO: we should either save or revert changes when the user clicks save or cancel.
+ //we might have to revert these changes below.
+ Device.RedScale = RedScale / 100d;
+ Device.GreenScale = GreenScale / 100d;
+ Device.BlueScale = BlueScale / 100d;
+ }
}
}
\ No newline at end of file