https://github.com/jomendez/shakedetection
Windows Phone Shake Detection Class
https://github.com/jomendez/shakedetection
Last synced: 2 months ago
JSON representation
Windows Phone Shake Detection Class
- Host: GitHub
- URL: https://github.com/jomendez/shakedetection
- Owner: jomendez
- License: gpl-2.0
- Created: 2014-07-23T02:08:09.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-07-25T04:29:56.000Z (about 11 years ago)
- Last Synced: 2025-02-21T21:32:32.417Z (8 months ago)
- Language: C#
- Size: 199 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ShakeDetection
==============Windows Phone Shake Detection Class
I think it is cool to have a Windows Phone application that the content can be updated by shaking the phone, so I wrote this Class in order to achieve that!!
```CSharp
AccelerometerSensorWithShakeDetection _shakeSensor = new AccelerometerSensorWithShakeDetection();
public MainPage()
{
InitializeComponent();//in the costructor of the MainPage class, we call the SetUpEvent method, and we pass the MainPage Class as context scope, and the event we want to call
//when the device is Shacked
_shakeSensor.SetUpEvent(this, ShakeDetected);
}//created a custom event to call the method that contain the code to execute when the device is shaked
private void ShakeDetected(object sender, EventArgs e)
{
//use this method to call MethodToExecWhenTheDeviceIsShaked method in another thread, different from the accelerometer thread
_shakeSensor.DispatcherInvoke(MethodToExecWhenTheDeviceIsShaked);
}private void MethodToExecWhenTheDeviceIsShaked()
{
myStoryboard.Begin();
//plase here the code you want to exec when the device is shaked
}
```