/// <summary>Paint on the graphics context</summary> /// <param name="context">The graphics context to draw on</param> public override void Paint(IDrawContext context) { CalcBezPoints(); if (bezPoints.Count != 0) { // Create point for upper-left corner of drawing. context.NewPath(); if (Selected) { context.SetColour(Color.Blue); } else { context.SetColour(DefaultOutlineColour); } // Draw text if necessary if (Name != null) { DrawCentredText(context, Name, Location); } context.MoveTo(bezPoints[0].X, bezPoints[0].Y); Point controlPoint = new Point(Location.X, Location.Y); Point bezPoint = bezPoints[bezPoints.Count - 1]; context.CurveTo(controlPoint.X, controlPoint.Y, controlPoint.X, controlPoint.Y, bezPoint.X, bezPoint.Y); context.Stroke(); // find closest point in the bezPoints to the intersection point that is outside the target // work backwards through BezPoints array and use the first one that is outside the target for (int i = bezPoints.Count - 1; i >= 0; i--) { Point arrowHead; if (!Target.HitTest(bezPoints[i])) { arrowHead = bezPoints[i]; i--; //keep moving along the line until distance = target radius double targetRadius = Target.Width / 2; while (i >= 0) { double dist = GetDistance(bezPoints[i], arrowHead); if (dist >= 20) { DrawArrow(context, bezPoints[i], arrowHead); break; } i--; } break; } } } }