2012-11-22 21:42:29 +01:00
|
|
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
2014-01-10 20:11:39 +01:00
|
|
|
|
// Copyright © 2014 Clemens Fischer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class TileLayer : DrawingVisual
|
|
|
|
|
|
{
|
|
|
|
|
|
partial void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
VisualTransform = transform;
|
|
|
|
|
|
VisualEdgeMode = EdgeMode.Aliased;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-05-08 17:05:17 +02:00
|
|
|
|
public Brush Background { get; set; }
|
|
|
|
|
|
|
2014-06-11 23:03:13 +02:00
|
|
|
|
private ContainerVisual TileContainer
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
get { return Parent as ContainerVisual; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-06-11 23:03:13 +02:00
|
|
|
|
private void RenderTiles()
|
2012-11-22 21:42:29 +01:00
|
|
|
|
{
|
|
|
|
|
|
using (var drawingContext = RenderOpen())
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (var tile in tiles)
|
|
|
|
|
|
{
|
2013-05-07 18:12:25 +02:00
|
|
|
|
var tileSize = TileSource.TileSize << (zoomLevel - tile.ZoomLevel);
|
|
|
|
|
|
var tileRect = new Rect(
|
|
|
|
|
|
tileSize * tile.X - TileSource.TileSize * grid.X,
|
|
|
|
|
|
tileSize * tile.Y - TileSource.TileSize * grid.Y,
|
|
|
|
|
|
tileSize, tileSize);
|
2012-11-22 21:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
drawingContext.DrawRectangle(tile.Brush, null, tileRect);
|
|
|
|
|
|
|
|
|
|
|
|
//if (tile.ZoomLevel == zoomLevel)
|
|
|
|
|
|
// drawingContext.DrawText(new FormattedText(string.Format("{0}-{1}-{2}", tile.ZoomLevel, tile.X, tile.Y),
|
|
|
|
|
|
// System.Globalization.CultureInfo.InvariantCulture, FlowDirection.LeftToRight, new Typeface("Segoe UI"), 14, Brushes.Black), tileRect.TopLeft);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|