XAML-Map-Control/MapControl/Avalonia/MapImageLayer.Avalonia.cs
2025-01-05 09:22:50 +01:00

33 lines
985 B
C#

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// Copyright © Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System.Threading.Tasks;
namespace MapControl
{
public partial class MapImageLayer
{
public static void FadeOver(Image topImage, Image bottomImage)
{
var animation = new Animation
{
FillMode = FillMode.Forward,
Duration = MapBase.ImageFadeDuration,
Children =
{
new KeyFrame
{
KeyTime = MapBase.ImageFadeDuration,
Setters = { new Setter(Visual.OpacityProperty, 1d) }
}
}
};
_ = animation.RunAsync(topImage).ContinueWith(
_ => bottomImage.Opacity = 0d,
TaskScheduler.FromCurrentSynchronizationContext());
}
}
}