From d368c9358c07f7ffed40057e059332da2ff44f6d Mon Sep 17 00:00:00 2001 From: ClemensF Date: Sat, 21 Jul 2012 09:09:58 +0200 Subject: [PATCH] Changed ImageTileSource --- MapControl/TileImageLoader.cs | 5 +++-- MapControl/TileSource.cs | 13 +++++++++---- SampleApps/SampleApplication/ImageTileSource.cs | 13 ------------- SampleApps/SampleApplication/MainWindow.xaml | 2 +- .../SampleApplication/SampleApplication.csproj | 1 - 5 files changed, 13 insertions(+), 21 deletions(-) delete mode 100644 SampleApps/SampleApplication/ImageTileSource.cs diff --git a/MapControl/TileImageLoader.cs b/MapControl/TileImageLoader.cs index 6af4a58b..59abec08 100644 --- a/MapControl/TileImageLoader.cs +++ b/MapControl/TileImageLoader.cs @@ -138,10 +138,11 @@ namespace MapControl private void BeginGetTilesAsync(object newTilesList) { List newTiles = (List)newTilesList; - ImageTileSource imageTileSource = tileLayer.TileSource as ImageTileSource; - if (imageTileSource != null) + if (tileLayer.TileSource is ImageTileSource) { + ImageTileSource imageTileSource = (ImageTileSource)tileLayer.TileSource; + newTiles.ForEach(tile => { Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => tile.Image = imageTileSource.GetImage(tile.XIndex, tile.Y, tile.ZoomLevel))); diff --git a/MapControl/TileSource.cs b/MapControl/TileSource.cs index b7d2c2d9..7da01562 100644 --- a/MapControl/TileSource.cs +++ b/MapControl/TileSource.cs @@ -8,6 +8,7 @@ using System.Globalization; using System.Text; using System.Windows; using System.Windows.Media; +using System.Windows.Media.Imaging; namespace MapControl { @@ -156,12 +157,16 @@ namespace MapControl } /// - /// Provides the image of a map tile. ImageTileSource bypasses downloading - /// and caching of tile images that is performed by TileImageLoader. + /// Provides the image of a map tile. ImageTileSource bypasses download and + /// cache processing in TileImageLoader. By overriding the GetImage method, + /// an application can provide tile images from an arbitrary source. /// - public abstract class ImageTileSource : TileSource + public class ImageTileSource : TileSource { - public abstract ImageSource GetImage(int x, int y, int zoomLevel); + public virtual ImageSource GetImage(int x, int y, int zoomLevel) + { + return new BitmapImage(GetUri(x, y, zoomLevel)); + } } /// diff --git a/SampleApps/SampleApplication/ImageTileSource.cs b/SampleApps/SampleApplication/ImageTileSource.cs deleted file mode 100644 index 7815e32e..00000000 --- a/SampleApps/SampleApplication/ImageTileSource.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Windows.Media; -using System.Windows.Media.Imaging; - -namespace SampleApplication -{ - public class ImageTileSource : MapControl.ImageTileSource - { - public override ImageSource GetImage(int x, int y, int zoomLevel) - { - return new BitmapImage(GetUri(x, y, zoomLevel)); - } - } -} diff --git a/SampleApps/SampleApplication/MainWindow.xaml b/SampleApps/SampleApplication/MainWindow.xaml index 781c0f98..6010075d 100644 --- a/SampleApps/SampleApplication/MainWindow.xaml +++ b/SampleApps/SampleApplication/MainWindow.xaml @@ -144,7 +144,7 @@ - + diff --git a/SampleApps/SampleApplication/SampleApplication.csproj b/SampleApps/SampleApplication/SampleApplication.csproj index 1807aac9..f8ae4383 100644 --- a/SampleApps/SampleApplication/SampleApplication.csproj +++ b/SampleApps/SampleApplication/SampleApplication.csproj @@ -54,7 +54,6 @@ MSBuild:Compile Designer - True True