KinectWithVRServer.MainWindow.DrawHandStateOnDepth C# (CSharp) Method

DrawHandStateOnDepth() private method

private DrawHandStateOnDepth ( Microsoft.Kinect.Joint joint, bool handState, double radius, Point offset, int kinectID ) : void
joint Microsoft.Kinect.Joint
handState bool
radius double
offset Point
kinectID int
return void
        private void DrawHandStateOnDepth(Joint joint, bool handState, double radius, Point offset, int kinectID)
        {
            if (joint.TrackingState == TrackingState.Tracked)
            {
                //Map the joint from the skeleton to the depth image
                Point point = server.kinects[kinectID].MapJointToDepth(joint, false);

                //Don't draw points that are off the image
                if (point.X < 0 || point.Y < 0 || point.X >= depthSource.PixelWidth || point.Y >= depthSource.PixelHeight)
                {
                    return;
                }

                //Calculate the coordinates on the image (the offset is also added in this section)
                Point imagePoint = new Point(0.0, 0.0);
                imagePoint.X = ((double)point.X / depthSource.PixelWidth) * DepthImage.ActualWidth + offset.X;
                imagePoint.Y = ((double)point.Y / depthSource.PixelHeight) * DepthImage.ActualHeight + offset.Y;

                //Generate the circle for the hand
                Ellipse circle = new Ellipse();
                if (handState)
                {
                    circle.Stroke = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    circle.Stroke = new SolidColorBrush(Colors.Green);
                }
                circle.Fill = new SolidColorBrush(Colors.Transparent);
                circle.StrokeThickness = 1.0;
                circle.Margin = new Thickness(imagePoint.X - radius, imagePoint.Y - radius, 0, 0);
                circle.HorizontalAlignment = HorizontalAlignment.Left;
                circle.VerticalAlignment = VerticalAlignment.Top;
                circle.Height = radius * 2;
                circle.Width = radius * 2;
                DepthImageCanvas.Children.Add(circle);
            }
        }
MainWindow