Browse Source

[Avalonia] Drag and drop adjustments, refactoring, and more.

Ruben 1 year ago
parent
commit
a4349e3f58

+ 2 - 1
src/PicView.Avalonia/CustomControls/GalleryAnimationControl.cs

@@ -35,7 +35,8 @@ public class GalleryAnimationControl : UserControl
                         GalleryMode.BottomToClosed => BottomToClosedAnimation(),
                         GalleryMode.ClosedToFull => ClosedToFullAnimation(),
                         GalleryMode.ClosedToBottom => ClosedToBottomAnimation(),
-                        GalleryMode.Closed => CloseWithNoAnimation()
+                        GalleryMode.Closed => CloseWithNoAnimation(),
+                        _ => throw new ArgumentOutOfRangeException(nameof(galleryMode), galleryMode, null)
                     };
                 }).Subscribe();
             

+ 9 - 10
src/PicView.Avalonia/Views/ImageViewer.axaml.cs

@@ -1,23 +1,22 @@
+using System.Reactive.Linq;
+using System.Runtime.InteropServices;
 using Avalonia;
 using Avalonia.Animation;
 using Avalonia.Controls;
+using Avalonia.Controls.Primitives;
 using Avalonia.Input;
 using Avalonia.Interactivity;
 using Avalonia.Media;
 using Avalonia.Threading;
+using PicView.Avalonia.Keybindings;
+using PicView.Avalonia.Navigation;
+using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
 using PicView.Core.Config;
-using PicView.Core.Navigation;
-using System.Runtime.InteropServices;
-using Avalonia.Controls.ApplicationLifetimes;
-using Avalonia.Controls.Primitives;
 using PicView.Core.ImageTransformations;
-using Point = Avalonia.Point;
+using PicView.Core.Navigation;
 using ReactiveUI;
-using System.Reactive.Linq;
-using PicView.Avalonia.Keybindings;
-using PicView.Avalonia.Navigation;
-using PicView.Avalonia.UI;
+using Point = Avalonia.Point;
 
 namespace PicView.Avalonia.Views;
 
@@ -477,7 +476,7 @@ public partial class ImageViewer : UserControl
         }
 
         WindowHelper.SetSize(vm);
-        //MainImage.InvalidateVisual();
+        MainImage.InvalidateVisual();
     }
     
     public void Rotate(double angle)

+ 2 - 1
src/PicView.Avalonia/Views/MainView.axaml.cs

@@ -13,6 +13,7 @@ using PicView.Avalonia.Navigation;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
 using PicView.Avalonia.Views.UC;
+using PicView.Core.Calculations;
 using PicView.Core.Config;
 using PicView.Core.Extensions;
 using PicView.Core.FileHandling;
@@ -249,7 +250,7 @@ public partial class MainView : UserControl
             }
             else if (path.IsSupported())
             {
-                var thumb = await ImageHelper.GetThumbAsync(path, 340).ConfigureAwait(false);
+                var thumb = await ImageHelper.GetThumbAsync(path, SizeDefaults.WindowMinSize - 30).ConfigureAwait(false);
 
                 await Dispatcher.UIThread.InvokeAsync(() =>
                 {

+ 2 - 2
src/PicView.Avalonia/Views/UC/DragDrogView.axaml

@@ -1,7 +1,7 @@
 <UserControl
     Background="{StaticResource AltBackgroundColor}"
     IsHitTestVisible="False"
-    ZIndex="999"
+    ZIndex="99"
     mc:Ignorable="d"
     x:Class="PicView.Avalonia.Views.UC.DragDropView"
     x:DataType="viewModels:MainViewModel"
@@ -22,7 +22,7 @@
                 RenderOptions.BitmapInterpolationMode="HighQuality"
                 x:Name="ContentHolder" />
 
-            <TextBlock
+            <TextBlock 
                 Classes="txt"
                 FontFamily="/Assets/Fonts/Roboto-Black.ttf#Roboto"
                 FontSize="16"

+ 1 - 1
src/PicView.Avalonia/Views/UC/DragDrogView.axaml.cs

@@ -70,7 +70,7 @@ public partial class DragDropView : UserControl
 
         var screen = ScreenHelper.ScreenSize;
         const int maxSize = SizeDefaults.WindowMinSize - 30;
-        var padding = vm.BottombarHeight + vm.TitlebarHeight + 20;
+        var padding = vm.BottombarHeight + vm.TitlebarHeight + 50;
         var boxedWidth = UIHelper.GetMainView.Bounds.Width * screen.Scaling - padding;
         var boxedHeight = UIHelper.GetMainView.Bounds.Height * screen.Scaling - padding;
         var scaledWidth = boxedWidth / image?.PixelSize.Width ?? maxSize;