Merge pull request #521 from irihitech/image
fix: fix image binding to stretch initialization issue.
This commit is contained in:
7
.github/workflows/test.yml
vendored
7
.github/workflows/test.yml
vendored
@@ -12,12 +12,17 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.1
|
uses: actions/checkout@v4.1.1
|
||||||
|
- name: Ursa Unit Test
|
||||||
|
run: dotnet test ./tests/Test.Ursa
|
||||||
- name: Ursa Headless Test
|
- name: Ursa Headless Test
|
||||||
run: dotnet test ./tests/HeadlessTest.Ursa
|
run: dotnet test ./tests/HeadlessTest.Ursa
|
||||||
|
|
||||||
ubuntu:
|
ubuntu:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4.1.1
|
uses: actions/checkout@v4.1.1
|
||||||
|
- name: Ursa Unit Test
|
||||||
|
run: dotnet test ./tests/Test.Ursa
|
||||||
- name: Ursa Headless Test
|
- name: Ursa Headless Test
|
||||||
run: dotnet test ./tests/HeadlessTest.Ursa
|
run: dotnet test ./tests/HeadlessTest.Ursa
|
||||||
|
|||||||
@@ -163,8 +163,9 @@ public class ImageViewer: TemplatedControl
|
|||||||
|
|
||||||
private void OnStretchChanged(AvaloniaPropertyChangedEventArgs args)
|
private void OnStretchChanged(AvaloniaPropertyChangedEventArgs args)
|
||||||
{
|
{
|
||||||
|
if (_image is null) return;
|
||||||
var stretch = args.GetNewValue<Stretch>();
|
var stretch = args.GetNewValue<Stretch>();
|
||||||
Scale = GetScaleRatio(Width / _image!.Width, Height / _image!.Height, stretch);
|
Scale = GetScaleRatio(Width / _image.Width, Height / _image.Height, stretch);
|
||||||
_sourceMinScale = _image is not null ? Math.Min(Width * MinScale / _image.Width, Height * MinScale / _image.Height) : MinScale;
|
_sourceMinScale = _image is not null ? Math.Min(Width * MinScale / _image.Width, Height * MinScale / _image.Height) : MinScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Ursa.Controls;
|
||||||
|
|
||||||
|
namespace Test.Ursa.Controls.ImageViewerTests.Stretch_Initial_Value;
|
||||||
|
|
||||||
|
public class StretchValueTest
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Stretch_Initial_Value_Does_Not_Crash()
|
||||||
|
{
|
||||||
|
ImageViewer iv = new ImageViewer()
|
||||||
|
{
|
||||||
|
Stretch = Stretch.UniformToFill
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user