private void Draw(Joint joint, Joint joint2) { var line = new Line(); line.X1 = (((((float)skeletonCanvas.ActualWidth) / (skeletonCanvas.ActualWidth / 1000)) / 2f) * joint.Position.X) + (skeletonCanvas.ActualWidth / 2); line.Y1 = (((((float)skeletonCanvas.ActualHeight) / (skeletonCanvas.ActualWidth / 1000)) / 2f) * -joint.Position.Y) + (skeletonCanvas.ActualHeight / 2); line.X2 = (((((float)skeletonCanvas.ActualWidth) / (skeletonCanvas.ActualWidth / 1000)) / 2f) * joint2.Position.X) + (skeletonCanvas.ActualWidth / 2); line.Y2 = (((((float)skeletonCanvas.ActualHeight) / (skeletonCanvas.ActualWidth / 1000)) / 2f) * -joint2.Position.Y) + (skeletonCanvas.ActualHeight / 2); line.Stroke = brush; line.StrokeThickness = 5; skeletonCanvas.Children.Add(line); }
private static void CheckMoves(Skeleton skeleton) { leftHand = skeleton.Joints[JointType.HandLeft]; rightHand = skeleton.Joints[JointType.HandRight]; shoulderCenter = skeleton.Joints[JointType.ShoulderCenter]; trackingId = skeleton.TrackingID; // Check if left hand is active. if (shoulderCenter.Position.Z - leftHand.Position.Z < 0.25) { leftHandActive = false; leftHandPositions.Clear(); } else if (!rightHandActive) { leftHandActive = true; leftHandPositions.Add(leftHand.Position); } // Check if right hand is active. if (shoulderCenter.Position.Z - rightHand.Position.Z < 0.25) { rightHandActive = false; rightHandPositions.Clear(); } else if (!leftHandActive) { rightHandActive = true; rightHandPositions.Add(rightHand.Position); } // When no hands are active, reset all starting points and reset swiping directions. if (!leftHandActive && !rightHandActive) { horizontalStartPoint = null; verticalStartPoint = null; horizontalDirection = SwipeDirection.None; verticalDirection = SwipeDirection.None; } else { if (rightHandActive) { // Check for horizontal swipes if the right hand is higher than the spine. if (rightHand.Position.Y > skeleton.Joints[JointType.Spine].Position.Y) CheckHorizontalSwipes(Hand.Right); // Check for vertical swipes. if (SwipeUp != null || SwipeDown != null) CheckVerticalSwipes(Hand.Right); } if (leftHandActive) { // Check for horizontal swipes if the left hand is higher than the spine. if (leftHand.Position.Y > skeleton.Joints[JointType.Spine].Position.Y) CheckHorizontalSwipes(Hand.Left); // Check for vertical swipes. if (SwipeUp != null || SwipeDown != null) CheckVerticalSwipes(Hand.Left); } } }