public void SetPolarAxes(Graphics g)
{
Pen aPen = new Pen (AngleColor, AngleThickness);
SolidBrush aBrush = new SolidBrush (TickFontColor);
StringFormat sFormat = new StringFormat ();
Rectangle rect = SetPolarArea ();
float xc = rect.X + rect.Width / 2;
float yc = rect.Y + rect.Height / 2;
// Draw circles:
float dr = RNorm (RMax / NTicks) - RNorm (RMin / nTicks);
aPen.DashStyle = AnglePattern;
for (int i = 0; i < NTicks; i++) {
RectangleF rect1 = new RectangleF (xc - (i + 1) * dr,
yc - (i + 1) * dr, 2 * (i + 1) * dr, 2 * (i + 1) * dr);
g.DrawEllipse (aPen, rect1);
}
// Draw radii:
aPen = new Pen (RadiusColor, RadiusThickness);
aPen.DashStyle = RadiusPattern;
for (int i = 0; i < (int)360 / AngleStep; i++) {
float x = RNorm (RMax) * (float)Math.Cos (i * AngleStep *
Math.PI / 180) + xc;
float y = RNorm (RMax) * (float)Math.Sin (i * AngleStep *
Math.PI / 180) + yc;
g.DrawLine (aPen, xc, yc, x, y);
}
// Draw the radius labels:
for (int i = 1; i <= nTicks; i++) {
float rlabel = RMin + i * (RMax - RMin) / NTicks;
sFormat.Alignment = StringAlignment.Near;
g.DrawString (rlabel.ToString (), TickFont, aBrush,
new PointF (xc, yc - i * dr + 5), sFormat);
}
// Draw the angle labels:
SizeF tickFontSize = g.MeasureString ("A", TickFont);
float angleLabel = 0;
for (int i = 0; i < (int)360 / AngleStep; i++) {
if (AngleDirection == AngleDirectionEnum.ClockWise) {
angleLabel = i * AngleStep;
} else if (AngleDirection == AngleDirectionEnum.CounterClockWise) {
angleLabel = 360 - i * AngleStep;
if (i == 0)
angleLabel = 0;
}
sFormat.Alignment = StringAlignment.Center;
float x = (RNorm (RMax) + 1.2f * tickFontSize.Width) *
(float)Math.Cos (i * AngleStep * Math.PI / 180) + xc;
float y = (RNorm (RMax) + 1.2f * tickFontSize.Width) *
(float)Math.Sin (i * AngleStep * Math.PI / 180) + yc;
g.DrawString (angleLabel.ToString (), TickFont, aBrush,
new PointF (x, y - tickFontSize.Height / 2), sFormat);
}
}