mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Fixed LED borders, need to focus on perf now
This commit is contained in:
1 parent
db85e6ba07
commit
d26b22fa9a
4 files changed
+52
-54
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
@@ -19,7 +20,6 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
public ProfileEditorViewModel(Module module, ISurfaceService surfaceService, ICoreService coreService) : base(module, "Profile Editor")
|
||||
{
|
||||
surfaceService.ActiveSurfaceConfigurationChanged += OnActiveSurfaceConfigurationChanged;
|
||||
coreService.FrameRendered += CoreServiceOnFrameRendered;
|
||||
Devices = new ObservableCollection<ProfileDeviceViewModel>();
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
@@ -28,8 +28,11 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
});
|
||||
|
||||
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
||||
|
||||
_timer = new Timer(1000.0 / 15) {AutoReset = true};
|
||||
_timer.Elapsed += UpdateLeds;
|
||||
}
|
||||
|
||||
|
||||
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
||||
public RectangleGeometry SelectionRectangle { get; set; }
|
||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||
@@ -39,7 +42,7 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
ApplySurfaceConfiguration(e.Surface);
|
||||
}
|
||||
|
||||
private void CoreServiceOnFrameRendered(object sender, FrameRenderedEventArgs e)
|
||||
private void UpdateLeds(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
foreach (var profileDeviceViewModel in Devices)
|
||||
profileDeviceViewModel.Update();
|
||||
@@ -60,10 +63,23 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
_timer.Start();
|
||||
base.OnActivate();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate()
|
||||
{
|
||||
_timer.Stop();
|
||||
base.OnDeactivate();
|
||||
}
|
||||
|
||||
#region Selection
|
||||
|
||||
private MouseDragStatus _mouseDragStatus;
|
||||
private Point _mouseDragStartPoint;
|
||||
private Timer _timer;
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void EditorGridMouseClick(object sender, MouseEventArgs e)
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Windows.Media;
|
||||
using Artemis.UI.Extensions;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Color = System.Windows.Media.Color;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
{
|
||||
@@ -14,8 +13,12 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
{
|
||||
Led = led;
|
||||
|
||||
Execute.OnUIThread(CreateLedGeometry);
|
||||
Update();
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
CreateLedGeometry();
|
||||
FillBrush = new SolidColorBrush { Opacity = 0.25 };
|
||||
BorderBrush = new SolidColorBrush();
|
||||
});
|
||||
}
|
||||
|
||||
public Led Led { get; }
|
||||
@@ -26,9 +29,9 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
public double Height { get; private set; }
|
||||
|
||||
public Geometry DisplayGeometry { get; private set; }
|
||||
public Geometry StrokeGeometry { get; private set; }
|
||||
public Color DisplayColor { get; private set; }
|
||||
public bool ColorsEnabled { get; set; } = true;
|
||||
public SolidColorBrush FillBrush { get; set; }
|
||||
public SolidColorBrush BorderBrush { get; set; }
|
||||
|
||||
|
||||
public string Tooltip => $"{Led.Id} - {Led.LedRectangle}";
|
||||
|
||||
@@ -66,35 +69,19 @@ namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||
GeometryCombineMode.Union,
|
||||
new ScaleTransform(Led.LedRectangle.Width, Led.LedRectangle.Height)
|
||||
);
|
||||
|
||||
// Create a smaller version of the display geometry
|
||||
var innerGeometry = Geometry.Combine(
|
||||
Geometry.Empty,
|
||||
geometry,
|
||||
GeometryCombineMode.Union,
|
||||
new TransformGroup
|
||||
{
|
||||
Children = new TransformCollection
|
||||
{
|
||||
new ScaleTransform(Led.LedRectangle.Width - 2, Led.LedRectangle.Height - 2),
|
||||
new TranslateTransform(1, 1)
|
||||
}
|
||||
}
|
||||
);
|
||||
// Stroke geometry is the display geometry excluding the inner geometry
|
||||
StrokeGeometry = Geometry.Combine(
|
||||
DisplayGeometry,
|
||||
innerGeometry,
|
||||
GeometryCombineMode.Exclude,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
var newColor = Led.Color.ToMediaColor();
|
||||
if (!DisplayColor.Equals(newColor))
|
||||
DisplayColor = newColor;
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
if (!FillBrush.Color.Equals(newColor))
|
||||
{
|
||||
FillBrush.Color = newColor;
|
||||
BorderBrush.Color = newColor;
|
||||
}
|
||||
});
|
||||
|
||||
if (Math.Abs(Led.LedRectangle.X - X) > 0.1)
|
||||
X = Led.LedRectangle.X;
|
||||
|
||||
Reference in new issue
Block a user