private void diagram_LinkCreated(object sender, LinkEventArgs e) { e.Link.Style = LinkStyle.Polyline; e.Link.SegmentCount = 2; e.Link.CustomDraw = CustomDraw.Full; } private void diagram_DrawLink(object sender, DrawLinkEventArgs e) { float x1, y1, /* beginning point */ x2, y2, /* mid point */ x3, y3, /* ending point */ sx1, sx2, sx3, /* squared x values */ sy1, sy2, sy3, /* squared y values */ ad, D, E, F, /* determinate values */ dc, ec, fc, /* coefficient values */ centrex, centrey, /* centre point of arc */ r, /* radius of arc */ ab, ae; /* beginning & ending angles */ x1 = e.Link.ControlPoints[0].X; y1 = e.Link.ControlPoints[0].Y; x2 = e.Link.ControlPoints[1].X; y2 = e.Link.ControlPoints[1].Y; x3 = e.Link.ControlPoints[2].X; y3 = e.Link.ControlPoints[2].Y; /* get squared values */ sx1 = x1 * x1; sx2 = x2 * x2; sx3 = x3 * x3; sy1 = y1 * y1; sy2 = y2 * y2; sy3 = y3 * y3; /* get "a" determinate */ ad = x1 * (y2 - y3) - y1 * (x2 - x3) + x2 * y3 - x3 * y2; /* get "D" determinate */ D = (sx1 + sy1) * (y2 - y3) - y1 * ((sx2 + sy2) - (sx3 + sy3)) + y3 * (sx2 + sy2) - y2 * (sx3 + sy3); /* get "E" determinate */ E = (sx1 + sy1) * (x2 - x3) - x1 * ((sx2 + sy2) - (sx3 + sy3)) + x3 * (sx2 + sy2) - x2 * (sx3 + sy3); /* get "F" determinate */ F = (sx1 + sy1) * (x2 * y3 - x3 * y2) - x1 * (y3 * (sx2 + sy2) - y2 * (sx3 + sy3)) + y1 * (x3 * (sx2 + sy2) - x2 * (sx3 + sy3)); D = -D; F = -F; /* check for colinear point */ if (ad == 0.0) { System.Drawing.Pen lpen = e.Link.Pen.CreateGdiPen(); e.Graphics.DrawLine(lpen, x1, y1, x3, y3); lpen.Dispose(); return; } /* get coefficients */ dc = D / (2.0f * ad); ec = E / (2.0f * ad); fc = F / ad; /* get centre point */ centrex = -dc; centrey = -ec; /* get radius */ r = (float)Math.Sqrt((dc * dc + ec * ec - fc)); /* get beginning and ending angles */ ab = (float)(Math.Atan2(y1 - centrey, x1 - centrex) * 180 / Math.PI); ae = (float)(Math.Atan2(y3 - centrey, x3 - centrex) * 180 / Math.PI); System.Drawing.Pen pen = e.Link.Pen.CreateGdiPen(); e.Graphics.DrawArc(pen, centrex - r, centrey - r, r * 2, r * 2, ab, ae - ab); pen.Dispose(); }