private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { IPoint point = new PointClass(); IFeatureClass featureClass = null; if (m_Feature == null) { return; } switch (strOperator) { case "move": //将当前鼠标位置的点转换为地图上的坐标 point = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { //设置显示对象,并启动移动 m_MovePointFeedback.Display = m_activeView.ScreenDisplay; m_MovePointFeedback.Start(m_Feature.Shape as IPoint, point); } else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { //设置显示对象,并启动移动 m_MoveLineFeedback.Display = m_activeView.ScreenDisplay; m_MoveLineFeedback.Start(m_Feature.Shape as IPolyline, point); } else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { //设置显示对象,并启动移动 m_MovePolygonFeedback.Display = m_activeView.ScreenDisplay; m_MovePolygonFeedback.Start(m_Feature.Shape as IPolygon, point); } break; } }
public void FeatureMoveMouseDown(int x, int y) { if (MyselectedLayer == null) { return; } if ((MyselectedLayer as IGeoFeatureLayer) == null) { return; } IFeatureLayer featureLayer = MyselectedLayer as IFeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass == null) { return; } if (MyselectedFeature.Count < 1) { return; } IFeature feature = MyselectedFeature[0]; IGeometry startGeom = feature.Shape; IPoint point = MyMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); try { switch (featureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: MyfeedBack = new MovePointFeedbackClass(); MyfeedBack.Display = MyMapControl.ActiveView.ScreenDisplay; IMovePointFeedback pointMoveFeedback = MyfeedBack as IMovePointFeedback; pointMoveFeedback.Start(startGeom as IPoint, point); break; case esriGeometryType.esriGeometryPolyline: MyfeedBack = new MoveLineFeedbackClass(); MyfeedBack.Display = MyMapControl.ActiveView.ScreenDisplay; IMoveLineFeedback lineMoveFeedback = MyfeedBack as IMoveLineFeedback; lineMoveFeedback.Start(startGeom as IPolyline, point); break; case esriGeometryType.esriGeometryPolygon: MyfeedBack = new MovePolygonFeedbackClass(); MyfeedBack.Display = MyMapControl.ActiveView.ScreenDisplay; IMovePolygonFeedback polygonMoveFeedback = MyfeedBack as IMovePolygonFeedback; polygonMoveFeedback.Start(startGeom as IPolygon, point); break; default: break; } } catch { return; } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ModifyShape.OnMouseDown implementation m_MapControl.Map.ClearSelection(); m_MapControl.ActiveView.Refresh(); SelectMouseDown(X, Y); IEnumFeature pSelected = (IEnumFeature)m_MapControl.Map.FeatureSelection; IFeature pFeature = pSelected.Next(); if (pFeature == null) { return; } IActiveView pActiveView = m_MapControl.ActiveView; IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //设置捕捉容差 double tol = ConvertPixelsToMapUnits(pActiveView, 4); IGeometry pGeom = pFeature.Shape; IObjectClass pObjectClass = pFeature.Class; m_EditFeature = pFeature; switch (pGeom.GeometryType) { case esriGeometryType.esriGeometryPoint: m_Feedback = new MovePointFeedbackClass(); m_Feedback.Display = pActiveView.ScreenDisplay; IMovePointFeedback pPointMove = (IMovePointFeedback)m_Feedback; pPointMove.Start((IPoint)pGeom, pPoint); break; case esriGeometryType.esriGeometryPolyline: m_Feedback = new MoveLineFeedbackClass(); m_Feedback.Display = pActiveView.ScreenDisplay; IMoveLineFeedback m_MoveLineFeedback = (IMoveLineFeedback)m_Feedback; m_MoveLineFeedback.Start((IPolyline)pGeom, pPoint); break; case esriGeometryType.esriGeometryPolygon: m_Feedback = new MovePolygonFeedbackClass(); m_Feedback.Display = pActiveView.ScreenDisplay; IMovePolygonFeedback m_MovePolygonFeedback = (IMovePolygonFeedback)m_Feedback; m_MovePolygonFeedback.Start((IPolygon)pGeom, pPoint); break; } }