Microsoft.Samples.Kinect.RecordAndPlaybackBasics.KinectBodyView.DrawBody C# (CSharp) Method

DrawBody() private method

Draws a body
private DrawBody ( Joint>.IReadOnlyDictionary joints, Point>.IDictionary jointPoints, System.Windows.Media.DrawingContext drawingContext, System.Windows.Media.Pen drawingPen ) : void
joints Joint>.IReadOnlyDictionary joints to draw
jointPoints Point>.IDictionary translated positions of joints to draw
drawingContext System.Windows.Media.DrawingContext drawing context to draw to
drawingPen System.Windows.Media.Pen specifies color to draw a specific body
return void
        private void DrawBody(IReadOnlyDictionary<JointType, Joint> joints, IDictionary<JointType, Point> jointPoints, DrawingContext drawingContext, Pen drawingPen)
        {
            // Draw the bones
            foreach (var bone in this.bones)
            {
                this.DrawBone(joints, jointPoints, bone.Item1, bone.Item2, drawingContext, drawingPen);
            }

            // Draw the joints
            foreach (JointType jointType in joints.Keys)
            {
                Brush drawBrush = null;

                TrackingState trackingState = joints[jointType].TrackingState;

                if (trackingState == TrackingState.Tracked)
                {
                    drawBrush = this.trackedJointBrush;
                }
                else if (trackingState == TrackingState.Inferred)
                {
                    drawBrush = this.inferredJointBrush;
                }

                if (drawBrush != null)
                {
                    drawingContext.DrawEllipse(drawBrush, null, jointPoints[jointType], JointThickness, JointThickness);
                }
            }
        }