public override void Highlight(Graphics g, Matrix xformWorldToPixel, Brush brush, bool erasing)
{
// Transform the thickness to pixel coords.
float thickness = TransformDistance(NormalCourseAppearance.lineThickness * appearance.lineWidth * scaleRatio, xformWorldToPixel);
// Transform the ellipse to pixel coords. Points array is 0=location, 1=upper-left corner, 2 = lower-right corner
float radius = ((diameter * appearance.controlCircleSize - NormalCourseAppearance.lineThickness * appearance.lineWidth) * scaleRatio) / 2F;
PointF[] pts = { location, new PointF(location.X - radius, location.Y - radius), new PointF(location.X + radius, location.Y + radius) };
xformWorldToPixel.TransformPoints(pts);
// Draw the control circle.
using (Pen pen = new Pen(brush, thickness)) {
RectangleF rect = RectangleF.FromLTRB(pts[1].X, pts[2].Y, pts[2].X, pts[1].Y);
CircleGap[] gapsToDraw = CircleGap.SimplifyGaps(gaps);
try {
if (gapsToDraw == null)
g.DrawEllipse(pen, rect);
else {
float[] arcStartSweeps = CircleGap.ArcStartSweeps(gapsToDraw);
for (int i = 0; i < arcStartSweeps.Length; i += 2) {
float startArc = arcStartSweeps[i];
float sweepArc = arcStartSweeps[i + 1];
g.DrawArc(pen, rect, startArc, sweepArc);
}
}
// No center dot for highlighting (crosshair instead)
}
catch (ExternalException) {
// Ignore this exeption. Not sure what causes it.
}
catch (OutOfMemoryException) {
// Similar.
}
}
// Draw the cross-hair.
HighlightCrossHair(g, xformWorldToPixel, brush);
}