Removed separate shape size

This commit is contained in:
SpoinkyNL committed 2020-02-04 22:01:02 +01:00
1 parent 436994129a
commit 2c60a42315
34 files changed
+81 -862

No files matched your search

@@ -32,35 +32,33 @@
</Style>
</UserControl.Resources>
<Canvas Style="{StaticResource SelectedStyle}">
<!-- The shape is inside the layer's bounds -->
<Canvas Canvas.Left="{Binding LayerBounds.X}" Canvas.Top="{Binding LayerBounds.Y}">
<!-- The part of the layer's shape that falls outside the layer -->
<Path Data="{Binding ShapeGeometry, Mode=OneWay}">
<Path.Fill>
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.05" />
</Path.Fill>
<Path.Stroke>
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.15" />
</Path.Stroke>
</Path>
<!-- The part of the layer's shape that is inside the layer -->
<Path Data="{Binding ShapeGeometry, Mode=OneWay}">
<Path.Fill>
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.15" />
</Path.Fill>
<Path.Stroke>
<SolidColorBrush Color="{StaticResource Accent700}" />
</Path.Stroke>
<Path.OpacityMask>
<VisualBrush Viewport="{Binding ViewportRectangle}" ViewportUnits="Absolute">
<VisualBrush.Visual>
<Path Data="{Binding LayerGeometry, Mode=OneWay}" ClipToBounds="False" Fill="Black" />
</VisualBrush.Visual>
</VisualBrush>
</Path.OpacityMask>
</Path>
</Canvas>
<!-- The part of the layer's shape that falls outside the layer -->
<Path Data="{Binding ShapeGeometry, Mode=OneWay}">
<Path.Fill>
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.05" />
</Path.Fill>
<Path.Stroke>
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.15" />
</Path.Stroke>
</Path>
<!-- The part of the layer's shape that is inside the layer -->
<Path Data="{Binding ShapeGeometry, Mode=OneWay}">
<Path.Fill>
<SolidColorBrush Color="{StaticResource Accent700}" Opacity="0.15" />
</Path.Fill>
<Path.Stroke>
<SolidColorBrush Color="{StaticResource Accent700}" />
</Path.Stroke>
<Path.OpacityMask>
<VisualBrush Viewport="{Binding ViewportRectangle}" ViewportUnits="Absolute">
<VisualBrush.Visual>
<Path Data="{Binding LayerGeometry, Mode=OneWay}" ClipToBounds="False" Fill="Black" />
</VisualBrush.Visual>
</VisualBrush>
</Path.OpacityMask>
</Path>
<Path Data="{Binding LayerGeometry, Mode=OneWay}" ClipToBounds="False" StrokeThickness="1.5" StrokeLineJoin="Round" x:Name="LayerPath">
<Path.Stroke>
@@ -30,11 +30,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
_profileEditorService.SelectedProfileElementUpdated += OnSelectedProfileElementUpdated;
_profileEditorService.ProfilePreviewUpdated += ProfileEditorServiceOnProfilePreviewUpdated;
}
public Layer Layer { get; }
public Rect LayerBounds { get; set; }
public Geometry LayerGeometry { get; set; }
public Geometry OpacityGeometry { get; set; }
public Geometry ShapeGeometry { get; set; }
@@ -53,7 +51,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
{
if (!Layer.Leds.Any())
{
LayerBounds = Rect.Empty;
LayerGeometry = Geometry.Empty;
OpacityGeometry = Geometry.Empty;
ViewportRectangle = Rect.Empty;
@@ -89,8 +86,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
var layerGeometry = group.GetOutlinedPathGeometry();
var opacityGeometry = Geometry.Combine(Geometry.Empty, layerGeometry, GeometryCombineMode.Exclude, new TranslateTransform());
LayerBounds = _layerEditorService.GetLayerBounds(Layer);
LayerGeometry = layerGeometry;
OpacityGeometry = opacityGeometry;
}
@@ -105,25 +101,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
Execute.PostToUIThread(() =>
{
var bounds = _layerEditorService.GetLayerShapeBounds(Layer.LayerShape);
var bounds = _layerEditorService.GetLayerBounds(Layer);
var shapeGeometry = Geometry.Empty;
switch (Layer.LayerShape)
{
case Ellipse _:
shapeGeometry = new EllipseGeometry(bounds);
break;
case Fill _:
// Shape originates from the center so compensate the geometry for that, create a copy
shapeGeometry = LayerGeometry.Clone();
// Add a transformation
shapeGeometry.Transform = new TranslateTransform(bounds.Left - shapeGeometry.Bounds.Left, bounds.Top - shapeGeometry.Bounds.Top);
// Apply the transformation so that it won't be overridden
shapeGeometry = shapeGeometry.GetOutlinedPathGeometry();
break;
case Polygon _:
// TODO
shapeGeometry = new RectangleGeometry(bounds);
break;
case Rectangle _:
shapeGeometry = new RectangleGeometry(bounds);
break;
@@ -142,8 +126,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
return;
}
var rect = _layerEditorService.GetLayerBounds(Layer);
ViewportRectangle = new Rect(0, 0, rect.Width, rect.Height);
ViewportRectangle = _layerEditorService.GetLayerBounds(Layer);
}
private Geometry CreateRectangleGeometry(ArtemisLed led)
@@ -8,7 +8,7 @@
xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization"
xmlns:utilities="clr-namespace:Artemis.UI.Utilities"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DesignHeight="510.9" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileViewModel}}">
<UserControl.Resources>
<Style TargetType="Grid" x:Key="InitializingFade">
@@ -65,21 +65,7 @@
<ListBoxItem ToolTip="Remove from layer selection">
<materialDesign:PackIcon Kind="SelectOff" />
</ListBoxItem>
<Separator />
<ListBoxItem ToolTip="Create round shape in layer">
<materialDesign:PackIcon Kind="ShapeCirclePlus" />
</ListBoxItem>
<ListBoxItem ToolTip="Create rectangular shape in layer">
<materialDesign:PackIcon Kind="ShapeRectanglePlus" />
</ListBoxItem>
<ListBoxItem ToolTip="Create polygonal shape in layer">
<materialDesign:PackIcon Kind="ShapePolygonPlus" />
</ListBoxItem>
<ListBoxItem ToolTip="Fill entire layer">
<materialDesign:PackIcon Kind="FormatColourFill" />
</ListBoxItem>
</ListBox>
</ToolBar>
</ToolBarTray>
<Grid Grid.Column="1"
@@ -259,22 +259,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
ActiveToolViewModel = new EditToolViewModel(this, _profileEditorService, _layerEditorService);
break;
case 2:
ActiveToolViewModel = new SelectionToolViewModel(this, _profileEditorService, _layerEditorService);
ActiveToolViewModel = new SelectionToolViewModel(this, _profileEditorService);
break;
case 3:
ActiveToolViewModel = new SelectionRemoveToolViewModel(this, _profileEditorService, _layerEditorService);
break;
case 5:
ActiveToolViewModel = new EllipseToolViewModel(this, _profileEditorService, _layerEditorService);
break;
case 6:
ActiveToolViewModel = new RectangleToolViewModel(this, _profileEditorService, _layerEditorService);
break;
case 7:
ActiveToolViewModel = new PolygonToolViewModel(this, _profileEditorService);
break;
case 8:
ActiveToolViewModel = new FillToolViewModel(this, _profileEditorService, _layerEditorService);
ActiveToolViewModel = new SelectionRemoveToolViewModel(this, _profileEditorService);
break;
}
@@ -11,9 +11,7 @@
d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type local:EditToolViewModel}}">
<Canvas UseLayoutRounding="False">
<userControls:LayerShapeControl Canvas.Left="{Binding LayerBounds.Left}"
Canvas.Top="{Binding LayerBounds.Top}"
Zoom="{Binding ProfileViewModel.PanZoomViewModel.Zoom}"
<userControls:LayerShapeControl Zoom="{Binding ProfileViewModel.PanZoomViewModel.Zoom}"
ShapePath="{Binding ShapePath}"
ShapeAnchor="{Binding ShapeAnchor}"
ShapeGeometry="{Binding ShapeGeometry}"
@@ -32,7 +32,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
profileEditorService.ProfilePreviewUpdated += (sender, args) => Update();
}
public Rect LayerBounds { get; set; }
public SKPath ShapePath { get; set; }
public SKPoint ShapeAnchor { get; set; }
public RectangleGeometry ShapeGeometry { get; set; }
@@ -42,12 +41,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
if (!(ProfileEditorService.SelectedProfileElement is Layer layer))
return;
LayerBounds = _layerEditorService.GetLayerBounds(layer);
ShapePath = _layerEditorService.GetLayerPath(layer, true, true, true);
ShapeAnchor = _layerEditorService.GetLayerAnchorPosition(layer).ToSKPoint();
Execute.PostToUIThread(() =>
{
var shapeGeometry = new RectangleGeometry(_layerEditorService.GetLayerShapeBounds(layer.LayerShape))
var shapeGeometry = new RectangleGeometry(_layerEditorService.GetLayerBounds(layer))
{
Transform = _layerEditorService.GetLayerTransformGroup(layer)
};
@@ -1,62 +0,0 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.EllipseToolView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style TargetType="Shape" x:Key="ShowIfMouseDown">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseDown}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity">
<DoubleAnimation From="0" To="1" Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity">
<DoubleAnimation From="1" To="0" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Canvas Background="Transparent" Width="50" Height="50">
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="Ellipse action 1" Command="{s:Action CreateLayer}" CommandParameter="{Binding}">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="LayersPlus" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Ellipse action 2" Command="{s:Action ApplyToLayer}" CommandParameter="{Binding}">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="Selection" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Canvas.ContextMenu>
<Ellipse Style="{StaticResource ShowIfMouseDown}"
Width="{Binding DragRectangle.Width}"
Height="{Binding DragRectangle.Height}"
Canvas.Left="{Binding DragRectangle.X}"
Canvas.Top="{Binding DragRectangle.Y}"
Stroke="{DynamicResource PrimaryHueLightBrush}"
StrokeThickness="1"
Opacity="0">
<Ellipse.Fill>
<SolidColorBrush Color="{DynamicResource Primary400}" Opacity="0.25" />
</Ellipse.Fill>
</Ellipse>
</Canvas>
</UserControl>
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
/// <summary>
/// Interaction logic for EllipseToolView.xaml
/// </summary>
public partial class EllipseToolView : UserControl
{
public EllipseToolView()
{
InitializeComponent();
}
}
}
@@ -1,74 +0,0 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class EllipseToolViewModel : VisualizationToolViewModel
{
private readonly ILayerEditorService _layerEditorService;
private bool _shiftDown;
public EllipseToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
: base(profileViewModel, profileEditorService)
{
_layerEditorService = layerEditorService;
using (var stream = new MemoryStream(Resources.aero_crosshair))
{
Cursor = new Cursor(stream);
}
}
public Rect DragRectangle { get; set; }
public override void MouseMove(object sender, MouseEventArgs e)
{
base.MouseMove(sender, e);
if (!IsMouseDown)
return;
var position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e);
if (!_shiftDown)
DragRectangle = new Rect(MouseDownStartPosition, position);
else
DragRectangle = GetSquareRectBetweenPoints(MouseDownStartPosition, position);
}
public override void MouseUp(object sender, MouseButtonEventArgs e)
{
base.MouseUp(sender, e);
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// Ensure the shape is an ellipse, we're all about ellipses up here
if (!(layer.LayerShape is Ellipse))
layer.LayerShape = new Ellipse(layer);
// Apply the drag rectangle
_layerEditorService.SetShapeBaseFromRectangle(layer.LayerShape, DragRectangle);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
public override void KeyUp(KeyEventArgs e)
{
base.KeyUp(e);
if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
_shiftDown = false;
}
public override void KeyDown(KeyEventArgs e)
{
base.KeyDown(e);
if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
_shiftDown = true;
}
}
}
@@ -1,9 +0,0 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.FillToolView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
</UserControl>
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
/// <summary>
/// Interaction logic for FillToolView.xaml
/// </summary>
public partial class FillToolView : UserControl
{
public FillToolView()
{
InitializeComponent();
}
}
}
@@ -1,46 +0,0 @@
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class FillToolViewModel : VisualizationToolViewModel
{
private readonly ILayerEditorService _layerEditorService;
public FillToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService) : base(profileViewModel, profileEditorService)
{
_layerEditorService = layerEditorService;
using (var stream = new MemoryStream(Resources.aero_fill))
{
Cursor = new Cursor(stream);
}
}
public override void MouseUp(object sender, MouseButtonEventArgs e)
{
base.MouseUp(sender, e);
// Find out if the click is inside a layer and if so, fill it
var position = e.GetPosition((IInputElement) sender);
var panZoomVm = ProfileViewModel.PanZoomViewModel;
var layer = ProfileEditorService.SelectedProfile
.GetAllLayers()
.FirstOrDefault(l => l.Leds.Any(
led => panZoomVm.TransformContainingRect(led.RgbLed.AbsoluteLedRectangle).Contains(position))
);
if (layer == null)
return;
layer.LayerShape = new Fill(layer);
// Apply the full layer rectangle
_layerEditorService.SetShapeBaseFromRectangle(layer.LayerShape, _layerEditorService.GetLayerBounds(layer));
ProfileEditorService.UpdateSelectedProfileElement();
}
}
}
@@ -1,10 +0,0 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.PolygonToolView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid />
</UserControl>
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
/// <summary>
/// Interaction logic for PolygonToolView.xaml
/// </summary>
public partial class PolygonToolView : UserControl
{
public PolygonToolView()
{
InitializeComponent();
}
}
}
@@ -1,18 +0,0 @@
using System.IO;
using System.Windows.Input;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class PolygonToolViewModel : VisualizationToolViewModel
{
public PolygonToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
{
using (var stream = new MemoryStream(Resources.aero_crosshair))
{
Cursor = new Cursor(stream);
}
}
}
}
@@ -1,62 +0,0 @@
<UserControl x:Class="Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools.RectangleToolView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<Style TargetType="Shape" x:Key="ShowIfMouseDown">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseDown}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity">
<DoubleAnimation From="0" To="1" Duration="0:0:0.1" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard TargetProperty="Opacity">
<DoubleAnimation From="1" To="0" Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<Canvas Background="Transparent" Width="50" Height="50">
<Canvas.ContextMenu>
<ContextMenu>
<MenuItem Header="Ellipse action 1" Command="{s:Action CreateLayer}" CommandParameter="{Binding}">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="LayersPlus" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Ellipse action 2" Command="{s:Action ApplyToLayer}" CommandParameter="{Binding}">
<MenuItem.Icon>
<materialDesign:PackIcon Kind="Selection" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</Canvas.ContextMenu>
<Rectangle Style="{StaticResource ShowIfMouseDown}"
Width="{Binding DragRectangle.Width}"
Height="{Binding DragRectangle.Height}"
Canvas.Left="{Binding DragRectangle.X}"
Canvas.Top="{Binding DragRectangle.Y}"
Stroke="{DynamicResource PrimaryHueLightBrush}"
StrokeThickness="1"
Opacity="0">
<Rectangle.Fill>
<SolidColorBrush Color="{DynamicResource Primary400}" Opacity="0.25" />
</Rectangle.Fill>
</Rectangle>
</Canvas>
</UserControl>
@@ -1,15 +0,0 @@
using System.Windows.Controls;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
/// <summary>
/// Interaction logic for RectangleToolView.xaml
/// </summary>
public partial class RectangleToolView : UserControl
{
public RectangleToolView()
{
InitializeComponent();
}
}
}
@@ -1,74 +0,0 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class RectangleToolViewModel : VisualizationToolViewModel
{
private readonly ILayerEditorService _layerEditorService;
private bool _shiftDown;
public RectangleToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
: base(profileViewModel, profileEditorService)
{
_layerEditorService = layerEditorService;
using (var stream = new MemoryStream(Resources.aero_crosshair))
{
Cursor = new Cursor(stream);
}
}
public Rect DragRectangle { get; set; }
public override void MouseMove(object sender, MouseEventArgs e)
{
base.MouseMove(sender, e);
if (!IsMouseDown)
return;
var position = ProfileViewModel.PanZoomViewModel.GetRelativeMousePosition(sender, e);
if (!_shiftDown)
DragRectangle = new Rect(MouseDownStartPosition, position);
else
DragRectangle = GetSquareRectBetweenPoints(MouseDownStartPosition, position);
}
public override void MouseUp(object sender, MouseButtonEventArgs e)
{
base.MouseUp(sender, e);
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// Ensure the shape is a rectangle
if (!(layer.LayerShape is Rectangle))
layer.LayerShape = new Rectangle(layer);
// Apply the drag rectangle
_layerEditorService.SetShapeBaseFromRectangle(layer.LayerShape, DragRectangle);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
public override void KeyUp(KeyEventArgs e)
{
base.KeyUp(e);
if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
_shiftDown = false;
}
public override void KeyDown(KeyEventArgs e)
{
base.KeyDown(e);
if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
_shiftDown = true;
}
}
}
@@ -8,18 +8,13 @@ using Artemis.Core.Models.Surface;
using Artemis.UI.Extensions;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class SelectionRemoveToolViewModel : VisualizationToolViewModel
{
private readonly ILayerEditorService _layerEditorService;
public SelectionRemoveToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService) : base(profileViewModel,
profileEditorService)
public SelectionRemoveToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
{
_layerEditorService = layerEditorService;
using (var stream = new MemoryStream(Resources.aero_pen_min))
{
Cursor = new Cursor(stream);
@@ -51,19 +46,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
// Apply the selection to the selected layer layer
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// If the layer has a shape, save it's size
var shapeSize = SKRect.Empty;
if (layer.LayerShape != null)
shapeSize = layer.LayerShape.GetUnscaledRectangle();
var remainingLeds = layer.Leds.Except(selectedLeds).ToList();
layer.ClearLeds();
layer.AddLeds(remainingLeds);
// Restore the saved size
if (layer.LayerShape != null)
layer.LayerShape.SetFromUnscaledRectangle(shapeSize);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
@@ -8,18 +8,13 @@ using Artemis.Core.Models.Surface;
using Artemis.UI.Extensions;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using SkiaSharp;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
public class SelectionToolViewModel : VisualizationToolViewModel
{
private readonly ILayerEditorService _layerEditorService;
public SelectionToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService, ILayerEditorService layerEditorService)
: base(profileViewModel, profileEditorService)
public SelectionToolViewModel(ProfileViewModel profileViewModel, IProfileEditorService profileEditorService) : base(profileViewModel, profileEditorService)
{
_layerEditorService = layerEditorService;
using (var stream = new MemoryStream(Resources.aero_crosshair))
{
Cursor = new Cursor(stream);
@@ -51,11 +46,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
// Apply the selection to the selected layer layer
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// If the layer has a shape, save it's size
var shapeSize = SKRect.Empty;
if (layer.LayerShape != null)
shapeSize = layer.LayerShape.GetUnscaledRectangle();
// If shift is held down, add to the selection instead of replacing it
if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
layer.AddLeds(selectedLeds.Except(layer.Leds));
@@ -65,10 +55,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
layer.AddLeds(selectedLeds);
}
// Restore the saved size
if (layer.LayerShape != null)
layer.LayerShape.SetFromUnscaledRectangle(shapeSize);
ProfileEditorService.UpdateSelectedProfileElement();
}
// If no layer selected, apply it to a new layer in the selected folder