mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Nearly fully implemented surface rearranging
This commit is contained in:
1 parent
171f63a1db
commit
9184bbdec2
9 files changed
+175
-547
No files matched your search
@@ -4,12 +4,15 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
||||
{
|
||||
public class RgbDeviceViewModel : PropertyChangedBase
|
||||
{
|
||||
private readonly List<RgbLedViewModel> _leds;
|
||||
private double _dragOffsetX;
|
||||
private double _dragOffsetY;
|
||||
|
||||
public RgbDeviceViewModel(IRGBDevice device)
|
||||
{
|
||||
@@ -38,6 +41,44 @@ namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
||||
rgbLedViewModel.ColorsEnabled = enabled;
|
||||
}
|
||||
|
||||
public void StartMouseDrag(Point mouseStartPosition)
|
||||
{
|
||||
_dragOffsetX = Device.Location.X - mouseStartPosition.X;
|
||||
_dragOffsetY = Device.Location.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;
|
||||
this.Device.Location = new RGB.NET.Core.Point(roundedX, roundedY);
|
||||
}
|
||||
|
||||
public void FinishMouseDrag(Point mouseEndPosition)
|
||||
{
|
||||
// TODO: Save and update
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void MouseEnter()
|
||||
{
|
||||
if (SelectionStatus == SelectionStatus.None)
|
||||
{
|
||||
SelectionStatus = SelectionStatus.Hover;
|
||||
Cursor = Cursors.Hand;
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void MouseLeave()
|
||||
{
|
||||
if (SelectionStatus == SelectionStatus.Hover)
|
||||
{
|
||||
SelectionStatus = SelectionStatus.None;
|
||||
Cursor = Cursors.Arrow;
|
||||
}
|
||||
}
|
||||
|
||||
public Rect DeviceRectangle => new Rect(Device.Location.X, Device.Location.Y, Device.Size.Width, Device.Size.Height);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
||||
Update();
|
||||
}
|
||||
|
||||
[DoNotNotify]
|
||||
public Led Led { get; }
|
||||
|
||||
public double X { get; private set; }
|
||||
@@ -97,6 +96,8 @@ namespace Artemis.UI.ViewModels.Controls.RgbDevice
|
||||
{
|
||||
if (ColorsEnabled)
|
||||
{
|
||||
if (Led.Id == LedId.Keyboard_Y)
|
||||
Console.WriteLine();
|
||||
var newColor = Led.Color.ToMediaColor();
|
||||
SetColor(newColor);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user