mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|||
|
|
// Copyright © 2024 Clemens Fischer
|
|||
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|||
|
|
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using System;
|
|||
|
|
using Avalonia.Controls;
|
|||
|
|
using Avalonia.Animation;
|
|||
|
|
using Avalonia.Styling;
|
|||
|
|
using System.Xml.Linq;
|
|||
|
|
|
|||
|
|
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);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static async Task SwapOpacities(Control topElement, Control bottomElement)
|
|||
|
|
{
|
|||
|
|
var animation = new Animation
|
|||
|
|
{
|
|||
|
|
Duration = MapBase.ImageFadeDuration,
|
|||
|
|
Children =
|
|||
|
|
{
|
|||
|
|
new KeyFrame
|
|||
|
|
{
|
|||
|
|
KeyTime = MapBase.ImageFadeDuration,
|
|||
|
|
Setters = { new Setter(Visual.OpacityProperty, 1d) }
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
await animation.RunAsync(topElement);
|
|||
|
|
|
|||
|
|
bottomElement.Opacity = 0d;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|