XAML-Map-Control/MapControl/Shared/Tile.cs

52 lines
1.3 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2018 Clemens Fischer
2012-05-04 12:52:20 +02:00
// Licensed under the Microsoft Public License (Ms-PL)
using System;
2017-08-04 21:38:58 +02:00
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media.Animation;
#else
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Animation;
#endif
2012-04-25 22:02:53 +02:00
namespace MapControl
{
public partial class Tile
2012-04-25 22:02:53 +02:00
{
2017-10-07 17:55:03 +02:00
public static TimeSpan FadeDuration { get; set; } = TimeSpan.FromSeconds(0.15);
2012-04-25 22:02:53 +02:00
public readonly int ZoomLevel;
public readonly int X;
public readonly int Y;
public readonly Image Image = new Image { Opacity = 0d };
2012-04-25 22:02:53 +02:00
2012-06-18 20:12:35 +02:00
public Tile(int zoomLevel, int x, int y)
2012-04-25 22:02:53 +02:00
{
ZoomLevel = zoomLevel;
X = x;
Y = y;
}
2017-07-17 21:31:09 +02:00
public bool Pending { get; set; } = true;
2012-04-25 22:02:53 +02:00
public int XIndex
{
get
{
var numTiles = 1 << ZoomLevel;
2012-04-25 22:02:53 +02:00
return ((X % numTiles) + numTiles) % numTiles;
}
}
private void FadeIn()
{
Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation { From = 0d, To = 1d, Duration = FadeDuration, FillBehavior = FillBehavior.Stop });
Image.Opacity = 1d;
}
2012-04-25 22:02:53 +02:00
}
}