From 140f800f33d8e4c4f5c7fe0d119d303e583f8864 Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Wed, 11 Jun 2025 22:39:54 +0200 Subject: [PATCH] Update Map.WinUI.cs --- MapControl/WinUI/Map.WinUI.cs | 88 +++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/MapControl/WinUI/Map.WinUI.cs b/MapControl/WinUI/Map.WinUI.cs index 17407a17..c2ce45b3 100644 --- a/MapControl/WinUI/Map.WinUI.cs +++ b/MapControl/WinUI/Map.WinUI.cs @@ -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; } /// @@ -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; + } } }