XAML-Map-Control/MapControl/Avalonia/OpacityHelper.Avalonia.cs

57 lines
1.6 KiB
C#
Raw Normal View History

2024-05-21 22:05:01 +02:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2025-01-01 18:57:55 +01:00
// Copyright © Clemens Fischer
2024-05-21 22:05:01 +02:00
// Licensed under the Microsoft Public License (Ms-PL)
using System.Threading.Tasks;
using System;
namespace MapControl
{
public static class OpacityHelper
{
public static Task FadeIn(Control element)
{
var animation = new Animation
{
Duration = MapBase.ImageFadeDuration,
Children =
{
new KeyFrame
{
KeyTime = TimeSpan.Zero,
Setters = { new Setter(Visual.OpacityProperty, 0d) }
},
new KeyFrame
{
KeyTime = MapBase.ImageFadeDuration,
Setters = { new Setter(Visual.OpacityProperty, 1d) }
}
}
};
return animation.RunAsync(element);
}
2024-08-31 11:55:59 +02:00
public static async Task SwapOpacitiesAsync(Control topElement, Control bottomElement)
2024-05-21 22:05:01 +02:00
{
var animation = new Animation
{
2024-05-21 23:18:00 +02:00
FillMode = FillMode.Forward,
2024-05-21 22:05:01 +02:00
Duration = MapBase.ImageFadeDuration,
Children =
{
new KeyFrame
{
KeyTime = MapBase.ImageFadeDuration,
Setters = { new Setter(Visual.OpacityProperty, 1d) }
}
}
};
await animation.RunAsync(topElement);
bottomElement.Opacity = 0d;
}
}
}