Fix shape positioning on layer LED selection change

This commit is contained in:
Robert committed 2020-01-30 22:08:38 +01:00
1 parent 5a44e5fbe8
commit 0794966e38
14 files changed
+89 -50

No files matched your search

@@ -105,7 +105,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
Execute.PostToUIThread(() =>
{
var rect = _layerEditorService.GetShapeRenderRect(Layer.LayerShape);
var rect = _layerEditorService.GetShapeUntransformedRect(Layer.LayerShape);
var shapeGeometry = Geometry.Empty;
switch (Layer.LayerShape)
{
@@ -46,7 +46,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
ShapeAnchor = _layerEditorService.GetLayerAnchor(layer, true);
Execute.PostToUIThread(() =>
{
var shapeGeometry = new RectangleGeometry(_layerEditorService.GetShapeRenderRect(layer.LayerShape))
var shapeGeometry = new RectangleGeometry(_layerEditorService.GetShapeUntransformedRect(layer.LayerShape))
{
Transform = _layerEditorService.GetLayerTransformGroup(layer)
};
@@ -53,7 +53,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
layer.LayerShape = new Ellipse(layer);
// Apply the drag rectangle
_layerEditorService.SetShapeRenderRect(layer.LayerShape, DragRectangle);
_layerEditorService.SetShapeBaseFromRectangle(layer.LayerShape, DragRectangle);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
@@ -42,7 +42,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
layer.LayerShape = new Fill(layer);
// Apply the full layer rectangle
_layerEditorService.SetShapeRenderRect(layer.LayerShape, _layerEditorService.GetLayerRect(layer));
_layerEditorService.SetShapeBaseFromRectangle(layer.LayerShape, _layerEditorService.GetLayerRect(layer));
ProfileEditorService.UpdateSelectedProfileElement();
}
}
@@ -52,7 +52,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
layer.LayerShape = new Rectangle(layer);
// Apply the drag rectangle
_layerEditorService.SetShapeRenderRect(layer.LayerShape, DragRectangle);
_layerEditorService.SetShapeBaseFromRectangle(layer.LayerShape, DragRectangle);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
@@ -9,6 +10,8 @@ using Artemis.UI.Extensions;
using Artemis.UI.Properties;
using Artemis.UI.Services;
using Artemis.UI.Services.Interfaces;
using SkiaSharp;
using SkiaSharp.Views.WPF;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
{
@@ -52,18 +55,18 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// If the layer has a shape, save it's size
var shapeSize = Rect.Empty;
var shapeSize = SKRect.Empty;
if (layer.LayerShape != null)
shapeSize = _layerEditorService.GetShapeRenderRect(layer.LayerShape);
shapeSize = layer.LayerShape.GetUnscaledRectangle();
var remainingLeds = layer.Leds.Except(selectedLeds).ToList();
layer.ClearLeds();
layer.AddLeds(remainingLeds);
// Restore the saved size
if (layer.LayerShape != null)
_layerEditorService.SetShapeRenderRect(layer.LayerShape, shapeSize);
layer.LayerShape.SetFromUnscaledRectangle(shapeSize);
ProfileEditorService.UpdateSelectedProfileElement();
}
}
@@ -53,9 +53,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
if (ProfileEditorService.SelectedProfileElement is Layer layer)
{
// If the layer has a shape, save it's size
var shapeSize = Rect.Empty;
var shapeSize = SKRect.Empty;
if (layer.LayerShape != null)
shapeSize = _layerEditorService.GetShapeRenderRect(layer.LayerShape);
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))
@@ -68,7 +68,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
// Restore the saved size
if (layer.LayerShape != null)
_layerEditorService.SetShapeRenderRect(layer.LayerShape, shapeSize);
layer.LayerShape.SetFromUnscaledRectangle(shapeSize);
ProfileEditorService.UpdateSelectedProfileElement();
}