PurplePen.FinishCourseObj.Highlight C# (CSharp) Method

Highlight() public method

public Highlight ( Graphics g, Matrix xformWorldToPixel, Brush brush, bool erasing ) : void
g System.Drawing.Graphics
xformWorldToPixel Matrix
brush System.Drawing.Brush
erasing bool
return void
        public override void Highlight(Graphics g, Matrix xformWorldToPixel, Brush brush, bool erasing)
        {
            // Transform the thickness to pixel coords.
            float thickness = TransformDistance(NormalCourseAppearance.lineThickness * scaleRatio * appearance.lineWidth, xformWorldToPixel);

            // Transform the ellipse to pixel coords. Points array is 0=location, 1=upper-left corner inner, 2 = lower-right corner inner, 3 = upper-left outer, 4=lower-right outer
            float radiusOuter = ((7.0F * appearance.controlCircleSize - NormalCourseAppearance.lineThickness * appearance.lineWidth) * scaleRatio) / 2F;
            float radiusInner = ((5.35F * appearance.controlCircleSize - 2 * NormalCourseAppearance.lineThickness * appearance.lineWidth) * scaleRatio) / 2F;
            PointF[] pts = { location, new PointF(location.X - radiusInner, location.Y - radiusInner), new PointF(location.X + radiusInner, location.Y + radiusInner),
                                                                         new PointF(location.X - radiusOuter, location.Y - radiusOuter), new PointF(location.X + radiusOuter, location.Y + radiusOuter)};
            xformWorldToPixel.TransformPoints(pts);

            // Draw the inner and outer circle.
            using (Pen pen = new Pen(brush, thickness)) {
                RectangleF rect1 = RectangleF.FromLTRB(pts[1].X, pts[2].Y, pts[2].X, pts[1].Y);
                RectangleF rect2 = RectangleF.FromLTRB(pts[3].X, pts[4].Y, pts[4].X, pts[3].Y);

                try {
                    if (gaps == null) {
                        g.DrawEllipse(pen, rect1);
                        g.DrawEllipse(pen, rect2);
                    }
                    else {
                        float[] arcStartSweeps = CircleGap.ArcStartSweeps(gaps);
                        for (int i = 0; i < arcStartSweeps.Length; i += 2) {
                            float startArc = arcStartSweeps[i];
                            float sweepArc = arcStartSweeps[i + 1];
                            g.DrawArc(pen, rect1, startArc, sweepArc);
                            g.DrawArc(pen, rect2, startArc, sweepArc);
                        }
                    }
                }
                catch (ExternalException) {
                    // Ignore this exeption. Not sure what causes it.
                }
                catch (OutOfMemoryException) {
                    // Similar.
                }

            }

            if (crossHairOptions == CrossHairOptions.HighlightCrossHair) {
                // Draw the cross-hair.
                HighlightCrossHair(g, xformWorldToPixel, brush);
            }
        }