public void Shutdown()
 {
     if (this.sensor != null)
     {
         //this.sensor.SkeletonFrameReady -= runtime_SkeletonFrameReady;
         this.sensor.AllFramesReady -= this.sensor_AllFramesReady;
         if (this.initialized)
         {
             this.sensor.Stop();
             InfoLogWriter.WriteMessage("Kinect runtime uninitialized.");
             this.sensor = null;
         }
     }
 }
        void sensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
        {
            using (this.skeletonFrame = e.OpenSkeletonFrame())
            {
                if (this.skeletonFrame == null)
                {
                    return;
                }

                var depthFrame = e.OpenDepthImageFrame();
                if (depthFrame != null)
                {
                    this.LastDepthBitmap = depthFrame.ToBitmapSource();
                    depthFrame.Dispose();
                }

                this.skeletonFrame.CopySkeletonDataTo(this.sensorSkeletons);

                var trackedSkeletons = this.sensorSkeletons.Where(s =>
                                                                  s.TrackingState == SkeletonTrackingState.Tracked);

                var count = trackedSkeletons.Count();

                if (count == Zero)
                {
                    this.currentTrackingId = int.MinValue;
                    return;
                }

                var trackedSkeleton =
                    trackedSkeletons.Where(s => s.TrackingId == this.currentTrackingId).FirstOrDefault();

                if (trackedSkeleton == null) // new user
                {
                    trackedSkeleton        = trackedSkeletons.FirstOrDefault();
                    this.currentTrackingId = trackedSkeleton.TrackingId;
                    InfoLogWriter.WriteMessage("Started tracking new user with ID '" + this.currentTrackingId.ToString() + "'");
                }

                this.UserIsInRange = this.GetUserIsInRange(trackedSkeleton.Joints[JointType.Spine]);

                if (this.UserIsInRange || this.IsInConfigMode)
                {
                    this.ProcessSkeleton(trackedSkeleton);
                }
            }
        }
 void nuiService_UserEnteredBounds(object sender, EventArgs e)
 {
     InfoLogWriter.WriteMessage("ExplorerViewModel: User entered bounds.");
     this.userIsInRange = true;
 }