diff --git a/Caching/FileDbCache/Properties/AssemblyInfo.cs b/Caching/FileDbCache/Properties/AssemblyInfo.cs
index 2216b01d..2e264f8d 100644
--- a/Caching/FileDbCache/Properties/AssemblyInfo.cs
+++ b/Caching/FileDbCache/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/Caching/ImageFileCache/Properties/AssemblyInfo.cs b/Caching/ImageFileCache/Properties/AssemblyInfo.cs
index 399b95bd..1d845a97 100644
--- a/Caching/ImageFileCache/Properties/AssemblyInfo.cs
+++ b/Caching/ImageFileCache/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/MapControl/Freezable.cs b/MapControl/Freezable.cs
new file mode 100644
index 00000000..aed1592a
--- /dev/null
+++ b/MapControl/Freezable.cs
@@ -0,0 +1,22 @@
+// XAML Map Control - http://xamlmapcontrol.codeplex.com/
+// Copyright © Clemens Fischer 2012-2013
+// Licensed under the Microsoft Public License (Ms-PL)
+
+#if NETFX_CORE
+using Windows.UI.Xaml;
+#else
+using System.Windows;
+#endif
+
+namespace MapControl
+{
+ internal static class Freezable
+ {
+ ///
+ /// Provides WPF compatibility.
+ ///
+ public static void Freeze(this DependencyObject obj)
+ {
+ }
+ }
+}
diff --git a/MapControl/MapControl.Silverlight.csproj b/MapControl/MapControl.Silverlight.csproj
index 92b2b338..3aeca3a1 100644
--- a/MapControl/MapControl.Silverlight.csproj
+++ b/MapControl/MapControl.Silverlight.csproj
@@ -64,6 +64,7 @@
+
@@ -75,7 +76,6 @@
-
@@ -85,7 +85,6 @@
-
diff --git a/MapControl/MapControl.WPF.csproj b/MapControl/MapControl.WPF.csproj
index 6b8397bb..d63ffd51 100644
--- a/MapControl/MapControl.WPF.csproj
+++ b/MapControl/MapControl.WPF.csproj
@@ -56,7 +56,6 @@
-
@@ -67,7 +66,6 @@
-
diff --git a/MapControl/MapImage.Silverlight.WinRT.cs b/MapControl/MapImage.Silverlight.WinRT.cs
deleted file mode 100644
index 2a9b6885..00000000
--- a/MapControl/MapImage.Silverlight.WinRT.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// XAML Map Control - http://xamlmapcontrol.codeplex.com/
-// Copyright © Clemens Fischer 2012-2013
-// Licensed under the Microsoft Public License (Ms-PL)
-
-#if NETFX_CORE
-using Windows.UI.Xaml.Media;
-#else
-using System.Windows.Media;
-#endif
-
-namespace MapControl
-{
- public partial class MapImage
- {
- private void SourceChanged(ImageSource image)
- {
- var imageTransform = new MatrixTransform
- {
- Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d)
- };
-
- Fill = new ImageBrush
- {
- ImageSource = image,
- RelativeTransform = imageTransform
- };
- }
- }
-}
diff --git a/MapControl/MapImage.WPF.cs b/MapControl/MapImage.WPF.cs
deleted file mode 100644
index 3be1e5cf..00000000
--- a/MapControl/MapImage.WPF.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// XAML Map Control - http://xamlmapcontrol.codeplex.com/
-// Copyright © Clemens Fischer 2012-2013
-// Licensed under the Microsoft Public License (Ms-PL)
-
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-
-namespace MapControl
-{
- public partial class MapImage
- {
- private void SourceChanged(ImageSource image)
- {
- var bitmap = image as BitmapSource;
-
- if (bitmap != null)
- {
- var imageTransform = new ScaleTransform(1d, -1d);
- imageTransform.Freeze();
-
- bitmap = new TransformedBitmap(bitmap, imageTransform);
- bitmap.Freeze();
-
- image = bitmap;
- }
-
- Fill = new ImageBrush { ImageSource = image };
- }
- }
-}
\ No newline at end of file
diff --git a/MapControl/MapImage.cs b/MapControl/MapImage.cs
index 77610e20..854315fd 100644
--- a/MapControl/MapImage.cs
+++ b/MapControl/MapImage.cs
@@ -15,8 +15,18 @@ namespace MapControl
///
/// Fills a rectangular area with an ImageBrush from the Source property.
///
- public partial class MapImage : MapRectangle
+ public class MapImage : MapRectangle
{
+ private static readonly MatrixTransform imageTransform = new MatrixTransform
+ {
+ Matrix = new Matrix(1d, 0d, 0d, -1d, 0d, 1d)
+ };
+
+ static MapImage()
+ {
+ imageTransform.Freeze();
+ }
+
public static readonly DependencyProperty SourceProperty = DependencyProperty.Register(
"Source", typeof(ImageSource), typeof(MapImage),
new PropertyMetadata(null, (o, e) => ((MapImage)o).SourceChanged((ImageSource)e.NewValue)));
@@ -26,5 +36,17 @@ namespace MapControl
get { return (ImageSource)GetValue(SourceProperty); }
set { SetValue(SourceProperty, value); }
}
+
+ private void SourceChanged(ImageSource image)
+ {
+ var imageBrush = new ImageBrush
+ {
+ ImageSource = image,
+ RelativeTransform = imageTransform
+ };
+
+ imageBrush.Freeze();
+ Fill = imageBrush;
+ }
}
}
diff --git a/MapControl/MapPolyline.cs b/MapControl/MapPolyline.cs
index b4f5cad8..a343e0e3 100644
--- a/MapControl/MapPolyline.cs
+++ b/MapControl/MapPolyline.cs
@@ -15,6 +15,9 @@ using System.ComponentModel;
namespace MapControl
{
+ ///
+ /// A polyline or polygon created from a collection of Locations.
+ ///
public partial class MapPolyline : MapPath
{
#if NETFX_CORE
diff --git a/MapControl/MapRectangle.Silverlight.WinRT.cs b/MapControl/MapRectangle.Silverlight.WinRT.cs
deleted file mode 100644
index d4b90df3..00000000
--- a/MapControl/MapRectangle.Silverlight.WinRT.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// XAML Map Control - http://xamlmapcontrol.codeplex.com/
-// Copyright © Clemens Fischer 2012-2013
-// Licensed under the Microsoft Public License (Ms-PL)
-
-#if NETFX_CORE
-using Windows.Foundation;
-using Windows.UI.Xaml.Media;
-#else
-using System.Windows;
-using System.Windows.Media;
-#endif
-
-namespace MapControl
-{
- public partial class MapRectangle
- {
- private void SetGeometry(Rect rect)
- {
- var geometry = (RectangleGeometry)Data;
-
- geometry.Rect = rect;
- RenderTransform = ParentMap.ViewportTransform;
- }
-
- private void ClearGeometry()
- {
- var geometry = (RectangleGeometry)Data;
-
- geometry.ClearValue(RectangleGeometry.RectProperty);
- ClearValue(RenderTransformProperty);
- }
- }
-}
diff --git a/MapControl/MapRectangle.WPF.cs b/MapControl/MapRectangle.WPF.cs
deleted file mode 100644
index c5f08281..00000000
--- a/MapControl/MapRectangle.WPF.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-// XAML Map Control - http://xamlmapcontrol.codeplex.com/
-// Copyright © Clemens Fischer 2012-2013
-// Licensed under the Microsoft Public License (Ms-PL)
-
-using System.Windows;
-using System.Windows.Media;
-
-namespace MapControl
-{
- public partial class MapRectangle
- {
- static MapRectangle()
- {
- StrokeThicknessProperty.OverrideMetadata(
- typeof(MapRectangle), new FrameworkPropertyMetadata(0d));
-
- FillProperty.OverrideMetadata(
- typeof(MapRectangle), new FrameworkPropertyMetadata(FillPropertyChanged));
- }
-
- private void SetGeometry(Rect rect)
- {
- // Instead of setting RenderTransform as done in the Silverlight and
- // WinRT versions, the ViewportTransform is applied to the Transform
- // properties of the Geometry and the Fill Brush. In WPF, setting the
- // RenderTransform property results in incorrect hit testing.
-
- var geometry = (RectangleGeometry)Data;
-
- geometry.Rect = rect;
- geometry.Transform = ParentMap.ViewportTransform;
-
- SetBrushTransform(Fill as TileBrush);
- }
-
- private void ClearGeometry()
- {
- var geometry = (RectangleGeometry)Data;
-
- geometry.ClearValue(RectangleGeometry.RectProperty);
- geometry.ClearValue(Geometry.TransformProperty);
- }
-
- private void SetBrushTransform(TileBrush tileBrush)
- {
- if (tileBrush != null && Data != null)
- {
- var geometry = (RectangleGeometry)Data;
-
- tileBrush.ViewportUnits = BrushMappingMode.Absolute;
- tileBrush.Viewport = geometry.Rect;
- tileBrush.Transform = geometry.Transform;
- }
- }
-
- private static void FillPropertyChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
- {
- if (e.NewValue != e.OldValue)
- {
- ((MapRectangle)o).SetBrushTransform(e.NewValue as TileBrush);
- }
- }
- }
-}
diff --git a/MapControl/MapRectangle.cs b/MapControl/MapRectangle.cs
index 34241a57..7984f651 100644
--- a/MapControl/MapRectangle.cs
+++ b/MapControl/MapRectangle.cs
@@ -16,8 +16,21 @@ namespace MapControl
///
/// Fills a rectangular area defined by South, North, West and East with a Brush.
///
- public partial class MapRectangle : MapPath
+ public class MapRectangle : MapPath
{
+ private const double geometryScale = 1e6;
+
+ private static readonly ScaleTransform geometryScaleTransform = new ScaleTransform
+ {
+ ScaleX = 1d / geometryScale,
+ ScaleY = 1d / geometryScale
+ };
+
+ static MapRectangle()
+ {
+ geometryScaleTransform.Freeze();
+ }
+
public static readonly DependencyProperty SouthProperty = DependencyProperty.Register(
"South", typeof(double), typeof(MapRectangle),
new PropertyMetadata(double.NaN, (o, e) => ((MapRectangle)o).UpdateData()));
@@ -66,6 +79,8 @@ namespace MapControl
protected override void UpdateData()
{
+ var geometry = (RectangleGeometry)Data;
+
if (ParentMap != null &&
!double.IsNaN(South) && !double.IsNaN(North) &&
!double.IsNaN(West) && !double.IsNaN(East) &&
@@ -74,11 +89,21 @@ namespace MapControl
var p1 = ParentMap.MapTransform.Transform(new Location(South, West));
var p2 = ParentMap.MapTransform.Transform(new Location(North, East));
- SetGeometry(new Rect(p1.X, p1.Y, p2.X - p1.X, p2.Y - p1.Y));
+ // Create a scaled RectangleGeometry due to inaccurate hit testing in WPF.
+ // See http://stackoverflow.com/a/19335624/1136211
+
+ geometry.Rect = new Rect(p1.X * geometryScale, p1.Y * geometryScale,
+ (p2.X - p1.X) * geometryScale, (p2.Y - p1.Y) * geometryScale);
+
+ var transform = new TransformGroup();
+ transform.Children.Add(geometryScaleTransform); // revert scaling
+ transform.Children.Add(ParentMap.ViewportTransform);
+ RenderTransform = transform;
}
else
{
- ClearGeometry();
+ geometry.ClearValue(RectangleGeometry.RectProperty);
+ ClearValue(RenderTransformProperty);
}
}
}
diff --git a/MapControl/Properties/AssemblyInfo.cs b/MapControl/Properties/AssemblyInfo.cs
index 96f52f3f..8cedfa28 100644
--- a/MapControl/Properties/AssemblyInfo.cs
+++ b/MapControl/Properties/AssemblyInfo.cs
@@ -15,8 +15,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/MapControl/TileContainer.Silverlight.WinRT.cs b/MapControl/TileContainer.Silverlight.WinRT.cs
index 816355a9..3be445ed 100644
--- a/MapControl/TileContainer.Silverlight.WinRT.cs
+++ b/MapControl/TileContainer.Silverlight.WinRT.cs
@@ -17,9 +17,9 @@ namespace MapControl
{
internal partial class TileContainer : Panel
{
- private void SetViewportTransform(Matrix transform)
+ private Matrix GetViewportTransformMatrix(Matrix transform)
{
- ViewportTransform.Matrix = transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
+ return transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
}
///
diff --git a/MapControl/TileContainer.WPF.cs b/MapControl/TileContainer.WPF.cs
index b4afe68a..9a87e1c4 100644
--- a/MapControl/TileContainer.WPF.cs
+++ b/MapControl/TileContainer.WPF.cs
@@ -9,10 +9,11 @@ namespace MapControl
{
internal partial class TileContainer : ContainerVisual
{
- private void SetViewportTransform(Matrix transform)
+ private Matrix GetViewportTransformMatrix(Matrix transform)
{
transform.RotateAt(rotation, viewportOrigin.X, viewportOrigin.Y);
- ViewportTransform.Matrix = transform;
+
+ return transform;
}
///
diff --git a/MapControl/TileContainer.cs b/MapControl/TileContainer.cs
index 7061b13e..667789bf 100644
--- a/MapControl/TileContainer.cs
+++ b/MapControl/TileContainer.cs
@@ -101,7 +101,7 @@ namespace MapControl
tileLayerOffset.X = transformOffsetX - 180d * scale;
tileLayerOffset.Y = transformOffsetY - 180d * scale;
- SetViewportTransform(new Matrix(scale, 0d, 0d, -scale, transformOffsetX, transformOffsetY));
+ ViewportTransform.Matrix = GetViewportTransformMatrix(new Matrix(scale, 0d, 0d, -scale, transformOffsetX, transformOffsetY));
if (Math.Sign(mapOrigin.X) != Math.Sign(oldMapOriginX) && Math.Abs(mapOrigin.X) > 90d)
{
diff --git a/MapControl/WinRT/MapControl.WinRT.csproj b/MapControl/WinRT/MapControl.WinRT.csproj
index 67d50e31..08cb46dd 100644
--- a/MapControl/WinRT/MapControl.WinRT.csproj
+++ b/MapControl/WinRT/MapControl.WinRT.csproj
@@ -36,6 +36,9 @@
AnimationEx.WinRT.cs
+
+ Freezable.cs
+
Int32Rect.cs
@@ -63,9 +66,6 @@
MapImage.cs
-
- MapImage.Silverlight.WinRT.cs
-
MapItem.Silverlight.WinRT.cs
@@ -93,9 +93,6 @@
MapRectangle.cs
-
- MapRectangle.Silverlight.WinRT.cs
-
MapTransform.cs
diff --git a/MapControl/WinRT/Properties/AssemblyInfo.cs b/MapControl/WinRT/Properties/AssemblyInfo.cs
index b8b8fc2f..c1d22872 100644
--- a/MapControl/WinRT/Properties/AssemblyInfo.cs
+++ b/MapControl/WinRT/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
index 4255b150..1b05264b 100644
--- a/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
+++ b/SampleApps/SilverlightApplication.Web/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
index 8d629f50..f5dcc0aa 100644
--- a/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/SilverlightApplication/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs
index 9ba7b66c..11077b9c 100644
--- a/SampleApps/StoreApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/StoreApplication/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs
index f30b6911..7f13f13f 100644
--- a/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/SurfaceApplication/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
diff --git a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs
index 40061b4f..a58071ee 100644
--- a/SampleApps/WpfApplication/Properties/AssemblyInfo.cs
+++ b/SampleApps/WpfApplication/Properties/AssemblyInfo.cs
@@ -8,8 +8,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("Copyright © Clemens Fischer 2012-2013")]
[assembly: AssemblyTrademark("")]
-[assembly: AssemblyVersion("1.4.2")]
-[assembly: AssemblyFileVersion("1.4.2")]
+[assembly: AssemblyVersion("1.5.0")]
+[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]