fix: Ensure each ImageView instance calculates its own aspect ratio

- Modified ArrangeOverride methods in ImageView class to independently calculate and apply the aspect ratio based on the instance's image.

Signed-off-by: Gadfly <gadfly@gadfly.vip>
This commit is contained in:
Gadfly 2025-01-27 16:07:00 +08:00
parent dd254ebf4f
commit bbb0ceada8
No known key found for this signature in database

View file

@ -92,6 +92,20 @@ namespace SourceGit.Views
return availableSize;
}
protected override Size ArrangeOverride(Size finalSize)
{
if (Image is { } image)
{
var imageSize = image.Size;
var scaleW = finalSize.Width / imageSize.Width;
var scaleH = finalSize.Height / imageSize.Height;
var scale = Math.Min(scaleW, scaleH);
return new Size(scale * imageSize.Width, scale * imageSize.Height);
}
return base.ArrangeOverride(finalSize);
}
}
public class ImageSwipeControl : ImageContainer