From ad04356a3539f1efef78abff5876726a4322f554 Mon Sep 17 00:00:00 2001 From: Phap Dieu Duong Date: Wed, 29 May 2024 18:59:23 +0800 Subject: [PATCH] fixed: cached thumbnail is not updated when replacing image with same name #1564, #1859, #1922 --- .../Cache/ThumbnailCacheManager.cs | 47 ++++++++++--------- .../ImageGlass.Gallery/ImageGallery.cs | 2 +- .../Item/Adaptor/FileSystemAdaptor.cs | 22 ++++----- .../Item/Adaptor/IAdaptor.cs | 16 +++---- .../Item/ImageGalleryItem.cs | 44 ++++++++--------- .../ImageGlass.Gallery/Item/ItemCollection.cs | 6 +-- .../Managers/NavigationManager.cs | 2 +- .../Renderer/StyleRenderer.cs | 4 +- Source/ImageGlass/FrmMain.cs | 4 +- .../ImageGlass/FrmMain/FrmMain.IGMethods.cs | 2 +- 10 files changed, 75 insertions(+), 74 deletions(-) diff --git a/Source/Components/ImageGlass.Gallery/Cache/ThumbnailCacheManager.cs b/Source/Components/ImageGlass.Gallery/Cache/ThumbnailCacheManager.cs index e5ba9a466..d52a50e7c 100644 --- a/Source/Components/ImageGlass.Gallery/Cache/ThumbnailCacheManager.cs +++ b/Source/Components/ImageGlass.Gallery/Cache/ThumbnailCacheManager.cs @@ -101,7 +101,7 @@ private class CacheRequest /// /// Gets the public key for the virtual item. /// - public object VirtualItemKey { get; private set; } + public string VirtualKey { get; private set; } /// /// Gets the size of the requested thumbnail. /// @@ -125,15 +125,15 @@ private class CacheRequest /// /// The guid of the . /// The adaptor of this item. - /// The public key for the virtual item. + /// The file path for item. /// The size of the requested thumbnail. /// UseEmbeddedThumbnails property of the owner control. /// AutoRotate property of the owner control. /// Type of this request. - public CacheRequest(Guid guid, IAdaptor adaptor, object key, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate, RequestType requestType) + public CacheRequest(Guid guid, IAdaptor adaptor, string filePath, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate, RequestType requestType) { Guid = guid; - VirtualItemKey = key; + VirtualKey = filePath; Adaptor = adaptor; Size = size; UseEmbeddedThumbnails = useEmbeddedThumbnails; @@ -146,7 +146,7 @@ public CacheRequest(Guid guid, IAdaptor adaptor, object key, Size size, UseEmbed /// public override string ToString() { - return "CacheRequest (" + VirtualItemKey.ToString() + ")"; + return "CacheRequest (" + VirtualKey.ToString() + ")"; } } #endregion @@ -512,7 +512,7 @@ private void Bw_DoWork(object? sender, QueuedWorkerDoWorkEventArgs e) } Image? thumb = null; - var diskCacheKey = request.Adaptor.GetUniqueIdentifier(request.VirtualItemKey, request.Size, request.UseEmbeddedThumbnails, request.AutoRotate); + var diskCacheKey = request.Adaptor.GetUniqueIdentifier(request.VirtualKey, request.Size, request.UseEmbeddedThumbnails, request.AutoRotate); // Check the disk cache using var cs = _diskCache.Read(diskCacheKey); @@ -527,7 +527,7 @@ private void Bw_DoWork(object? sender, QueuedWorkerDoWorkEventArgs e) { try { - thumb = request.Adaptor.GetThumbnail(request.VirtualItemKey, request.Size, request.UseEmbeddedThumbnails, request.AutoRotate); + thumb = request.Adaptor.GetThumbnail(request.VirtualKey, request.Size, request.UseEmbeddedThumbnails, request.AutoRotate); } // fix infinite re-cache when throwing error catch { } @@ -694,7 +694,7 @@ public void Remove(Guid guid, bool removeNow) if (item != null) { var diskCacheKey = item.Adaptor.GetUniqueIdentifier( - item.VirtualItemKey, + item.VirtualKey, cacheItem.Size, cacheItem.UseEmbeddedThumbnails, cacheItem.AutoRotate); @@ -820,11 +820,11 @@ private static int GetImageMemorySize(int width, int height) /// /// The guid representing this item. /// he adaptor for this item. - /// The key of this item. + /// The file path of this item. /// Requested thumbnail size. /// UseEmbeddedThumbnails property of the owner control. /// AutoRotate property of the owner control. - public void Add(Guid guid, IAdaptor adaptor, object key, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) + public void Add(Guid guid, IAdaptor adaptor, string filePath, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) { // Already cached? if (_thumbCache.TryGetValue(guid, out CacheItem? item)) @@ -834,7 +834,7 @@ public void Add(Guid guid, IAdaptor adaptor, object key, Size thumbSize, UseEmbe } // Add to cache queue - RunWorker(new CacheRequest(guid, adaptor, key, thumbSize, useEmbeddedThumbnails, autoRotate, RequestType.Thumbnail)); + RunWorker(new CacheRequest(guid, adaptor, filePath, thumbSize, useEmbeddedThumbnails, autoRotate, RequestType.Thumbnail)); } /// @@ -842,12 +842,12 @@ public void Add(Guid guid, IAdaptor adaptor, object key, Size thumbSize, UseEmbe /// /// The guid representing this item. /// The adaptor for this item. - /// The key of this item. + /// The file path of this item. /// Requested thumbnail size. /// Thumbnail image to add to cache. /// UseEmbeddedThumbnails property of the owner control. /// AutoRotate property of the owner control. - public void Add(Guid guid, IAdaptor adaptor, object key, Size thumbSize, Image? thumb, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) + public void Add(Guid guid, IAdaptor adaptor, string filePath, Size thumbSize, Image? thumb, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) { // Already cached? if (_thumbCache.TryGetValue(guid, out CacheItem? item)) @@ -864,7 +864,7 @@ public void Add(Guid guid, IAdaptor adaptor, object key, Size thumbSize, Image? // Add to disk cache using var stream = new MemoryStream(); - var diskCacheKey = adaptor.GetUniqueIdentifier(key, thumbSize, useEmbeddedThumbnails, autoRotate); + var diskCacheKey = adaptor.GetUniqueIdentifier(filePath, thumbSize, useEmbeddedThumbnails, autoRotate); thumb.Save(stream, System.Drawing.Imaging.ImageFormat.Png); _diskCache.Write(diskCacheKey, stream); @@ -882,11 +882,11 @@ public void Add(Guid guid, IAdaptor adaptor, object key, Size thumbSize, Image? /// /// The guid representing this item. /// The adaptor for this item. - /// The key of this item. + /// The file path of this item. /// Requested thumbnail size. /// UseEmbeddedThumbnails property of the owner control. /// AutoRotate property of the owner control. - public void AddToGalleryCache(Guid guid, IAdaptor adaptor, object key, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) + public void AddToGalleryCache(Guid guid, IAdaptor adaptor, string filePath, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) { // Already cached? if (_galleryItem != null @@ -898,7 +898,7 @@ public void AddToGalleryCache(Guid guid, IAdaptor adaptor, object key, Size thum return; // Add to cache queue - RunWorker(new CacheRequest(guid, adaptor, key, thumbSize, useEmbeddedThumbnails, autoRotate, RequestType.Gallery), 2); + RunWorker(new CacheRequest(guid, adaptor, filePath, thumbSize, useEmbeddedThumbnails, autoRotate, RequestType.Gallery), 2); } /// @@ -906,11 +906,11 @@ public void AddToGalleryCache(Guid guid, IAdaptor adaptor, object key, Size thum /// /// The guid representing this item. /// The adaptor of this item. - /// The key of this item. + /// The file path of this item. /// Requested thumbnail size. /// UseEmbeddedThumbnails property of the owner control. /// AutoRotate property of the owner control. - public void AddToRendererCache(Guid guid, IAdaptor adaptor, object key, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) + public void AddToRendererCache(Guid guid, IAdaptor adaptor, string filePath, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate) { // Already cached? if (_rendererItem != null @@ -922,7 +922,7 @@ public void AddToRendererCache(Guid guid, IAdaptor adaptor, object key, Size thu return; // Add to cache queue - RunWorker(new CacheRequest(guid, adaptor, key, thumbSize, useEmbeddedThumbnails, autoRotate, RequestType.Renderer), 1); + RunWorker(new CacheRequest(guid, adaptor, filePath, thumbSize, useEmbeddedThumbnails, autoRotate, RequestType.Renderer), 1); } /// @@ -973,12 +973,12 @@ public void AddToRendererCache(Guid guid, IAdaptor adaptor, object key, Size thu /// /// The guid representing this item. /// The adaptor of this item. - /// The key of this item. + /// The key of this item. /// Requested thumbnail size. /// UseEmbeddedThumbnails property of the owner control. /// AutoRotate property of the owner control. /// true to return a clone of the cached image; otherwise false. - public Image? GetImage(Guid guid, IAdaptor adaptor, object key, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate, bool clone) + public Image? GetImage(Guid guid, IAdaptor adaptor, string filePath, Size thumbSize, UseEmbeddedThumbnails useEmbeddedThumbnails, bool autoRotate, bool clone) { if (_thumbCache.TryGetValue(guid, out CacheItem? item) && item != null @@ -998,7 +998,8 @@ public void AddToRendererCache(Guid guid, IAdaptor adaptor, object key, Size thu } else { - var diskCacheKey = adaptor.GetUniqueIdentifier(key, thumbSize, useEmbeddedThumbnails, autoRotate); + var fi = new FileInfo(filePath.ToString()); + var diskCacheKey = adaptor.GetUniqueIdentifier(filePath, thumbSize, useEmbeddedThumbnails, autoRotate); // Check the disk cache using var stream = _diskCache.Read(diskCacheKey); diff --git a/Source/Components/ImageGlass.Gallery/ImageGallery.cs b/Source/Components/ImageGlass.Gallery/ImageGallery.cs index 7a8668a19..258bff238 100644 --- a/Source/Components/ImageGlass.Gallery/ImageGallery.cs +++ b/Source/Components/ImageGlass.Gallery/ImageGallery.cs @@ -1049,7 +1049,7 @@ public void ClearThumbnailCache() { foreach (ImageGalleryItem item in mItems) { - thumbnailCache.Add(item.Guid, item.Adaptor, item.VirtualItemKey, mThumbnailSize, mUseEmbeddedThumbnails, AutoRotateThumbnails); + thumbnailCache.Add(item.Guid, item.Adaptor, item.VirtualKey, mThumbnailSize, mUseEmbeddedThumbnails, AutoRotateThumbnails); } } Refresh(); diff --git a/Source/Components/ImageGlass.Gallery/Item/Adaptor/FileSystemAdaptor.cs b/Source/Components/ImageGlass.Gallery/Item/Adaptor/FileSystemAdaptor.cs index 7914160e9..91f4e5931 100644 --- a/Source/Components/ImageGlass.Gallery/Item/Adaptor/FileSystemAdaptor.cs +++ b/Source/Components/ImageGlass.Gallery/Item/Adaptor/FileSystemAdaptor.cs @@ -53,16 +53,14 @@ public FileSystemAdaptor() { } /// Embedded thumbnail usage. /// true to automatically rotate images based on Exif orientation; otherwise false. /// The thumbnail image from the given item or null if an error occurs. - public override Image? GetThumbnail(object key, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation) + public override Image? GetThumbnail(string filePath, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation) { if (_isDisposed) return null; try { - var filename = (string)key; - - return Extractor.Current.GetThumbnail(filename, size, useEmbeddedThumbnails, useExifOrientation); + return Extractor.Current.GetThumbnail(filePath, size, useEmbeddedThumbnails, useExifOrientation); } catch (Exception) { @@ -79,10 +77,14 @@ public FileSystemAdaptor() { } /// Embedded thumbnail usage. /// true to automatically rotate images based on Exif orientation; otherwise false. /// A unique identifier string for the thumnail. - public override string GetUniqueIdentifier(object key, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation) + public override string GetUniqueIdentifier(string filePath, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation) { + var fi = new FileInfo(filePath); using var sb = ZString.CreateStringBuilder(); - sb.Append((string)key); // Filename + + sb.Append(filePath); + sb.Append(':'); + sb.Append(fi.LastWriteTimeUtc.ToBinary()); sb.Append(':'); sb.Append(size.Width); // Thumbnail size sb.Append(','); @@ -100,11 +102,11 @@ public override string GetUniqueIdentifier(object key, Size size, UseEmbeddedThu /// /// Item key. /// The path to the source image. - public override string GetSourceImage(object key) + public override string GetSourceImage(string filePath) { if (_isDisposed) return string.Empty; - return (string)key; + return filePath; } /// @@ -112,12 +114,10 @@ public override string GetSourceImage(object key) /// /// Item key. /// An array of tuples containing item details or null if an error occurs. - public override IgMetadata GetDetails(object key) + public override IgMetadata GetDetails(string filePath) { if (_isDisposed) return new IgMetadata(); - var filePath = (string)key; - return PhotoCodec.LoadMetadata(filePath); } diff --git a/Source/Components/ImageGlass.Gallery/Item/Adaptor/IAdaptor.cs b/Source/Components/ImageGlass.Gallery/Item/Adaptor/IAdaptor.cs index 09c80fdf7..2c1e3ee32 100644 --- a/Source/Components/ImageGlass.Gallery/Item/Adaptor/IAdaptor.cs +++ b/Source/Components/ImageGlass.Gallery/Item/Adaptor/IAdaptor.cs @@ -37,36 +37,36 @@ public abstract class IAdaptor : IDisposable /// /// Returns the thumbnail image for the given item. /// - /// Item key. + /// Item file path. /// Requested image size. /// Embedded thumbnail usage. /// true to automatically rotate images based on Exif orientation; otherwise false. /// The thumbnail image from the given item or null if an error occurs. - public abstract Image? GetThumbnail(object key, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation); + public abstract Image? GetThumbnail(string filePath, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation); /// /// Returns a unique identifier for this thumbnail to be used in persistent /// caching. /// - /// Item key. + /// Item file path. /// Requested image size. /// Embedded thumbnail usage. /// true to automatically rotate images based on Exif orientation; otherwise false. /// A unique identifier string for the thumnail. - public abstract string GetUniqueIdentifier(object key, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation); + public abstract string GetUniqueIdentifier(string filePath, Size size, UseEmbeddedThumbnails useEmbeddedThumbnails, bool useExifOrientation); /// /// Returns the path to the source image for use in drag operations. /// - /// Item key. + /// Item file path. /// The path to the source image. - public abstract string GetSourceImage(object key); + public abstract string GetSourceImage(string filePath); /// /// Returns the details for the given item. /// - /// Item key. - public abstract IgMetadata GetDetails(object key); + /// Item file path. + public abstract IgMetadata GetDetails(string filePath); /// /// Performs application-defined tasks associated with freeing, diff --git a/Source/Components/ImageGlass.Gallery/Item/ImageGalleryItem.cs b/Source/Components/ImageGlass.Gallery/Item/ImageGalleryItem.cs index 5a3e44925..84f1867ce 100644 --- a/Source/Components/ImageGlass.Gallery/Item/ImageGalleryItem.cs +++ b/Source/Components/ImageGlass.Gallery/Item/ImageGalleryItem.cs @@ -51,10 +51,10 @@ public class ImageGalleryItem : ICloneable // File info private IgMetadata? _details = null; internal string extension = string.Empty; - internal string mFileName = string.Empty; + internal string mFilePath = string.Empty; // Adaptor - internal object mVirtualItemKey; + internal string mVirtualKey; internal IAdaptor? mAdaptor = null; // Used for cloned items @@ -157,7 +157,7 @@ public IgMetadata Details /// Gets the virtual item key associated with this item. /// [Category("Behavior"), Browsable(false)] - public object VirtualItemKey => mVirtualItemKey; + public string VirtualKey => mVirtualKey; /// /// Gets the ImageListView owning this item. @@ -254,22 +254,22 @@ public string Text } /// - /// Gets or sets the name of the image file represented by this item. + /// Gets or sets the file path of the image file represented by this item. /// [Category("File Properties")] - public string FileName + public string FilePath { - get => mFileName; + get => mFilePath; set { if (string.IsNullOrEmpty(value)) - throw new ArgumentException("FileName cannot be null"); + throw new ArgumentException("File path cannot be null"); - if (mFileName != value) + if (mFilePath != value) { - mFileName = value; - mVirtualItemKey = mFileName; - extension = _stringCache.GetFromCache(Path.GetExtension(mFileName)); + mFilePath = value; + mVirtualKey = mFilePath; + extension = _stringCache.GetFromCache(Path.GetExtension(mFilePath)); isDirty = true; if (ImageGalleryOwner != null) @@ -298,11 +298,11 @@ public Image? ThumbnailImage if (ThumbnailCacheState != CacheState.Cached) { - ImageGalleryOwner.thumbnailCache.Add(Guid, mAdaptor, mVirtualItemKey, ImageGalleryOwner.ThumbnailSize, + ImageGalleryOwner.thumbnailCache.Add(Guid, mAdaptor, mVirtualKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails); } - return ImageGalleryOwner.thumbnailCache.GetImage(Guid, mAdaptor, mVirtualItemKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, + return ImageGalleryOwner.thumbnailCache.GetImage(Guid, mAdaptor, mVirtualKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails, true); } } @@ -439,9 +439,9 @@ public string FileType public ImageGalleryItem(string filename, string text = "") { // important! to make it load faster using virtual items - mVirtualItemKey = filename; + mVirtualKey = filename; - mFileName = filename; + mFilePath = filename; mText = string.IsNullOrEmpty(text) ? Path.GetFileName(filename) : text; extension = _stringCache.GetFromCache(Path.GetExtension(filename)); } @@ -531,13 +531,13 @@ public ImageGalleryItem(string filename, string text = "") return img; } - img = ImageGalleryOwner.thumbnailCache.GetImage(Guid, mAdaptor, mVirtualItemKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, + img = ImageGalleryOwner.thumbnailCache.GetImage(Guid, mAdaptor, mVirtualKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails, false); if (state == CacheState.Cached) return img; - ImageGalleryOwner.thumbnailCache.Add(Guid, mAdaptor, mVirtualItemKey, ImageGalleryOwner.ThumbnailSize, + ImageGalleryOwner.thumbnailCache.Add(Guid, mAdaptor, mVirtualKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails); if (img == null && string.IsNullOrEmpty(iconPath)) @@ -564,11 +564,11 @@ public void UpdateDetails(bool force = false) if (!isDirty || Adaptor == null || ImageGalleryOwner == null - || mVirtualItemKey == null) return; + || mVirtualKey == null) return; if (force || _details == null) { - _details = Adaptor.GetDetails(mVirtualItemKey); + _details = Adaptor.GetDetails(mVirtualKey); } } @@ -596,7 +596,7 @@ private string PathForShellIcon() { if (ImageGalleryOwner != null && ImageGalleryOwner.ShellIconFromFileContent && (string.Compare(extension, ".ico", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(extension, ".exe", StringComparison.OrdinalIgnoreCase) == 0)) - return mFileName; + return mFilePath; else return extension; } @@ -613,7 +613,7 @@ private string PathForShellIcon() /// public object Clone() { - var item = new ImageGalleryItem(mFileName, mText) + var item = new ImageGalleryItem(mFilePath, mText) { // File info extension = extension, @@ -626,7 +626,7 @@ public object Clone() // Current thumbnail if (ImageGalleryOwner != null && mAdaptor != null) { - item.clonedThumbnail = ImageGalleryOwner.thumbnailCache.GetImage(Guid, mAdaptor, mVirtualItemKey, ImageGalleryOwner.ThumbnailSize, + item.clonedThumbnail = ImageGalleryOwner.thumbnailCache.GetImage(Guid, mAdaptor, mVirtualKey, ImageGalleryOwner.ThumbnailSize, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails, true); } diff --git a/Source/Components/ImageGlass.Gallery/Item/ItemCollection.cs b/Source/Components/ImageGlass.Gallery/Item/ItemCollection.cs index 9737fb98e..c9e737405 100644 --- a/Source/Components/ImageGlass.Gallery/Item/ItemCollection.cs +++ b/Source/Components/ImageGlass.Gallery/Item/ItemCollection.cs @@ -135,7 +135,7 @@ public ImageGalleryItem this[int index] _imageGallery.thumbnailCache.Add( item.Guid, item.Adaptor, - item.VirtualItemKey, + item.VirtualKey, _imageGallery.ThumbnailSize, _imageGallery.UseEmbeddedThumbnails, _imageGallery.AutoRotateThumbnails); @@ -507,7 +507,7 @@ internal bool InsertInternal(int index, ImageGalleryItem item, IAdaptor adaptor) // Add current thumbnail to cache if (item.clonedThumbnail != null) { - _imageGallery.thumbnailCache.Add(item.Guid, item.Adaptor, item.VirtualItemKey, _imageGallery.ThumbnailSize, + _imageGallery.thumbnailCache.Add(item.Guid, item.Adaptor, item.VirtualKey, _imageGallery.ThumbnailSize, item.clonedThumbnail, _imageGallery.UseEmbeddedThumbnails, _imageGallery.AutoRotateThumbnails); item.clonedThumbnail = null; } @@ -515,7 +515,7 @@ internal bool InsertInternal(int index, ImageGalleryItem item, IAdaptor adaptor) // Add to thumbnail cache if (_imageGallery.CacheMode == CacheMode.Continuous) { - _imageGallery.thumbnailCache.Add(item.Guid, item.Adaptor, item.VirtualItemKey, + _imageGallery.thumbnailCache.Add(item.Guid, item.Adaptor, item.VirtualKey, _imageGallery.ThumbnailSize, _imageGallery.UseEmbeddedThumbnails, _imageGallery.AutoRotateThumbnails); } diff --git a/Source/Components/ImageGlass.Gallery/Managers/NavigationManager.cs b/Source/Components/ImageGlass.Gallery/Managers/NavigationManager.cs index 314a47fb4..2e8910f2d 100644 --- a/Source/Components/ImageGlass.Gallery/Managers/NavigationManager.cs +++ b/Source/Components/ImageGlass.Gallery/Managers/NavigationManager.cs @@ -383,7 +383,7 @@ public void MouseMove(MouseEventArgs e) foreach (var item in _imageGallery.SelectedItems) { // Get the source image - var sourceFile = item.Adaptor.GetSourceImage(item.VirtualItemKey); + var sourceFile = item.Adaptor.GetSourceImage(item.VirtualKey); if (!string.IsNullOrEmpty(sourceFile)) filenames.Add(sourceFile); } diff --git a/Source/Components/ImageGlass.Gallery/Renderer/StyleRenderer.cs b/Source/Components/ImageGlass.Gallery/Renderer/StyleRenderer.cs index 9d346c640..8a4e9f9dc 100644 --- a/Source/Components/ImageGlass.Gallery/Renderer/StyleRenderer.cs +++ b/Source/Components/ImageGlass.Gallery/Renderer/StyleRenderer.cs @@ -334,7 +334,7 @@ private int CompareByFocused(DrawItemParams param1, DrawItemParams param2) if (img == null) { - ImageGalleryOwner.thumbnailCache.AddToRendererCache(item.Guid, item.mAdaptor, item.VirtualItemKey, + ImageGalleryOwner.thumbnailCache.AddToRendererCache(item.Guid, item.mAdaptor, item.VirtualKey, size, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails); } @@ -664,7 +664,7 @@ private Image GetGalleryImageAsync(ImageGalleryItem item, Size size) if (img == null) { - ImageGalleryOwner.thumbnailCache.AddToGalleryCache(item.Guid, item.mAdaptor, item.VirtualItemKey, + ImageGalleryOwner.thumbnailCache.AddToGalleryCache(item.Guid, item.mAdaptor, item.VirtualKey, size, ImageGalleryOwner.UseEmbeddedThumbnails, ImageGalleryOwner.AutoRotateThumbnails); } diff --git a/Source/ImageGlass/FrmMain.cs b/Source/ImageGlass/FrmMain.cs index 41265ef1a..d815c48e3 100644 --- a/Source/ImageGlass/FrmMain.cs +++ b/Source/ImageGlass/FrmMain.cs @@ -255,7 +255,7 @@ private void Gallery_ItemTooltipShowing(object sender, ItemTooltipShowingEventAr // build tooltip content using var sb = ZString.CreateStringBuilder(); - sb.AppendLine(e.Item.FileName); + sb.AppendLine(e.Item.FilePath); sb.AppendLine($"{Config.Language[$"{langPath}._{nameof(IgMetadata.FileSize)}"]}: {e.Item.Details.FileSizeFormated}"); sb.AppendLine($"{Config.Language[$"{langPath}._{nameof(IgMetadata.FileLastWriteTime)}"]}: {e.Item.Details.FileLastWriteTimeFormated}"); var tooltipLinesCount = 4; @@ -1236,7 +1236,7 @@ public void ShowImagePreview(string filePath, CancellationToken token = default) var thumbItem = Gallery.Items[Local.CurrentIndex]; if (thumbItem.ThumbnailImage is Image thumb - && thumbItem.FileName.Equals(filePath, StringComparison.OrdinalIgnoreCase)) + && thumbItem.FilePath.Equals(filePath, StringComparison.OrdinalIgnoreCase)) { wicSrc?.Dispose(); wicSrc = BHelper.ToWicBitmapSource(thumb); diff --git a/Source/ImageGlass/FrmMain/FrmMain.IGMethods.cs b/Source/ImageGlass/FrmMain/FrmMain.IGMethods.cs index 934e9b26b..cd51cb95f 100644 --- a/Source/ImageGlass/FrmMain/FrmMain.IGMethods.cs +++ b/Source/ImageGlass/FrmMain/FrmMain.IGMethods.cs @@ -1966,7 +1966,7 @@ public void IG_Rename() if (!Config.EnableRealTimeFileUpdate) { Local.Images.SetFileName(Local.CurrentIndex, newFilePath); - Gallery.Items[Local.CurrentIndex].FileName = newFilePath; + Gallery.Items[Local.CurrentIndex].FilePath = newFilePath; Gallery.Items[Local.CurrentIndex].Text = newName; LoadImageInfo(ImageInfoUpdateTypes.Name | ImageInfoUpdateTypes.Path); }