Browse Source

Gallery updates

Ruben 1 year ago
parent
commit
094e5707c9

+ 6 - 0
src/PicView.Avalonia/CustomControls/GalleryListBox.cs

@@ -161,6 +161,12 @@ public class GalleryListBox : ListBox
         _autoScrollViewer.Offset = new Vector(double.PositiveInfinity, double.PositiveInfinity);
         _autoScrollViewer.ScrollToEnd();
     }
+    
+    public void ScrollToHome()
+    {
+        _autoScrollViewer.Offset = new Vector(double.NegativeInfinity, double.NegativeInfinity);
+        _autoScrollViewer.ScrollToHome();
+    }
 
     public void PageLeft()
     {

+ 51 - 0
src/PicView.Avalonia/CustomControls/ThumbImage.cs

@@ -0,0 +1,51 @@
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Media;
+
+namespace PicView.Avalonia.CustomControls;
+
+public class ThumbImage : Image
+{
+    protected override Size MeasureOverride(Size availableSize)
+    {
+        Size? size = null;
+        try
+        {
+            size = new Size();
+
+
+        if (Source != null)
+        {
+            size = Stretch.CalculateSize(availableSize, Source.Size, StretchDirection);
+        }
+        }
+        catch (Exception e)
+        {
+#if DEBUG
+            Console.WriteLine(e);
+#endif
+        }
+
+        return size ?? new Size();
+    }
+    
+    protected override Size ArrangeOverride(Size finalSize)
+    {
+        try
+        {
+            if (Source != null)
+            {
+                var sourceSize = Source.Size;
+                var result = Stretch.CalculateSize(finalSize, sourceSize);
+                return result;
+            }
+        }
+        catch (Exception e)
+        {
+#if DEBUG
+            Console.WriteLine(e);
+#endif
+        }
+        return new Size();
+    }
+}

+ 243 - 293
src/PicView.Avalonia/Gallery/GalleryFunctions.cs

@@ -1,5 +1,4 @@
 using Avalonia.Layout;
-using Avalonia.Media;
 using Avalonia.Svg.Skia;
 using Avalonia.Threading;
 using PicView.Avalonia.ImageHandling;
@@ -8,14 +7,247 @@ using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
 using PicView.Avalonia.Views.UC;
 using PicView.Core.Config;
-using PicView.Core.Extensions;
 using PicView.Core.Gallery;
 using PicView.Core.Localization;
 
 namespace PicView.Avalonia.Gallery;
+
 public static class GalleryFunctions
 {
+    public static bool RenameGalleryItem(int index, string newFileLocation, string newName, MainViewModel? vm)
+    {
+        var mainView = UIHelper.GetMainView;
+
+        var galleryListBox = mainView.GalleryView.GalleryListBox;
+        if (galleryListBox == null)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count <= index)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count < 0 || index >= galleryListBox.ItemCount)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count <= 0 || index >= galleryListBox.Items.Count)
+        {
+            return false;
+        }
+
+        if (Dispatcher.UIThread.CheckAccess())
+        {
+            return Rename();
+        }
+        Dispatcher.UIThread.InvokeAsync(Rename);
+
+        if (vm != null)
+        {
+            vm.SelectedGalleryItemIndex = vm.ImageIterator.CurrentIndex;
+        }
+
+        return true;
+
+        bool Rename()
+        {
+            if (galleryListBox.Items[index] is not GalleryItem galleryItem)
+            {
+                return false;
+            }
+            galleryItem.FileName.Text = newName;
+            galleryItem.FileLocation.Text = newFileLocation;
+            return true;
+        }
+    }
+    
+    public static bool RemoveGalleryItem(int index, MainViewModel? vm)
+    {
+        var mainView = UIHelper.GetMainView;
+
+        var galleryListBox = mainView.GalleryView.GalleryListBox;
+        if (galleryListBox == null)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count <= index)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count < 0 || index >= galleryListBox.ItemCount)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count <= 0 || index >= galleryListBox.Items.Count)
+        {
+            return false;
+        }
+
+        if (Dispatcher.UIThread.CheckAccess())
+        {
+            galleryListBox.Items.RemoveAt(index);
+        }
+        else
+        {
+            Dispatcher.UIThread.InvokeAsync(() => { galleryListBox.Items.RemoveAt(index); });
+        }
+
+        if (vm != null)
+        {
+            vm.SelectedGalleryItemIndex = vm.ImageIterator.CurrentIndex;
+        }
+
+        return true;
+    }
+
+    public static async Task<bool> AddGalleryItem(int index, FileInfo fileInfo, MainViewModel? vm)
+    {
+        var mainView = UIHelper.GetMainView;
+
+        var galleryListBox = mainView.GalleryView.GalleryListBox;
+        if (galleryListBox == null)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count <= index)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count < 0 || index >= galleryListBox.ItemCount)
+        {
+            return false;
+        }
+
+        if (galleryListBox.Items.Count <= 0 || index >= galleryListBox.Items.Count)
+        {
+            return false;
+        }
+
+        GalleryItem? galleryItem;
+        var thumb = await GetThumbnails.GetThumbAsync(fileInfo.FullName, (uint)vm.GetGalleryItemHeight, fileInfo);
+        var galleryThumbInfo = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfo);
+        try
+        {
+            await Dispatcher.UIThread.InvokeAsync(() =>
+            {
+                galleryItem = new GalleryItem
+                {
+                    FileLocation =
+                    {
+                        Text = galleryThumbInfo.FileLocation
+                    },
+                    FileDate =
+                    {
+                        Text = galleryThumbInfo.FileDate
+                    },
+                    FileSize =
+                    {
+                        Text = galleryThumbInfo.FileSize
+                    },
+                    FileName =
+                    {
+                        Text = galleryThumbInfo.FileName
+                    }
+                };
+                galleryItem.PointerPressed += async (_, _) =>
+                {
+                    if (IsFullGalleryOpen)
+                    {
+                        await ToggleGallery(vm);
+                    }
+
+                    await vm.ImageIterator.IterateToIndex(vm.ImageIterator.ImagePaths.IndexOf(fileInfo.FullName))
+                        .ConfigureAwait(false);
+                };
+                galleryListBox.Items.Insert(index, galleryItem);
+                var isSvg = fileInfo.Extension.Equals(".svg", StringComparison.OrdinalIgnoreCase) ||
+                            fileInfo.Extension.Equals(".svgz", StringComparison.OrdinalIgnoreCase);
+                if (isSvg)
+                {
+                    galleryItem.GalleryImage.Source = new SvgImage
+                        { Source = SvgSource.Load(fileInfo.FullName) };
+                }
+                else if (thumb is not null)
+                {
+                    galleryItem.GalleryImage.Source = thumb;
+                }
+            }, DispatcherPriority.Render);
+            return true;
+        }
+        catch (Exception exception)
+        {
+#if DEBUG
+            Console.WriteLine(exception);
+#endif
+        }
+
+        return false;
+    }
+
+    public static void Clear()
+    {
+        if (Dispatcher.UIThread.CheckAccess())
+        {
+            ClearItems();
+        }
+        else
+        {
+            Dispatcher.UIThread.Post(ClearItems);
+        }
+#if DEBUG
+        Console.WriteLine("Gallery items cleared");
+#endif
+
+        return;
+
+        void ClearItems()
+        {
+            try
+            {
+                var mainView = UIHelper.GetMainView;
+
+                var galleryListBox = mainView.GalleryView.GalleryListBox;
+                if (galleryListBox == null)
+                {
+                    return;
+                }
+
+                for (var i = 0; i < galleryListBox.ItemCount; i++)
+                {
+                    if (galleryListBox.Items[i] is not GalleryItem galleryItem)
+                    {
+                        continue;
+                    }
+
+                    if (galleryItem.GalleryImage.Source is IDisposable galleryImage)
+                    {
+                        galleryImage.Dispose();
+                    }
+
+                    galleryListBox.Items.Remove(galleryItem);
+                }
+
+                galleryListBox.Items.Clear();
+            }
+            catch (Exception e)
+            {
+#if DEBUG
+                Console.WriteLine(e);
+#endif
+            }
+        }
+    }
+
     #region Gallery toggle
