mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-20 22:05:07 +00:00
Use local function
This commit is contained in:
parent
f4d43eeb44
commit
3d6fc375b2
2 changed files with 30 additions and 28 deletions
|
|
@ -14,17 +14,16 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
var image = await loadImageFunc().ConfigureAwait(false);
|
var image = await loadImageFunc().ConfigureAwait(false);
|
||||||
|
|
||||||
await Dispatcher.UIThread.InvokeAsync(
|
void SetImageSource()
|
||||||
() =>
|
{
|
||||||
{
|
Image.Source = image;
|
||||||
Image.Source = image;
|
|
||||||
|
|
||||||
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
var fadeInAnimation = new Animation
|
||||||
{
|
{
|
||||||
var fadeInAnimation = new Animation
|
Duration = MapBase.ImageFadeDuration,
|
||||||
{
|
Children =
|
||||||
Duration = MapBase.ImageFadeDuration,
|
|
||||||
Children =
|
|
||||||
{
|
{
|
||||||
new KeyFrame
|
new KeyFrame
|
||||||
{
|
{
|
||||||
|
|
@ -37,11 +36,13 @@ namespace MapControl
|
||||||
Setters = { new Setter(Visual.OpacityProperty, 1d) }
|
Setters = { new Setter(Visual.OpacityProperty, 1d) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_ = fadeInAnimation.RunAsync(Image);
|
_ = fadeInAnimation.RunAsync(Image);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(SetImageSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,24 +14,25 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
var image = await loadImageFunc().ConfigureAwait(false);
|
var image = await loadImageFunc().ConfigureAwait(false);
|
||||||
|
|
||||||
await Image.Dispatcher.InvokeAsync(
|
void SetImageSource()
|
||||||
() =>
|
{
|
||||||
{
|
Image.Source = image;
|
||||||
Image.Source = image;
|
|
||||||
|
|
||||||
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||||
|
{
|
||||||
|
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
|
||||||
{
|
{
|
||||||
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
|
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
||||||
{
|
bitmap.DownloadFailed += BitmapDownloadFailed;
|
||||||
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
|
||||||
bitmap.DownloadFailed += BitmapDownloadFailed;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BeginFadeInAnimation();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
else
|
||||||
|
{
|
||||||
|
BeginFadeInAnimation();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Image.Dispatcher.InvokeAsync(SetImageSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BeginFadeInAnimation()
|
private void BeginFadeInAnimation()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue