XAML-Map-Control/MapControl/WinUI/MapImageLayer.WinUI.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2025-01-05 09:22:50 +01:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// Copyright © Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
#if UWP
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
#else
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media.Animation;
#endif
namespace MapControl
{
public partial class MapImageLayer
{
public static void FadeOver(Image topImage, Image bottomImage)
{
2025-01-05 10:31:15 +01:00
var fadeInAnimation = new DoubleAnimation
2025-01-05 09:22:50 +01:00
{
To = 1d,
Duration = MapBase.ImageFadeDuration
};
2025-01-05 10:31:15 +01:00
var fadeOutAnimation = new DoubleAnimation
2025-01-05 09:22:50 +01:00
{
To = 0d,
BeginTime = MapBase.ImageFadeDuration,
2025-01-05 10:31:15 +01:00
Duration = TimeSpan.Zero,
FillBehavior = FillBehavior.Stop
2025-01-05 09:22:50 +01:00
};
2025-01-05 10:31:15 +01:00
Storyboard.SetTargetProperty(fadeInAnimation, nameof(Opacity));
Storyboard.SetTarget(fadeInAnimation, topImage);
2025-01-05 09:22:50 +01:00
2025-01-05 10:31:15 +01:00
Storyboard.SetTargetProperty(fadeOutAnimation, nameof(Opacity));
Storyboard.SetTarget(fadeOutAnimation, bottomImage);
2025-01-05 09:22:50 +01:00
var storyboard = new Storyboard();
2025-01-05 10:31:15 +01:00
storyboard.Children.Add(fadeInAnimation);
storyboard.Children.Add(fadeOutAnimation);
2025-01-05 09:22:50 +01:00
storyboard.Begin();
}
}
}