コード例 #1
0
 void kinectService_SkeletonUpdated(object sender, SkeletonUpdatedEventArgs e)
 {
     this.AnalyzeSkeleton(e);
 }
コード例 #2
0
        void AnalyzeSkeleton(SkeletonUpdatedEventArgs e)
        {
            if (e.HandRight.Position.Y > e.HipRight.Position.Y &&
                e.HandRight.Position.Y < e.Head.Position.Y &&
                e.HandRight.Position.X > (e.HipRight.Position.X + .2f)
                )
            {
                // adjust Y values so that head is at zero of y axis
                var hand = e.HandRight.Position.Y - e.Head.Position.Y;
                var hip = e.HipRight.Position.Y - e.Head.Position.Y;
                var result = hand / hip;

                var fraction = 1d / this.MenuItems.Count;

                for (var i = 1; i <= this.MenuItems.Count; i++)
                {
                    if (fraction * i > result)
                    {
                        var item = this.MenuItems[i - 1];
                        if (selectedItem != item)
                        {
                            if (selectedItem != null)
                            {
                                this.selectedItem.IsSelected = false;
                            }
                            this.selectedItem = this.MenuItems[i - 1];
                            this.selectedItem.IsSelected = true;
                        }
                        break;
                    }
                }
            }
            //else
            //{
            //    if (this.selectedItem != null)
            //    {
            //        this.selectedItem.IsSelected = false;
            //        this.selectedItem = null;
            //    }
            //}
        }