C#/ARCENGINE编程问题,我设计了一个窗体,现在想通过一个按钮然后在MAPCONTROL上添加点
这个按钮的MOUSEDOWN事件该如何写呢?(包括获取鼠标的坐标,把坐标输入到点的过程)谢谢,求大神写个代码~!...
这个按钮的MOUSEDOWN事件该如何写呢?(包括获取鼠标的坐标,把坐标输入到点的过程)谢谢,求大神写个代码~!
展开
展开全部
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
try
{
IMap pFoucusMap = axMapControl1.Map;
//// 根据鼠标点构造点图形
IPoint pMousePoint = new PointClass()
{
X = e.mapX,
Y = e.mapY,
SpatialReference = pFoucusMap.SpatialReference
};
// 方式一
IColor pPointColor=new RgbColorClass(){Green=200,Red=130,Blue=0}; // 点颜色
ISymbol pDrawSymbol = new SimpleMarkerSymbolClass(); // 符号样式
(pDrawSymbol as ISimpleMarkerSymbol).Color = pPointColor;
axMapControl1.DrawShape(pPointColor,ref pDrawSymbol); // 绘制点
// 方式二
IElement pPointElement = new MarkerElementClass();
pPointElement.Geometry = pMousePoint;
(pPointElement as IMarkerElement).Symbol = pDrawSymbol;
(pFoucusMap as IGraphicsContainer).AddElement(pPointElement,0);
(pFoucusMap as IActiveView).Refresh();
}
catch (Exception ex)
{
MessageBox.Show("绘制异常:" + ex.Message);
}
}
{
try
{
IMap pFoucusMap = axMapControl1.Map;
//// 根据鼠标点构造点图形
IPoint pMousePoint = new PointClass()
{
X = e.mapX,
Y = e.mapY,
SpatialReference = pFoucusMap.SpatialReference
};
// 方式一
IColor pPointColor=new RgbColorClass(){Green=200,Red=130,Blue=0}; // 点颜色
ISymbol pDrawSymbol = new SimpleMarkerSymbolClass(); // 符号样式
(pDrawSymbol as ISimpleMarkerSymbol).Color = pPointColor;
axMapControl1.DrawShape(pPointColor,ref pDrawSymbol); // 绘制点
// 方式二
IElement pPointElement = new MarkerElementClass();
pPointElement.Geometry = pMousePoint;
(pPointElement as IMarkerElement).Symbol = pDrawSymbol;
(pFoucusMap as IGraphicsContainer).AddElement(pPointElement,0);
(pFoucusMap as IActiveView).Refresh();
}
catch (Exception ex)
{
MessageBox.Show("绘制异常:" + ex.Message);
}
}
追问
你好 我是需要通过图层编辑添加点的~
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询