axMapControl1_OnMouseDown


private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
{
//If left hand mouse button 如果点击鼠标左键
if (e.button == 1)
{
//Create a point and grab hold of the IPoint inteface 实例化一个点,并将实例化的点转化成IPoint 接口
IPoint point = new PointClass();
//Set point properties 设置点的属性
point.X = e.mapX;
point.Y = e.mapY;

//If this is the first point of a new line 如果这个点是新线的起始点
if (m_Polyline == null)
{
//Create the forms private polyline member and grab hold of the IPolyline interface 创新一个Polyline对象,并将Polyline对象转化成IPolyline接口(m_Polyline)。
m_Polyline = new PolylineClass();
}

//QI for the IPointsCollection interface using the IPolyline interface 将IPolyline接口强制转化成一个IPointsCollection接口进行操作。
object o = Type.Missing;
//object o1 = m_PointCollection.PointCount-1;
m_PointCollection = (IPointCollection) m_Polyline;
m_PointCollection.AddPoint(point, ref o, ref o);

//Refresh the foreground thereby removing any text annotation 刷新地图的显示,以屏蔽文本注释。
axMapControl1.Refresh(esriViewDrawPhase.esriViewForeground, Type.Missing,Type.Missing);
}
else
{
//If right or middle mouse button zoom to user defined rectangle 如果点击了鼠标右键或中键,则去自定义矩形
//Create an envelope and grab hold of the IEnvelope interface 将axMapControl1.TrackRectangle转化成 IEnvelope接口
IEnvelope envelope = axMapControl1.TrackRectangle();
//If user dragged a rectangle 如果用户拖动了一个矩形。
if (envelope != null)
{
//Set map controls extent property 设置地图控件 Extent(范围)属性。
axMapControl1.Extent = envelope;
}
}
}
本贴来自ZDNetChina中文社区 http://bbs.zdnet.com.cn ,本贴地址:http://bbs.zdnet.com.cn/viewthread.php?tid=726219

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值