public IGeometry EndFeatureMove(int x, int y) { if (MyfeedBack == null) { return(null); } IGeometry geometry = null; try { if ((MyfeedBack as IMovePointFeedback) != null) { IMovePointFeedback pointMoveFeedback = MyfeedBack as IMovePointFeedback; geometry = pointMoveFeedback.Stop(); } else if ((MyfeedBack as IMoveLineFeedback) != null) { IMoveLineFeedback lineMoveFeedback = MyfeedBack as IMoveLineFeedback; geometry = lineMoveFeedback.Stop(); } else if ((MyfeedBack as IMovePolygonFeedback) != null) { IMovePolygonFeedback polygonMoveFeedback = MyfeedBack as IMovePolygonFeedback; geometry = polygonMoveFeedback.Stop(); } } catch { return(null); } MyfeedBack = null; return(geometry); }
public override void OnMouseUp(int Button, int Shift, int X, int Y) { // TODO: Add ModifyShape.OnMouseUp implementation if (m_Feedback == null) { return; } IActiveView pActiveView = m_MapControl.ActiveView; IPoint pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_Feedback is IMovePointFeedback) { IMovePointFeedback pPointMove = (IMovePointFeedback)m_Feedback; IGeometry pGeometry = pPointMove.Stop(); UpdateFeature(m_EditFeature, pGeometry); } else if (m_Feedback is IMoveLineFeedback) //线 对象移动 { IMoveLineFeedback pLineMove = (IMoveLineFeedback)m_Feedback; IGeometry pGeometry = pLineMove.Stop(); UpdateFeature(m_EditFeature, pGeometry); } else if (m_Feedback is IMovePolygonFeedback) { IMovePolygonFeedback pPolygonMove = (IMovePolygonFeedback)m_Feedback; IGeometry pGeometry = pPolygonMove.Stop(); UpdateFeature(m_EditFeature, pGeometry); } m_Feedback = null; pActiveView.Refresh(); }
//初始化反馈对象参数 private void button3_Click(object sender, EventArgs e) { strOperator = "move"; m_MovePointFeedback = new MovePointFeedbackClass(); m_MoveLineFeedback = new MoveLineFeedbackClass(); m_MovePolygonFeedback = new MovePolygonFeedbackClass(); }
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 Form1() { ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop); ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Engine); m_MovePointFeedback = new MovePointFeedbackClass(); m_MoveLineFeedback = new MoveLineFeedbackClass(); m_MovePolygonFeedback = new MovePolygonFeedbackClass(); InitializeComponent(); }
private void axMapControl1_OnMouseUp(object sender, IMapControlEvents2_OnMouseUpEvent e) { if (m_Feature == null) { return; } IGeometry resultGeometry = null; switch (strOperator) { case "move": if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { //停止移动 resultGeometry = m_MovePointFeedback.Stop() as IGeometry; m_Feature.Shape = resultGeometry; } else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { //停止移动 resultGeometry = m_MoveLineFeedback.Stop() as IGeometry; m_Feature.Shape = resultGeometry; } else if (m_Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { //停止移动 resultGeometry = m_MovePolygonFeedback.Stop() as IGeometry; m_Feature.Shape = resultGeometry; } IWorkspaceEdit workspaceEdit; IWorkspace workspace; IDataset dataset = m_FeatureLayer.FeatureClass as IDataset; workspace = dataset.Workspace; workspaceEdit = workspace as IWorkspaceEdit; //开始编辑 workspaceEdit.StartEditing(true); workspaceEdit.StartEditOperation(); //保存实体 m_Feature.Store(); //结束编辑 workspaceEdit.StopEditOperation(); workspaceEdit.StopEditing(true); m_MovePointFeedback = null; m_MoveLineFeedback = null; m_MovePolygonFeedback = null; break; } m_activeView.Refresh(); this.axMapControl1.Map.ClearSelection(); }
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; } }
/// <summary> /// 完成地图对象移动,取得移动后的对象,并将其更新到图层中 /// 建议在Map.MouseUp事件中调用本方法 /// </summary> public void MoveFeatureEnd() { IGeometry pGeometry; try { if (m_pFeedback == null) { return; } if (m_pFeedback is IMovePointFeedback) { IMovePointFeedback pPointMove = (IMovePointFeedback)m_pFeedback; pGeometry = pPointMove.Stop(); UpdateFeature(m_pEditFeature, pGeometry); } else if (m_pFeedback is IMoveLineFeedback) { IMoveLineFeedback pLineMove = (IMoveLineFeedback)m_pFeedback; pGeometry = pLineMove.Stop(); UpdateFeature(m_pEditFeature, pGeometry); } else if (m_pFeedback is IMovePolygonFeedback) { IMovePolygonFeedback pPolyMove = (IMovePolygonFeedback)m_pFeedback; pGeometry = pPolyMove.Stop(); UpdateFeature(m_pEditFeature, pGeometry); } m_pFeedback = null; IActiveView pActiveView = (IActiveView)m_pMap; pActiveView.Refresh(); } catch (Exception e) { Console.WriteLine(e.Message.ToString()); } }