+
     public static bool IsFullGalleryOpen { get; private set; }
     public static bool IsBottomGalleryOpen { get; private set; }
 
@@ -25,7 +257,7 @@ public static class GalleryFunctions
         {
             return;
         }
-        
+
         UIHelper.CloseMenus(vm);
         if (SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
         {
@@ -63,6 +295,7 @@ public static class GalleryFunctions
                 vm.GetGalleryItemHeight = vm.GetFullGalleryItemHeight;
             }
         }
+
         _ = Task.Run(() => GalleryLoad.LoadGallery(vm, Path.GetDirectoryName(vm.ImageIterator.ImagePaths[0])));
         await SettingsHelper.SaveSettingsAsync();
     }
@@ -73,8 +306,9 @@ public static class GalleryFunctions
         {
             return;
         }
+
         UIHelper.CloseMenus(vm);
-        
+
         if (SettingsHelper.Settings.Gallery.IsBottomGalleryShown)
         {
             SettingsHelper.Settings.Gallery.IsBottomGalleryShown = false;
@@ -93,12 +327,14 @@ public static class GalleryFunctions
         {
             vm.GalleryMode = GalleryMode.ClosedToBottom;
         }
+
         vm.GetIsShowingBottomGalleryTranslation = TranslationHelper.Translation.HideBottomGallery;
         await SettingsHelper.SaveSettingsAsync();
         if (!NavigationHelper.CanNavigate(vm))
         {
             return;
         }
+
         await Task.Run(() => GalleryLoad.LoadGallery(vm, Path.GetDirectoryName(vm.ImageIterator.ImagePaths[0])));
     }
 
