mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Use local function
This commit is contained in:
parent
f4d43eeb44
commit
3d6fc375b2
|
|
@ -14,17 +14,16 @@ namespace MapControl
|
|||
{
|
||||
var image = await loadImageFunc().ConfigureAwait(false);
|
||||
|
||||
await Dispatcher.UIThread.InvokeAsync(
|
||||
() =>
|
||||
{
|
||||
Image.Source = image;
|
||||
void SetImageSource()
|
||||
{
|
||||
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
|
||||
{
|
||||
|
|
@ -37,11 +36,13 @@ namespace MapControl
|
|||
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);
|
||||
|
||||
await Image.Dispatcher.InvokeAsync(
|
||||
() =>
|
||||
{
|
||||
Image.Source = image;
|
||||
void SetImageSource()
|
||||
{
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginFadeInAnimation();
|
||||
}
|
||||
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
||||
bitmap.DownloadFailed += BitmapDownloadFailed;
|
||||
}
|
||||
});
|
||||
else
|
||||
{
|
||||
BeginFadeInAnimation();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await Image.Dispatcher.InvokeAsync(SetImageSource);
|
||||
}
|
||||
|
||||
private void BeginFadeInAnimation()
|
||||
|
|
|
|||
Loading…
Reference in a new issue