@@ -10,23 +10,21 @@ public class ResizeShapesAction : IAction
1010 private readonly IReadOnlyCollection < ShapeViewModel > _resizedShapes ;
1111 private readonly Dictionary < ShapeViewModel , Size > _initialSizes ;
1212 private Dictionary < ShapeViewModel , Size > ? _finalSizes ;
13-
14- // Resizing could also move the shape
15- private readonly MoveShapesAction _moveShapesAction ;
13+ private readonly Dictionary < ShapeViewModel , Point > _initialLocations ;
14+ private Dictionary < ShapeViewModel , Point > ? _finalLocations ;
1615
1716 public ResizeShapesAction ( CanvasViewModel canvas )
1817 {
1918 _resizedShapes = canvas . SelectedShapes ;
2019 _initialSizes = _resizedShapes . ToDictionary ( x => x , x => new Size ( x . Width , x . Height ) ) ;
21-
22- _moveShapesAction = new MoveShapesAction ( canvas ) ;
20+ _initialLocations = _resizedShapes . ToDictionary ( x => x , x => x . Location ) ;
2321 }
2422
2523 public string ? Label => "Resize shapes" ;
2624
2725 public void Execute ( )
2826 {
29- _moveShapesAction . Execute ( ) ;
27+ _finalLocations ? . ForEach ( x => x . Key . Location = x . Value ) ;
3028
3129 _finalSizes ? . ForEach ( x =>
3230 {
@@ -43,13 +41,12 @@ public void Undo()
4341 x . Key . Height = x . Value . Height ;
4442 } ) ;
4543
46- _moveShapesAction . Undo ( ) ;
44+ _initialLocations . ForEach ( x => x . Key . Location = x . Value ) ;
4745 }
4846
4947 public void SaveSizes ( )
5048 {
51- _moveShapesAction . SaveLocations ( ) ;
52-
49+ _finalLocations = _resizedShapes . ToDictionary ( x => x , x => x . Location ) ;
5350 _finalSizes = _resizedShapes . ToDictionary ( x => x , x => new Size ( x . Width , x . Height ) ) ;
5451 }
5552 }
0 commit comments