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

59 lines
1.4 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2021-01-13 21:19:27 +01:00
// © 2021 Clemens Fischer
2012-05-04 12:52:20 +02:00
// Licensed under the Microsoft Public License (Ms-PL)
2017-08-04 21:38:58 +02:00
#if WINDOWS_UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
2018-12-02 20:22:59 +01:00
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Animation;
#else
using System.Windows;
using System.Windows.Controls;
2018-12-02 20:22:59 +01:00
using System.Windows.Media;
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
{
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;
}
2020-10-29 21:46:41 +01:00
public int ZoomLevel { get; }
public int X { get; }
public int Y { get; }
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;
}
}
2020-10-29 21:46:41 +01:00
public Image Image { get; } = new Image { Opacity = 0d, Stretch = Stretch.Fill };
public bool Pending { get; set; } = true;
private void FadeIn()
{
Image.BeginAnimation(UIElement.OpacityProperty, new DoubleAnimation
{
From = 0d,
To = 1d,
2020-04-22 16:16:17 +02:00
Duration = MapBase.ImageFadeDuration,
FillBehavior = FillBehavior.Stop
});
Image.Opacity = 1d;
}
2012-04-25 22:02:53 +02:00
}
}