现在扇型已经画好,数据也得到,关键是要保存其轨迹。思想是把确定的扇型的成员内容保存在类或结构中,当mo移动时候,从新画扇型。在AfterLayerDraw事件下
/// <summary>
/// for re-draw sector. store sector
/// </summary>
public struct SectorElement
{
public ESRI.MapObjects2.Core.Point CenterPoint;
// public ESRI.MapObjects2.Core.Point RadiusPoint;
public float SweepAngle;
public float StartAngle;
public float Radius;
// public int Index; // Draw mark need sign.
}
画扇型,有专门对象来保存SectorElement/// <summary>
/// for re-draw sector. store sector
/// </summary>
public struct SectorElement
{
public ESRI.MapObjects2.Core.Point CenterPoint;
// public ESRI.MapObjects2.Core.Point RadiusPoint;
public float SweepAngle;
public float StartAngle;
public float Radius;
// public int Index; // Draw mark need sign.
}
/// <summary>
/// draw sector for all opened windows.
/// </summary>
private void DrawSectorMark()
{
if (this.gdiLists == null && this.gdiLists.Count == 0) return;
foreach (object obj in gdiLists.Keys)
{
SectorElement gpiElem = (SectorElement)gdiLists[obj];
float clientCenterX =0.0f ,clientCenterY =0.0f,clientRadius = 0.0f;
map.FromMapPoint(gpiElem.CenterPoint,ref clientCenterX,ref clientCenterY);
clientRadius = map.FromMapDistance(gpiElem.Radius);
//注意,创建Graphic必须使用System.Drawing.Graphics.FromHdc
Graphics gpArc = System.Drawing.Graphics.FromHdc(hDC);
Pen pen = new Pen(Color.Black,1);
pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
pen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
gpArc.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//draw pie
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)(clientCenterX-clientRadius),
(int)(clientCenterY -clientRadius),(int)clientRadius*2,(int)clientRadius*2);
gpArc.DrawPie(pen,rectangle,gpiElem.StartAngle,gpiElem.SweepAngle);
//draw index
// Font ft = new Font("Tahoma",10);//(this.Font.Name,this.Font.Size);//,FontStyle.Bold);
// gpArc.DrawString(gpiElem.Index.ToString(),ft,new SolidBrush(Color.Black),(int)(clientCenterX - 5),(int)clientCenterY);
}
}
/// draw sector for all opened windows.
/// </summary>
private void DrawSectorMark()
{
if (this.gdiLists == null && this.gdiLists.Count == 0) return;
foreach (object obj in gdiLists.Keys)
{
SectorElement gpiElem = (SectorElement)gdiLists[obj];
float clientCenterX =0.0f ,clientCenterY =0.0f,clientRadius = 0.0f;
map.FromMapPoint(gpiElem.CenterPoint,ref clientCenterX,ref clientCenterY);
clientRadius = map.FromMapDistance(gpiElem.Radius);
//注意,创建Graphic必须使用System.Drawing.Graphics.FromHdc
Graphics gpArc = System.Drawing.Graphics.FromHdc(hDC);
Pen pen = new Pen(Color.Black,1);
pen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
pen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
gpArc.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
//draw pie
System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle((int)(clientCenterX-clientRadius),
(int)(clientCenterY -clientRadius),(int)clientRadius*2,(int)clientRadius*2);
gpArc.DrawPie(pen,rectangle,gpiElem.StartAngle,gpiElem.SweepAngle);
//draw index
// Font ft = new Font("Tahoma",10);//(this.Font.Name,this.Font.Size);//,FontStyle.Bold);
// gpArc.DrawString(gpiElem.Index.ToString(),ft,new SolidBrush(Color.Black),(int)(clientCenterX - 5),(int)clientCenterY);
}
}
浙公网安备 33010602011771号