KinectWithVRServer.MainWindow.DrawHandStateOnColor C# (CSharp) Method

DrawHandStateOnColor() private method

private DrawHandStateOnColor ( 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 DrawHandStateOnColor(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].MapJointToColor(joint, false);

                //Don't draw points that are off the image
                if (point.X < 0 || point.Y < 0 || point.X >= colorSource.PixelWidth || point.Y >= colorSource.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 / colorSource.PixelWidth) * ColorImage.ActualWidth + offset.X;
                imagePoint.Y = ((double)point.Y / colorSource.PixelHeight) * ColorImage.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;
                ColorImageCanvas.Children.Add(circle);
            }
        }
MainWindow