Skip to content

Commit

Permalink
fix: image viewer crash issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Mar 6, 2024
1 parent 0e4e7c9 commit 66ad32f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Shared/HandyControl_Shared/Controls/Image/ImageViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -962,20 +962,19 @@ private static void OnUriChanged(DependencyObject d, DependencyPropertyChangedEv

private void OnUriChanged(Uri newValue)
{
if (newValue is not null)
ImageSource = newValue is not null ? GetBitmapFrame(newValue) : null;
if (ImageSource is not null && newValue.IsAbsoluteUri)
{
ImageSource = GetBitmapFrame(newValue);
ImgPath = newValue.AbsolutePath;

if (File.Exists(ImgPath))
{
ImgSize = new FileInfo(ImgPath).Length;
}
}
else
{
ImageSource = null;
ImgPath = string.Empty;
ImgSize = 0;
}

static BitmapFrame GetBitmapFrame(Uri source)
Expand Down

0 comments on commit 66ad32f

Please sign in to comment.