@@ -108,7 +344,7 @@ public static class GalleryFunctions
         vm.GalleryMode = GalleryMode.ClosedToBottom;
         vm.GalleryVerticalAlignment = VerticalAlignment.Bottom;
     }
-    
+
     public static async Task CloseGallery(MainViewModel vm)
     {
         if (IsFullGalleryOpen)
@@ -120,294 +356,8 @@ public static class GalleryFunctions
             await OpenCloseBottomGallery(vm);
         }
     }
-    
-    #endregion
-    
-    #region Sorting
-    
-    private readonly struct TempGalleryItem(
-        string fileLocation,
-        string fileName,
-        string fileSize,
-        string fileDate,
-        IImage source)
-    {
-        internal readonly string FileLocation = fileLocation;
-        internal readonly string FileName = fileName;
-        internal readonly string FileSize = fileSize;
-        internal readonly string FileDate = fileDate;
-        internal IImage Source { get; } = source;
-    }
-    
-     public static async Task SortGalleryItems(List<string> files, MainViewModel vm)
-    {
-        var cancellationTokenSource = new CancellationTokenSource();
-
-        var mainView = UIHelper.GetMainView;
 
-        var galleryListBox = mainView.GalleryView.GalleryListBox;
-        if (galleryListBox == null) return;
-        if (galleryListBox.Items.Count < 0)
-        {
-            return;
-        }
-        var initialDirectory = Path.GetDirectoryName(vm.FileInfo.FullName);
-        try
-        {
-            while (GalleryLoad.IsLoading)
-            {
-                await Task.Delay(200, cancellationTokenSource.Token);
-                if (initialDirectory == Path.GetDirectoryName(files[0]))
-                {
-                    continue;
-                }
+    #endregion
 
-                // Directory changed, cancel the operation
-                await cancellationTokenSource.CancelAsync();
-                return;
-            }
-            
-            var thumbs = new List<TempGalleryItem>();
-            for (var i = 0; i < files.Count; i++)
-            {
-                await Dispatcher.UIThread.InvokeAsync(() =>
-                {
-                    if (galleryListBox.Items.Count <= i)
-                        return;
-                    if (galleryListBox.Items[i] is not GalleryItem galleryItem)
-                        return;
-                    
-                    thumbs.Add(new TempGalleryItem(
-                        galleryItem.FileLocation.Text,
-                        galleryItem.FileName.Text,
-                        galleryItem.FileSize.Text,
-                        galleryItem.FileDate.Text,
-                        galleryItem.GalleryImage.Source));
-                }, DispatcherPriority.Render, cancellationTokenSource.Token);
-                if (initialDirectory != Path.GetDirectoryName(files[0]))
-                {
-                    // Directory changed, cancel the operation
-                    await cancellationTokenSource.CancelAsync();
-                    return;
-                }
-            }
-            await Dispatcher.UIThread.InvokeAsync(() =>
-                thumbs = thumbs.OrderBySequence(files, x => x.FileLocation).ToList());
-            vm.SelectedGalleryItemIndex = -1;
 
-            for (var i = 0; i < files.Count; i++)
-            {
-                var index = i;
-                await Dispatcher.UIThread.InvokeAsync(() =>
-                {
-                    if (galleryListBox.Items[index] is not GalleryItem galleryItem)
-                        return;
-                    
-                    galleryItem.FileLocation.Text = thumbs[index].FileLocation;
-                    galleryItem.FileName.Text = thumbs[index].FileName;
-                    galleryItem.FileSize.Text = thumbs[index].FileSize;
-                    galleryItem.FileDate.Text = thumbs[index].FileDate;
-                    galleryItem.GalleryImage.Source = thumbs[index].Source;
-                }, DispatcherPriority.Background, cancellationTokenSource.Token);
-
-                if (initialDirectory != Path.GetDirectoryName(files[0]))
-                {
-                    // Directory changed, cancel the operation
-                    await cancellationTokenSource.CancelAsync();
-                    return;
-                }
-            }
-            vm.SelectedGalleryItemIndex = files.IndexOf(files[vm.ImageIterator.CurrentIndex]);
-            GalleryNavigation.CenterScrollToSelectedItem(vm);
-        }
-        catch (TaskCanceledException)
-        {
-            await Dispatcher.UIThread.InvokeAsync(() =>
-            {
-                galleryListBox.Items.Clear();
-            });
-        }
-        catch (Exception e)
-        {
-            await Dispatcher.UIThread.InvokeAsync(() =>
-            {
-                galleryListBox.Items.Clear();
-            });
-            await TooltipHelper.ShowTooltipMessageAsync(e.Message);
-#if DEBUG
-            Console.WriteLine(e);
-#endif
-        }
-
-    }
-     #endregion
-
-     public static bool RemoveGalleryItem(int index, MainViewModel? vm)
-     {
-         var mainView = UIHelper.GetMainView;
-
-         var galleryListBox = mainView.GalleryView.GalleryListBox;
-         if (galleryListBox == null) 
-             return false;
-
-         if (galleryListBox.Items.Count <= index)
-         {
-             return false;
-         }
-
-         if (galleryListBox.Items.Count < 0 || index >= galleryListBox.ItemCount)
-         {
-             return false;
-         }
-
-         if (galleryListBox.Items.Count <= 0 || index >= galleryListBox.Items.Count)
-         {
-             return false;
-         }
-
-         if (Dispatcher.UIThread.CheckAccess())
-         {
-             galleryListBox.Items.RemoveAt(index);
-         }
-         else
-         {
-             Dispatcher.UIThread.InvokeAsync(() =>
-             {
-                 galleryListBox.Items.RemoveAt(index);
-             });
-         }
-         if (vm != null)
-         {
-             vm.SelectedGalleryItemIndex = vm.ImageIterator.CurrentIndex;
-         }
-
-         return true;
-
-     }
-
-     public static async Task<bool> AddGalleryItem(int index, FileInfo fileInfo, MainViewModel? vm)
-     {
-         var mainView = UIHelper.GetMainView;
-
-         var galleryListBox = mainView.GalleryView.GalleryListBox;
-         if (galleryListBox == null) 
-             return false;
-
-         if (galleryListBox.Items.Count <= index)
-         {
-             return false;
-         }
-
-         if (galleryListBox.Items.Count < 0 || index >= galleryListBox.ItemCount)
-         {
-             return false;
-         }
-
-         if (galleryListBox.Items.Count <= 0 || index >= galleryListBox.Items.Count)
-         {
-             return false;
-         }
-
-         GalleryItem? galleryItem;
-         var thumb = await GetThumbnails.GetThumbAsync(fileInfo.FullName, (uint)vm.GetGalleryItemHeight, fileInfo);
-         var galleryThumbInfo = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfo);
-         try
-         {
-             await Dispatcher.UIThread.InvokeAsync(() =>
-             {
-                 galleryItem = new GalleryItem
-                 {
-                     FileLocation =
-                     {
-                         Text = galleryThumbInfo.FileLocation
-                     },
-                     FileDate =
-                     {
-                         Text = galleryThumbInfo.FileDate
-                     },
-                     FileSize =
-                     {
-                         Text = galleryThumbInfo.FileSize
-                     },
-                     FileName =
-                     {
-                         Text = galleryThumbInfo.FileName
-                     }
-                 };
-                 galleryItem.PointerPressed += async (_, _) =>
-                 {
-                     if (IsFullGalleryOpen)
-                     {
-                         await ToggleGallery(vm);
-                     }
-                     await vm.ImageIterator.IterateToIndex(vm.ImageIterator.ImagePaths.IndexOf(fileInfo.FullName)).ConfigureAwait(false);
-                 };
-                 galleryListBox.Items.Insert(index, galleryItem);
-                 var isSvg = fileInfo.Extension.Equals(".svg", StringComparison.OrdinalIgnoreCase) ||
-                             fileInfo.Extension.Equals(".svgz", StringComparison.OrdinalIgnoreCase);
-                 if (isSvg)
-                 {
-                     galleryItem.GalleryImage.Source = new SvgImage
-                         { Source = SvgSource.Load(fileInfo.FullName) };
-                 }
-                 else if (thumb is not null)
-                 {
-                     galleryItem.GalleryImage.Source = thumb;
-                 }
-             }, DispatcherPriority.Render);
-             return true;
-         }
-         catch (Exception exception)
-         {
-#if DEBUG
-             Console.WriteLine(exception);
-#endif
-         }
-         return false;
-     }
-
-     public static void Clear()
-     {
-         if (Dispatcher.UIThread.CheckAccess())
-         {
-             ClearItems();
-         }
-         else
-         {
-             Dispatcher.UIThread.Post(ClearItems);
-         }
-#if DEBUG
-         Console.WriteLine("Gallery items cleared");
-#endif
-         
-         return;
-         void ClearItems()
-         {
-             try
-             {
-                 var mainView = UIHelper.GetMainView;
-
-                 var galleryListBox = mainView.GalleryView.GalleryListBox;
-                 if (galleryListBox == null) 
-                     return;
-                 for (var i = 0; i < galleryListBox.ItemCount; i++)
-                 {
-                     if (galleryListBox.Items[i] is not GalleryItem galleryItem) 
-                         continue;
-                     if (galleryItem.GalleryImage.Source is IDisposable galleryImage)
-                     {
-                         galleryImage.Dispose();
-                     }
-                     galleryListBox.Items.Remove(galleryItem);
-                 }
-                 galleryListBox.Items.Clear();
-             }
-             catch (Exception e)
-             {
-#if DEBUG
-                     Console.WriteLine(e);
-#endif
-             }
-         }
-     }
-}
+}

