Beispiel #1
0
        /// <summary>
        /// Handles the SkeletonReady event of the kinect control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="KinectSkeltonTracker.SkeletonEventArgs"/> instance containing the event data.</param>
        private void Kinect_SkeletonReady(object sender, SkeletonEventArgs e)
        {
            //Console.WriteLine("EH: Kinect_SkeletonReady()");
            if (this.skeletonDictionary.ContainsKey(e.Skeleton.TrackingId))
            {
                this.skeletonDictionary[e.Skeleton.TrackingId].Skeleton = e.Skeleton;
                this.skeletonDictionary[e.Skeleton.TrackingId].ResetTimer();
            }
            else
            {
                SkeletonViewModel viewModel = new SkeletonViewModel();
                viewModel.Skeleton = e.Skeleton;
                viewModel.JointColor = availableColors[colorID];
                if (colorID == availableColors.Length - 1)
                {
                    colorID = 0;
                }
                else
                {
                    colorID += 1;
                }

                this.skeletonDictionary.Add(e.Skeleton.TrackingId, viewModel);
                this.Skeletons.Add(viewModel);
                viewModel.DeleteSkeleton += new EventHandler(this.ViewModel_DeleteSkeleton);
            }
        }