mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
|
|
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
|||
|
|
// Copyright © 2014 Clemens Fischer
|
|||
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|||
|
|
|
|||
|
|
#if NETFX_CORE
|
|||
|
|
using Windows.UI.Xaml;
|
|||
|
|
using Windows.UI.Xaml.Media.Imaging;
|
|||
|
|
#else
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Media.Imaging;
|
|||
|
|
using System.Windows.Threading;
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
namespace MapControl
|
|||
|
|
{
|
|||
|
|
public partial class MapImageLayer
|
|||
|
|
{
|
|||
|
|
private readonly DispatcherTimer updateTimer = new DispatcherTimer();
|
|||
|
|
|
|||
|
|
private void AddDownloadEventHandlers(BitmapSource bitmap)
|
|||
|
|
{
|
|||
|
|
var bitmapImage = bitmap as BitmapImage;
|
|||
|
|
|
|||
|
|
if (bitmapImage != null)
|
|||
|
|
{
|
|||
|
|
bitmapImage.ImageOpened += BitmapImageOpened;
|
|||
|
|
bitmapImage.ImageFailed += BitmapImageFailed;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BlendImages();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BitmapImageOpened(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
var bitmap = (BitmapImage)sender;
|
|||
|
|
|
|||
|
|
bitmap.ImageOpened -= BitmapImageOpened;
|
|||
|
|
bitmap.ImageFailed -= BitmapImageFailed;
|
|||
|
|
|
|||
|
|
BlendImages();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BitmapImageFailed(object sender, ExceptionRoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
var bitmap = (BitmapImage)sender;
|
|||
|
|
|
|||
|
|
bitmap.ImageOpened -= BitmapImageOpened;
|
|||
|
|
bitmap.ImageFailed -= BitmapImageFailed;
|
|||
|
|
|
|||
|
|
((MapImage)Children[currentImageIndex]).Source = null;
|
|||
|
|
BlendImages();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|