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 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(); }
/// <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()); } }