+ 8 - 20
src/PicView.Avalonia/Gallery/GalleryLoad.cs

@@ -6,7 +6,6 @@ using PicView.Avalonia.ViewModels;
 using PicView.Avalonia.Views.UC;
 using PicView.Core.Config;
 using PicView.Core.Gallery;
-using PicView.Core.Localization;
 
 namespace PicView.Avalonia.Gallery;
 
@@ -67,16 +66,14 @@ public static class GalleryLoad
         IsLoading = true;
         var index = vm.ImageIterator.CurrentIndex;
         var galleryItemSize = Math.Max(vm.GetBottomGalleryItemHeight, vm.GetFullGalleryItemHeight);
-        var loading = TranslationHelper.Translation.Loading;
+        
         var endIndex = vm.ImageIterator.ImagePaths.Count;
         // Set priority low when loading excess images to ensure app responsiveness
         var priority = endIndex switch
         {
-            >= 3000 => DispatcherPriority.ApplicationIdle,
             >= 2000 => DispatcherPriority.Background,
-            >= 1000 => DispatcherPriority.Input,
-            >= 500 => DispatcherPriority.Render,
-            _ => DispatcherPriority.Normal
+            >= 1000 => DispatcherPriority.Loaded,
+            _ => DispatcherPriority.Render
         };
 
         GalleryStretchMode.SetSquareFillStretch(vm);
