diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs index f08e7e4a..f65192fc 100644 --- a/Caching/FileDbCache/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs index 8b70492c..672be51b 100644 --- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index ce422578..adbef922 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -16,6 +16,6 @@ using System.Windows; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/MapControl/Tile.Silverlight.WinRT.cs b/MapControl/Tile.Silverlight.WinRT.cs index 82c5ad14..6bd8d4ec 100644 --- a/MapControl/Tile.Silverlight.WinRT.cs +++ b/MapControl/Tile.Silverlight.WinRT.cs @@ -17,28 +17,27 @@ using System.Windows.Media.Imaging; namespace MapControl { - internal partial class Tile + public partial class Tile { public readonly Image Image = new Image { Stretch = Stretch.Uniform, Opacity = 0d }; public ImageSource ImageSource { get { return Image.Source; } - private set { Image.Source = value; } } - public void SetImageSource(ImageSource source, bool animateOpacity) + public void SetImageSource(ImageSource image, bool animateOpacity) { - if (ImageSource == null) + if (Image.Source == null) { if (animateOpacity) { - var bitmap = source as BitmapImage; + var bitmapImage = image as BitmapImage; - if (bitmap != null) // TODO Check if bitmap is downloading somehow, maybe PixelWidth == 0? + if (bitmapImage != null) { - bitmap.ImageOpened += BitmapImageOpened; - bitmap.ImageFailed += BitmapImageFailed; + bitmapImage.ImageOpened += BitmapImageOpened; + bitmapImage.ImageFailed += BitmapImageFailed; } else { @@ -51,7 +50,7 @@ namespace MapControl } } - ImageSource = source; + Image.Source = image; } private void BitmapImageOpened(object sender, RoutedEventArgs e) @@ -65,7 +64,7 @@ namespace MapControl { ((BitmapImage)sender).ImageOpened -= BitmapImageOpened; ((BitmapImage)sender).ImageFailed -= BitmapImageFailed; - ImageSource = null; + Image.Source = null; } } } diff --git a/MapControl/Tile.WPF.cs b/MapControl/Tile.WPF.cs index 95803f34..757d2da3 100644 --- a/MapControl/Tile.WPF.cs +++ b/MapControl/Tile.WPF.cs @@ -5,31 +5,31 @@ using System; using System.Windows.Media; using System.Windows.Media.Imaging; +using System.Windows.Threading; namespace MapControl { - internal partial class Tile + public partial class Tile { public readonly ImageBrush Brush = new ImageBrush { Opacity = 0d }; public ImageSource ImageSource { get { return Brush.ImageSource; } - private set { Brush.ImageSource = value; } } - public void SetImageSource(ImageSource source, bool animateOpacity) + public void SetImageSource(ImageSource image, bool animateOpacity) { - if (ImageSource == null) + if (Brush.ImageSource == null) { if (animateOpacity) { - var bitmap = source as BitmapImage; + var bitmapImage = image as BitmapImage; - if (bitmap != null && bitmap.IsDownloading) + if (bitmapImage != null && bitmapImage.IsDownloading) { - bitmap.DownloadCompleted += BitmapDownloadCompleted; - bitmap.DownloadFailed += BitmapDownloadFailed; + bitmapImage.DownloadCompleted += BitmapDownloadCompleted; + bitmapImage.DownloadFailed += BitmapDownloadFailed; } else { @@ -42,7 +42,7 @@ namespace MapControl } } - ImageSource = source; + Brush.ImageSource = image; } private void BitmapDownloadCompleted(object sender, EventArgs e) @@ -56,7 +56,7 @@ namespace MapControl { ((BitmapImage)sender).DownloadCompleted -= BitmapDownloadCompleted; ((BitmapImage)sender).DownloadFailed -= BitmapDownloadFailed; - ImageSource = null; + Brush.ImageSource = null; } } } diff --git a/MapControl/Tile.cs b/MapControl/Tile.cs index c78061fd..2e50d7a5 100644 --- a/MapControl/Tile.cs +++ b/MapControl/Tile.cs @@ -11,7 +11,7 @@ using System.Windows.Media.Animation; namespace MapControl { - internal partial class Tile + public partial class Tile { public readonly int ZoomLevel; public readonly int X; @@ -35,7 +35,7 @@ namespace MapControl } } - DoubleAnimation OpacityAnimation + public DoubleAnimation OpacityAnimation { get { diff --git a/MapControl/TileContainer.cs b/MapControl/TileContainer.cs index 7a31aaf4..81dd3084 100644 --- a/MapControl/TileContainer.cs +++ b/MapControl/TileContainer.cs @@ -54,7 +54,7 @@ namespace MapControl } index++; - tileLayer.TransformMatrix = tileLayerTransform; + tileLayer.SetTransformMatrix(tileLayerTransform); tileLayer.UpdateTiles(tileZoomLevel, tileGrid); } } @@ -98,15 +98,15 @@ namespace MapControl ViewportTransform.Matrix = GetTransformMatrix(new Matrix(1d, 0d, 0d, -1d, 180d, 180d), scale); - var tileLayerTransform = GetTileLayerTransformMatrix(); - - foreach (TileLayer tileLayer in Children) - { - tileLayer.TransformMatrix = tileLayerTransform; - } - if (Math.Sign(mapOrigin.X) == Math.Sign(oldMapOriginX)) { + var tileLayerTransform = GetTileLayerTransformMatrix(); + + foreach (TileLayer tileLayer in Children) + { + tileLayer.SetTransformMatrix(tileLayerTransform); + } + updateTimer.Start(); } else @@ -162,7 +162,7 @@ namespace MapControl foreach (TileLayer tileLayer in Children) { - tileLayer.TransformMatrix = tileLayerTransform; + tileLayer.SetTransformMatrix(tileLayerTransform); tileLayer.UpdateTiles(tileZoomLevel, tileGrid); } } diff --git a/MapControl/TileImageLoader.WPF.cs b/MapControl/TileImageLoader.WPF.cs index 1c806d4a..67aee2d9 100644 --- a/MapControl/TileImageLoader.WPF.cs +++ b/MapControl/TileImageLoader.WPF.cs @@ -87,16 +87,31 @@ namespace MapControl var newTiles = (List)newTilesList; var imageTileSource = tileLayer.TileSource as ImageTileSource; - if (imageTileSource == null) + if (imageTileSource != null) { - if (Cache == null || string.IsNullOrWhiteSpace(tileLayer.SourceName)) + if (imageTileSource.CanLoadAsync) { foreach (var tile in newTiles) { - pendingTiles.Enqueue(tile); + tileLayer.Dispatcher.BeginInvoke( + (Action)((t, i) => t.SetImageSource(i, true)), + DispatcherPriority.Background, tile, + imageTileSource.LoadImage(tile.XIndex, tile.Y, tile.ZoomLevel)); } } else + { + foreach (var tile in newTiles) + { + tileLayer.Dispatcher.BeginInvoke( + (Action)((t, i) => t.SetImageSource(i.LoadImage(t.XIndex, t.Y, t.ZoomLevel), true)), + DispatcherPriority.Background, tile, imageTileSource); + } + } + } + else + { + if (Cache != null && !string.IsNullOrWhiteSpace(tileLayer.SourceName)) { var outdatedTiles = new List(newTiles.Count); @@ -127,6 +142,13 @@ namespace MapControl pendingTiles.Enqueue(tile); } } + else + { + foreach (var tile in newTiles) + { + pendingTiles.Enqueue(tile); + } + } while (downloadThreadCount < Math.Min(pendingTiles.Count, tileLayer.MaxParallelDownloads)) { @@ -135,26 +157,6 @@ namespace MapControl ThreadPool.QueueUserWorkItem(DownloadTiles); } } - else if (imageTileSource.CanLoadAsync) - { - foreach (var tile in newTiles) - { - tileLayer.Dispatcher.BeginInvoke( - (Action)((t, s) => t.SetImageSource(s, true)), - DispatcherPriority.Background, - tile, imageTileSource.LoadImage(tile.XIndex, tile.Y, tile.ZoomLevel)); - } - } - else - { - foreach (var tile in newTiles) - { - tileLayer.Dispatcher.BeginInvoke( - (Action)(t => t.SetImageSource(imageTileSource.LoadImage(t.XIndex, t.Y, t.ZoomLevel), true)), - DispatcherPriority.Background, - tile); - } - } } private void DownloadTiles(object o) @@ -181,17 +183,17 @@ namespace MapControl private bool CreateTileImage(Tile tile, byte[] buffer) { - var bitmap = new BitmapImage(); + var image = new BitmapImage(); try { using (var stream = new MemoryStream(buffer, 8, buffer.Length - 8, false)) { - bitmap.BeginInit(); - bitmap.CacheOption = BitmapCacheOption.OnLoad; - bitmap.StreamSource = stream; - bitmap.EndInit(); - bitmap.Freeze(); + image.BeginInit(); + image.CacheOption = BitmapCacheOption.OnLoad; + image.StreamSource = stream; + image.EndInit(); + image.Freeze(); } } catch (Exception ex) @@ -201,9 +203,8 @@ namespace MapControl } tileLayer.Dispatcher.BeginInvoke( - (Action)(t => t.SetImageSource(bitmap, true)), - DispatcherPriority.Background, - tile); + (Action)((t, i) => t.SetImageSource(i, true)), + DispatcherPriority.Background, tile, image); return true; } diff --git a/MapControl/TileLayer.Silverlight.WinRT.cs b/MapControl/TileLayer.Silverlight.WinRT.cs index f92d1f37..17db56a7 100644 --- a/MapControl/TileLayer.Silverlight.WinRT.cs +++ b/MapControl/TileLayer.Silverlight.WinRT.cs @@ -19,12 +19,12 @@ namespace MapControl RenderTransform = transform; } - private Panel TileContainer + protected Panel TileContainer { get { return Parent as Panel; } } - private void RenderTiles() + protected void RenderTiles() { Children.Clear(); foreach (var tile in tiles) diff --git a/MapControl/TileLayer.WPF.cs b/MapControl/TileLayer.WPF.cs index 4245d6aa..6942c660 100644 --- a/MapControl/TileLayer.WPF.cs +++ b/MapControl/TileLayer.WPF.cs @@ -15,12 +15,12 @@ namespace MapControl VisualEdgeMode = EdgeMode.Aliased; } - private ContainerVisual TileContainer + protected ContainerVisual TileContainer { get { return Parent as ContainerVisual; } } - private void RenderTiles() + protected void RenderTiles() { //System.Diagnostics.Trace.TraceInformation("{0} Tiles: {1}", tiles.Count, string.Join(", ", tiles.Select(t => t.ZoomLevel.ToString()))); diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 3cac941e..2f2e9fa4 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -76,13 +76,12 @@ namespace MapControl set { TileSource = new TileSource(value); } } - internal Matrix TransformMatrix + internal void SetTransformMatrix(Matrix transformMatrix) { - get { return transform.Matrix; } - set { transform.Matrix = value; } + transform.Matrix = transformMatrix; } - internal void UpdateTiles(int zoomLevel, Int32Rect grid) + protected internal virtual void UpdateTiles(int zoomLevel, Int32Rect grid) { this.grid = grid; this.zoomLevel = zoomLevel; @@ -97,14 +96,14 @@ namespace MapControl } } - internal void ClearTiles() + protected internal virtual void ClearTiles() { tileImageLoader.CancelGetTiles(); tiles.Clear(); RenderTiles(); } - private void SelectTiles() + protected void SelectTiles() { var maxZoomLevel = Math.Min(zoomLevel, MaxZoomLevel); var minZoomLevel = maxZoomLevel; @@ -151,6 +150,5 @@ namespace MapControl tiles = newTiles; } - } } diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 026519b7..7b6cb9d4 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index bc33f0b6..bf0ac9a4 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 324a8784..e1938105 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index 8d072a6b..eee28623 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs index 806f104b..1448e532 100644 --- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ using System.Windows; [assembly: AssemblyCopyright("Copyright © 2012 Clemens Fischer")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.1.3")] -[assembly: AssemblyFileVersion("1.1.3")] +[assembly: AssemblyVersion("1.1.4")] +[assembly: AssemblyFileVersion("1.1.4")] [assembly: ComVisible(false)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] diff --git a/SampleApps/WpfApplication/App.config b/SampleApps/WpfApplication/App.config index 7b7b9d68..25b1eb77 100644 --- a/SampleApps/WpfApplication/App.config +++ b/SampleApps/WpfApplication/App.config @@ -2,15 +2,15 @@ -
+
- + - + - + diff --git a/SampleApps/WpfApplication/MainWindow.xaml b/SampleApps/WpfApplication/MainWindow.xaml index a3e6cc52..3f503f27 100644 --- a/SampleApps/WpfApplication/MainWindow.xaml +++ b/SampleApps/WpfApplication/MainWindow.xaml @@ -24,7 +24,7 @@ @@ -149,7 +147,7 @@ - +