图形绘制是GIS系统中一个常用的功能,
MapControl提供了常用的线,圆,矩形,多变形的绘制
需要在axMapControl_OnMouseDown事件中设置绘制的方法
drawMapShape函数
private void drawMapShape(IGeometry geometry)
{
IRgbColor rgbColor;
rgbColor = new RgbColorClass();
rgbColor.Red = 255;
rgbColor.Green = 255;
rgbColor.Blue = 0;
object symbol = null;
if (geometry.GeometryType == esriGeometryType.esriGeometryPolyline ||
geometry.GeometryType == esriGeometryType.esriGeometryLine)
{
ISimpleLineSymbol simpleLineSymbol;
simpleLineSymbol = new SimpleLineSymbolClass();
simpleLineSymbol.Color = rgbColor;
simpleLineSymbol.Width = 5;
symbol = simpleLineSymbol;
}
else
{
ISimpleFillSymbol simpleFillSymbol;
simpleFillSymbol = new SimpleFillSymbolClass();
simpleFillSymbol.Color = rgbColor;
symbol = simpleFillSymbol;
}
axMapControl1.DrawShape(geometry, ref symbol);
}
axMapControl_OnMouseDown事件
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
if (key == "Draw")
{
IGeometry geometry = this.axMapControl1.TrackCircle();
drawMapShape(geometry);
}
}
按钮事件
private void botton_Click(object sender, EventArgs e)
{
key = "Draw";
}