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 partial class MapImageLayer
|
||||||
{
|
{
|
||||||
public static void FadeOver(Image topImage, Image bottomImage)
|
private void FadeOver()
|
||||||
{
|
{
|
||||||
var fadeInAnimation = new Animation
|
var fadeInAnimation = new Animation
|
||||||
{
|
{
|
||||||
|
|
@ -24,8 +24,8 @@ namespace MapControl
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_ = fadeInAnimation.RunAsync(topImage).ContinueWith(
|
_ = fadeInAnimation.RunAsync(Children[1]).ContinueWith(
|
||||||
_ => bottomImage.Opacity = 0d,
|
_ => Children[0].Opacity = 0d,
|
||||||
TaskScheduler.FromCurrentSynchronizationContext());
|
TaskScheduler.FromCurrentSynchronizationContext());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,10 +125,7 @@ namespace MapControl
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the progress of the ImageLoader as a double value between 0 and 1.
|
/// Gets the progress of the ImageLoader as a double value between 0 and 1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public double LoadingProgress
|
public double LoadingProgress => (double)GetValue(LoadingProgressProperty);
|
||||||
{
|
|
||||||
get => (double)GetValue(LoadingProgressProperty);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void SetParentMap(MapBase map)
|
protected override void SetParentMap(MapBase map)
|
||||||
{
|
{
|
||||||
|
|
@ -136,11 +133,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
while (Children.Count < 2)
|
while (Children.Count < 2)
|
||||||
{
|
{
|
||||||
Children.Add(new Image
|
Children.Add(new Image { Stretch = Stretch.Fill });
|
||||||
{
|
|
||||||
Opacity = 0d,
|
|
||||||
Stretch = Stretch.Fill,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -236,7 +229,6 @@ namespace MapControl
|
||||||
if (Children.Count >= 2)
|
if (Children.Count >= 2)
|
||||||
{
|
{
|
||||||
var topImage = (Image)Children[0];
|
var topImage = (Image)Children[0];
|
||||||
var bottomImage = (Image)Children[1];
|
|
||||||
|
|
||||||
Children.RemoveAt(0);
|
Children.RemoveAt(0);
|
||||||
Children.Insert(1, topImage);
|
Children.Insert(1, topImage);
|
||||||
|
|
@ -244,7 +236,7 @@ namespace MapControl
|
||||||
topImage.Source = image;
|
topImage.Source = image;
|
||||||
SetBoundingBox(topImage, boundingBox);
|
SetBoundingBox(topImage, boundingBox);
|
||||||
|
|
||||||
FadeOver(topImage, bottomImage);
|
FadeOver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,14 @@
|
||||||
// Licensed under the Microsoft Public License (Ms-PL)
|
// Licensed under the Microsoft Public License (Ms-PL)
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Controls;
|
using System.Windows;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
namespace MapControl
|
namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class MapImageLayer
|
public partial class MapImageLayer
|
||||||
{
|
{
|
||||||
public static void FadeOver(Image topImage, Image bottomImage)
|
private void FadeOver()
|
||||||
{
|
{
|
||||||
var fadeInAnimation = new DoubleAnimation
|
var fadeInAnimation = new DoubleAnimation
|
||||||
{
|
{
|
||||||
|
|
@ -25,8 +25,16 @@ namespace MapControl
|
||||||
Duration = TimeSpan.Zero
|
Duration = TimeSpan.Zero
|
||||||
};
|
};
|
||||||
|
|
||||||
topImage.BeginAnimation(OpacityProperty, fadeInAnimation);
|
Storyboard.SetTarget(fadeInAnimation, Children[1]);
|
||||||
bottomImage.BeginAnimation(OpacityProperty, fadeOutAnimation);
|
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;
|
using System;
|
||||||
#if UWP
|
#if UWP
|
||||||
using Windows.UI.Xaml.Controls;
|
|
||||||
using Windows.UI.Xaml.Media.Animation;
|
using Windows.UI.Xaml.Media.Animation;
|
||||||
#else
|
#else
|
||||||
using Microsoft.UI.Xaml.Controls;
|
|
||||||
using Microsoft.UI.Xaml.Media.Animation;
|
using Microsoft.UI.Xaml.Media.Animation;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -15,7 +13,7 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public partial class MapImageLayer
|
public partial class MapImageLayer
|
||||||
{
|
{
|
||||||
public static void FadeOver(Image topImage, Image bottomImage)
|
private void FadeOver()
|
||||||
{
|
{
|
||||||
var fadeInAnimation = new DoubleAnimation
|
var fadeInAnimation = new DoubleAnimation
|
||||||
{
|
{
|
||||||
|
|
@ -30,11 +28,11 @@ namespace MapControl
|
||||||
Duration = TimeSpan.Zero
|
Duration = TimeSpan.Zero
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Storyboard.SetTarget(fadeInAnimation, Children[1]);
|
||||||
Storyboard.SetTargetProperty(fadeInAnimation, nameof(Opacity));
|
Storyboard.SetTargetProperty(fadeInAnimation, nameof(Opacity));
|
||||||
Storyboard.SetTarget(fadeInAnimation, topImage);
|
|
||||||
|
|
||||||
|
Storyboard.SetTarget(fadeOutAnimation, Children[0]);
|
||||||
Storyboard.SetTargetProperty(fadeOutAnimation, nameof(Opacity));
|
Storyboard.SetTargetProperty(fadeOutAnimation, nameof(Opacity));
|
||||||
Storyboard.SetTarget(fadeOutAnimation, bottomImage);
|
|
||||||
|
|
||||||
var storyboard = new Storyboard();
|
var storyboard = new Storyboard();
|
||||||
storyboard.Children.Add(fadeInAnimation);
|
storyboard.Children.Add(fadeInAnimation);
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ namespace MapControl
|
||||||
FillBehavior = FillBehavior.Stop
|
FillBehavior = FillBehavior.Stop
|
||||||
};
|
};
|
||||||
|
|
||||||
Storyboard.SetTargetProperty(fadeInAnimation, nameof(UIElement.Opacity));
|
|
||||||
Storyboard.SetTarget(fadeInAnimation, Image);
|
Storyboard.SetTarget(fadeInAnimation, Image);
|
||||||
|
Storyboard.SetTargetProperty(fadeInAnimation, nameof(UIElement.Opacity));
|
||||||
|
|
||||||
var storyboard = new Storyboard();
|
var storyboard = new Storyboard();
|
||||||
storyboard.Children.Add(fadeInAnimation);
|
storyboard.Children.Add(fadeInAnimation);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue