mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Removed OpacityHelper
This commit is contained in:
parent
3afbdadf0c
commit
b9a34fd5e4
10 changed files with 144 additions and 171 deletions
45
MapControl/WinUI/MapImageLayer.WinUI.cs
Normal file
45
MapControl/WinUI/MapImageLayer.WinUI.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// 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)
|
||||
{
|
||||
var topImageAnimation = new DoubleAnimation
|
||||
{
|
||||
To = 1d,
|
||||
Duration = MapBase.ImageFadeDuration
|
||||
};
|
||||
|
||||
var bottomImageAnimation = new DoubleAnimation
|
||||
{
|
||||
To = 0d,
|
||||
BeginTime = MapBase.ImageFadeDuration,
|
||||
Duration = TimeSpan.Zero
|
||||
};
|
||||
|
||||
Storyboard.SetTargetProperty(topImageAnimation, nameof(Opacity));
|
||||
Storyboard.SetTarget(topImageAnimation, topImage);
|
||||
|
||||
Storyboard.SetTargetProperty(bottomImageAnimation, nameof(Opacity));
|
||||
Storyboard.SetTarget(bottomImageAnimation, bottomImage);
|
||||
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(topImageAnimation);
|
||||
storyboard.Children.Add(bottomImageAnimation);
|
||||
storyboard.Begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// Copyright © Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
#if UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
#else
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Media.Animation;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public static class OpacityHelper
|
||||
{
|
||||
public static void BeginOpacityAnimation(DependencyObject obj, DoubleAnimation animation)
|
||||
{
|
||||
Storyboard.SetTargetProperty(animation, nameof(UIElement.Opacity));
|
||||
Storyboard.SetTarget(animation, obj);
|
||||
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(animation);
|
||||
storyboard.Begin();
|
||||
}
|
||||
|
||||
public static Task SwapOpacitiesAsync(UIElement topElement, UIElement bottomElement)
|
||||
{
|
||||
BeginOpacityAnimation(topElement, new DoubleAnimation
|
||||
{
|
||||
To = 1d,
|
||||
Duration = MapBase.ImageFadeDuration
|
||||
});
|
||||
|
||||
BeginOpacityAnimation(bottomElement, new DoubleAnimation
|
||||
{
|
||||
To = 0d,
|
||||
BeginTime = MapBase.ImageFadeDuration,
|
||||
Duration = TimeSpan.Zero
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,13 +18,19 @@ namespace MapControl
|
|||
{
|
||||
private void BeginOpacityAnimation()
|
||||
{
|
||||
OpacityHelper.BeginOpacityAnimation(Image,
|
||||
new DoubleAnimation
|
||||
{
|
||||
From = 0d,
|
||||
Duration = MapBase.ImageFadeDuration,
|
||||
FillBehavior = FillBehavior.Stop
|
||||
});
|
||||
var animation = new DoubleAnimation
|
||||
{
|
||||
From = 0d,
|
||||
Duration = MapBase.ImageFadeDuration,
|
||||
FillBehavior = FillBehavior.Stop
|
||||
};
|
||||
|
||||
Storyboard.SetTargetProperty(animation, nameof(UIElement.Opacity));
|
||||
Storyboard.SetTarget(animation, Image);
|
||||
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(animation);
|
||||
storyboard.Begin();
|
||||
}
|
||||
|
||||
private void AnimateImageOpacity()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue