mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Made Device, DeviceLed and Surface implement INotifyPropertChange
This commit is contained in:
1 parent
32f07a8772
commit
e7c891c7ba
14 files changed
+107
-37
No files matched your search
@@ -104,8 +104,8 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemContainerStyle>
|
||||
<Style TargetType="ContentPresenter">
|
||||
<Setter Property="Canvas.Left" Value="{Binding RgbDeviceRectangle.Location.X}" />
|
||||
<Setter Property="Canvas.Top" Value="{Binding RgbDeviceRectangle.Location.Y}" />
|
||||
<Setter Property="Canvas.Left" Value="{Binding Device.X}" />
|
||||
<Setter Property="Canvas.Top" Value="{Binding Device.Y}" />
|
||||
</Style>
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -15,7 +15,6 @@ using Artemis.UI.Screens.Shared;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Dialogs;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Ninject.Parameters;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor
|
||||
|
||||
@@ -19,11 +19,12 @@
|
||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.LayoutTransform>
|
||||
<RotateTransform Angle="{Binding Device.RgbDevice.Rotation.Degrees}"></RotateTransform>
|
||||
</Grid.LayoutTransform>
|
||||
<!-- Device image with fallback -->
|
||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" VerticalAlignment="Top" HorizontalAlignment="Left">
|
||||
<Image.LayoutTransform>
|
||||
<RotateTransform Angle="{Binding Device.Rotation}" />
|
||||
</Image.LayoutTransform>
|
||||
</Image>
|
||||
|
||||
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
||||
Stroke="{DynamicResource ControlBorderBrush}"
|
||||
@@ -38,6 +39,9 @@
|
||||
|
||||
<!-- LEDs -->
|
||||
<ItemsControl ItemsSource="{Binding Leds}">
|
||||
<ItemsControl.LayoutTransform>
|
||||
<RotateTransform Angle="{Binding Device.Rotation}" />
|
||||
</ItemsControl.LayoutTransform>
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Canvas />
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using PropertyChanged;
|
||||
using RGB.NET.Core;
|
||||
using Stylet;
|
||||
using Point = System.Windows.Point;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
||||
{
|
||||
@@ -26,24 +25,12 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
||||
foreach (var led in Device.RgbDevice)
|
||||
_leds.Add(new SurfaceLedViewModel(led));
|
||||
}
|
||||
|
||||
Device.DeviceUpdated += DeviceOnDeviceUpdated;
|
||||
}
|
||||
|
||||
private void DeviceOnDeviceUpdated(object sender, EventArgs e)
|
||||
{
|
||||
NotifyOfPropertyChange(() => RgbDeviceRectangle);
|
||||
NotifyOfPropertyChange(() => RgbDeviceRectangle.Location.X);
|
||||
NotifyOfPropertyChange(() => RgbDeviceRectangle.Location.Y);
|
||||
|
||||
}
|
||||
|
||||
public Device Device { get; set; }
|
||||
public SelectionStatus SelectionStatus { get; set; }
|
||||
public Cursor Cursor { get; set; }
|
||||
|
||||
public Rectangle RgbDeviceRectangle => Device.RgbDevice.DeviceRectangle;
|
||||
|
||||
public IReadOnlyCollection<SurfaceLedViewModel> Leds => _leds.AsReadOnly();
|
||||
|
||||
public Rect DeviceRectangle => Device.RgbDevice == null
|
||||
@@ -86,10 +73,7 @@ namespace Artemis.UI.Screens.SurfaceEditor.Visualization
|
||||
|
||||
public MouseDevicePosition GetMouseDevicePosition(Point position)
|
||||
{
|
||||
if ((new Point(0, 0) - position).LengthSquared < 5)
|
||||
{
|
||||
return MouseDevicePosition.TopLeft;
|
||||
}
|
||||
if ((new Point(0, 0) - position).LengthSquared < 5) return MouseDevicePosition.TopLeft;
|
||||
|
||||
return MouseDevicePosition.Regular;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user