mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-24 03:45:00 +00:00
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:
parent
dd254ebf4f
commit
bbb0ceada8
1 changed files with 14 additions and 0 deletions
|
@ -92,6 +92,20 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
return availableSize;
|
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
|
public class ImageSwipeControl : ImageContainer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue