mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Updated DrawingTile
This commit is contained in:
parent
21d7938d33
commit
f382c59d19
|
|
@ -1,6 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
@ -9,26 +8,15 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
public class DrawingTile : Tile
|
public class DrawingTile : Tile
|
||||||
{
|
{
|
||||||
private readonly ImageDrawing imageDrawing = new ImageDrawing();
|
|
||||||
|
|
||||||
public DrawingTile(int zoomLevel, int x, int y, int columnCount)
|
public DrawingTile(int zoomLevel, int x, int y, int columnCount)
|
||||||
: base(zoomLevel, x, y, columnCount)
|
: base(zoomLevel, x, y, columnCount)
|
||||||
{
|
{
|
||||||
Drawing.Children.Add(imageDrawing);
|
Drawing.Children.Add(ImageDrawing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DrawingGroup Drawing { get; } = new DrawingGroup();
|
public DrawingGroup Drawing { get; } = new DrawingGroup();
|
||||||
|
|
||||||
public ImageSource ImageSource
|
public ImageDrawing ImageDrawing { get; } = new ImageDrawing();
|
||||||
{
|
|
||||||
get => imageDrawing.ImageSource;
|
|
||||||
set => imageDrawing.ImageSource = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetRect(int xMin, int yMin, int tileWidth, int tileHeight)
|
|
||||||
{
|
|
||||||
imageDrawing.Rect = new Rect(tileWidth * (X - xMin), tileHeight * (Y - yMin), tileWidth, tileHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override async Task LoadImageAsync(Func<Task<ImageSource>> loadImageFunc)
|
public override async Task LoadImageAsync(Func<Task<ImageSource>> loadImageFunc)
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +24,7 @@ namespace MapControl
|
||||||
|
|
||||||
void SetImageSource()
|
void SetImageSource()
|
||||||
{
|
{
|
||||||
imageDrawing.ImageSource = image;
|
ImageDrawing.ImageSource = image;
|
||||||
|
|
||||||
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
|
|
@ -84,7 +72,7 @@ namespace MapControl
|
||||||
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
||||||
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
||||||
|
|
||||||
imageDrawing.ImageSource = null;
|
ImageDrawing.ImageSource = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,16 +88,20 @@ namespace MapControl
|
||||||
{
|
{
|
||||||
tile = new DrawingTile(TileMatrix.ZoomLevel, x, y, WmtsTileMatrix.MatrixWidth);
|
tile = new DrawingTile(TileMatrix.ZoomLevel, x, y, WmtsTileMatrix.MatrixWidth);
|
||||||
|
|
||||||
var equivalentTile = Tiles.FirstOrDefault(t => t.ImageSource != null && t.Column == tile.Column && t.Row == tile.Row);
|
var equivalentTile = Tiles.FirstOrDefault(t => t.ImageDrawing.ImageSource != null && t.Column == tile.Column && t.Row == tile.Row);
|
||||||
|
|
||||||
if (equivalentTile != null)
|
if (equivalentTile != null)
|
||||||
{
|
{
|
||||||
tile.IsPending = false;
|
tile.IsPending = false;
|
||||||
tile.ImageSource = equivalentTile.ImageSource; // no Opacity animation
|
tile.ImageDrawing.ImageSource = equivalentTile.ImageDrawing.ImageSource; // no Opacity animation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tile.SetRect(TileMatrix.XMin, TileMatrix.YMin, WmtsTileMatrix.TileWidth, WmtsTileMatrix.TileHeight);
|
tile.ImageDrawing.Rect = new Rect(
|
||||||
|
WmtsTileMatrix.TileWidth * (x - TileMatrix.XMin),
|
||||||
|
WmtsTileMatrix.TileHeight * (y - TileMatrix.YMin),
|
||||||
|
WmtsTileMatrix.TileWidth,
|
||||||
|
WmtsTileMatrix.TileHeight);
|
||||||
|
|
||||||
tiles.Add(tile);
|
tiles.Add(tile);
|
||||||
drawings.Add(tile.Drawing);
|
drawings.Add(tile.Drawing);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue