mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Added LED selection
This commit is contained in:
parent
3084869d75
commit
b8fbb3fa24
@ -5,6 +5,7 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||||
xmlns:visualization="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization"
|
xmlns:visualization="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization"
|
||||||
|
xmlns:surfaceEditor="clr-namespace:Artemis.UI.Screens.SurfaceEditor.Visualization"
|
||||||
x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.ProfileLedView"
|
x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.ProfileLedView"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileLedViewModel}}"
|
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileLedViewModel}}"
|
||||||
@ -28,5 +29,66 @@
|
|||||||
<SolidColorBrush Color="{Binding DisplayColor, Mode=OneWay}" />
|
<SolidColorBrush Color="{Binding DisplayColor, Mode=OneWay}" />
|
||||||
</Path.Fill>
|
</Path.Fill>
|
||||||
</Path>
|
</Path>
|
||||||
|
|
||||||
|
<Path Data="{Binding DisplayGeometry, Mode=OneWay}" ClipToBounds="False" StrokeThickness="2">
|
||||||
|
<Path.Style>
|
||||||
|
<Style TargetType="{x:Type Path}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding SelectionStatus}" Value="{x:Static surfaceEditor:SelectionStatus.Hover}">
|
||||||
|
<DataTrigger.EnterActions>
|
||||||
|
<StopStoryboard BeginStoryboardName="ToSelected" />
|
||||||
|
<BeginStoryboard x:Name="ToHover">
|
||||||
|
<Storyboard>
|
||||||
|
<ColorAnimation
|
||||||
|
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
|
||||||
|
To="{StaticResource IdealForegroundColor}" Duration="0:0:0.25" />
|
||||||
|
<ColorAnimation
|
||||||
|
Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)"
|
||||||
|
To="{StaticResource IdealForegroundColor}" Duration="0:0:0.25" />
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</DataTrigger.EnterActions>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectionStatus}" Value="{x:Static surfaceEditor:SelectionStatus.Selected}">
|
||||||
|
<DataTrigger.EnterActions>
|
||||||
|
<StopStoryboard BeginStoryboardName="ToHover" />
|
||||||
|
<BeginStoryboard x:Name="ToSelected">
|
||||||
|
<Storyboard>
|
||||||
|
<ColorAnimation
|
||||||
|
Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)"
|
||||||
|
To="{StaticResource Accent700}" Duration="0:0:0.25" />
|
||||||
|
<ColorAnimation
|
||||||
|
Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)"
|
||||||
|
To="{StaticResource Accent400}" Duration="0:0:0.25" />
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</DataTrigger.EnterActions>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding SelectionStatus}" Value="{x:Static surfaceEditor:SelectionStatus.None}">
|
||||||
|
<DataTrigger.EnterActions>
|
||||||
|
<BeginStoryboard>
|
||||||
|
<Storyboard>
|
||||||
|
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:0.25" />
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</DataTrigger.EnterActions>
|
||||||
|
<DataTrigger.ExitActions>
|
||||||
|
<BeginStoryboard>
|
||||||
|
<Storyboard>
|
||||||
|
<DoubleAnimation Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:0.25" />
|
||||||
|
</Storyboard>
|
||||||
|
</BeginStoryboard>
|
||||||
|
</DataTrigger.ExitActions>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Path.Style>
|
||||||
|
<Path.Fill>
|
||||||
|
<SolidColorBrush Color="{StaticResource Accent400}" Opacity="0.65" />
|
||||||
|
</Path.Fill>
|
||||||
|
<Path.Stroke>
|
||||||
|
<SolidColorBrush Color="{StaticResource Accent400}"></SolidColorBrush>
|
||||||
|
</Path.Stroke>
|
||||||
|
</Path>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@ -2,6 +2,7 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Artemis.UI.Extensions;
|
using Artemis.UI.Extensions;
|
||||||
|
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
using Color = System.Windows.Media.Color;
|
using Color = System.Windows.Media.Color;
|
||||||
@ -24,6 +25,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Led Led { get; }
|
public Led Led { get; }
|
||||||
|
public SelectionStatus SelectionStatus { get; set; }
|
||||||
|
|
||||||
public double X { get; }
|
public double X { get; }
|
||||||
public double Y { get; }
|
public double Y { get; }
|
||||||
|
|||||||
@ -41,7 +41,8 @@
|
|||||||
MouseWheel="{s:Action EditorGridMouseWheel}"
|
MouseWheel="{s:Action EditorGridMouseWheel}"
|
||||||
MouseUp="{s:Action EditorGridMouseClick}"
|
MouseUp="{s:Action EditorGridMouseClick}"
|
||||||
MouseDown="{s:Action EditorGridMouseClick}"
|
MouseDown="{s:Action EditorGridMouseClick}"
|
||||||
MouseMove="{s:Action EditorGridMouseMove}">
|
MouseMove="{s:Action EditorGridMouseMove}"
|
||||||
|
Cursor="{Binding Cursor}">
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
<VisualBrush TileMode="Tile" Stretch="Uniform" Viewport="{Binding PanZoomViewModel.BackgroundViewport}" ViewportUnits="Absolute">
|
||||||
<VisualBrush.Visual>
|
<VisualBrush.Visual>
|
||||||
|
|||||||
@ -8,8 +8,10 @@ using Artemis.Core.Events;
|
|||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.Core.Services.Storage.Interfaces;
|
using Artemis.Core.Services.Storage.Interfaces;
|
||||||
|
using Artemis.UI.Extensions;
|
||||||
using Artemis.UI.Screens.Shared;
|
using Artemis.UI.Screens.Shared;
|
||||||
using Artemis.UI.Screens.SurfaceEditor;
|
using Artemis.UI.Screens.SurfaceEditor;
|
||||||
|
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
using Point = System.Windows.Point;
|
using Point = System.Windows.Point;
|
||||||
@ -28,6 +30,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
SelectionRectangle = new RectangleGeometry();
|
SelectionRectangle = new RectangleGeometry();
|
||||||
PanZoomViewModel = new PanZoomViewModel();
|
PanZoomViewModel = new PanZoomViewModel();
|
||||||
});
|
});
|
||||||
|
Cursor = null;
|
||||||
|
|
||||||
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
ApplySurfaceConfiguration(surfaceService.ActiveSurface);
|
||||||
|
|
||||||
@ -45,6 +48,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
public ObservableCollection<ProfileDeviceViewModel> Devices { get; set; }
|
||||||
public RectangleGeometry SelectionRectangle { get; set; }
|
public RectangleGeometry SelectionRectangle { get; set; }
|
||||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||||
|
public Cursor Cursor { get; set; }
|
||||||
|
|
||||||
private void OnActiveSurfaceConfigurationChanged(object sender, SurfaceConfigurationEventArgs e)
|
private void OnActiveSurfaceConfigurationChanged(object sender, SurfaceConfigurationEventArgs e)
|
||||||
{
|
{
|
||||||
@ -158,9 +162,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
private void StopMouseDrag(Point position)
|
private void StopMouseDrag(Point position)
|
||||||
{
|
{
|
||||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||||
// TODO: Select LEDs
|
foreach (var device in Devices)
|
||||||
|
{
|
||||||
|
foreach (var profileLedViewModel in device.Leds)
|
||||||
|
{
|
||||||
|
if (PanZoomViewModel.TransformContainingRect(profileLedViewModel.Led.AbsoluteLedRectangle.ToWindowsRect(1)).IntersectsWith(selectedRect))
|
||||||
|
profileLedViewModel.SelectionStatus = SelectionStatus.Selected;
|
||||||
|
else if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
profileLedViewModel.SelectionStatus = SelectionStatus.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Mouse.OverrideCursor = null;
|
|
||||||
_mouseDragStatus = MouseDragStatus.None;
|
_mouseDragStatus = MouseDragStatus.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -169,12 +181,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
if (IsPanKeyDown())
|
if (IsPanKeyDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (Devices)
|
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||||
{
|
SelectionRectangle.Rect = selectedRect;
|
||||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
|
||||||
SelectionRectangle.Rect = selectedRect;
|
|
||||||
|
|
||||||
// TODO: Highlight LEDs
|
foreach (var device in Devices)
|
||||||
|
{
|
||||||
|
foreach (var profileLedViewModel in device.Leds)
|
||||||
|
{
|
||||||
|
if (PanZoomViewModel.TransformContainingRect(profileLedViewModel.Led.AbsoluteLedRectangle.ToWindowsRect(1)).IntersectsWith(selectedRect))
|
||||||
|
profileLedViewModel.SelectionStatus = SelectionStatus.Selected;
|
||||||
|
else if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
||||||
|
profileLedViewModel.SelectionStatus = SelectionStatus.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,13 +208,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
|
|||||||
public void EditorGridKeyDown(object sender, KeyEventArgs e)
|
public void EditorGridKeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if ((e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) && e.IsDown)
|
if ((e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) && e.IsDown)
|
||||||
Mouse.OverrideCursor = Cursors.ScrollAll;
|
Cursor = Cursors.ScrollAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EditorGridKeyUp(object sender, KeyEventArgs e)
|
public void EditorGridKeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
if ((e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) && e.IsUp)
|
if ((e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl) && e.IsUp)
|
||||||
Mouse.OverrideCursor = null;
|
Cursor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pan(object sender, MouseEventArgs e)
|
public void Pan(object sender, MouseEventArgs e)
|
||||||
|
|||||||
@ -333,18 +333,15 @@ namespace Artemis.UI.Screens.SurfaceEditor
|
|||||||
if (IsPanKeyDown())
|
if (IsPanKeyDown())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock (Devices)
|
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
||||||
{
|
SelectionRectangle.Rect = selectedRect;
|
||||||
var selectedRect = new Rect(_mouseDragStartPoint, position);
|
|
||||||
SelectionRectangle.Rect = selectedRect;
|
|
||||||
|
|
||||||
foreach (var device in Devices)
|
foreach (var device in Devices)
|
||||||
{
|
{
|
||||||
if (PanZoomViewModel.TransformContainingRect(device.DeviceRectangle).IntersectsWith(selectedRect))
|
if (PanZoomViewModel.TransformContainingRect(device.DeviceRectangle).IntersectsWith(selectedRect))
|
||||||
device.SelectionStatus = SelectionStatus.Selected;
|
device.SelectionStatus = SelectionStatus.Selected;
|
||||||
else if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
else if (!Keyboard.IsKeyDown(Key.LeftShift) && !Keyboard.IsKeyDown(Key.RightShift))
|
||||||
device.SelectionStatus = SelectionStatus.None;
|
device.SelectionStatus = SelectionStatus.None;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -71,8 +71,7 @@
|
|||||||
<Rectangle.Style>
|
<Rectangle.Style>
|
||||||
<Style TargetType="{x:Type Rectangle}">
|
<Style TargetType="{x:Type Rectangle}">
|
||||||
<Style.Triggers>
|
<Style.Triggers>
|
||||||
<DataTrigger Binding="{Binding SelectionStatus}"
|
<DataTrigger Binding="{Binding SelectionStatus}" Value="{x:Static surfaceEditor:SelectionStatus.Hover}">
|
||||||
Value="{x:Static surfaceEditor:SelectionStatus.Hover}">
|
|
||||||
<DataTrigger.EnterActions>
|
<DataTrigger.EnterActions>
|
||||||
<StopStoryboard BeginStoryboardName="ToSelected" />
|
<StopStoryboard BeginStoryboardName="ToSelected" />
|
||||||
<BeginStoryboard x:Name="ToHover">
|
<BeginStoryboard x:Name="ToHover">
|
||||||
@ -87,8 +86,7 @@
|
|||||||
</BeginStoryboard>
|
</BeginStoryboard>
|
||||||
</DataTrigger.EnterActions>
|
</DataTrigger.EnterActions>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
<DataTrigger Binding="{Binding SelectionStatus}"
|
<DataTrigger Binding="{Binding SelectionStatus}" Value="{x:Static surfaceEditor:SelectionStatus.Selected}">
|
||||||
Value="{x:Static surfaceEditor:SelectionStatus.Selected}">
|
|
||||||
<DataTrigger.EnterActions>
|
<DataTrigger.EnterActions>
|
||||||
<StopStoryboard BeginStoryboardName="ToHover" />
|
<StopStoryboard BeginStoryboardName="ToHover" />
|
||||||
<BeginStoryboard x:Name="ToSelected">
|
<BeginStoryboard x:Name="ToSelected">
|
||||||
@ -103,8 +101,7 @@
|
|||||||
</BeginStoryboard>
|
</BeginStoryboard>
|
||||||
</DataTrigger.EnterActions>
|
</DataTrigger.EnterActions>
|
||||||
</DataTrigger>
|
</DataTrigger>
|
||||||
<DataTrigger Binding="{Binding SelectionStatus}"
|
<DataTrigger Binding="{Binding SelectionStatus}" Value="{x:Static surfaceEditor:SelectionStatus.None}">
|
||||||
Value="{x:Static surfaceEditor:SelectionStatus.None}">
|
|
||||||
<DataTrigger.EnterActions>
|
<DataTrigger.EnterActions>
|
||||||
<BeginStoryboard>
|
<BeginStoryboard>
|
||||||
<Storyboard>
|
<Storyboard>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user