CCT.NUI.WPFSamples.KinectTouchWindow.handDataSource_NewDataAvailable C# (CSharp) Метод

handDataSource_NewDataAvailable() приватный Метод

private handDataSource_NewDataAvailable ( HandCollection data ) : void
data HandCollection
Результат void
        private void handDataSource_NewDataAvailable(HandCollection data)
        {
            if (data.HandsDetected)
            {
                var hand = data.Hands.Last();

                var location = MapToScreen(hand.Location);

                //if (hand.HasPalmPoint)
                //{
                //    location = MapToScreen(hand.PalmPoint.Value);
                //}
                //else
                //{
                //    return;
                //}

                Debug.WriteLine("timespan: {0}, fingerCount: {2}, lastFingerCount: {3}, location: {4}",
                    DateTime.Now - lastUpdate,
                    lastUpdate,
                    hand.FingerCount,
                    lastFingerCount,
                    location);

                if (DateTime.Now > lastUpdate.AddMilliseconds(100))
                {
                    lastUpdate = DateTime.Now;

                    int x = (int)location.X,
                        y = (int)location.Y;

                    //set mouse position
                    MouseController.SendMouseInput(x, y, ScreenWidth, ScreenHeight, false);

                    var fingerCountChanged = lastFingerCount != hand.FingerCount;
                    lastFingerCount = hand.FingerCount;

                    if (fingerCountChanged)
                    {
                        if (hand.FingerCount == TouchGestureFingerCount)
                        {
                            //start
                            OnTouchStart(x, y);
                        }
                        else if (hand.FingerCount == MoveGestureFingerCount)
                        {
                            //end
                            OnTouchEnd(x, y);
                        }
                    }
                    else if (hand.FingerCount == TouchGestureFingerCount)
                    {
                        // update touch
                        OnTouchMove(x, y);
                    }
                }

                this.Dispatcher.Invoke(() =>
                                           {
                                               this.labelHandLocation.Content = location.ToString();
                                               this.labelFingerCount.Content = hand.FingerCount;
                                           });
            }
        }