@@ -93,14 +90,15 @@ public static class GalleryLoad
                 
                 _cancellationTokenSource.Token.ThrowIfCancellationRequested();
                 fileInfos[i] = new FileInfo(vm.ImageIterator.ImagePaths[i]);
+                var thumbData = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfos[i]);
                 await Dispatcher.UIThread.InvokeAsync(() =>
                 {
                     var galleryItem = new GalleryItem
                     {
                         DataContext = vm,
-                        FileName = { Text = loading },
-                        FileSize = { Text = loading },
-                        FileDate = { Text = loading },
+                        FileName = { Text = thumbData.FileName },
+                        FileSize = { Text = thumbData.FileSize },
+                        FileDate = { Text = thumbData.FileDate },
                         FileLocation = { Text = fileInfos[i].FullName },
                     };
                     var i1 = i;
@@ -182,15 +180,10 @@ public static class GalleryLoad
                 }
 
                 var thumb = await GetThumbnails.GetThumbAsync(fileInfos[i].FullName, (uint)galleryItemSize, fileInfos[i]);
-                var thumbData = GalleryThumbInfo.GalleryThumbHolder.GetThumbData(fileInfos[i]);
+
                 var isSvg = fileInfos[i].Extension.Equals(".svg", StringComparison.OrdinalIgnoreCase) ||
                            fileInfos[i].Extension.Equals(".svgz", StringComparison.OrdinalIgnoreCase);
 
-                if (isSvg)
-                {
-                    Console.WriteLine($"{fileInfos[i].FullName} is svg");
-                }
-
                 await Dispatcher.UIThread.InvokeAsync(() =>
                 {
                     if (i < 0 || i >= galleryListBox.Items.Count)
@@ -211,11 +204,6 @@ public static class GalleryLoad
                     {
                         galleryItem.GalleryImage.Source = thumb;
                     }
-
-                    galleryItem.FileLocation.Text = thumbData.FileLocation;
-                    galleryItem.FileDate.Text = thumbData.FileDate;
-                    galleryItem.FileSize.Text = thumbData.FileSize;
-                    galleryItem.FileName.Text = thumbData.FileName;
                     
                     if (vm.ImageIterator is null)
                     {

+ 2 - 2
src/PicView.Avalonia/Navigation/FileListManager.cs

@@ -80,7 +80,7 @@ public static class FileListManager
         }
         else return;
 
-        await GalleryFunctions.SortGalleryItems(files, vm);
+        await GalleryLoad.ReloadGalleryAsync(vm, vm.FileInfo.DirectoryName);
     }
 
     public static async Task UpdateFileList(IPlatformSpecificService? platformSpecificService, MainViewModel vm, bool ascending)
@@ -98,6 +98,6 @@ public static class FileListManager
         }
         else return;
 
-        await GalleryFunctions.SortGalleryItems(files, vm);
+        await GalleryLoad.ReloadGalleryAsync(vm, vm.FileInfo.DirectoryName);
     }
 }

