diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d35bf76..b73040b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -14,7 +14,7 @@ jobs: #Needs windows to build the windows version runs-on: windows-latest env: - NUPKG_MAJOR: 1.0.5 + NUPKG_MAJOR: 1.0.6 DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_NOLOGO: true PROJECT: MauiGestures/MauiGestures.csproj diff --git a/.gitignore b/.gitignore index ac19e01..8e448a8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ riderModule.iml /_ReSharper.Caches/ .idea/ .vs/ +*.user diff --git a/Demo/DemoApp/DemoApp.csproj b/Demo/DemoApp/DemoApp.csproj index a709708..ba01da6 100644 --- a/Demo/DemoApp/DemoApp.csproj +++ b/Demo/DemoApp/DemoApp.csproj @@ -52,8 +52,8 @@ - - + + diff --git a/MauiGestures/Gesture.cs b/MauiGestures/Gesture.cs index cc8147e..ea6ed76 100644 --- a/MauiGestures/Gesture.cs +++ b/MauiGestures/Gesture.cs @@ -48,6 +48,9 @@ public static class Gesture public static readonly BindableProperty SwipeThresholdProperty = BindableProperty.CreateAttached("SwipeThreshold", typeof(int), typeof(Gesture), 40, propertyChanged: CommandChanged); public static readonly BindableProperty CommandParameterProperty = BindableProperty.CreateAttached("CommandParameter", typeof(object), typeof(Gesture), null); + //Windows only + public static readonly BindableProperty ReturnAllPointsOnWindowsProperty = BindableProperty.CreateAttached("ReturnAllPointsOnWindows", typeof(bool), typeof(Gesture), false, propertyChanged: CommandChanged); + public static ICommand GetLongPressCommand(BindableObject view) => (ICommand)view.GetValue(LongPressCommandProperty); public static ICommand GetTapCommand(BindableObject view) => (ICommand)view.GetValue(TapCommandProperty); public static ICommand GetDoubleTapCommand(BindableObject view) => (ICommand)view.GetValue(DoubleTapCommandProperty); @@ -76,6 +79,9 @@ public static class Gesture /// Take a (Point,GestureStatus) parameter (it is a tuple) /// public static ICommand GetPanPointCommand(BindableObject view) => (ICommand)view.GetValue(PanPointCommandProperty); + + + public static bool GetReturnAllPointsOnWindows(BindableObject view) => (bool)view.GetValue(ReturnAllPointsOnWindowsProperty); public static void SetLongPressCommand(BindableObject view, ICommand value) => view.SetValue(LongPressCommandProperty, value); public static void SetTapCommand(BindableObject view, ICommand value) => view.SetValue(TapCommandProperty, value); diff --git a/MauiGestures/MauiGestures.csproj b/MauiGestures/MauiGestures.csproj index c25b2f4..f1efcc6 100644 --- a/MauiGestures/MauiGestures.csproj +++ b/MauiGestures/MauiGestures.csproj @@ -29,7 +29,7 @@ - + diff --git a/MauiGestures/Platform/Standard/PlatformGestureEffect.cs b/MauiGestures/Platform/Standard/PlatformGestureEffect.cs index 1af73e3..d64f28f 100644 --- a/MauiGestures/Platform/Standard/PlatformGestureEffect.cs +++ b/MauiGestures/Platform/Standard/PlatformGestureEffect.cs @@ -31,33 +31,43 @@ protected override partial void OnDetached() {} /// 1 parameter: PinchEventArgs /// private ICommand? pinchCommand; - + +#if WINDOWS + private bool returnAllPointsOnWindows; +#endif + protected override void OnElementPropertyChanged(PropertyChangedEventArgs args) { if (args.PropertyName is not "X" and not "Y" and not "Width" and not "Height") { - tapCommand = Gesture.GetTapCommand(Element); - panCommand = Gesture.GetPanCommand(Element); + var element = Element; + + tapCommand = Gesture.GetTapCommand(element); + panCommand = Gesture.GetPanCommand(element); + + pinchCommand = Gesture.GetPinchCommand(element); + doubleTapCommand = Gesture.GetDoubleTapCommand(element); + longPressCommand = Gesture.GetLongPressCommand(element); - pinchCommand = Gesture.GetPinchCommand(Element); - doubleTapCommand = Gesture.GetDoubleTapCommand(Element); - longPressCommand = Gesture.GetLongPressCommand(Element); + swipeLeftCommand = Gesture.GetSwipeLeftCommand(element); + swipeRightCommand = Gesture.GetSwipeRightCommand(element); + swipeTopCommand = Gesture.GetSwipeTopCommand(element); + swipeBottomCommand = Gesture.GetSwipeBottomCommand(element); - swipeLeftCommand = Gesture.GetSwipeLeftCommand(Element); - swipeRightCommand = Gesture.GetSwipeRightCommand(Element); - swipeTopCommand = Gesture.GetSwipeTopCommand(Element); - swipeBottomCommand = Gesture.GetSwipeBottomCommand(Element); + tapPointCommand = Gesture.GetTapPointCommand(element); + panPointCommand = Gesture.GetPanPointCommand(element); + doubleTapPointCommand = Gesture.GetDoubleTapPointCommand(element); + longPressPointCommand = Gesture.GetLongPressPointCommand(element); - tapPointCommand = Gesture.GetTapPointCommand(Element); - panPointCommand = Gesture.GetPanPointCommand(Element); - doubleTapPointCommand = Gesture.GetDoubleTapPointCommand(Element); - longPressPointCommand = Gesture.GetLongPressPointCommand(Element); + commandParameter = Gesture.GetCommandParameter(element); - commandParameter = Gesture.GetCommandParameter(Element); +#if WINDOWS + returnAllPointsOnWindows = Gesture.GetReturnAllPointsOnWindows(element); +#endif #if IOS || MACCATALYST - panDetector.IsImmediate = Gesture.GetIsPanImmediate(Element); - pinchDetector.IsImmediate = Gesture.GetIsPinchImmediate(Element); + panDetector.IsImmediate = Gesture.GetIsPanImmediate(element); + pinchDetector.IsImmediate = Gesture.GetIsPinchImmediate(element); #endif } } diff --git a/MauiGestures/Platforms/Windows/PlatformGestureEffect.cs b/MauiGestures/Platforms/Windows/PlatformGestureEffect.cs index a24a758..56f2398 100644 --- a/MauiGestures/Platforms/Windows/PlatformGestureEffect.cs +++ b/MauiGestures/Platforms/Windows/PlatformGestureEffect.cs @@ -142,7 +142,9 @@ private void ControlOnPointerPressed(object sender, PointerRoutedEventArgs point private void ControlOnPointerMoved(object sender, PointerRoutedEventArgs pointerRoutedEventArgs) { - detector.ProcessMoveEvents(pointerRoutedEventArgs.GetIntermediatePoints(Control ?? Container)); + detector.ProcessMoveEvents(returnAllPointsOnWindows ? + pointerRoutedEventArgs.GetIntermediatePoints(Control ?? Container) + : new List { pointerRoutedEventArgs.GetCurrentPoint(Control ?? Container) }); pointerRoutedEventArgs.Handled = true; }