您的位置:首页 > 其它

几何对象Gemetry及DrawShape方法的注意事项

2009-07-16 09:11 309 查看
几何对象Gemetry及DrawShape方法的注意事项

Admin 发布于 2007年9月26日

DrawShape 方法只支持以下对象,而Line等对象不被支持

Geometry objects implementing IEnvelope, IMultiPatch, IMultiPoint, IPoint, IPolygon and IPolyline are supported
DrawShape draws the supplied geometry onto the display. Use the DrawShape method within the esriViewForeground phase of the IMapControlEvents2::OnAfterDraw event.

FlashShape flashes the supplied geometry onto the display.

DrawShape 方法只支持以下对象,而Line等对象不被支持
Geometry objects implementing IEnvelope, IMultiPatch, IMultiPoint, IPoint, IPolygon and IPolyline are supported

public partial class Form1 : Form
{
ILine m_line;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{
if (e.button == 1)
{
IPoint fromPoint = new PointClass();
fromPoint.PutCoords(100, 100);
IPoint toPoint = new PointClass();
toPoint.PutCoords(150, 150);
ILine line = new LineClass();
line.PutCoords(fromPoint, toPoint);
Console.WriteLine(line.Length.ToString());
m_line = line;
axMapControl1.FullExtent = line.Envelope;
IEnvelope pRect = new EnvelopeClass();
pRect = axMapControl1.Extent;
pRect.Expand(2, 2, true);
axMapControl1.Extent = pRect;
axMapControl1.Refresh(esriViewDrawPhase.esriViewForeground, Type.Missing, Type.Missing);
}
if (e.button == 2)
{
axMapControl1.Extent = axMapControl1.TrackRectangle();
}

}
private IRgbColor GetRGBColor(int red, int green, int blue)
{
//Create rgb color and grab hold of the IRGBColor interface
IRgbColor rGB = new RgbColorClass();
//Set rgb color properties
rGB.Red = red;
rGB.Green = green;
rGB.Blue = blue;
rGB.UseWindowsDithering = true;
return rGB;
}
private void axMapControl1_OnAfterDraw(object sender, IMapControlEvents2_OnAfterDrawEvent e)
{
if (e.viewDrawPhase == (int)esriViewDrawPhase.esriViewForeground & m_line != null)
{
ILineSymbol lineSymbol = new SimpleLineSymbolClass();
//Set line symbol properties
lineSymbol.Color = GetRGBColor(0, 0, 0);
lineSymbol.Width = 2;
object oLineSymbol = lineSymbol;
IPolyline m_Polyline = new PolylineClass();
ISegmentCollection pSeg = m_Polyline as ISegmentCollection;
object Missing = Type.Missing;
pSeg.AddSegment((ISegment)m_line, ref Missing, ref Missing);
axMapControl1.DrawShape(m_Polyline, ref oLineSymbol);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: