mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Update Map.WinUI.cs
This commit is contained in:
parent
71e7e29200
commit
140f800f33
|
|
@ -31,11 +31,11 @@ namespace MapControl
|
|||
| ManipulationModes.TranslateY
|
||||
| ManipulationModes.TranslateInertia;
|
||||
|
||||
ManipulationDelta += OnManipulationDelta;
|
||||
ManipulationCompleted += OnManipulationCompleted;
|
||||
PointerWheelChanged += OnPointerWheelChanged;
|
||||
PointerPressed += OnPointerPressed;
|
||||
PointerMoved += OnPointerMoved;
|
||||
PointerWheelChanged += OnPointerWheelChanged;
|
||||
ManipulationDelta += OnManipulationDelta;
|
||||
ManipulationCompleted += OnManipulationCompleted;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -48,47 +48,6 @@ namespace MapControl
|
|||
set => SetValue(MouseWheelZoomDeltaProperty, value);
|
||||
}
|
||||
|
||||
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
if (manipulationEnabled.HasValue && manipulationEnabled.Value)
|
||||
{
|
||||
if (e.PointerDeviceType == PointerDeviceType.Mouse)
|
||||
{
|
||||
TranslateMap(e.Delta.Translation);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
|
||||
{
|
||||
manipulationEnabled = null;
|
||||
}
|
||||
|
||||
private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
// Set manipulationEnabled before ManipulationStarted.
|
||||
// IsLeftButtonPressed: input was triggered by the primary action mode of an input device.
|
||||
//
|
||||
manipulationEnabled =
|
||||
e.GetCurrentPoint(this).Properties.IsLeftButtonPressed &&
|
||||
e.KeyModifiers == VirtualKeyModifiers.None;
|
||||
}
|
||||
|
||||
private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
// Set manipulationEnabled before ManipulationStarted when no PointerPressed was received.
|
||||
//
|
||||
if (!manipulationEnabled.HasValue &&
|
||||
e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
{
|
||||
manipulationEnabled = e.KeyModifiers == VirtualKeyModifiers.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPointerWheelChanged(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (e.Pointer.PointerDeviceType == PointerDeviceType.Mouse)
|
||||
|
|
@ -110,5 +69,46 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
// Set manipulationEnabled before ManipulationStarted.
|
||||
// IsLeftButtonPressed: input was triggered by the primary action mode of an input device.
|
||||
//
|
||||
manipulationEnabled =
|
||||
e.GetCurrentPoint(this).Properties.IsLeftButtonPressed &&
|
||||
e.KeyModifiers == VirtualKeyModifiers.None;
|
||||
}
|
||||
|
||||
private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
// Set manipulationEnabled before ManipulationStarted when no PointerPressed was received.
|
||||
//
|
||||
if (!manipulationEnabled.HasValue &&
|
||||
e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||
{
|
||||
manipulationEnabled = e.KeyModifiers == VirtualKeyModifiers.None;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
if (manipulationEnabled.HasValue && manipulationEnabled.Value)
|
||||
{
|
||||
if (e.PointerDeviceType == PointerDeviceType.Mouse)
|
||||
{
|
||||
TranslateMap(e.Delta.Translation);
|
||||
}
|
||||
else
|
||||
{
|
||||
TransformMap(e.Position, e.Delta.Translation, e.Delta.Rotation, e.Delta.Scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnManipulationCompleted(object sender, ManipulationCompletedRoutedEventArgs e)
|
||||
{
|
||||
manipulationEnabled = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue