Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for touch panning in WPF #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions GMap.NET.Core/GMap.NET.Internals/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal class Core : IDisposable
public GPoint mouseDown;
public GPoint mouseCurrent;
public GPoint mouseLastZoom;
public GPoint touchCurrent;

public MouseWheelZoomType MouseWheelZoomType = MouseWheelZoomType.MousePositionAndCenter;
public bool MouseWheelZoomEnabled = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,19 @@ protected override void OnStylusMove(StylusEventArgs e)
}
}

protected override void OnManipulationStarted(ManipulationStartedEventArgs e)
{
base.OnManipulationStarted(e);

if (MultiTouchEnabled && !TouchEnabled)
{
Core.mouseDown.X = 0;
Core.mouseDown.Y = 0;
Core.touchCurrent.X = 0;
Core.touchCurrent.Y = 0;
}
}

/// <summary>
/// Called when the <see cref="E:System.Windows.UIElement.ManipulationDelta" /> event occurs.
/// </summary>
Expand Down Expand Up @@ -1971,12 +1984,15 @@ protected virtual void SingleTouchPanMap(Point deltaPoint)
{
if(MultiTouchEnabled && !TouchEnabled) // redundent check in case this is invoked outside of the manipulation events
{
if(!Core.IsDragging)
{
deltaPoint = ApplyRotationInversion(deltaPoint.X, deltaPoint.Y);
deltaPoint = ApplyRotationInversion(deltaPoint.X, deltaPoint.Y);

Core.touchCurrent.X += (int)deltaPoint.X;
Core.touchCurrent.Y += (int)deltaPoint.Y;

if (!Core.IsDragging)
{
// cursor has moved beyond drag tolerance
if(Math.Abs(deltaPoint.X - Core.mouseDown.X) * 2 >= SystemParameters.MinimumHorizontalDragDistance || Math.Abs(deltaPoint.Y - Core.mouseDown.Y) * 2 >= SystemParameters.MinimumVerticalDragDistance)
if(Math.Abs(Core.touchCurrent.X - Core.mouseDown.X) * 2 >= SystemParameters.MinimumHorizontalDragDistance || Math.Abs(Core.touchCurrent.Y - Core.mouseDown.Y) * 2 >= SystemParameters.MinimumVerticalDragDistance)
{
Core.BeginDrag(Core.mouseDown);
}
Expand All @@ -1999,13 +2015,7 @@ protected virtual void SingleTouchPanMap(Point deltaPoint)
}
else
{
deltaPoint = ApplyRotationInversion(deltaPoint.X, deltaPoint.Y);

Core.mouseCurrent.X += (int)deltaPoint.X;
Core.mouseCurrent.Y += (int)deltaPoint.Y;
{
Core.Drag(Core.mouseCurrent);
}
Core.Drag(Core.touchCurrent);

if(IsRotated)
{
Expand Down