mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Implemented surface config loading/saving/activating
This commit is contained in:
1 parent
c4e5e412e0
commit
c2c849201d
8 files changed
+210
-134
No files matched your search
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Point = System.Windows.Point;
|
||||
@@ -14,39 +15,56 @@ namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
|
||||
private double _dragOffsetY;
|
||||
private readonly List<SurfaceLedViewModel> _leds;
|
||||
|
||||
public SurfaceDeviceViewModel(IRGBDevice device)
|
||||
public SurfaceDeviceViewModel(SurfaceDeviceConfiguration deviceConfiguration)
|
||||
{
|
||||
Device = device;
|
||||
DeviceConfiguration = deviceConfiguration;
|
||||
_leds = new List<SurfaceLedViewModel>();
|
||||
|
||||
foreach (var led in Device)
|
||||
_leds.Add(new SurfaceLedViewModel(led));
|
||||
if (DeviceConfiguration.Device != null)
|
||||
{
|
||||
foreach (var led in DeviceConfiguration.Device)
|
||||
_leds.Add(new SurfaceLedViewModel(led));
|
||||
}
|
||||
}
|
||||
|
||||
public IRGBDevice Device { get; }
|
||||
public SurfaceDeviceConfiguration DeviceConfiguration { get; }
|
||||
public SelectionStatus SelectionStatus { get; set; }
|
||||
public Cursor Cursor { get; set; }
|
||||
public int ZIndex { get; set; }
|
||||
|
||||
public double X
|
||||
{
|
||||
get => DeviceConfiguration.X;
|
||||
set => DeviceConfiguration.X = value;
|
||||
}
|
||||
|
||||
public double Y
|
||||
{
|
||||
get => DeviceConfiguration.Y;
|
||||
set => DeviceConfiguration.Y = value;
|
||||
}
|
||||
|
||||
public int ZIndex
|
||||
{
|
||||
get => DeviceConfiguration.ZIndex;
|
||||
set => DeviceConfiguration.ZIndex = value;
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<SurfaceLedViewModel> Leds => _leds.AsReadOnly();
|
||||
public Rect DeviceRectangle => new Rect(Device.Location.X, Device.Location.Y, Device.Size.Width, Device.Size.Height);
|
||||
|
||||
public Rect DeviceRectangle => new Rect(X, Y, DeviceConfiguration.Device.Size.Width, DeviceConfiguration.Device.Size.Height);
|
||||
|
||||
public void StartMouseDrag(Point mouseStartPosition)
|
||||
{
|
||||
_dragOffsetX = Device.Location.X - mouseStartPosition.X;
|
||||
_dragOffsetY = Device.Location.Y - mouseStartPosition.Y;
|
||||
_dragOffsetX = X - mouseStartPosition.X;
|
||||
_dragOffsetY = Y - mouseStartPosition.Y;
|
||||
}
|
||||
|
||||
public void UpdateMouseDrag(Point mousePosition)
|
||||
{
|
||||
var roundedX = Math.Round((mousePosition.X + _dragOffsetX) / 10, 0, MidpointRounding.AwayFromZero) * 10;
|
||||
var roundedY = Math.Round((mousePosition.Y + _dragOffsetY) / 10, 0, MidpointRounding.AwayFromZero) * 10;
|
||||
Device.Location = new RGB.NET.Core.Point(roundedX, roundedY);
|
||||
}
|
||||
|
||||
public void FinishMouseDrag(Point mouseEndPosition)
|
||||
{
|
||||
// TODO: Save and update
|
||||
X = roundedX;
|
||||
Y = roundedY;
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
|
||||
Reference in new issue
Block a user