@@ -10,24 +10,28 @@ namespace Pinta.Tools;
1010/// </summary>
1111public class RectangleHandle : IToolHandle
1212{
13+ private readonly IWorkspaceService workspace ;
14+
1315 private PointD start_pt ;
1416 private PointD end_pt ;
1517 private Size image_size ;
1618 private readonly ImmutableArray < MoveHandle > handles ;
1719 private MoveHandle ? active_handle ;
1820 private PointD ? drag_start_pos ;
1921
20- public RectangleHandle ( )
22+ public RectangleHandle ( IWorkspaceService workspace )
2123 {
24+ this . workspace = workspace ;
25+
2226 handles = [
23- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeNW ) } ,
24- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeSW ) } ,
25- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeNE ) } ,
26- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeSE ) } ,
27- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeW ) } ,
28- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeN ) } ,
29- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeE ) } ,
30- new ( ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeS ) } ,
27+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeNW ) } ,
28+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeSW ) } ,
29+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeNE ) } ,
30+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeSE ) } ,
31+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeW ) } ,
32+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeN ) } ,
33+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeE ) } ,
34+ new ( workspace ) { Cursor = GdkExtensions . CursorFromName ( Resources . StandardCursors . ResizeS ) } ,
3135 ] ;
3236
3337 foreach ( var handle in handles )
@@ -79,7 +83,7 @@ public bool BeginDrag (in PointD canvasPos, in Size imageSize)
7983
8084 image_size = imageSize ;
8185
82- PointD viewPos = PintaCore . Workspace . CanvasPointToView ( canvasPos ) ;
86+ PointD viewPos = workspace . CanvasPointToView ( canvasPos ) ;
8387 UpdateHandleUnderPoint ( viewPos ) ;
8488
8589 if ( active_handle is null )
@@ -122,7 +126,7 @@ public bool HasDragged (PointD canvasPos)
122126 if ( drag_start_pos is null )
123127 throw new InvalidOperationException ( "Drag operation has not been started!" ) ;
124128
125- PointD viewPos = PintaCore . Workspace . CanvasPointToView ( canvasPos ) ;
129+ PointD viewPos = workspace . CanvasPointToView ( canvasPos ) ;
126130 return drag_start_pos . Value . Distance ( viewPos ) > 1 ;
127131 }
128132
0 commit comments