Ruben 1 year ago
parent
commit
08b020a717

+ 8 - 5
src/PicView.Avalonia/Clipboard/ClipboardHelper.cs

@@ -19,8 +19,10 @@ public static class ClipboardHelper
 {
     private static async Task CopyAnimation()
     {
-        var startOpacityAnimation = AnimationsHelper.OpacityAnimation(0, .5, 0.25);
-        var endOpacityAnimation = AnimationsHelper.OpacityAnimation(.5, 0, 0.25);
+        const double speed = 0.2;
+        const double opacity = 0.4;
+        var startOpacityAnimation = AnimationsHelper.OpacityAnimation(0, opacity, speed);
+        var endOpacityAnimation = AnimationsHelper.OpacityAnimation(opacity, 0, speed);
         Rectangle? rectangle = null;
         await Dispatcher.UIThread.InvokeAsync(() =>
         {
@@ -29,13 +31,14 @@ public static class ClipboardHelper
                 Width = UIHelper.GetMainView.Width,
                 Height = UIHelper.GetMainView.Height,
                 Opacity = 0,
-                Fill = Brushes.Black
+                Fill = Brushes.Black,
+                IsHitTestVisible = false
             };
             UIHelper.GetMainView.MainGrid.Children.Add(rectangle);
         });
         await startOpacityAnimation.RunAsync(rectangle);
         await endOpacityAnimation.RunAsync(rectangle);
-        await Task.Delay(500);
+        await Task.Delay(200);
         await Dispatcher.UIThread.InvokeAsync(() =>
         {
             UIHelper.GetMainView.MainGrid.Children.Remove(rectangle);
@@ -57,7 +60,7 @@ public static class ClipboardHelper
         await CopyAnimation();
     }
 
-    public static async Task CopyImageToClipboard(string path)
+    public static async Task CopyImageToClipboard()
     {
         // TODO: Implement CopyImageToClipboard
     }

+ 2 - 2
src/PicView.Avalonia/Gallery/GalleryLoad.cs

@@ -178,7 +178,7 @@ public static class GalleryLoad
                     (uint)galleryItemSize);
                 var thumbData = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfos[i]);
 
-                await Dispatcher.UIThread.InvokeAsync(() =>
+                Dispatcher.UIThread.Post(() =>
                 {
                     if (i < 0 || i >= galleryListBox.Items.Count)
                     {
@@ -216,7 +216,7 @@ public static class GalleryLoad
                     {
                         galleryListBox.ScrollToCenterOfItem(galleryItem);
                     }
-                }, priority, ct);
+                }, priority);
             });
         }
     }

+ 1 - 5
src/PicView.Avalonia/UI/FunctionsHelper.cs

@@ -653,11 +653,7 @@ public static class FunctionsHelper
 
     public static async Task CopyImage()
     {
-        if (Vm is null)
-        {
-            return;
-        }
-        await ClipboardHelper.CopyImageToClipboard(Vm.FileInfo?.FullName);
+        await ClipboardHelper.CopyImageToClipboard();
     }
 
     public static async Task CopyBase64()

+ 2 - 15
src/PicView.Avalonia/ViewModels/MainViewModel.cs

@@ -440,7 +440,7 @@ public class MainViewModel : ViewModelBase
     public ReactiveCommand<string, Unit>? CopyBase64Command { get; }
     public ReactiveCommand<string, Unit>? CopyFilePathCommand { get; }
     public ReactiveCommand<string, Unit>? FilePropertiesCommand { get; }
-    public ReactiveCommand<string, Unit>? CopyImageCommand { get; }
+    public ReactiveCommand<Unit, Unit>? CopyImageCommand { get; }
     public ReactiveCommand<string, Unit>? CutCommand { get; }
     public ReactiveCommand<Unit, Unit>? ReloadCommand { get; }
     public ReactiveCommand<string, Unit>? PrintCommand { get; }
@@ -1450,19 +1450,6 @@ public class MainViewModel : ViewModelBase
         await ClipboardHelper.CopyTextToClipboard(path);
     }
     
-    private async Task CopyImageTask(string path)
-    {
-        if (string.IsNullOrWhiteSpace(path))
-        {
-            return;
-        }
-        if (PlatformService is null)
-        {
-            return;
-        }
-        await ClipboardHelper.CopyImageToClipboard(path);
-    }
-    
     private async Task CopyBase64Task(string path)
     {
         if (PlatformService is null)
@@ -1796,7 +1783,7 @@ public class MainViewModel : ViewModelBase
         
         FilePropertiesCommand = ReactiveCommand.CreateFromTask<string>(ShowFilePropertiesTask);
 
-        CopyImageCommand = ReactiveCommand.CreateFromTask<string>(CopyImageTask);
+        CopyImageCommand = ReactiveCommand.CreateFromTask(FunctionsHelper.CopyImage);
         
         CopyBase64Command = ReactiveCommand.CreateFromTask<string>(CopyBase64Task);