mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
// XAML Map Control - http://xamlmapcontrol.codeplex.com/
|
|
// © 2015 Clemens Fischer
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
using System;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
|
|
namespace MapControl
|
|
{
|
|
public partial class MapImageLayer
|
|
{
|
|
private void ImageUpdated(BitmapSource bitmap)
|
|
{
|
|
if (bitmap != null && !bitmap.IsFrozen && bitmap.IsDownloading)
|
|
{
|
|
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
|
bitmap.DownloadFailed += BitmapDownloadFailed;
|
|
}
|
|
else
|
|
{
|
|
SwapImages();
|
|
}
|
|
}
|
|
|
|
private void BitmapDownloadCompleted(object sender, EventArgs e)
|
|
{
|
|
var bitmap = (BitmapSource)sender;
|
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
|
|
|
SwapImages();
|
|
}
|
|
|
|
private void BitmapDownloadFailed(object sender, ExceptionEventArgs e)
|
|
{
|
|
var bitmap = (BitmapSource)sender;
|
|
bitmap.DownloadCompleted -= BitmapDownloadCompleted;
|
|
bitmap.DownloadFailed -= BitmapDownloadFailed;
|
|
|
|
var mapImage = (MapImage)Children[currentImageIndex];
|
|
mapImage.Source = null;
|
|
|
|
SwapImages();
|
|
}
|
|
}
|
|
}
|