From 6c4dc65bd4ae1477719e0794780bbc6b1b010e24 Mon Sep 17 00:00:00 2001 From: ClemensF Date: Mon, 26 Jan 2015 19:45:05 +0100 Subject: [PATCH] Version 2.4.4: Fixed image swapping in MapImageLayer --- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- MapControl/MapBase.cs | 16 +++--- MapControl/MapImageLayer.Silverlight.WinRT.cs | 6 +-- MapControl/MapImageLayer.WPF.cs | 6 +-- MapControl/MapImageLayer.cs | 40 ++++++++------- MapControl/MapRectangle.cs | 49 ++++++++++++------- MapControl/Properties/AssemblyInfo.cs | 4 +- MapControl/TileLayer.cs | 4 +- MapControl/WinRT/Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../WpfApplication/Properties/AssemblyInfo.cs | 4 +- 17 files changed, 94 insertions(+), 71 deletions(-) diff --git a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs index 544b17b3..5d0eb267 100644 --- a/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WPF/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs index 019bdf55..1dffcacb 100644 --- a/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/FileDbCache.WinRT/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs index 5de975a9..5e67f4f0 100644 --- a/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WPF/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs index b64ebd7b..c5ac8d7c 100644 --- a/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs +++ b/Caching/ImageFileCache.WinRT/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/MapBase.cs b/MapControl/MapBase.cs index 2048174e..0a213e3e 100644 --- a/MapControl/MapBase.cs +++ b/MapControl/MapBase.cs @@ -32,6 +32,7 @@ namespace MapControl private const double MaximumZoomLevel = 22d; public static double ZoomLevelSwitchDelta = 0d; + public static bool UpdateTilesWhileViewportChanging = true; public static TimeSpan TileUpdateInterval = TimeSpan.FromSeconds(0.5); public static TimeSpan AnimationDuration = TimeSpan.FromSeconds(0.3); public static EasingFunctionBase AnimationEasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }; @@ -594,8 +595,7 @@ namespace MapControl From = mapTransform.Transform(Center), To = mapTransform.Transform(targetCenter, Center.Longitude), Duration = AnimationDuration, - EasingFunction = AnimationEasingFunction, - FillBehavior = FillBehavior.HoldEnd + EasingFunction = AnimationEasingFunction }; centerAnimation.Completed += CenterAnimationCompleted; @@ -699,8 +699,7 @@ namespace MapControl { To = targetZoomLevel, Duration = AnimationDuration, - EasingFunction = AnimationEasingFunction, - FillBehavior = FillBehavior.HoldEnd + EasingFunction = AnimationEasingFunction }; zoomLevelAnimation.Completed += ZoomLevelAnimationCompleted; @@ -774,8 +773,7 @@ namespace MapControl { By = delta, Duration = AnimationDuration, - EasingFunction = AnimationEasingFunction, - FillBehavior = FillBehavior.HoldEnd + EasingFunction = AnimationEasingFunction }; headingAnimation.Completed += HeadingAnimationCompleted; @@ -872,6 +870,12 @@ namespace MapControl else { SetTileLayerTransform(); + + if (!UpdateTilesWhileViewportChanging) + { + tileUpdateTimer.Stop(); + } + tileUpdateTimer.Start(); } } diff --git a/MapControl/MapImageLayer.Silverlight.WinRT.cs b/MapControl/MapImageLayer.Silverlight.WinRT.cs index 8497fcc7..3adf2851 100644 --- a/MapControl/MapImageLayer.Silverlight.WinRT.cs +++ b/MapControl/MapImageLayer.Silverlight.WinRT.cs @@ -25,7 +25,7 @@ namespace MapControl } else { - BlendImages(); + SwapImages(); } } @@ -35,7 +35,7 @@ namespace MapControl bitmap.ImageOpened -= BitmapImageOpened; bitmap.ImageFailed -= BitmapImageFailed; - BlendImages(); + SwapImages(); } private void BitmapImageFailed(object sender, ExceptionRoutedEventArgs e) @@ -47,7 +47,7 @@ namespace MapControl var mapImage = (MapImage)Children[currentImageIndex]; mapImage.Source = null; - BlendImages(); + SwapImages(); } } } diff --git a/MapControl/MapImageLayer.WPF.cs b/MapControl/MapImageLayer.WPF.cs index 2d6c82c5..7e15f89d 100644 --- a/MapControl/MapImageLayer.WPF.cs +++ b/MapControl/MapImageLayer.WPF.cs @@ -19,7 +19,7 @@ namespace MapControl } else { - BlendImages(); + SwapImages(); } } @@ -29,7 +29,7 @@ namespace MapControl bitmap.DownloadCompleted -= BitmapDownloadCompleted; bitmap.DownloadFailed -= BitmapDownloadFailed; - BlendImages(); + SwapImages(); } private void BitmapDownloadFailed(object sender, ExceptionEventArgs e) @@ -41,7 +41,7 @@ namespace MapControl var mapImage = (MapImage)Children[currentImageIndex]; mapImage.Source = null; - BlendImages(); + SwapImages(); } } } diff --git a/MapControl/MapImageLayer.cs b/MapControl/MapImageLayer.cs index 25e4cbd9..b8f78d21 100644 --- a/MapControl/MapImageLayer.cs +++ b/MapControl/MapImageLayer.cs @@ -7,10 +7,12 @@ using System.Globalization; #if WINDOWS_RUNTIME using Windows.Foundation; using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Imaging; using Windows.UI.Xaml.Media.Animation; #else using System.Windows; +using System.Windows.Controls; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Threading; @@ -157,37 +159,39 @@ namespace MapControl currentImageIndex = (currentImageIndex + 1) % 2; var mapImage = (MapImage)Children[currentImageIndex]; - mapImage.North = double.NaN; // avoid frequent MapRectangle.UpdateData() calls - mapImage.West = west; - mapImage.East = east; - mapImage.South = south; - mapImage.North = north; + mapImage.SetBoundingBox(west, east, south, north); mapImage.Source = bitmap; ImageUpdated(bitmap); } - private void BlendImages() + private void SwapImages() { var topImage = (MapImage)Children[currentImageIndex]; var bottomImage = (MapImage)Children[(currentImageIndex + 1) % 2]; + Canvas.SetZIndex(topImage, 1); + Canvas.SetZIndex(bottomImage, 0); + if (topImage.Source != null) { - topImage.BeginAnimation(UIElement.OpacityProperty, - new DoubleAnimation { To = 1d, Duration = Tile.OpacityAnimationDuration }); - } - - if (bottomImage.Source != null) - { - var fadeOutAnimation = new DoubleAnimation { To = 0d, Duration = Tile.OpacityAnimationDuration }; - - if (topImage.Source != null) + var fadeAnimation = new DoubleAnimation { - fadeOutAnimation.BeginTime = Tile.OpacityAnimationDuration; - } + From = 0d, + To = 1d, + Duration = Tile.OpacityAnimationDuration, + FillBehavior = FillBehavior.Stop + }; - bottomImage.BeginAnimation(UIElement.OpacityProperty, fadeOutAnimation); + fadeAnimation.Completed += (s, e) => bottomImage.Opacity = 0d; + + topImage.BeginAnimation(UIElement.OpacityProperty, fadeAnimation); + topImage.Opacity = 1d; + } + else + { + topImage.Opacity = 0d; + bottomImage.Opacity = 0d; } updateInProgress = false; diff --git a/MapControl/MapRectangle.cs b/MapControl/MapRectangle.cs index 7a03012e..8b4eda69 100644 --- a/MapControl/MapRectangle.cs +++ b/MapControl/MapRectangle.cs @@ -34,6 +34,8 @@ namespace MapControl "North", typeof(double), typeof(MapRectangle), new PropertyMetadata(double.NaN, (o, e) => ((MapRectangle)o).UpdateData())); + private bool updatingBoundBox; + public MapRectangle() { Data = new RectangleGeometry(); @@ -64,28 +66,41 @@ namespace MapControl set { SetValue(NorthProperty, value); } } + public void SetBoundingBox(double west, double east, double south, double north) + { + updatingBoundBox = true; + West = west; + East = east; + South = south; + updatingBoundBox = false; + North = north; + } + protected override void UpdateData() { - var geometry = (RectangleGeometry)Data; - - if (ParentMap != null && - !double.IsNaN(South) && !double.IsNaN(North) && - !double.IsNaN(West) && !double.IsNaN(East) && - South < North && West < East) + if (!updatingBoundBox) { - var rect = new Rect(ParentMap.MapTransform.Transform(new Location(South, West)), - ParentMap.MapTransform.Transform(new Location(North, East))); - var transform = ParentMap.ViewportTransform; + var geometry = (RectangleGeometry)Data; - ScaleRect(ref rect, ref transform); + if (ParentMap != null && + !double.IsNaN(South) && !double.IsNaN(North) && + !double.IsNaN(West) && !double.IsNaN(East) && + South < North && West < East) + { + var rect = new Rect(ParentMap.MapTransform.Transform(new Location(South, West)), + ParentMap.MapTransform.Transform(new Location(North, East))); + var transform = ParentMap.ViewportTransform; - geometry.Rect = rect; - RenderTransform = transform; - } - else - { - geometry.ClearValue(RectangleGeometry.RectProperty); - ClearValue(RenderTransformProperty); + ScaleRect(ref rect, ref transform); + + geometry.Rect = rect; + RenderTransform = transform; + } + else + { + geometry.ClearValue(RectangleGeometry.RectProperty); + ClearValue(RenderTransformProperty); + } } } diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs index 953fe01d..c25661b9 100644 --- a/MapControl/Properties/AssemblyInfo.cs +++ b/MapControl/Properties/AssemblyInfo.cs @@ -17,8 +17,8 @@ using System.Windows; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/MapControl/TileLayer.cs b/MapControl/TileLayer.cs index 321c25dd..f46fc6fb 100644 --- a/MapControl/TileLayer.cs +++ b/MapControl/TileLayer.cs @@ -222,10 +222,10 @@ namespace MapControl var maxZoomLevel = Math.Min(zoomLevel, MaxZoomLevel); var minZoomLevel = MinZoomLevel; - if (parentMap.TileLayers.FirstOrDefault() != this) + if (minZoomLevel < maxZoomLevel && this != parentMap.TileLayers.FirstOrDefault()) { // do not load background tiles if this is not the base layer - minZoomLevel = Math.Max(maxZoomLevel, minZoomLevel); + minZoomLevel = maxZoomLevel; } for (var z = minZoomLevel; z <= maxZoomLevel; z++) diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs index 0865a506..4f0317d7 100644 --- a/MapControl/WinRT/Properties/AssemblyInfo.cs +++ b/MapControl/WinRT/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs index a07a0c44..1fa47f1c 100644 --- a/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/PhoneApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs index 06e5e2f9..79005f84 100644 --- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs index 19d1aee2..b6fc65ab 100644 --- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs index 224aba4c..22a6ff1a 100644 --- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)] diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs index 20a0a0e0..0425900a 100644 --- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs +++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs @@ -7,8 +7,8 @@ using System.Runtime.InteropServices; [assembly: AssemblyCompany("Clemens Fischer")] [assembly: AssemblyCopyright("© 2015 Clemens Fischer")] [assembly: AssemblyTrademark("")] -[assembly: AssemblyVersion("2.4.3")] -[assembly: AssemblyFileVersion("2.4.3")] +[assembly: AssemblyVersion("2.4.4")] +[assembly: AssemblyFileVersion("2.4.4")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCulture("")] [assembly: ComVisible(false)]