2013-05-07 18:12:25 +02:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2016-02-23 20:07:30 +01:00
|
|
|
|
// © 2016 Clemens Fischer
|
2013-05-07 18:12:25 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Globalization;
|
2017-02-05 18:35:30 +01:00
|
|
|
|
using System.Linq;
|
2015-08-09 20:04:44 +02:00
|
|
|
|
#if NETFX_CORE
|
2014-04-05 14:53:58 +02:00
|
|
|
|
using Windows.Foundation;
|
|
|
|
|
|
using Windows.UI.Xaml;
|
2015-01-26 19:45:05 +01:00
|
|
|
|
using Windows.UI.Xaml.Controls;
|
2014-04-05 14:53:58 +02:00
|
|
|
|
using Windows.UI.Xaml.Media.Imaging;
|
|
|
|
|
|
using Windows.UI.Xaml.Media.Animation;
|
|
|
|
|
|
#else
|
2013-05-07 18:12:25 +02:00
|
|
|
|
using System.Windows;
|
2015-01-26 19:45:05 +01:00
|
|
|
|
using System.Windows.Controls;
|
2013-05-07 18:12:25 +02:00
|
|
|
|
using System.Windows.Media.Animation;
|
|
|
|
|
|
using System.Windows.Media.Imaging;
|
2014-10-19 21:50:23 +02:00
|
|
|
|
using System.Windows.Threading;
|
2014-04-05 14:53:58 +02:00
|
|
|
|
#endif
|
2013-05-07 18:12:25 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2017-02-05 18:35:30 +01:00
|
|
|
|
/// Map image overlay. Fills the entire viewport with a map image provided by a web service,
|
2014-10-19 21:50:23 +02:00
|
|
|
|
/// e.g. a Web Map Service (WMS). The image request Uri is specified by the UriFormat property.
|
2013-05-07 18:12:25 +02:00
|
|
|
|
/// </summary>
|
2014-04-05 14:53:58 +02:00
|
|
|
|
public partial class MapImageLayer : MapPanel
|
2013-05-07 18:12:25 +02:00
|
|
|
|
{
|
2016-02-23 20:07:30 +01:00
|
|
|
|
public struct BoundingBox
|
|
|
|
|
|
{
|
|
|
|
|
|
public readonly double West;
|
|
|
|
|
|
public readonly double East;
|
|
|
|
|
|
public readonly double South;
|
|
|
|
|
|
public readonly double North;
|
|
|
|
|
|
|
|
|
|
|
|
public BoundingBox(double west, double east, double south, double north)
|
|
|
|
|
|
{
|
|
|
|
|
|
West = west;
|
|
|
|
|
|
East = east;
|
|
|
|
|
|
South = south;
|
|
|
|
|
|
North = north;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-04-05 14:53:58 +02:00
|
|
|
|
public static readonly DependencyProperty UriFormatProperty = DependencyProperty.Register(
|
|
|
|
|
|
"UriFormat", typeof(string), typeof(MapImageLayer),
|
|
|
|
|
|
new PropertyMetadata(null, (o, e) => ((MapImageLayer)o).UpdateImage()));
|
|
|
|
|
|
|
2016-02-23 20:07:30 +01:00
|
|
|
|
public static readonly DependencyProperty MinLongitudeProperty = DependencyProperty.Register(
|
|
|
|
|
|
"MinLongitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty MaxLongitudeProperty = DependencyProperty.Register(
|
|
|
|
|
|
"MaxLongitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty MinLatitudeProperty = DependencyProperty.Register(
|
|
|
|
|
|
"MinLatitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN));
|
|
|
|
|
|
|
|
|
|
|
|
public static readonly DependencyProperty MaxLatitudeProperty = DependencyProperty.Register(
|
|
|
|
|
|
"MaxLatitude", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN));
|
|
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
public static readonly DependencyProperty MaxBoundingBoxWidthProperty = DependencyProperty.Register(
|
|
|
|
|
|
"MaxBoundingBoxWidth", typeof(double), typeof(MapImageLayer), new PropertyMetadata(double.NaN));
|
|
|
|
|
|
|
2013-12-05 17:56:04 +01:00
|
|
|
|
public static readonly DependencyProperty RelativeImageSizeProperty = DependencyProperty.Register(
|
2013-05-15 15:58:07 +02:00
|
|
|
|
"RelativeImageSize", typeof(double), typeof(MapImageLayer), new PropertyMetadata(1d));
|
|
|
|
|
|
|
2015-08-09 20:04:44 +02:00
|
|
|
|
public static readonly DependencyProperty UpdateIntervalProperty = DependencyProperty.Register(
|
|
|
|
|
|
"UpdateInterval", typeof(TimeSpan), typeof(MapImageLayer),
|
|
|
|
|
|
new PropertyMetadata(TimeSpan.FromSeconds(0.5), (o, e) => ((MapImageLayer)o).updateTimer.Interval = (TimeSpan)e.NewValue));
|
|
|
|
|
|
|
2014-10-19 21:50:23 +02:00
|
|
|
|
private readonly DispatcherTimer updateTimer;
|
2013-05-07 18:12:25 +02:00
|
|
|
|
private int currentImageIndex;
|
2013-12-05 17:56:04 +01:00
|
|
|
|
private bool updateInProgress;
|
2013-05-07 18:12:25 +02:00
|
|
|
|
|
|
|
|
|
|
public MapImageLayer()
|
|
|
|
|
|
{
|
|
|
|
|
|
Children.Add(new MapImage { Opacity = 0d });
|
|
|
|
|
|
Children.Add(new MapImage { Opacity = 0d });
|
|
|
|
|
|
|
2015-08-09 20:04:44 +02:00
|
|
|
|
updateTimer = new DispatcherTimer { Interval = UpdateInterval };
|
2014-06-11 23:03:13 +02:00
|
|
|
|
updateTimer.Tick += (s, e) => UpdateImage();
|
2014-04-05 14:53:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2014-10-19 21:50:23 +02:00
|
|
|
|
/// The format string of the image request Uri. The format must contain
|
|
|
|
|
|
/// {X} and {Y} format specifiers for the map width and height in pixels and either
|
2016-02-23 20:07:30 +01:00
|
|
|
|
/// {w},{s},{e},{n} for a latitude/longitude bounding box (like EPSG:4326) or
|
|
|
|
|
|
/// {W},{S},{E},{N} for a projected bounding box (e.g. in meters like EPSG:3857).
|
2014-04-05 14:53:58 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string UriFormat
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (string)GetValue(UriFormatProperty); }
|
|
|
|
|
|
set { SetValue(UriFormatProperty, value); }
|
2013-05-07 18:12:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2016-02-23 20:07:30 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Optional minimum longitude value. Default is NaN.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MinLongitude
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(MinLongitudeProperty); }
|
|
|
|
|
|
set { SetValue(MinLongitudeProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Optional maximum longitude value. Default is NaN.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MaxLongitude
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(MaxLongitudeProperty); }
|
|
|
|
|
|
set { SetValue(MaxLongitudeProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Optional minimum latitude value. Default is NaN.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MinLatitude
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(MinLatitudeProperty); }
|
|
|
|
|
|
set { SetValue(MinLatitudeProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Optional maximum latitude value. Default is NaN.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MaxLatitude
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(MaxLatitudeProperty); }
|
|
|
|
|
|
set { SetValue(MaxLatitudeProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-15 16:28:57 +02:00
|
|
|
|
/// <summary>
|
2017-02-05 18:35:30 +01:00
|
|
|
|
/// Optional maximum width of the map image's bounding box. Default is NaN.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public double MaxBoundingBoxWidth
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(MaxBoundingBoxWidthProperty); }
|
|
|
|
|
|
set { SetValue(MaxBoundingBoxWidthProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Relative size of the map image in relation to the current viewport size.
|
2013-05-15 16:28:57 +02:00
|
|
|
|
/// Setting a value greater than one will let MapImageLayer request images that
|
2014-11-19 21:11:14 +01:00
|
|
|
|
/// are larger than the viewport, in order to support smooth panning.
|
2013-05-15 16:28:57 +02:00
|
|
|
|
/// </summary>
|
2013-05-15 15:58:07 +02:00
|
|
|
|
public double RelativeImageSize
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (double)GetValue(RelativeImageSizeProperty); }
|
|
|
|
|
|
set { SetValue(RelativeImageSizeProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-08-09 20:04:44 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Minimum time interval between images updates.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public TimeSpan UpdateInterval
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return (TimeSpan)GetValue(UpdateIntervalProperty); }
|
|
|
|
|
|
set { SetValue(UpdateIntervalProperty, value); }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
protected BoundingBox ImageBoundingBox { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual BoundingBox ProjectedBoundingBox
|
2016-02-23 20:07:30 +01:00
|
|
|
|
{
|
2017-02-05 18:35:30 +01:00
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
var p1 = ParentMap.MapTransform.Transform(new Location(ImageBoundingBox.South, ImageBoundingBox.West));
|
|
|
|
|
|
var p2 = ParentMap.MapTransform.Transform(new Location(ImageBoundingBox.North, ImageBoundingBox.East));
|
2016-02-23 20:07:30 +01:00
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
return new BoundingBox(
|
|
|
|
|
|
TileSource.MetersPerDegree * p1.X, TileSource.MetersPerDegree * p2.X,
|
|
|
|
|
|
TileSource.MetersPerDegree * p1.Y, TileSource.MetersPerDegree * p2.Y);
|
|
|
|
|
|
}
|
2016-02-23 20:07:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
protected override void OnViewportChanged(ViewportChangedEventArgs e)
|
2013-05-07 18:12:25 +02:00
|
|
|
|
{
|
2017-02-05 18:35:30 +01:00
|
|
|
|
base.OnViewportChanged(e);
|
|
|
|
|
|
|
|
|
|
|
|
if (Math.Abs(e.OriginOffset) > 180d)
|
|
|
|
|
|
{
|
|
|
|
|
|
var offset = 360d * Math.Sign(e.OriginOffset);
|
|
|
|
|
|
|
|
|
|
|
|
ImageBoundingBox = new BoundingBox(ImageBoundingBox.West + offset, ImageBoundingBox.East + offset, ImageBoundingBox.South, ImageBoundingBox.North);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var mapImage in Children.OfType<MapImage>().Where(i => i.BoundingBoxValid))
|
|
|
|
|
|
{
|
|
|
|
|
|
mapImage.SetBoundingBox(mapImage.West + offset, mapImage.East + offset, mapImage.South, mapImage.North);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-05-07 18:12:25 +02:00
|
|
|
|
|
|
|
|
|
|
updateTimer.Stop();
|
|
|
|
|
|
updateTimer.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-10-19 21:50:23 +02:00
|
|
|
|
protected void UpdateImage()
|
2013-05-13 23:49:48 +02:00
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
updateTimer.Stop();
|
|
|
|
|
|
|
|
|
|
|
|
if (updateInProgress)
|
|
|
|
|
|
{
|
|
|
|
|
|
updateTimer.Start(); // update image on next timer tick
|
|
|
|
|
|
}
|
2016-02-23 20:07:30 +01:00
|
|
|
|
else if (ParentMap != null && ParentMap.RenderSize.Width > 0 && ParentMap.RenderSize.Height > 0)
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
|
|
|
|
|
updateInProgress = true;
|
2013-05-13 23:49:48 +02:00
|
|
|
|
|
2014-10-19 21:50:23 +02:00
|
|
|
|
var relativeSize = Math.Max(RelativeImageSize, 1d);
|
2016-02-23 20:07:30 +01:00
|
|
|
|
var width = ParentMap.RenderSize.Width * relativeSize;
|
|
|
|
|
|
var height = ParentMap.RenderSize.Height * relativeSize;
|
|
|
|
|
|
var dx = (ParentMap.RenderSize.Width - width) / 2d;
|
|
|
|
|
|
var dy = (ParentMap.RenderSize.Height - height) / 2d;
|
2014-10-19 21:50:23 +02:00
|
|
|
|
|
|
|
|
|
|
var loc1 = ParentMap.ViewportPointToLocation(new Point(dx, dy));
|
|
|
|
|
|
var loc2 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy));
|
|
|
|
|
|
var loc3 = ParentMap.ViewportPointToLocation(new Point(dx, dy + height));
|
|
|
|
|
|
var loc4 = ParentMap.ViewportPointToLocation(new Point(dx + width, dy + height));
|
|
|
|
|
|
|
|
|
|
|
|
var west = Math.Min(loc1.Longitude, Math.Min(loc2.Longitude, Math.Min(loc3.Longitude, loc4.Longitude)));
|
|
|
|
|
|
var east = Math.Max(loc1.Longitude, Math.Max(loc2.Longitude, Math.Max(loc3.Longitude, loc4.Longitude)));
|
|
|
|
|
|
var south = Math.Min(loc1.Latitude, Math.Min(loc2.Latitude, Math.Min(loc3.Latitude, loc4.Latitude)));
|
|
|
|
|
|
var north = Math.Max(loc1.Latitude, Math.Max(loc2.Latitude, Math.Max(loc3.Latitude, loc4.Latitude)));
|
|
|
|
|
|
|
2016-02-23 20:07:30 +01:00
|
|
|
|
if (!double.IsNaN(MinLongitude) && west < MinLongitude)
|
|
|
|
|
|
{
|
|
|
|
|
|
west = MinLongitude;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!double.IsNaN(MaxLongitude) && east > MaxLongitude)
|
|
|
|
|
|
{
|
|
|
|
|
|
east = MaxLongitude;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!double.IsNaN(MinLatitude) && south < MinLatitude)
|
|
|
|
|
|
{
|
|
|
|
|
|
south = MinLatitude;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!double.IsNaN(MaxLatitude) && north > MaxLatitude)
|
|
|
|
|
|
{
|
|
|
|
|
|
north = MaxLatitude;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
if (!double.IsNaN(MaxBoundingBoxWidth) && east - west > MaxBoundingBoxWidth)
|
|
|
|
|
|
{
|
|
|
|
|
|
var d = (east - west - MaxBoundingBoxWidth) / 2d;
|
|
|
|
|
|
west += d;
|
|
|
|
|
|
east -= d;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ImageBoundingBox = new BoundingBox(west, east, south, north);
|
|
|
|
|
|
|
2014-10-19 21:50:23 +02:00
|
|
|
|
var p1 = ParentMap.MapTransform.Transform(new Location(south, west));
|
|
|
|
|
|
var p2 = ParentMap.MapTransform.Transform(new Location(north, east));
|
|
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
UpdateImage((int)Math.Round((p2.X - p1.X) * ParentMap.ViewportScale),
|
|
|
|
|
|
(int)Math.Round((p2.Y - p1.Y) * ParentMap.ViewportScale));
|
2014-10-19 21:50:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
protected virtual void UpdateImage(int width, int height)
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
2014-04-05 14:53:58 +02:00
|
|
|
|
if (UriFormat != null && width > 0 && height > 0)
|
2013-05-13 23:49:48 +02:00
|
|
|
|
{
|
2015-08-09 20:04:44 +02:00
|
|
|
|
var uri = UriFormat
|
|
|
|
|
|
.Replace("{X}", width.ToString())
|
|
|
|
|
|
.Replace("{Y}", height.ToString());
|
2013-05-13 23:49:48 +02:00
|
|
|
|
|
2016-02-23 20:07:30 +01:00
|
|
|
|
if (uri.Contains("{W}") && uri.Contains("{E}") && uri.Contains("{S}") && uri.Contains("{N}"))
|
2013-05-15 15:58:07 +02:00
|
|
|
|
{
|
2017-02-05 18:35:30 +01:00
|
|
|
|
var projectedBoundingBox = ProjectedBoundingBox;
|
2013-05-15 15:58:07 +02:00
|
|
|
|
|
2015-08-09 20:04:44 +02:00
|
|
|
|
uri = uri
|
2016-02-23 20:07:30 +01:00
|
|
|
|
.Replace("{W}", projectedBoundingBox.West.ToString(CultureInfo.InvariantCulture))
|
|
|
|
|
|
.Replace("{S}", projectedBoundingBox.South.ToString(CultureInfo.InvariantCulture))
|
|
|
|
|
|
.Replace("{E}", projectedBoundingBox.East.ToString(CultureInfo.InvariantCulture))
|
|
|
|
|
|
.Replace("{N}", projectedBoundingBox.North.ToString(CultureInfo.InvariantCulture));
|
2013-05-15 15:58:07 +02:00
|
|
|
|
}
|
2013-06-07 15:09:59 +02:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2015-08-09 20:04:44 +02:00
|
|
|
|
uri = uri
|
2017-02-05 18:35:30 +01:00
|
|
|
|
.Replace("{w}", ImageBoundingBox.West.ToString(CultureInfo.InvariantCulture))
|
|
|
|
|
|
.Replace("{s}", ImageBoundingBox.South.ToString(CultureInfo.InvariantCulture))
|
|
|
|
|
|
.Replace("{e}", ImageBoundingBox.East.ToString(CultureInfo.InvariantCulture))
|
|
|
|
|
|
.Replace("{n}", ImageBoundingBox.North.ToString(CultureInfo.InvariantCulture));
|
2013-06-07 15:09:59 +02:00
|
|
|
|
}
|
2013-05-13 23:49:48 +02:00
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
UpdateImage(new Uri(uri));
|
2013-06-19 18:57:54 +02:00
|
|
|
|
}
|
2014-04-05 14:53:58 +02:00
|
|
|
|
else
|
2013-05-07 18:12:25 +02:00
|
|
|
|
{
|
2017-02-05 18:35:30 +01:00
|
|
|
|
UpdateImage((BitmapSource)null);
|
2013-05-15 15:58:07 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2013-05-07 18:12:25 +02:00
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
private void SetTopImage(BitmapSource bitmap)
|
2013-05-15 15:58:07 +02:00
|
|
|
|
{
|
2014-04-05 14:53:58 +02:00
|
|
|
|
currentImageIndex = (currentImageIndex + 1) % 2;
|
2016-02-23 20:07:30 +01:00
|
|
|
|
var topImage = (MapImage)Children[currentImageIndex];
|
2014-04-05 14:53:58 +02:00
|
|
|
|
|
2017-02-05 18:35:30 +01:00
|
|
|
|
topImage.SetBoundingBox(ImageBoundingBox.West, ImageBoundingBox.East, ImageBoundingBox.South, ImageBoundingBox.North);
|
2016-02-23 20:07:30 +01:00
|
|
|
|
topImage.Source = bitmap;
|
2014-04-05 14:53:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-01-26 19:45:05 +01:00
|
|
|
|
private void SwapImages()
|
2014-04-05 14:53:58 +02:00
|
|
|
|
{
|
2014-10-19 21:50:23 +02:00
|
|
|
|
var topImage = (MapImage)Children[currentImageIndex];
|
|
|
|
|
|
var bottomImage = (MapImage)Children[(currentImageIndex + 1) % 2];
|
2014-04-05 14:53:58 +02:00
|
|
|
|
|
2015-01-26 19:45:05 +01:00
|
|
|
|
Canvas.SetZIndex(topImage, 1);
|
|
|
|
|
|
Canvas.SetZIndex(bottomImage, 0);
|
2014-04-05 14:53:58 +02:00
|
|
|
|
|
2015-01-26 19:45:05 +01:00
|
|
|
|
if (topImage.Source != null)
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
2015-01-26 19:45:05 +01:00
|
|
|
|
var fadeAnimation = new DoubleAnimation
|
2014-10-19 21:50:23 +02:00
|
|
|
|
{
|
2015-01-26 19:45:05 +01:00
|
|
|
|
From = 0d,
|
|
|
|
|
|
To = 1d,
|
2015-11-11 19:48:50 +01:00
|
|
|
|
Duration = Tile.FadeDuration,
|
2015-01-26 19:45:05 +01:00
|
|
|
|
FillBehavior = FillBehavior.Stop
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2016-02-23 20:07:30 +01:00
|
|
|
|
fadeAnimation.Completed += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
bottomImage.Opacity = 0d;
|
|
|
|
|
|
bottomImage.Source = null;
|
|
|
|
|
|
};
|
2014-10-19 21:50:23 +02:00
|
|
|
|
|
2015-01-26 19:45:05 +01:00
|
|
|
|
topImage.BeginAnimation(UIElement.OpacityProperty, fadeAnimation);
|
|
|
|
|
|
topImage.Opacity = 1d;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
topImage.Opacity = 0d;
|
|
|
|
|
|
bottomImage.Opacity = 0d;
|
2016-02-23 20:07:30 +01:00
|
|
|
|
bottomImage.Source = null;
|
2014-10-19 21:50:23 +02:00
|
|
|
|
}
|
2014-04-05 14:53:58 +02:00
|
|
|
|
|
|
|
|
|
|
updateInProgress = false;
|
2013-05-07 18:12:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|