diff --git a/src/PicView.Avalonia.Win32/PicView.Avalonia.Win32.csproj b/src/PicView.Avalonia.Win32/PicView.Avalonia.Win32.csproj
index c2e08b2c0..ff1527ee6 100644
--- a/src/PicView.Avalonia.Win32/PicView.Avalonia.Win32.csproj
+++ b/src/PicView.Avalonia.Win32/PicView.Avalonia.Win32.csproj
@@ -13,6 +13,7 @@
true
Speed
false
+ false
x64
enable
PicView
diff --git a/src/PicView.Avalonia.Win32/Program.cs b/src/PicView.Avalonia.Win32/Program.cs
index f5e75f212..0dd41ec23 100644
--- a/src/PicView.Avalonia.Win32/Program.cs
+++ b/src/PicView.Avalonia.Win32/Program.cs
@@ -5,6 +5,7 @@
namespace PicView.Avalonia.Win32;
+// ReSharper disable once ClassNeverInstantiated.Global
internal class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
diff --git a/src/PicView.Avalonia/CustomControls/GalleryAnimationControl.cs b/src/PicView.Avalonia/CustomControls/GalleryAnimationControl.cs
index 9fbd8a0e4..334c94918 100644
--- a/src/PicView.Avalonia/CustomControls/GalleryAnimationControl.cs
+++ b/src/PicView.Avalonia/CustomControls/GalleryAnimationControl.cs
@@ -81,12 +81,10 @@ await Dispatcher.UIThread.InvokeAsync(() =>
await Dispatcher.UIThread.InvokeAsync(() =>
{
Opacity = to;
- Height = double.NaN;
GalleryNavigation.CenterScrollToSelectedItem(vm);
});
vm.GalleryVerticalAlignment = VerticalAlignment.Stretch;
-
_isAnimating = false;
}
@@ -205,7 +203,7 @@ private async Task BottomToFullAnimation()
await heightAnimation.RunAsync(this);
await Dispatcher.UIThread.InvokeAsync(() =>
{
- Height = double.NaN;
+ Height = to;
GalleryNavigation.CenterScrollToSelectedItem(vm);
});
UIHelper.SetStretchMode(vm);
diff --git a/src/PicView.Avalonia/Helpers/ImageHelper.cs b/src/PicView.Avalonia/Helpers/ImageHelper.cs
index 24a2f4ca9..201c04dee 100644
--- a/src/PicView.Avalonia/Helpers/ImageHelper.cs
+++ b/src/PicView.Avalonia/Helpers/ImageHelper.cs
@@ -6,6 +6,7 @@
using PicView.Avalonia.Navigation;
using PicView.Core.FileHandling;
using PicView.Core.ImageDecoding;
+using SkiaSharp;
namespace PicView.Avalonia.Helpers;
@@ -101,10 +102,10 @@ await Task.Run(() =>
void Add(Stream stream)
{
- var bmp = new Bitmap(stream);
- imageModel.Image = bmp;
- imageModel.PixelWidth = bmp?.PixelSize.Width ?? 0;
- imageModel.PixelHeight = bmp?.PixelSize.Height ?? 0;
+ var writeableBitmap = WriteableBitmap.Decode(stream);
+ imageModel.Image = writeableBitmap;
+ imageModel.PixelWidth = writeableBitmap?.PixelSize.Width ?? 0;
+ imageModel.PixelHeight = writeableBitmap?.PixelSize.Height ?? 0;
imageModel.ImageType = ImageType.Bitmap;
}
@@ -179,7 +180,7 @@ async Task CreateThumb(IMagickImage magick)
await using var memoryStream = new MemoryStream();
await magick.WriteAsync(memoryStream);
memoryStream.Position = 0;
- return new Bitmap(memoryStream);
+ return WriteableBitmap.Decode(memoryStream);
}
}
diff --git a/src/PicView.Avalonia/Models/ImageModel.cs b/src/PicView.Avalonia/Models/ImageModel.cs
index 68cd2c13d..9886428c7 100644
--- a/src/PicView.Avalonia/Models/ImageModel.cs
+++ b/src/PicView.Avalonia/Models/ImageModel.cs
@@ -5,10 +5,8 @@
namespace PicView.Avalonia.Models;
-public class ImageModel : IDisposable
+public class ImageModel
{
- private bool _disposedValue;
-
public object? Image { get; set; }
public FileInfo? FileInfo { get; set; }
public int PixelWidth { get; set; }
@@ -36,39 +34,4 @@ EXIFHelper.EXIFOrientation.None or EXIFHelper.EXIFOrientation.Normal
};
}
}
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposedValue)
- {
- return;
- }
-
- if (disposing)
- {
- if (Image is Bitmap bmp)
- {
- bmp.Dispose();
- }
- FileInfo = null;
- }
-
- // TODO: free unmanaged resources (unmanaged objects) and override finalizer
- // TODO: set large fields to null
- _disposedValue = true;
- }
-
- // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
- ~ImageModel()
- {
- // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
- Dispose(disposing: false);
- }
-
- public void Dispose()
- {
- // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
- Dispose(disposing: true);
- GC.SuppressFinalize(this);
- }
}
\ No newline at end of file
diff --git a/src/PicView.Avalonia/Navigation/PreloaderService.cs b/src/PicView.Avalonia/Navigation/PreloaderService.cs
index db197bad6..ef9d6f061 100644
--- a/src/PicView.Avalonia/Navigation/PreloaderService.cs
+++ b/src/PicView.Avalonia/Navigation/PreloaderService.cs
@@ -3,6 +3,7 @@
using PicView.Core.ImageDecoding;
using System.Collections.Concurrent;
using System.Diagnostics;
+using Avalonia.Media.Imaging;
using PicView.Avalonia.Helpers;
namespace PicView.Avalonia.Navigation;
@@ -193,8 +194,13 @@ public bool Remove(int key, List list)
try
{
- _preLoadList[key].ImageModel?.Dispose();
- _ = _preLoadList[key];
+ var item = _preLoadList[key];
+ if (item.ImageModel.Image is Bitmap img)
+ {
+ img.Dispose();
+ }
+ item.ImageModel.Image = null;
+ item.ImageModel.FileInfo = null;
var remove = _preLoadList.TryRemove(key, out _);
#if DEBUG
if (remove && ShowAddRemove)
diff --git a/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml b/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml
index 9f1f74df3..34b09712a 100644
--- a/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml
+++ b/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml
@@ -20,6 +20,8 @@
CornerRadius="6">
diff --git a/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml.cs b/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml.cs
index 1753ab76f..16a284788 100644
--- a/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml.cs
+++ b/src/PicView.Avalonia/Views/UC/ToolTipMessage.axaml.cs
@@ -34,17 +34,18 @@ private async Task DoAnimation()
_isRunning = true;
- // Start opacity animation from 0 to 1
- var fadeInAnimation = AnimationsHelper.OpacityAnimation(from: 0, to: 1, 1.5);
- await fadeInAnimation.RunAsync(this);
+ // ReSharper disable once CompareOfFloatsByEqualityOperator
+ if (Opacity != 1)
+ {
+ var fadeInAnimation = AnimationsHelper.OpacityAnimation(from: 0, to: 1, 1.5);
+ await fadeInAnimation.RunAsync(this);
+ }
// Wait for the duration before fading out
await Task.Delay(TimeSpan.FromSeconds(1.5));
-
- // Start opacity animation from 1 to 0
+ _isRunning = false;
+
var fadeOutAnimation = AnimationsHelper.OpacityAnimation(from: 1, to: 0, 1.5);
await fadeOutAnimation.RunAsync(this);
-
- _isRunning = false;
}
}