public DrawingClass() { TmpPath = Directory.GetCurrentDirectory() + "\\Tmp"; if (!Directory.Exists(TmpPath)) { // Create The Directory if not exist Directory.CreateDirectory(TmpPath); } lines = new List <Line>(); pivots = new List <Pivot>(); piv = new PivotO(100, 100); Line tmp; f = new Face(100, 100, 20); lines.Add(new Line(100f, 100f, 60, Radians(90))); // 0 chest lines.Add(new Line(100f, 100f, 60, Radians(30))); // 1 rhand lines.Add(new Line(100f, 100f, 60, Radians(150))); // 2 lhand DrawLine(0, 30); // 3 rleg DrawLine(0, 150); // 4 lleg DrawLine(1, 270); // 5 rhand wrist DrawLine(2, 270); // 6 lhand wrist DrawLine(3, 90); // 7 lleg foot DrawLine(4, 90); // 8 rleg foot for (int i = 0; i <= 8; i++) { tmp = lines[i]; pivots.Add(new Pivot((int)tmp.ex, (int)tmp.ey, ref tmp)); } SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); }
bool DistanceBtwO(Point p, PivotO joint) { bool ret = false; double x = p.X - joint.x; double y = p.Y - joint.y; x *= x; y *= y; if (Math.Sqrt(x + y) <= 2 * joint.r) { ret = true; } return(ret); }
protected override void OnMouseDown(MouseEventArgs e) { moving = true; if (DistanceBtwO(e.Location, piv)) { selPo = piv; } for (int i = 0; i < pivots.Count; i++) { if (DistanceBtw(e.Location, pivots[i])) { selP = pivots[i]; } } }
protected override void OnMouseUp(MouseEventArgs e) { moving = false; selP = null; selPo = null; }