mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
MapImageLayer animation
This commit is contained in:
parent
2d6b2eb2aa
commit
e0e2061014
|
|
@ -8,7 +8,7 @@ namespace MapControl
|
|||
{
|
||||
public partial class MapImageLayer
|
||||
{
|
||||
public static void FadeOver(Image topImage, Image bottomImage)
|
||||
private void FadeOver()
|
||||
{
|
||||
var fadeInAnimation = new Animation
|
||||
{
|
||||
|
|
@ -24,8 +24,8 @@ namespace MapControl
|
|||
}
|
||||
};
|
||||
|
||||
_ = fadeInAnimation.RunAsync(topImage).ContinueWith(
|
||||
_ => bottomImage.Opacity = 0d,
|
||||
_ = fadeInAnimation.RunAsync(Children[1]).ContinueWith(
|
||||
_ => Children[0].Opacity = 0d,
|
||||
TaskScheduler.FromCurrentSynchronizationContext());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,10 +125,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets the progress of the ImageLoader as a double value between 0 and 1.
|
||||
/// </summary>
|
||||
public double LoadingProgress
|
||||
{
|
||||
get => (double)GetValue(LoadingProgressProperty);
|
||||
}
|
||||
public double LoadingProgress => (double)GetValue(LoadingProgressProperty);
|
||||
|
||||
protected override void SetParentMap(MapBase map)
|
||||
{
|
||||
|
|
@ -136,11 +133,7 @@ namespace MapControl
|
|||
{
|
||||
while (Children.Count < 2)
|
||||
{
|
||||
Children.Add(new Image
|
||||
{
|
||||
Opacity = 0d,
|
||||
Stretch = Stretch.Fill,
|
||||
});
|
||||
Children.Add(new Image { Stretch = Stretch.Fill });
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -236,7 +229,6 @@ namespace MapControl
|
|||
if (Children.Count >= 2)
|
||||
{
|
||||
var topImage = (Image)Children[0];
|
||||
var bottomImage = (Image)Children[1];
|
||||
|
||||
Children.RemoveAt(0);
|
||||
Children.Insert(1, topImage);
|
||||
|
|
@ -244,7 +236,7 @@ namespace MapControl
|
|||
topImage.Source = image;
|
||||
SetBoundingBox(topImage, boundingBox);
|
||||
|
||||
FadeOver(topImage, bottomImage);
|
||||
FadeOver();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
using System.Windows.Media.Animation;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public partial class MapImageLayer
|
||||
{
|
||||
public static void FadeOver(Image topImage, Image bottomImage)
|
||||
private void FadeOver()
|
||||
{
|
||||
var fadeInAnimation = new DoubleAnimation
|
||||
{
|
||||
|
|
@ -25,8 +25,16 @@ namespace MapControl
|
|||
Duration = TimeSpan.Zero
|
||||
};
|
||||
|
||||
topImage.BeginAnimation(OpacityProperty, fadeInAnimation);
|
||||
bottomImage.BeginAnimation(OpacityProperty, fadeOutAnimation);
|
||||
Storyboard.SetTarget(fadeInAnimation, Children[1]);
|
||||
Storyboard.SetTargetProperty(fadeInAnimation, new PropertyPath(OpacityProperty));
|
||||
|
||||
Storyboard.SetTarget(fadeOutAnimation, Children[0]);
|
||||
Storyboard.SetTargetProperty(fadeOutAnimation, new PropertyPath(OpacityProperty));
|
||||
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(fadeInAnimation);
|
||||
storyboard.Children.Add(fadeOutAnimation);
|
||||
storyboard.Begin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@
|
|||
|
||||
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
|
||||
|
||||
|
|
@ -15,7 +13,7 @@ namespace MapControl
|
|||
{
|
||||
public partial class MapImageLayer
|
||||
{
|
||||
public static void FadeOver(Image topImage, Image bottomImage)
|
||||
private void FadeOver()
|
||||
{
|
||||
var fadeInAnimation = new DoubleAnimation
|
||||
{
|
||||
|
|
@ -30,11 +28,11 @@ namespace MapControl
|
|||
Duration = TimeSpan.Zero
|
||||
};
|
||||
|
||||
Storyboard.SetTarget(fadeInAnimation, Children[1]);
|
||||
Storyboard.SetTargetProperty(fadeInAnimation, nameof(Opacity));
|
||||
Storyboard.SetTarget(fadeInAnimation, topImage);
|
||||
|
||||
Storyboard.SetTarget(fadeOutAnimation, Children[0]);
|
||||
Storyboard.SetTargetProperty(fadeOutAnimation, nameof(Opacity));
|
||||
Storyboard.SetTarget(fadeOutAnimation, bottomImage);
|
||||
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(fadeInAnimation);
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ namespace MapControl
|
|||
FillBehavior = FillBehavior.Stop
|
||||
};
|
||||
|
||||
Storyboard.SetTargetProperty(fadeInAnimation, nameof(UIElement.Opacity));
|
||||
Storyboard.SetTarget(fadeInAnimation, Image);
|
||||
Storyboard.SetTargetProperty(fadeInAnimation, nameof(UIElement.Opacity));
|
||||
|
||||
var storyboard = new Storyboard();
|
||||
storyboard.Children.Add(fadeInAnimation);
|
||||
|
|
|
|||
Loading…
Reference in a new issue