diff --git a/MapControl/Shared/Map.cs b/MapControl/Shared/Map.cs
deleted file mode 100644
index 68a416a7..00000000
--- a/MapControl/Shared/Map.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
-// © 2020 Clemens Fischer
-// Licensed under the Microsoft Public License (Ms-PL)
-
-#if WINDOWS_UWP
-using Windows.UI.Xaml;
-#else
-using System.Windows;
-#endif
-
-namespace MapControl
-{
- ///
- /// MapBase with default input event handling.
- ///
- public partial class Map : MapBase
- {
- public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
- nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(1d));
-
- ///
- /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
- /// The default value is 1.
- ///
- public double MouseWheelZoomDelta
- {
- get { return (double)GetValue(MouseWheelZoomDeltaProperty); }
- set { SetValue(MouseWheelZoomDeltaProperty, value); }
- }
-
- private Vector translation;
- private double rotation;
- private double scale = 1d;
- private bool transformPending;
-
- private void ResetTransform()
- {
- translation.X = 0d;
- translation.Y = 0d;
- rotation = 0d;
- scale = 1d;
- transformPending = false;
- }
- }
-}
diff --git a/MapControl/UWP/Map.UWP.cs b/MapControl/UWP/Map.UWP.cs
index f8f0d50d..3d21c01c 100644
--- a/MapControl/UWP/Map.UWP.cs
+++ b/MapControl/UWP/Map.UWP.cs
@@ -2,14 +2,19 @@
// © 2020 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
-using System;
-using Windows.UI.Core;
+using Windows.UI.Xaml;
using Windows.UI.Xaml.Input;
namespace MapControl
{
- public partial class Map
+ ///
+ /// MapBase with default input event handling.
+ ///
+ public class Map : MapBase
{
+ public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
+ nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(1d));
+
public Map()
{
ManipulationMode = ManipulationModes.Scale
@@ -21,22 +26,19 @@ namespace MapControl
PointerWheelChanged += OnPointerWheelChanged;
}
- private async void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
+ ///
+ /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
+ /// The default value is 1.
+ ///
+ public double MouseWheelZoomDelta
{
- translation.X += e.Delta.Translation.X;
- translation.Y += e.Delta.Translation.Y;
- rotation += e.Delta.Rotation;
- scale *= e.Delta.Scale;
+ get { return (double)GetValue(MouseWheelZoomDeltaProperty); }
+ set { SetValue(MouseWheelZoomDeltaProperty, value); }
+ }
- if (!transformPending)
- {
- transformPending = true;
-
- await Dispatcher.RunAsync(CoreDispatcherPriority.Low,
- () => TransformMap(e.Position, translation, rotation, scale));
-
- ResetTransform();
- }
+ private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
+ {
+ TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
}
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
diff --git a/MapControl/UWP/MapControl.UWP.csproj b/MapControl/UWP/MapControl.UWP.csproj
index 59899415..136c3a7b 100644
--- a/MapControl/UWP/MapControl.UWP.csproj
+++ b/MapControl/UWP/MapControl.UWP.csproj
@@ -86,9 +86,6 @@
LocationEx.cs
-
- Map.cs
-
MapBase.cs
diff --git a/MapControl/WPF/Map.WPF.cs b/MapControl/WPF/Map.WPF.cs
index 4abcbdb7..f8a55ab1 100644
--- a/MapControl/WPF/Map.WPF.cs
+++ b/MapControl/WPF/Map.WPF.cs
@@ -2,22 +2,22 @@
// © 2020 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
-using System;
-using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
-using System.Windows.Threading;
namespace MapControl
{
- public partial class Map
+ ///
+ /// MapBase with default input event handling.
+ ///
+ public class Map : MapBase
{
+ public static readonly DependencyProperty MouseWheelZoomDeltaProperty = DependencyProperty.Register(
+ nameof(MouseWheelZoomDelta), typeof(double), typeof(Map), new PropertyMetadata(1d));
+
public static readonly DependencyProperty ManipulationModeProperty = DependencyProperty.Register(
nameof(ManipulationMode), typeof(ManipulationModes), typeof(Map), new PropertyMetadata(ManipulationModes.All));
- public static readonly DependencyProperty TransformDelayProperty = DependencyProperty.Register(
- nameof(TransformDelay), typeof(TimeSpan), typeof(Map), new PropertyMetadata(TimeSpan.FromMilliseconds(50)));
-
private Point? mousePosition;
static Map()
@@ -35,6 +35,16 @@ namespace MapControl
MouseWheel += OnMouseWheel;
}
+ ///
+ /// Gets or sets the amount by which the ZoomLevel property changes during a MouseWheel event.
+ /// The default value is 1.
+ ///
+ public double MouseWheelZoomDelta
+ {
+ get { return (double)GetValue(MouseWheelZoomDeltaProperty); }
+ set { SetValue(MouseWheelZoomDeltaProperty, value); }
+ }
+
///
/// Gets or sets a value that specifies how the map control handles manipulations.
///
@@ -44,46 +54,17 @@ namespace MapControl
set { SetValue(ManipulationModeProperty, value); }
}
- ///
- /// Gets or sets a delay interval between adjacent calls to TranslateMap or TransformMap during mouse pan and manipulation.
- /// The default value is 50 milliseconds.
- ///
- public TimeSpan TransformDelay
- {
- get { return (TimeSpan)GetValue(TransformDelayProperty); }
- set { SetValue(TransformDelayProperty, value); }
- }
-
- private async Task InvokeTransformAsync(Action action)
- {
- if (!transformPending)
- {
- transformPending = true;
-
- if (TransformDelay > TimeSpan.Zero)
- {
- await Task.Delay(TransformDelay);
- }
-
- await Dispatcher.InvokeAsync(action);
-
- ResetTransform();
- }
- }
-
private void OnManipulationStarted(object sender, ManipulationStartedEventArgs e)
{
Manipulation.SetManipulationMode(this, ManipulationMode);
}
- private async void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
+ private void OnManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
- translation.X += e.DeltaManipulation.Translation.X;
- translation.Y += e.DeltaManipulation.Translation.Y;
- rotation += e.DeltaManipulation.Rotation;
- scale *= e.DeltaManipulation.Scale.LengthSquared / 2d;
-
- await InvokeTransformAsync(() => TransformMap(e.ManipulationOrigin, translation, rotation, scale));
+ TransformMap(e.ManipulationOrigin,
+ e.DeltaManipulation.Translation,
+ e.DeltaManipulation.Rotation,
+ e.DeltaManipulation.Scale.LengthSquared / 2d);
}
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
@@ -103,15 +84,15 @@ namespace MapControl
}
}
- private async void OnMouseMove(object sender, MouseEventArgs e)
+ private void OnMouseMove(object sender, MouseEventArgs e)
{
if (mousePosition.HasValue)
{
var position = e.GetPosition(this);
- translation += position - mousePosition.Value;
+ var translation = position - mousePosition.Value;
mousePosition = position;
- await InvokeTransformAsync(() => TranslateMap(translation));
+ TranslateMap(translation);
}
}