diff --git a/src/MauiShakeDetector/IShakeDetector.cs b/src/MauiShakeDetector/IShakeDetector.cs index 3a299aa..1736f4b 100644 --- a/src/MauiShakeDetector/IShakeDetector.cs +++ b/src/MauiShakeDetector/IShakeDetector.cs @@ -69,6 +69,12 @@ public interface IShakeDetector event EventHandler? ShakeDetected; #nullable disable + /// + /// Shake stopped event for detecting whether shake detector is stopped when Auto Stop is more than 0 + /// +#nullable enable + event EventHandler? ShakeStopped; +#nullable disable /// /// Shake Detected Command for detecting whether user shook the device /// @@ -77,6 +83,11 @@ public interface IShakeDetector /// ICommand ShakeDetectedCommand { get; set; } + /// + /// Shake stopped command for detecting whether shake detector is stopped when Auto Stop is more than 0 + /// + ICommand ShakeStoppedCommand { get; set; } + /// /// Start listening for shake event /// diff --git a/src/MauiShakeDetector/MauiShakeDetector.csproj b/src/MauiShakeDetector/MauiShakeDetector.csproj index 449f76b..3bd5c6f 100644 --- a/src/MauiShakeDetector/MauiShakeDetector.csproj +++ b/src/MauiShakeDetector/MauiShakeDetector.csproj @@ -37,12 +37,12 @@ Maui Shake Detector Shake Event Detector Library with Lots of Customization like GForce Tuning, Shake Intervals and Haptics for Shake Events icon.png $(AssemblyName) ($(TargetFramework)) - 0.4.0.0 - 0.4.0.0 - 0.4.0 + 1.0.0.0 + 1.0.0.0 + 1.0.0 $(Version)$(VersionSuffix) true - Maui,Shake,ShakeDetector,MauiShake, + Maui,Shake,ShakeDetector,MauiShake,Accelerometer,Vibration Debug;Release False $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/ReleaseNotes.txt")) diff --git a/src/MauiShakeDetector/ReleaseNotes.txt b/src/MauiShakeDetector/ReleaseNotes.txt index fd4f82a..075aa7d 100644 --- a/src/MauiShakeDetector/ReleaseNotes.txt +++ b/src/MauiShakeDetector/ReleaseNotes.txt @@ -1,4 +1,7 @@ -v0.4.0 +v1.0.0 +• Added Shake Stopped Event and Command for Auto Stop Enabled Scenerios + +v0.4.0 • Added Command Support v0.3.0 diff --git a/src/MauiShakeDetector/ShakeDetector.cs b/src/MauiShakeDetector/ShakeDetector.cs index 104d977..8be0430 100644 --- a/src/MauiShakeDetector/ShakeDetector.cs +++ b/src/MauiShakeDetector/ShakeDetector.cs @@ -19,7 +19,14 @@ public static event EventHandler ShakeDetected add => Default.ShakeDetected += value; remove => Default.ShakeDetected -= value; } + + public static event EventHandler ShakeStopped + { + add => Default.ShakeStopped += value; + remove => Default.ShakeStopped -= value; + } public static ICommand ShakeDetectedCommand => Default.ShakeDetectedCommand; + public static ICommand ShakeStoppedCommand => Default.ShakeStoppedCommand; public static void StartListening(SensorSpeed sensorSpeed) => Default.StartListening(sensorSpeed); diff --git a/src/MauiShakeDetector/ShakeDetectorDefault.cs b/src/MauiShakeDetector/ShakeDetectorDefault.cs index 26c0b6b..698d661 100644 --- a/src/MauiShakeDetector/ShakeDetectorDefault.cs +++ b/src/MauiShakeDetector/ShakeDetectorDefault.cs @@ -31,7 +31,10 @@ internal sealed class ShakeDetectorDefault : IShakeDetector // Event & Commands public event EventHandler ShakeDetected; + public event EventHandler ShakeStopped; + public ICommand ShakeDetectedCommand { get; set; } + public ICommand ShakeStoppedCommand { get; set; } public void StartListening(SensorSpeed sensorSpeed = SensorSpeed.Default) { @@ -93,7 +96,13 @@ void AutoStopAfterNoShakeEvents() if(AutoStopAfterNoShakes is not defaultShakeCount && currentTriggeredShakesCount >= AutoStopAfterNoShakes) { currentTriggeredShakesCount = defaultShakeCount; + StopListening(); + + ShakeStopped?.Invoke(this, new EventArgs()); + if (ShakeStoppedCommand is not null && ShakeStoppedCommand.CanExecute(null)) + ShakeStoppedCommand.Execute(null); + } } diff --git a/src/MauiShakeDetector/readme.md b/src/MauiShakeDetector/readme.md index 6b1e2a9..1edff73 100644 --- a/src/MauiShakeDetector/readme.md +++ b/src/MauiShakeDetector/readme.md @@ -76,10 +76,12 @@ using MauiShakeDetector; | **ShakeIntervalInMilliseconds** | `TimeSpan` | Get or Set the value of Minimum Delay betweem Shakes | | **ShakeResetIntervalInMilliseconds** | `TimeSpan` | Get or Set the Value of Shake Reset Interval in Milliseconds | | **MinimumShakeCount** | `int` | Get or Set the Value for Number of Shakes Required Before Shake is Triggered | -| **AutoStopAfterNoShakes** | `int` | Gets or sets the value of Auto Stop listening to shake event after number of shakes triggered | +| **AutoStopAfterNoShakes** | `int` | Gets or sets the value of Auto Stop listening to shake event after number of shakes triggered, Minimum is 1 | | **HapticsDurationInMilliseconds** | `TimeSpan` | Get or Set the Value Of Haptics Duration | | **ShakeDetectedCommand** | `ICommand` | Shake Detected Command for Detecting Whether User Shooked the Device | | **ShakeDetected** | `event` | Shake Detected Event for Detecting Whether User Shooked the Device | +| **ShakeStoppedCommand** | `ICommand` | Shake Stopped Command for Detecting Whether Shake Detector is Stopped When Auto Stop is more than 0 | +| **ShakeStopped** | `event` | Shake Stopped Event for Detecting Whether Shake Detector is Stopped When Auto Stop is more than 0 | | **StartListening()** | `method` | Start listening for Shake Event | | **SensorSpeed** | `enum` | Set the value for Shake Detection Speed When Using Start Listning Method | | **StopListening()** | `method` | Stop Already Monitoring Shake Event |