+ 1 - 3
src/PicView.Avalonia/Navigation/ImageIterator.cs

@@ -305,9 +305,7 @@ public sealed class ImageIterator : IDisposable
 
         IsRunning = false;
         FileHistoryNavigation.Rename(e.OldFullPath, e.FullPath);
-        GalleryFunctions.RemoveGalleryItem(oldIndex, _vm);
-        await GalleryFunctions.AddGalleryItem(index, fileInfo, _vm);
-        await GalleryFunctions.SortGalleryItems(ImagePaths, _vm);
+        await Dispatcher.UIThread.InvokeAsync(() => GalleryFunctions.RenameGalleryItem(oldIndex, Path.GetFileNameWithoutExtension(e.Name), e.FullPath, _vm));
     }
 
     #endregion

+ 7 - 2
src/PicView.Avalonia/Views/UC/GalleryItem.axaml

@@ -5,6 +5,7 @@
     x:Class="PicView.Avalonia.Views.UC.GalleryItem"
     x:DataType="viewModels:MainViewModel"
     xmlns="https://github.com/avaloniaui"
+    xmlns:customControls="clr-namespace:PicView.Avalonia.CustomControls"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
     xmlns:uc="clr-namespace:PicView.Avalonia.Views.UC"
@@ -23,30 +24,34 @@
                                 Mode=OneWay}"
         x:DataType="viewModels:MainViewModel"
         x:Name="ImageBorder">
