2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2024-02-03 21:01:53 +01:00
|
|
|
|
// Copyright © 2024 Clemens Fischer
|
2012-05-04 12:52:20 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
2022-11-19 18:00:26 +01:00
|
|
|
|
using System;
|
2021-06-14 21:41:37 +02:00
|
|
|
|
#if WINUI
|
|
|
|
|
|
using Microsoft.UI.Xaml;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Controls;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media;
|
|
|
|
|
|
using Microsoft.UI.Xaml.Media.Animation;
|
2021-11-17 23:17:11 +01:00
|
|
|
|
#elif UWP
|
2018-08-15 23:29:03 +02:00
|
|
|
|
using Windows.UI.Xaml;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using Windows.UI.Xaml.Controls;
|
2018-12-02 20:22:59 +01:00
|
|
|
|
using Windows.UI.Xaml.Media;
|
2018-08-15 23:29:03 +02:00
|
|
|
|
using Windows.UI.Xaml.Media.Animation;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
#else
|
2018-08-15 23:29:03 +02:00
|
|
|
|
using System.Windows;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
using System.Windows.Controls;
|
2018-12-02 20:22:59 +01:00
|
|
|
|
using System.Windows.Media;
|
2018-08-15 23:29:03 +02:00
|
|
|
|
using System.Windows.Media.Animation;
|
2014-07-01 18:57:44 +02:00
|
|
|
|
#endif
|
2012-04-25 22:02:53 +02:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2013-01-03 15:33:46 +01:00
|
|
|
|
public partial class Tile
|
2012-04-25 22:02:53 +02:00
|
|
|
|
{
|
2022-11-22 19:15:34 +01:00
|
|
|
|
public Tile(int zoomLevel, int x, int y, int columnCount)
|
2012-04-25 22:02:53 +02:00
|
|
|
|
{
|
|
|
|
|
|
ZoomLevel = zoomLevel;
|
|
|
|
|
|
X = x;
|
|
|
|
|
|
Y = y;
|
2022-11-22 19:15:34 +01:00
|
|
|
|
Column = ((x % columnCount) + columnCount) % columnCount;
|
2012-04-25 22:02:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-29 21:46:41 +01:00
|
|
|
|
public int ZoomLevel { get; }
|
|
|
|
|
|
public int X { get; }
|
|
|
|
|
|
public int Y { get; }
|
2022-11-22 19:15:34 +01:00
|
|
|
|
public int Column { get; }
|
|
|
|
|
|
public int Row => Y;
|
2018-08-15 23:29:03 +02:00
|
|
|
|
|
2022-11-12 11:08:10 +01:00
|
|
|
|
public Image Image { get; } = new Image
|
|
|
|
|
|
{
|
|
|
|
|
|
Stretch = Stretch.Fill,
|
|
|
|
|
|
IsHitTestVisible = false // avoid touch capture issues
|
|
|
|
|
|
};
|
2020-10-29 21:46:41 +01:00
|
|
|
|
|
2023-08-12 17:36:37 +02:00
|
|
|
|
public bool IsPending { get; set; } = true;
|
2020-10-29 21:46:41 +01:00
|
|
|
|
|
2023-08-21 20:48:51 +02:00
|
|
|
|
public void SetImageSource(ImageSource image)
|
2022-11-17 23:11:40 +01:00
|
|
|
|
{
|
2023-08-12 17:36:37 +02:00
|
|
|
|
IsPending = false;
|
2023-08-22 18:16:24 +02:00
|
|
|
|
Image.Source = image;
|
2022-11-19 18:00:26 +01:00
|
|
|
|
|
2023-08-21 20:48:51 +02:00
|
|
|
|
if (image != null && MapBase.ImageFadeDuration > TimeSpan.Zero)
|
2022-11-19 18:00:26 +01:00
|
|
|
|
{
|
2023-08-22 18:16:24 +02:00
|
|
|
|
AnimateImageOpacity();
|
2022-11-19 18:00:26 +01:00
|
|
|
|
}
|
2022-11-17 23:11:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-19 18:00:26 +01:00
|
|
|
|
private void BeginOpacityAnimation()
|
2018-08-15 23:29:03 +02:00
|
|
|
|
{
|
2023-08-22 06:44:21 +02:00
|
|
|
|
Image.BeginAnimation(UIElement.OpacityProperty,
|
|
|
|
|
|
new DoubleAnimation
|
|
|
|
|
|
{
|
|
|
|
|
|
From = 0d,
|
|
|
|
|
|
Duration = MapBase.ImageFadeDuration,
|
|
|
|
|
|
FillBehavior = FillBehavior.Stop
|
|
|
|
|
|
});
|
2018-08-15 23:29:03 +02:00
|
|
|
|
}
|
2012-04-25 22:02:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|