2012-05-04 12:52:20 +02:00
|
|
|
|
// WPF MapControl - http://wpfmapcontrol.codeplex.com/
|
|
|
|
|
|
// Copyright © 2012 Clemens Fischer
|
|
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2012-04-25 22:02:53 +02:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using System.Windows.Media.Animation;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class Tile
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly DoubleAnimation opacityAnimation = new DoubleAnimation(0d, 1d, TimeSpan.FromSeconds(0.5), FillBehavior.Stop);
|
|
|
|
|
|
|
|
|
|
|
|
public readonly int ZoomLevel;
|
|
|
|
|
|
public readonly int X;
|
|
|
|
|
|
public readonly int Y;
|
|
|
|
|
|
public readonly ImageBrush Brush = new ImageBrush();
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2012-06-18 20:12:35 +02:00
|
|
|
|
public Uri Uri { get; set; }
|
2012-04-25 22:02:53 +02:00
|
|
|
|
|
|
|
|
|
|
public int XIndex
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
int numTiles = 1 << ZoomLevel;
|
|
|
|
|
|
return ((X % numTiles) + numTiles) % numTiles;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ImageSource Image
|
|
|
|
|
|
{
|
|
|
|
|
|
get { return Brush.ImageSource; }
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Brush.ImageSource == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Brush.BeginAnimation(ImageBrush.OpacityProperty, opacityAnimation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Brush.ImageSource = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format("{0}.{1}.{2}", ZoomLevel, X, Y);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|