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