-        <Image Stretch="{CompiledBinding GalleryStretch, Mode=OneWay}" x:Name="GalleryImage" />
+        <customControls:ThumbImage Stretch="{CompiledBinding GalleryStretch, Mode=OneWay}" x:Name="GalleryImage" />
         <ToolTip.Tip>
-            <StackPanel>
+            <StackPanel MaxWidth="600">
                 <TextBlock
                     Classes="txt"
                     FontFamily="/Assets/Fonts/Roboto-Bold.ttf#Roboto"
                     FontSize="14"
                     Foreground="{DynamicResource MainTextColor}"
                     Margin="2,0,2,6"
+                    TextWrapping="NoWrap"
                     x:Name="FileName" />
                 <TextBlock
                     Classes="txt"
                     Foreground="{DynamicResource MainTextColor}"
                     Margin="2,0,2,2"
+                    TextWrapping="NoWrap"
                     x:Name="FileLocation" />
                 <TextBlock
                     Classes="txt"
                     Foreground="{DynamicResource MainTextColor}"
                     Margin="2,0,2,2"
+                    TextWrapping="NoWrap"
                     x:Name="FileSize" />
                 <TextBlock
                     Classes="txt"
                     Foreground="{DynamicResource MainTextColor}"
                     Margin="2,0,2,4"
+                    TextWrapping="NoWrap"
                     x:Name="FileDate" />
             </StackPanel>
         </ToolTip.Tip>

+ 0 - 10
src/PicView.Core/Extensions/FileExtensions.cs

@@ -41,14 +41,4 @@ public static class FileExtensions
 
         return value.ToString($"0.## {prefix}B", CultureInfo.CurrentCulture);
     }
-    
-    public static IEnumerable<T> OrderBySequence<T, TId>(this IEnumerable<T> source,
-        IEnumerable<TId> order, Func<T, TId> idSelector) where TId : notnull
-    {
-        var lookup = source?.ToDictionary(idSelector, t => t);
-        foreach (var id in order)
-        {
-            yield return lookup[id];
-        }
-    }
 }

+ 0 - 3
src/PicView.Core/Gallery/GalleryThumbInfo.cs

@@ -38,11 +38,8 @@ public static class GalleryThumbInfo
         /// <returns>The <see cref="GalleryThumbHolder"/> instance containing thumbnail data.</returns>
         public static GalleryThumbHolder GetThumbData(FileInfo? fileInfo)
         {
-            const int fileNameLength = 75;
             var fileLocation = fileInfo.FullName;
-            fileLocation = fileLocation.Length > fileNameLength ? $"{fileLocation.Shorten(fileNameLength)}{fileInfo.Extension}" : fileLocation;
             var fileName = Path.GetFileNameWithoutExtension(fileInfo.Name);
-            fileName = fileName.Length > fileNameLength ? fileName.Shorten(fileNameLength) : fileName;
             var fileSize = 
                 $"{TranslationHelper.Translation.FileSize}: {fileInfo.Length.GetReadableFileSize()}";
             var fileDate =