static MoveGesture() { leftHandPositions = new List<SkeletonPoint>(); rightHandPositions = new List<SkeletonPoint>(); // Initialize timers. // If there is no event fired after 250 milliseconds of setting a starting point, // the tick event will reset the parameters. Deployment.Current.Dispatcher.BeginInvoke(() => { horizontalTimer = new DispatcherTimer(); horizontalTimer.Interval = new TimeSpan(0, 0, 0, 0, 250); // 250 Milliseconds horizontalTimer.Tick += (o, e) => { horizontalDirection = SwipeDirection.None; horizontalStartPoint = null; horizontalTimer.Stop(); }; verticalTimer = new DispatcherTimer(); verticalTimer.Interval = new TimeSpan(0, 0, 0, 0, 250); // 250 Milliseconds verticalTimer.Tick += (o, e) => { verticalDirection = SwipeDirection.None; verticalStartPoint = null; verticalTimer.Stop(); }; }); sensor = Move.Sensor; if (sensor.IsRunning) { KinectRunning = true; sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady); } }
/// <summary> /// Gets a kinectSensor instance. /// </summary> /// <returns>A kinectSensor instance.</returns> public static KinectSensor GetKinectSensor() { if (sensor == null) sensor = new KinectSensor(); return sensor; }
private void start_Click(object sender, RoutedEventArgs e) { //1. Working with the Kinect sensor. sensor = KinectSensor.GetKinectSensor(); sensor.KinectInitializeFailed += new EventHandler<KinectInitializeArgs>(sensor_KinectInitializeFailed); if (!sensor.IsRunning) sensor.Start(KinectSensorOptions.UseSkeleton | KinectSensorOptions.UseColor | KinectSensorOptions.UseDepth); // Not yet working. // //if (!sensor.ColorStream.IsEnabled) // sensor.ColorStream.Enable(ImageType.Color, ImageResolution.Resolution640x480); //sensor.ColorFrameReady += new EventHandler<ImageFrameReadyEventArgs>(sensor_ColorFrameReady); //if (!sensor.DepthStream.IsEnabled) // sensor.DepthStream.Enable(ImageType.Depth); //sensor.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(sensor_DepthFrameReady); if (!sensor.SkeletonStream.IsEnabled) sensor.SkeletonStream.Enable(); sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady); // 2. Working with events if (!Move.KinectRunning) { MessageBox.Show("Not running"); Application.Current.MainWindow.Close(); } // HAND MOVES //Move.MoveLeftHandDown += new MoveEventHandler(Move_MoveLeftHandDown); //Move.MoveLeftHandUp += new MoveEventHandler(Move_MoveLeftHandUp); //Move.MoveLeftHandNavigating += new MoveEventHandler(Move_MoveLeftHandNavigating); //Move.MoveRightHandDown += new MoveEventHandler(Move_MoveRightHandDown); //Move.MoveRightHandUp += new MoveEventHandler(Move_MoveRightHandUp); //Move.MoveRightHandNavigating += new MoveEventHandler(Move_MoveRightHandNavigating); // TRANSFORMATIONS //Move.Scale += new ScaleEventHandler(Move_ScaleMove); //Move.Rotate += new RotateEventHandler(Move_RotateMove); //Move.Translate += new TranslateEventHandler(Move_TranslateMove); // ALL IN ONE TRANFORMATION Move.Transform += new TransformEventHandler(Move_TransformMove); // SWIPES //MoveGesture.SwipeDown += new MoveGestureEventHandler(MoveGesture_SwipeDown); //MoveGesture.SwipeLeft += new MoveGestureEventHandler(MoveGesture_SwipeLeft); //MoveGesture.SwipeRight += new MoveGestureEventHandler(MoveGesture_SwipeRight); //MoveGesture.SwipeUp += new MoveGestureEventHandler(MoveGesture_SwipeUp); }