/// <summary> /// The callback for when the zoom gesture is detected. /// </summary> /// <param name="e">Gesture event args</param> private void GestureZoomOutCallback(GestureEventArgs e) { ZoomOut(); DisplayStatus(String.Format("Gesture: {0} Detected", e.Name)); ResetGestureSyncTime(); }
/// <summary> /// The callback for when an unmapped gesture is detected. /// </summary> /// <param name="e">Gesture event args</param> private void GestureUnmappedCallback(GestureEventArgs e) { DisplayStatus(String.Format("Unmapped Gesture: {0} Detected", e.Name)); ResetGestureSyncTime(); }
/// <summary> /// The callback for when the Up Swipe gesture is detected. /// </summary> /// <param name="e">Gesture event args</param> private void GestureSwipeUpCallback(GestureEventArgs e) { MoveSouth(); DisplayStatus(String.Format("Gesture: {0} Detected", e.Name)); ResetGestureSyncTime(); }
/// <summary> /// Fires the appropriate callback when a gesture has been recognized /// </summary> /// <param name="sender">Event sender</param> /// <param name="e">GestureEventArgs containing the name of the recognized gesture</param> protected void OnGestureRecognized(object sender, GestureEventArgs e) { // If we just synced, set the flag and return if (e.Name == SyncGesture.Name) { m_syncContext.Post(new SendOrPostCallback(delegate(object state) { OnSynced(this, e); }), null); // We want to wait 2 seconds before looking for gestures again _detectingGestures = false; _timeoutTimer.Start(); // The engine does this but since this is event driven, the engine will // receive new frames before we have time to stop sending them for the // timeout duration. _engine.SupportedGestures.ForEach(x => x.Reset()); return; } if (GestureCallbacks.ContainsKey(e.Name)) { // We found a command, reset the timer ResetTimer(); // Throw the gesture event m_syncContext.Post(new SendOrPostCallback(delegate(object state) { GestureCallbacks[e.Name].Invoke(e); }), null); // Reset all the gesture states SupportedGestures.ForEach(x => x.Reset()); // We want to wait 2 seconds before looking for gestures again _detectingGestures = false; _timeoutTimer.Start(); } else { /* No one cares about this gesture =( */ } }
/// <summary> /// Raises when a gesture is detected from the list of gestures. /// </summary> /// <param name="e"></param> private void OnGestureDetected(GestureEventArgs e) { if (!popStatus.IsOpen) { m_pTimer.Interval = 2000; // 2 seconds m_pTimer.Elapsed += OnTimerElapsed; m_pTimer.Enabled = true; popStatus.IsOpen = true; lblStatus.Content = e.Name; } else { m_pTimer.Interval = 2000; lblStatus.Content = e.Name; } System.Media.SystemSounds.Beep.Play(); }
/// <summary> /// Fires the GestureRecognized event when a gesture is detected and resets /// the partially recognized states of all the supported gestures /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnGestureRecognized(object sender, GestureEventArgs e) { // If anyone is interested in the event, throw it if (GestureRecognized != null) { GestureRecognized(sender, e); } // Reset the current state of all the Gestures SupportedGestures.ForEach(x => x.Reset()); }