I draw some icon by using drawing polygon (connect some points to create icons).
you can review my code following:
public static void DrawTrack(AxMap axMap, ref clsTrack symTrack)
{
if (symTrack.mConsIsOnDraw == false)
return;
axMap.DegreesToPixel(symTrack.mTrkLon, symTrack.mTrkLat, ref symTrack.mConsScreenX, ref symTrack.mConsScreenY);
if ((symTrack.mConsScreenX <= 0) || (symTrack.mConsScreenX >= GlobalVar.screenWidth)
|| (symTrack.mConsScreenY <= 0) || (symTrack.mConsScreenY >= GlobalVar.screenHeight))
{
symTrack.mConsIsOnDraw = false;
return;
}
symTrack.mConsScreenX = Math.Round(symTrack.mConsScreenX);
symTrack.mConsScreenY = Math.Round(symTrack.mConsScreenY);
uint drawPen;
int nSize;
switch (symTrack.mConsIden)
{
case (byte)GlobalVar.TRACK_TYPE.IDEN_TRACK_FRIEND:
drawPen = mwgUtils.ColorByName(tkMapColor.Red);
break;
case (byte)GlobalVar.TRACK_TYPE.IDEN_TRACK_ENERMY:
drawPen = mwgUtils.ColorByName(tkMapColor.Green);
break;
default:
drawPen = mwgUtils.ColorByName(tkMapColor.Navy);
break;
}
if (symTrack.mConsIsWarning)
{
if (symTrack.mConsBlinkDraw)
{
drawPen = mwgUtils.ColorByName(tkMapColor.Orange);
symTrack.mConsBlinkDraw = false;
}
else
{
drawPen = mwgUtils.ColorByName(tkMapColor.Navy);
symTrack.mConsBlinkDraw = true;
}
}
nSize = GlobalVar.zoomNow - 2;
double rdHead = Math.PI * symTrack.mTrkHead / 180.0;
double[] x;
double[] y;
double[] X;
double[] Y;
object xObj = null;
object yObj = null;
int nPoint = 0;
if (symTrack.mTrkType == "PLOT")
{
nPoint = 5;
x = new double[5];
y = new double[5];
X = new double[5];
Y = new double[5];
x[0] = symTrack.mConsScreenX - Math.Round(0.5 * nSize); y[0] = symTrack.mConsScreenY - Math.Round(0.5 * nSize);
x[1] = symTrack.mConsScreenX + Math.Round(0.5 * nSize); y[1] = symTrack.mConsScreenY - Math.Round(0.5 * nSize);
x[2] = symTrack.mConsScreenX + Math.Round(0.5 * nSize); y[2] = symTrack.mConsScreenY + Math.Round(0.5 * nSize);
x[3] = symTrack.mConsScreenX - Math.Round(0.5 * nSize); y[3] = symTrack.mConsScreenY + Math.Round(0.5 * nSize);
x[4] = symTrack.mConsScreenX - Math.Round(0.5 * nSize); y[4] = symTrack.mConsScreenY - Math.Round(0.5 * nSize);
RotatePolygon(x, y, symTrack.mConsScreenX, symTrack.mConsScreenY, 0, ref X, ref Y);
xObj = X as object;
yObj = Y as object;
}
if (symTrack.mTrkType == "PLANE")
{
nPoint = 19;
x = new double[19];
y = new double[19];
X = new double[19];
Y = new double[19];
x[0] = symTrack.mConsScreenX; y[0] = symTrack.mConsScreenY - Math.Round(1.7 * nSize);
x[1] = symTrack.mConsScreenX + Math.Round(0.25 * nSize); y[1] = symTrack.mConsScreenY - Math.Round(1.2 * nSize);
x[2] = symTrack.mConsScreenX + Math.Round(0.25 * nSize); y[2] = symTrack.mConsScreenY - Math.Round(0.3 * nSize);
x[3] = symTrack.mConsScreenX + Math.Round(1.5 * nSize); y[3] = symTrack.mConsScreenY + Math.Round(0.6 * nSize);
x[4] = symTrack.mConsScreenX + Math.Round(1.5 * nSize); y[4] = symTrack.mConsScreenY + Math.Round(0.9 * nSize);
x[5] = symTrack.mConsScreenX + Math.Round(0.25 * nSize); y[5] = symTrack.mConsScreenY + Math.Round(0.3 * nSize);
x[6] = symTrack.mConsScreenX + Math.Round(0.25 * nSize); y[6] = symTrack.mConsScreenY + Math.Round(1.2 * nSize);
x[7] = symTrack.mConsScreenX + Math.Round(0.6 * nSize); y[7] = symTrack.mConsScreenY + Math.Round(1.5 * nSize);
x[8] = symTrack.mConsScreenX + Math.Round(0.6 * nSize); y[8] = symTrack.mConsScreenY + Math.Round(1.7 * nSize);
x[9] = symTrack.mConsScreenX; y[9] = symTrack.mConsScreenY + Math.Round(1.5 * nSize);
x[10] = symTrack.mConsScreenX - Math.Round(0.6 * nSize); y[10] = symTrack.mConsScreenY + Math.Round(1.7 * nSize);
x[11] = symTrack.mConsScreenX - Math.Round(0.6 * nSize); y[11] = symTrack.mConsScreenY + Math.Round(1.5 * nSize);
x[12] = symTrack.mConsScreenX - Math.Round(0.25 * nSize); y[12] = symTrack.mConsScreenY + Math.Round(1.2 * nSize);
x[13] = symTrack.mConsScreenX - Math.Round(0.25 * nSize); y[13] = symTrack.mConsScreenY + Math.Round(0.3 * nSize);
x[14] = symTrack.mConsScreenX - Math.Round(1.5 * nSize); y[14] = symTrack.mConsScreenY + Math.Round(0.9 * nSize);
x[15] = symTrack.mConsScreenX - Math.Round(1.5 * nSize); y[15] = symTrack.mConsScreenY + Math.Round(0.6 * nSize);
x[16] = symTrack.mConsScreenX - Math.Round(0.25 * nSize); y[16] = symTrack.mConsScreenY - Math.Round(0.3 * nSize);
x[17] = symTrack.mConsScreenX - Math.Round(0.25 * nSize); y[17] = symTrack.mConsScreenY - Math.Round(1.2 * nSize);
x[18] = symTrack.mConsScreenX; y[18] = symTrack.mConsScreenY - Math.Round(1.7 * nSize);
RotatePolygon(x, y, symTrack.mConsScreenX, symTrack.mConsScreenY, rdHead, ref X, ref Y);
xObj = X as object;
yObj = Y as object;
}
if (symTrack.mTrkType == "SHIP")
{
nPoint = 7;
x = new double[7];
y = new double[7];
X = new double[7];
Y = new double[7];
x[0] = symTrack.mConsScreenX; y[0] = symTrack.mConsScreenY - Math.Round(1.6 * nSize);
x[1] = symTrack.mConsScreenX - Math.Round(0.6 * nSize); y[1] = symTrack.mConsScreenY - Math.Round(1.0 * nSize);
x[2] = symTrack.mConsScreenX - Math.Round(0.6 * nSize); y[2] = symTrack.mConsScreenY + Math.Round(1.5 * nSize);
x[3] = symTrack.mConsScreenX; y[3] = symTrack.mConsScreenY + Math.Round(1.0 * nSize);
x[4] = symTrack.mConsScreenX + Math.Round(0.6 * nSize); y[4] = symTrack.mConsScreenY + Math.Round(1.5 * nSize);
x[5] = symTrack.mConsScreenX + Math.Round(0.6 * nSize); y[5] = symTrack.mConsScreenY - Math.Round(1.0 * nSize);
x[6] = symTrack.mConsScreenX; y[6] = symTrack.mConsScreenY - Math.Round(1.6 * nSize);
RotatePolygon(x, y, symTrack.mConsScreenX, symTrack.mConsScreenY, rdHead, ref X, ref Y);
xObj = X as object;
yObj = Y as object;
}
if ((xObj != null) && (yObj != null))
{
// Draw Track
axMap.DrawPolygon(ref xObj, ref yObj, nPoint, drawPen, true); // BGR
//axMap.DrawWidePolygon(ref xObj, ref yObj, nPoint, drawPen, true, 1);
}
// Draw circle for selected track
if (symTrack.mConsIsSelected)
{
axMap.DrawCircle(symTrack.mConsScreenX, symTrack.mConsScreenY, nSize * 1.8, drawPen, false);
}
// Draw History
if (symTrack.mConsIsHistOn)
{
foreach (var key in symTrack.mConsTrkHis.Keys)
{
clsMwgPoint tmp = (clsMwgPoint)symTrack.mConsTrkHis[key];
axMap.DegreesToPixel(tmp.m_Long, tmp.m_Lat, ref tmp.m_ScreenX, ref tmp.m_ScreenY);
axMap.DrawPoint(tmp.m_ScreenX, tmp.m_ScreenY, 2, drawPen);
}
}
// Darw
if (symTrack.mConsIsPredicOn)
{
foreach (var key in symTrack.mConsTrkPredic.Keys)
{
clsMwgPoint tmp = (clsMwgPoint)symTrack.mConsTrkPredic[key];
axMap.DegreesToPixel(tmp.m_Long, tmp.m_Lat, ref tmp.m_ScreenX, ref tmp.m_ScreenY);
axMap.DrawPoint(tmp.m_ScreenX, tmp.m_ScreenY, 2, drawPen);
}
}
}