/// <summary> /// Helper function to register all available /// </summary> private void RegisterGestures() { IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[20]; JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1(); for (int i = 0; i < 20; i++) { // gesture consists of the same thing 10 times joinedhandsSegments[i] = joinedhandsSegment; } gestureController.AddGesture("JoinedHands", joinedhandsSegments); IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); gestureController.AddGesture("SwipeLeft", swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); gestureController.AddGesture("SwipeRight", swiperightSegments); IRelativeGestureSegment[] swipeUpSegments = new IRelativeGestureSegment[3]; swipeUpSegments[0] = new SwipeUpSegment1(); swipeUpSegments[1] = new SwipeUpSegment2(); swipeUpSegments[2] = new SwipeUpSegment3(); gestureController.AddGesture("SwipeUp", swipeUpSegments); }
/// <summary> /// Helper function to register all available /// </summary> #region registergestures private void RegisterGestures() { // define the gestures for the demo IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[20]; JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1(); for (int i = 0; i < 20; i++) { // gesture consists of the same thing 10 times joinedhandsSegments[i] = joinedhandsSegment; } gestureController.AddGesture("JoinedHands", joinedhandsSegments); IRelativeGestureSegment[] menuSegments = new IRelativeGestureSegment[20]; MenuSegment1 menuSegment = new MenuSegment1(); for (int i = 0; i < 20; i++) { // gesture consists of the same thing 20 times menuSegments[i] = menuSegment; } gestureController.AddGesture("Menu", menuSegments); IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); gestureController.AddGesture("SwipeLeft", swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); gestureController.AddGesture("SwipeRight", swiperightSegments); IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[6]; WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1(); WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2(); waveRightSegments[0] = waveRightSegment1; waveRightSegments[1] = waveRightSegment2; waveRightSegments[2] = waveRightSegment1; waveRightSegments[3] = waveRightSegment2; waveRightSegments[4] = waveRightSegment1; waveRightSegments[5] = waveRightSegment2; gestureController.AddGesture("WaveRight", waveRightSegments); IRelativeGestureSegment[] waveLeftSegments = new IRelativeGestureSegment[6]; WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1(); WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2(); waveLeftSegments[0] = waveLeftSegment1; waveLeftSegments[1] = waveLeftSegment2; waveLeftSegments[2] = waveLeftSegment1; waveLeftSegments[3] = waveLeftSegment2; waveLeftSegments[4] = waveLeftSegment1; waveLeftSegments[5] = waveLeftSegment2; gestureController.AddGesture("WaveLeft", waveLeftSegments); IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3]; zoomInSegments[0] = new ZoomSegment1(); zoomInSegments[1] = new ZoomSegment2(); zoomInSegments[2] = new ZoomSegment3(); gestureController.AddGesture("ZoomIn", zoomInSegments); IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3]; zoomOutSegments[0] = new ZoomSegment3(); zoomOutSegments[1] = new ZoomSegment2(); zoomOutSegments[2] = new ZoomSegment1(); gestureController.AddGesture("ZoomOut", zoomOutSegments); IRelativeGestureSegment[] swipeUpSegments = new IRelativeGestureSegment[3]; swipeUpSegments[0] = new SwipeUpSegment1(); swipeUpSegments[1] = new SwipeUpSegment2(); swipeUpSegments[2] = new SwipeUpSegment3(); gestureController.AddGesture("SwipeUp", swipeUpSegments); IRelativeGestureSegment[] swipeDownSegments = new IRelativeGestureSegment[3]; swipeDownSegments[0] = new SwipeDownSegment1(); swipeDownSegments[1] = new SwipeDownSegment2(); swipeDownSegments[2] = new SwipeDownSegment3(); gestureController.AddGesture("SwipeDown", swipeDownSegments); }
/// <summary> /// Helper function to register all available /// </summary> private void RegisterGestures() { // define the gestures for the demo IRelativeGestureSegment[] mouseClick = new IRelativeGestureSegment[2]; mouseClick[0] = new MouseClick(); mouseClick[1] = new MouseClick2(); gestureController.AddGesture("MouseClick", mouseClick); IRelativeGestureSegment[] mouseDownSegments = new IRelativeGestureSegment[2]; mouseDownSegments[0] = new MouseDown(); mouseDownSegments[1] = new MouseDown2(); gestureController.AddGesture("MouseDown", mouseDownSegments); IRelativeGestureSegment[] mouseUpSegments = new IRelativeGestureSegment[2]; mouseUpSegments[0] = new MouseUp(); mouseUpSegments[1] = new MouseUp2(); gestureController.AddGesture("MouseUp", mouseUpSegments); IRelativeGestureSegment[] handtoear = new IRelativeGestureSegment[50]; for (int i = 0; i < handtoear.Count(); i++) { handtoear[i] = new HandToEar(); } gestureController.AddGesture("HandtoEar", handtoear); IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); gestureController.AddGesture("SwipeLeft", swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); gestureController.AddGesture("SwipeRight", swiperightSegments); IRelativeGestureSegment[] waveLeftSegments = new IRelativeGestureSegment[5]; WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1(); WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2(); waveLeftSegments[0] = waveLeftSegment1; waveLeftSegments[1] = waveLeftSegment2; waveLeftSegments[2] = waveLeftSegment1; waveLeftSegments[3] = waveLeftSegment2; // waveLeftSegments[4] = waveLeftSegment1; //waveLeftSegments[5] = waveLeftSegment2; gestureController.AddGesture("WaveLeft", waveLeftSegments); IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3]; zoomInSegments[0] = new ZoomSegment1(); zoomInSegments[1] = new ZoomSegment2(); zoomInSegments[2] = new ZoomSegment3(); gestureController.AddGesture("ZoomIn", zoomInSegments); IRelativeGestureSegment[] scrolldownsegments = new IRelativeGestureSegment[4]; scrolldownsegments[0] = new ScrollDown1(); scrolldownsegments[1] = new ScrollDown2(); scrolldownsegments[2] = new ScrollDown3(); scrolldownsegments[3] = new ScrollDown4(); gestureController.AddGesture("ScrollDown", scrolldownsegments); IRelativeGestureSegment[] scrollupsegments = new IRelativeGestureSegment[4]; scrollupsegments[0] = new ScrollUp1(); scrollupsegments[1] = new ScrollUp2(); scrollupsegments[2] = new ScrollUp3(); scrollupsegments[3] = new ScrollUp4(); gestureController.AddGesture("ScrollUp", scrollupsegments); /*IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3]; * zoomInSegments[0] = new ZoomSegment1(); * zoomInSegments[1] = new ZoomSegment2(); * zoomInSegments[2] = new ZoomSegment3(); * gestureController.AddGesture("ZoomIn", zoomInSegments); * * IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3]; * zoomOutSegments[0] = new ZoomSegment3(); * zoomOutSegments[1] = new ZoomSegment2(); * zoomOutSegments[2] = new ZoomSegment1(); * gestureController.AddGesture("ZoomOut", zoomOutSegments);*/ IRelativeGestureSegment[] swipeUpSegments = new IRelativeGestureSegment[3]; swipeUpSegments[0] = new SwipeUpSegment1(); swipeUpSegments[1] = new SwipeUpSegment2(); swipeUpSegments[2] = new SwipeUpSegment3(); gestureController.AddGesture("SwipeUp", swipeUpSegments); IRelativeGestureSegment[] swipeDownSegments = new IRelativeGestureSegment[3]; swipeDownSegments[0] = new SwipeDownSegment1(); swipeDownSegments[1] = new SwipeDownSegment2(); swipeDownSegments[2] = new SwipeDownSegment3(); gestureController.AddGesture("SwipeDown", swipeDownSegments); IRelativeGestureSegment[] volumeIncrease = new IRelativeGestureSegment[15]; for (int i = 0; i < volumeIncrease.Count(); i++) { volumeIncrease[i] = new volumeUp(); } gestureController.AddGesture("VolumeUp", volumeIncrease); IRelativeGestureSegment[] volumeDecrease = new IRelativeGestureSegment[15]; for (int i = 0; i < volumeDecrease.Count(); i++) { volumeDecrease[i] = new volumeDown(); } gestureController.AddGesture("VolumeDown", volumeDecrease); }
/// <summary> /// Adds the specified gesture for recognition. /// </summary> /// <param name="type">The predefined <see cref="GestureType" />.</param> public void AddGesture(GestureType type) { // Check whether the gesure is already added. if (_gestures.Where(g => g.GestureType == type).Count() > 0) { return; } IGestureSegment[] segments = null; // DEVELOPERS: If you add a new predefined gesture with a new GestureType, // simply add the proper segments to the switch statement here. switch (type) { case GestureType.JoinedHands: segments = new IGestureSegment[20]; JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1(); for (int i = 0; i < 20; i++) { segments[i] = joinedhandsSegment; } break; case GestureType.Menu: segments = new IGestureSegment[20]; MenuSegment1 menuSegment = new MenuSegment1(); for (int i = 0; i < 20; i++) { segments[i] = menuSegment; } break; case GestureType.SwipeDown: segments = new IGestureSegment[3]; segments[0] = new SwipeDownSegment1(); segments[1] = new SwipeDownSegment2(); segments[2] = new SwipeDownSegment3(); break; case GestureType.SwipeLeft: segments = new IGestureSegment[3]; segments[0] = new SwipeLeftSegment1(); segments[1] = new SwipeLeftSegment2(); segments[2] = new SwipeLeftSegment3(); break; case GestureType.SwipeRight: segments = new IGestureSegment[3]; segments[0] = new SwipeRightSegment1(); segments[1] = new SwipeRightSegment2(); segments[2] = new SwipeRightSegment3(); break; case GestureType.SwipeUp: segments = new IGestureSegment[3]; segments[0] = new SwipeUpSegment1(); segments[1] = new SwipeUpSegment2(); segments[2] = new SwipeUpSegment3(); break; case GestureType.WaveLeft: segments = new IGestureSegment[6]; WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1(); WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2(); segments[0] = waveLeftSegment1; segments[1] = waveLeftSegment2; segments[2] = waveLeftSegment1; segments[3] = waveLeftSegment2; segments[4] = waveLeftSegment1; segments[5] = waveLeftSegment2; break; case GestureType.WaveRight: segments = new IGestureSegment[6]; WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1(); WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2(); segments[0] = waveRightSegment1; segments[1] = waveRightSegment2; segments[2] = waveRightSegment1; segments[3] = waveRightSegment2; segments[4] = waveRightSegment1; segments[5] = waveRightSegment2; break; case GestureType.ZoomIn: segments = new IGestureSegment[3]; segments[0] = new ZoomSegment1(); segments[1] = new ZoomSegment2(); segments[2] = new ZoomSegment3(); break; case GestureType.ZoomOut: segments = new IGestureSegment[3]; segments[0] = new ZoomSegment3(); segments[1] = new ZoomSegment2(); segments[2] = new ZoomSegment1(); break; default: break; } if (segments != null) { Gesture gesture = new Gesture(type, segments); gesture.GestureRecognized += OnGestureRecognized; _gestures.Add(gesture); } }
/* * /// <summary> * /// Handles the GestureRecognised event of the g control. * /// </summary> * /// <param name="sender">The source of the event.</param> * /// <param name="e">The <see cref="KinectSkeltonTracker.GestureEventArgs"/> instance containing the event data.</param> * private void Gesture_GestureRecognised(object sender, GestureEventArgs e) * { * if (this.GestureRecognised != null) * { * this.GestureRecognised(this, e); * } * * foreach (Gesture g in this.gestures) * { * g.Reset(); * } * } */ public void DefineGesture() { /* * IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[6]; * WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1(); * WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2(); * waveRightSegments[0] = waveRightSegment1; * waveRightSegments[1] = waveRightSegment2; * waveRightSegments[2] = waveRightSegment1; * waveRightSegments[3] = waveRightSegment2; * waveRightSegments[4] = waveRightSegment1; * waveRightSegments[5] = waveRightSegment2; * this.gestures.AddGesture(GestureType.WaveRight, waveRightSegments); * * IRelativeGestureSegment[] waveLeftSegments = new IRelativeGestureSegment[6]; * WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1(); * WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2(); * waveLeftSegments[0] = waveLeftSegment1; * waveLeftSegments[1] = waveLeftSegment2; * waveLeftSegments[2] = waveLeftSegment1; * waveLeftSegments[3] = waveLeftSegment2; * waveLeftSegments[4] = waveLeftSegment1; * waveLeftSegments[5] = waveLeftSegment2; * this.gestures.AddGesture(GestureType.WaveLeft, waveLeftSegments); */ IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); this.AddGesture(GestureType.LeftSwipe, swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); this.AddGesture(GestureType.RightSwipe, swiperightSegments); IRelativeGestureSegment[] swipeupSegments = new IRelativeGestureSegment[3]; swipeupSegments[0] = new SwipeUpSegment1(); swipeupSegments[1] = new SwipeUpSegment2(); swipeupSegments[2] = new SwipeUpSegment3(); this.AddGesture(GestureType.UpSwipe, swipeupSegments); IRelativeGestureSegment[] swipedownSegments = new IRelativeGestureSegment[3]; swipedownSegments[0] = new SwipeDownSegment1(); swipedownSegments[1] = new SwipeDownSegment2(); swipedownSegments[2] = new SwipeDownSegment3(); this.AddGesture(GestureType.DownSwipe, swipedownSegments); /* * IRelativeGestureSegment[] menuSegments = new IRelativeGestureSegment[20]; * MenuSegments1 menuSegment = new MenuSegments1(); * for (int i = 0; i < 20; i++) * { * // gesture consists of the same thing 20 times * menuSegments[i] = menuSegment; * } * * this.gestures.AddGesture(GestureType.Menu, menuSegments); */ }
/// <summary> /// Helper function to register all available /// </summary> private void RegisterGestures() { // define the gestures for the demo IRelativeGestureSegment[] mouseClick = new IRelativeGestureSegment[2]; mouseClick[0] = new MouseClick(); mouseClick[1] = new MouseClick2(); gestureController.AddGesture("MouseClick", mouseClick); IRelativeGestureSegment[] mouseDownSegments = new IRelativeGestureSegment[2]; mouseDownSegments[0] = new MouseDown(); mouseDownSegments[1] = new MouseDown2(); gestureController.AddGesture("MouseDown", mouseDownSegments); IRelativeGestureSegment[] mouseUpSegments = new IRelativeGestureSegment[2]; mouseUpSegments[0] = new MouseUp(); mouseUpSegments[1] = new MouseUp2(); gestureController.AddGesture("MouseUp", mouseUpSegments); IRelativeGestureSegment[] handtoear = new IRelativeGestureSegment[50]; for (int i = 0; i < handtoear.Count(); i++) { handtoear[i] = new HandToEar(); } gestureController.AddGesture("HandtoEar", handtoear); IRelativeGestureSegment[] joinedhandsSegments = new IRelativeGestureSegment[20]; JoinedHandsSegment1 joinedhandsSegment = new JoinedHandsSegment1(); for (int i = 0; i < 20; i++) { // gesture consists of the same thing 10 times joinedhandsSegments[i] = joinedhandsSegment; } gestureController.AddGesture("JoinedHands", joinedhandsSegments); IRelativeGestureSegment[] menuSegments = new IRelativeGestureSegment[20]; MenuSegment1 menuSegment = new MenuSegment1(); for (int i = 0; i < 20; i++) { // gesture consists of the same thing 20 times menuSegments[i] = menuSegment; } gestureController.AddGesture("Menu", menuSegments); IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); gestureController.AddGesture("SwipeLeft", swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); gestureController.AddGesture("SwipeRight", swiperightSegments); IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[6]; WaveRightSegment1 waveRightSegment1 = new WaveRightSegment1(); WaveRightSegment2 waveRightSegment2 = new WaveRightSegment2(); waveRightSegments[0] = waveRightSegment1; waveRightSegments[1] = waveRightSegment2; waveRightSegments[2] = waveRightSegment1; waveRightSegments[3] = waveRightSegment2; waveRightSegments[4] = waveRightSegment1; waveRightSegments[5] = waveRightSegment2; gestureController.AddGesture("WaveRight", waveRightSegments); IRelativeGestureSegment[] waveLeftSegments = new IRelativeGestureSegment[5]; WaveLeftSegment1 waveLeftSegment1 = new WaveLeftSegment1(); WaveLeftSegment2 waveLeftSegment2 = new WaveLeftSegment2(); waveLeftSegments[0] = waveLeftSegment1; waveLeftSegments[1] = waveLeftSegment2; waveLeftSegments[2] = waveLeftSegment1; waveLeftSegments[3] = waveLeftSegment2; waveLeftSegments[4] = waveLeftSegment1; //waveLeftSegments[5] = waveLeftSegment2; gestureController.AddGesture("WaveLeft", waveLeftSegments); IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3]; zoomInSegments[0] = new ZoomSegment1(); zoomInSegments[1] = new ZoomSegment2(); zoomInSegments[2] = new ZoomSegment3(); gestureController.AddGesture("ZoomIn", zoomInSegments); IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3]; zoomOutSegments[0] = new ZoomSegment3(); zoomOutSegments[1] = new ZoomSegment2(); zoomOutSegments[2] = new ZoomSegment1(); gestureController.AddGesture("ZoomOut", zoomOutSegments); IRelativeGestureSegment[] swipeUpSegments = new IRelativeGestureSegment[3]; swipeUpSegments[0] = new SwipeUpSegment1(); swipeUpSegments[1] = new SwipeUpSegment2(); swipeUpSegments[2] = new SwipeUpSegment3(); gestureController.AddGesture("SwipeUp", swipeUpSegments); IRelativeGestureSegment[] swipeDownSegments = new IRelativeGestureSegment[3]; swipeDownSegments[0] = new SwipeDownSegment1(); swipeDownSegments[1] = new SwipeDownSegment2(); swipeDownSegments[2] = new SwipeDownSegment3(); gestureController.AddGesture("SwipeDown", swipeDownSegments); }