protected virtual void OnFrameDrawn(DrawingFrameEventArgs e) { if (FrameDrawn != null) { FrameDrawn(this, e); } }
protected virtual void OnDrawingFrame(DrawingFrameEventArgs e) { if (DrawingFrame != null) { DrawingFrame(this, e); } }
/// <summary> /// High-level code to call when you really only want to draw one body frame at a time. /// </summary> /// <param name="Frame"></param> void drawBodyFromFrame(GesturePak.Frame Frame) { try { var mapper = KinectSensor.GetDefault().CoordinateMapper; using (DrawingContext dc = this.drawingGroup.Open()) { // Draw a transparent background to set the render size dc.DrawRectangle(Brushes.Transparent, null, new Rect(0.0, 0.0, this.displayWidth, this.displayHeight)); // draw the body var joints = (Dictionary <JointType, Joint>)Frame.Joints; Dictionary <JointType, Point> jointPoints = new Dictionary <JointType, Point>(); foreach (JointType jointType in joints.Keys) { DepthSpacePoint depthSpacePoint = mapper.MapCameraPointToDepthSpace(joints[jointType].Position); jointPoints[jointType] = new Point(depthSpacePoint.X, depthSpacePoint.Y); } var args = new DrawingFrameEventArgs(Frame, jointPoints, dc); OnDrawingFrame(args); this.DrawBodyGP(Frame, jointPoints, dc); // just draw the hands if (DrawHandsEnabled == true) { this.DrawHand(Frame.LeftHandState, jointPoints[JointType.HandLeft], dc); this.DrawHand(Frame.RightHandState, jointPoints[JointType.HandRight], dc); } OnFrameDrawn(args); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }