/// <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); }
public SwipeRightHand(bool right = true) { SwipeRightSegment1 swipeRightSegment1 = new SwipeRightSegment1(); SwipeRightSegment2 swipeRightSegment2 = new SwipeRightSegment2(); SwipeRightSegment3 swipeRightSegment3 = new SwipeRightSegment3(); if (right) { _segments = new IGestureSegment[] { swipeRightSegment1, swipeRightSegment2, swipeRightSegment3 }; } else { _segments = new IGestureSegment[] { swipeRightSegment3, swipeRightSegment2, swipeRightSegment1 }; } }
/// <summary> /// Defines the gestures. /// </summary> private void DefineGestures() { 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.gestures.AddGesture(GestureType.LeftSwipe, swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); this.gestures.AddGesture(GestureType.RightSwipe, swiperightSegments); 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[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); gestureController.AddGesture("SwipeRight", swiperightSegments); IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); gestureController.AddGesture("SwipeLeft", swipeleftSegments); }
/// <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> /// Initializes a new instance of the <see cref="GestureController"/> class. /// </summary> public GestureController() { // Define the gestures 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; } AddGesture(GestureType.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; } AddGesture(GestureType.Menu, menuSegments); IRelativeGestureSegment[] swipeleftSegments = new IRelativeGestureSegment[3]; swipeleftSegments[0] = new SwipeLeftSegment1(); swipeleftSegments[1] = new SwipeLeftSegment2(); swipeleftSegments[2] = new SwipeLeftSegment3(); AddGesture(GestureType.SwipeLeft, swipeleftSegments); IRelativeGestureSegment[] swiperightSegments = new IRelativeGestureSegment[3]; swiperightSegments[0] = new SwipeRightSegment1(); swiperightSegments[1] = new SwipeRightSegment2(); swiperightSegments[2] = new SwipeRightSegment3(); AddGesture(GestureType.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; 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; AddGesture(GestureType.WaveLeft, waveLeftSegments); IRelativeGestureSegment[] zoomInSegments = new IRelativeGestureSegment[3]; zoomInSegments[0] = new ZoomSegment1(); zoomInSegments[1] = new ZoomSegment2(); zoomInSegments[2] = new ZoomSegment3(); AddGesture(GestureType.ZoomIn, zoomInSegments); IRelativeGestureSegment[] zoomOutSegments = new IRelativeGestureSegment[3]; zoomOutSegments[0] = new ZoomSegment3(); zoomOutSegments[1] = new ZoomSegment2(); zoomOutSegments[2] = new ZoomSegment1(); AddGesture(GestureType.ZoomOut, zoomOutSegments); }
/// <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> /// 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.CrossedHands: segments = new IGestureSegment[8]; CrossHandsSegment1 segment = new CrossHandsSegment1(); for (int i = 0; i < 8; i++) { segments[i] = segment; } break; case GestureType.HandsAboveHead: segments = new IGestureSegment[8]; HandsAboveHeadSegment1 segment_hand_head = new HandsAboveHeadSegment1(); for (int i = 0; i < 8; i++) { segments[i] = segment_hand_head; } break; case GestureType.SwipeLeftReversed: segments = new IGestureSegment[3]; segments[0] = new SwipeLeftReversedSegment3(); segments[1] = new SwipeLeftReversedSegment2(); segments[2] = new SwipeLeftReversedSegment1(); break; case GestureType.SwipeLeftSupport: segments = new IGestureSegment[3]; segments[0] = new SwipeLeftReversedSegment1(); segments[1] = new SwipeLeftReversedSegment2(); segments[2] = new SwipeLeftReversedSegment3(); break; case GestureType.SwipeLeft: segments = new IGestureSegment[3]; segments[0] = new SwipeLeftSegment1(); segments[1] = new SwipeLeftSegment2(); segments[2] = new SwipeLeftSegment3(); break; case GestureType.SwipeRightReversed: segments = new IGestureSegment[3]; segments[0] = new SwipeRightSegment3(); segments[1] = new SwipeRightSegment2(); segments[2] = new SwipeRightSegment1(); break; case GestureType.SwipeRight: segments = new IGestureSegment[3]; segments[0] = new SwipeRightSegment1(); segments[1] = new SwipeRightSegment2(); segments[2] = new SwipeRightSegment3(); break; case GestureType.ZoomIn: segments = new IGestureSegment[3]; segments[0] = new ZoomInSegment1(); segments[1] = new ZoomInSegment2(); segments[2] = new ZoomInSegment3(); break; case GestureType.ZoomOut: segments = new IGestureSegment[3]; segments[0] = new ZoomOutSegment1(); segments[1] = new ZoomOutSegment2(); segments[2] = new ZoomOutSegment3(); break; default: break; } if (segments != null) { Gesture gesture = new Gesture(type, segments); gesture.GestureRecognized += OnGestureRecognized; _gestures.Add(gesture); } }
private void RegisterGestures() { 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[] 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 SwipeVerticalSegment1(); swipeUpSegments[1] = new SwipeVerticalSegment2(); swipeUpSegments[2] = new SwipeVerticalSegment3(); gestureController.AddGesture("SwipeUp", swipeUpSegments); IRelativeGestureSegment[] swipeDownSegments = new IRelativeGestureSegment[3]; swipeDownSegments[0] = new SwipeVerticalSegment3(); swipeDownSegments[1] = new SwipeVerticalSegment2(); swipeDownSegments[2] = new SwipeVerticalSegment1(); gestureController.AddGesture("SwipeDown", swipeDownSegments); IRelativeGestureSegment[] hideWindowSegments = new IRelativeGestureSegment[3]; hideWindowSegments[0] = new HideWindowSegment1(); hideWindowSegments[1] = new HideWindowSegment2(); hideWindowSegments[2] = new HideWindowSegment3(); gestureController.AddGesture("HideWindow", hideWindowSegments); IRelativeGestureSegment[] showWindowSegments = new IRelativeGestureSegment[3]; showWindowSegments[0] = new HideWindowSegment3(); showWindowSegments[1] = new HideWindowSegment2(); showWindowSegments[2] = new HideWindowSegment1(); gestureController.AddGesture("ShowWindow", showWindowSegments); IRelativeGestureSegment[] waveRightSegments = new IRelativeGestureSegment[20]; for (int i = 0; i < 20; i = i + 2) { if (i % 4 == 0) { for (int j = i; j < i + 2; j++) { waveRightSegments[j] = new WaveRightSegment1(); } } else { for (int j = i; j < i + 2; j++) { waveRightSegments[j] = new WaveRightSegment2(); } } } gestureController.AddGesture("WaveRight", waveRightSegments); }
/* * /// <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); }