Browse Source

Fire on `Enter`, stop dragging on lost focus

Ruben 10 months ago
parent
commit
ee6bf572ca

+ 1 - 1
src/PicView.Avalonia/ViewModels/ImageCropperViewModel.cs

@@ -15,7 +15,7 @@ public class ImageCropperViewModel : ViewModelBase
         Bitmap = bitmap;
         CropImageCommand  = ReactiveCommand.CreateFromTask(async () =>
         {
-        
+            
         });
         CloseCropCommand  = ReactiveCommand.Create(() =>
         {

+ 5 - 1
src/PicView.Avalonia/Views/UC/CropControl.axaml

@@ -22,7 +22,11 @@
     </UserControl.Styles>
     <UserControl.ContextMenu>
         <ContextMenu x:Name="CropContextMenu">
-            <MenuItem Command="{CompiledBinding CropImageCommand}" Header="{CompiledBinding Crop, Mode=OneWay}">
+            <MenuItem
+                Command="{CompiledBinding CropImageCommand}"
+                Header="{CompiledBinding Crop,
+                                         Mode=OneWay}"
+                HotKey="Enter">
                 <MenuItem.Icon>
                     <Path
                         Data="{StaticResource CropGeometry}"

+ 6 - 0
src/PicView.Avalonia/Views/UC/CropControl.axaml.cs

@@ -49,6 +49,12 @@ public partial class CropControl : UserControl
             RightMiddleButton.PointerReleased += OnResizePointerReleased;
             TopMiddleButton.PointerReleased += OnResizePointerReleased;
             BottomMiddleButton.PointerReleased += OnResizePointerReleased;
+
+            LostFocus += delegate
+            {
+                _isResizing = false;
+                _isDragging = false;
+            };
         };
     }