Browse Source

Fixed selection visual

flabbet 5 years ago
parent
commit
b4770912e7

+ 2 - 2
PixiEditor/Models/DataHolders/Selection.cs

@@ -12,9 +12,9 @@ namespace PixiEditor.Models.DataHolders
         public Coordinates[] SelectedPoints { get; set; } = null;
         public int VisualCanvasTop => SelectedPoints != null ? SelectedPoints.Min(x => x.Y) : -1;
         public int VisualCanvasLeft => SelectedPoints != null ? SelectedPoints.Min(x => x.X) : -1;
-        public int VisualWidth => SelectedPoints != null ? Math.Abs(SelectedPoints[0].X - SelectedPoints[^1].X) : 0;
+        public int VisualWidth => SelectedPoints != null ? Math.Abs(VisualCanvasLeft + 1 - (SelectedPoints.Max(x => x.X) + 1)) + 1 : 0;
 
-        public int VisualHeight => SelectedPoints != null ? Math.Abs(SelectedPoints[0].Y - SelectedPoints[^1].Y) : 0;
+        public int VisualHeight => SelectedPoints != null ? Math.Abs(VisualCanvasTop + 1 - (SelectedPoints.Max(x => x.Y) + 1)) + 1 : 0;
         public Visibility Visibility => SelectedPoints != null ? Visibility.Visible : Visibility.Collapsed;
 
         public Selection()

+ 1 - 0
PixiEditor/Models/Tools/Tools/SelectTool.cs

@@ -5,6 +5,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
+using System.Windows.Media;
 
 namespace PixiEditor.Models.Tools.Tools
 {