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

37 lines
1.1 KiB
C#
Raw Normal View History

2023-01-03 15:12:53 +01:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2024-02-03 21:01:53 +01:00
// Copyright © 2024 Clemens Fischer
2022-11-22 19:15:34 +01:00
// Licensed under the Microsoft Public License (Ms-PL)
using System.Collections.Generic;
using System.Linq;
namespace MapControl
{
public class TileCollection : List<Tile>
{
/// <summary>
/// Get a matching Tile from a TileCollection or create a new one.
/// </summary>
public Tile GetTile(int zoomLevel, int x, int y, int columnCount)
{
var tile = this.FirstOrDefault(t => t.ZoomLevel == zoomLevel && t.X == x && t.Y == y);
if (tile == null)
{
tile = new Tile(zoomLevel, x, y, columnCount);
var equivalentTile = this.FirstOrDefault(
2023-08-12 17:36:37 +02:00
t => t.Image.Source != null && t.ZoomLevel == tile.ZoomLevel && t.Column == tile.Column && t.Row == tile.Row);
2022-11-22 19:15:34 +01:00
if (equivalentTile != null)
{
2023-08-21 20:48:51 +02:00
tile.IsPending = false;
tile.Image.Source = equivalentTile.Image.Source; // no opacity animation
2022-11-22 19:15:34 +01:00
}
}
return tile;
}
}
}