path.AddRectangle (RectF (54,267, 194,39));
graphics.SetClip (&path);
graphics.FillRectangle (&darkbrownBrush, 54, 267, 194, 39);
// In order to make compass drawing logic relatively simply mathematically,
// we are going to draw the compass with degree zero being at the left margin
// of the compass strip (which is xPixel 54), but then use TranslateTransform to "shift"
// the compass strip so that the desired value is in the MIDDLE of the compass strip.
// Remember, the compass strip is 194 xPixels wide, so the center is at xPixel 98.
// wcompass is the compass degrees
xAdjust = ((xpixelsPerDegree * wcompass) - 98)*-1; // -1 reverses movement
graphics.TranslateTransform(xAdjust,0); // translate everything to the middle of the compass strip.
WCHAR* hsinr;
bool drawText;
// Compass Ledger Lines
LongTickMark = true;
RectF clipRectF;
stringFormat.SetAlignment(StringAlignmentCenter);
for (int i=-390; i<390; i+=5)
{
switch (INT(i))
{
case -390:
hsinr = L"33";
drawText = TRUE;
break;
case -360:
hsinr = L"N";
drawText = TRUE;
break;
case -330:
hsinr = L"03";
drawText = TRUE;
break;
case -300:
hsinr = L"06";
drawText = TRUE;
break;
case -270:
hsinr = L"E";
drawText = TRUE;
break;
case -240:
hsinr = L"12";
drawText = TRUE;
break;
case -210:
hsinr = L"15";
drawText = TRUE;
break;
case -180:
hsinr = L"S";
drawText = TRUE;
break;
case -150:
hsinr = L"21";
drawText = TRUE;
break;
case -120:
hsinr = L"24";
drawText = TRUE;
break;
case -90:
hsinr = L"W";
drawText = TRUE;
break;
case -60:
hsinr = L"30";
drawText = TRUE;
break;
case -30:
hsinr = L"33";
drawText = TRUE;
break;
case 0:
hsinr = L"N";
drawText = TRUE;
break;
case 30:
hsinr = L"03";
drawText = TRUE;
break;
case 60:
hsinr = L"06";
drawText = TRUE;
break;
case 90:
hsinr = L"E";
drawText = TRUE;
break;
case 120:
hsinr = L"12";
drawText = TRUE;
break;
case 150:
hsinr = L"15";
drawText = TRUE;
break;
case 180:
hsinr = L"S";
drawText = TRUE;
break;
case 210:
hsinr = L"21";
drawText = TRUE;
break;
case 240:
hsinr = L"24";
drawText = TRUE;
break;
case 270:
hsinr = L"W";
drawText = TRUE;
break;
case 300:
hsinr = L"30";
drawText = TRUE;
break;
case 330:
hsinr = L"33";
drawText = TRUE;
break;
case 360:
hsinr = L"N";
drawText = TRUE;
break;
case 390:
hsinr = L"03";
drawText = TRUE;
break;
default:
drawText = FALSE;
break;
}
if (LongTickMark == false || drawText == true)
{
graphics.FillRectangle(&whiteBrush,(INT)(54+(xpixelsPerDegree * i)-2), 270, 4, 10); // short tickmark
if (drawText == TRUE)
{
xPos = 54+(xpixelsPerDegree * i);
clipRectF = RectF(xPos-20, 273, 40, 40);
graphics.DrawString(hsinr,-1,&Arial28,PointF((INT)(54+(xpixelsPerDegree*i)), 277),&stringFormat,&whiteBrush);
}
}
else
graphics.FillRectangle(&whiteBrush, (INT)(54+(xpixelsPerDegree * i)-2), 270, 4, 20); // long tickmark
if (LongTickMark == true)
LongTickMark = false;
else
LongTickMark = true;
}
graphics.ResetClip ();
ResetTransform (graphics);
path.Reset ();