public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolCreateParallel.OnMouseDown implementation if (Button == 1 && (m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) != null) { IMap pMap = m_pMapCtl.Map; IPoint po = m_pMapCtl.ToMapPoint(X, Y); ISelectionEnvironment pSelectionEnv = new SelectionEnvironmentClass(); IGeometry geometry = new PolygonClass(); geometry = m_pMapCtl.TrackRectangle(); pMap.SelectByShape(geometry, pSelectionEnv, true); m_pMapCtl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); IEnumFeatureSetup pSelectionsetup = pMap.FeatureSelection as IEnumFeatureSetup; pSelectionsetup.AllFields = true;//这里是关键 IEnumFeature pFeatureCollection = pSelectionsetup as IEnumFeature; IFeature pF = pFeatureCollection.Next(); if (pF != null && pF.Shape is IPolyline) { FrmParallelLineOffset frm = new FrmParallelLineOffset(); if (frm.ShowDialog() == DialogResult.OK) { IPolyline pPolyline = ConstructOffset(pF.Shape as IPolyline, frm.offset); IFeature pFeature = m_FLayer.FeatureClass.CreateFeature(); pFeature.Shape = pPolyline; pFeature.Store(); m_pMapCtl.Refresh(); } } } }
public override void OnDblClick() { IMapControl3 pMapCtrl = ClsGlobal.GetMapControl(m_hookHelper); if (pMapCtrl == null) { if (m_NewPolygonFeedback != null) { m_NewPolygonFeedback.Stop(); m_NewPolygonFeedback = null; return; } } IGeometry pGeometry = m_NewPolygonFeedback.Stop(); m_NewPolygonFeedback = null; if (pGeometry == null) { return; } m_pClipPolygon = pGeometry as IPolygon; double dbNoDataValue = m_pFrmSetRasterNoDataValue.NoDataValue; //获取到无效值区域、无效值、栅格数据之后,开始设置 ClsSetRasterRegionToDataValue pSetRasterToNoDataValue = new ClsSetRasterRegionToDataValue(m_pRasterLayer.Raster, m_pClipPolygon, dbNoDataValue); if (!pSetRasterToNoDataValue.SetRegionToNoDataValue()) { MessageBox.Show("设置无效值出错!"); } else { //MessageBox.Show("设置无效值成功!"); //重新加载栅格数据 try { IRaster2 pSrcRaster2 = m_pRasterLayer.Raster as IRaster2; IRasterDataset pDstRasterDataset = pSrcRaster2.RasterDataset; IRasterPyramid3 pDstRasterPyramid3 = pDstRasterDataset as IRasterPyramid3; if (pDstRasterPyramid3.Present) { IDataLayer2 pDataLayer = m_pRasterLayer as IDataLayer2; pDataLayer.Disconnect(); pDstRasterPyramid3.DeletePyramid(); pDstRasterPyramid3.Create(); m_pRasterLayer.CreateFromDataset(pDstRasterDataset); } IMapControl3 pMapControl3 = ClsGlobal.GetMapControl(m_hookHelper); pMapControl3.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null); } catch (System.Exception ex) { MessageBox.Show(ex.Message); } } base.OnDblClick(); }
public override void OnMouseMove(int Button, int Shift, int X, int Y) { // TODO: Add ToolRasterEdit.OnMouseMove implementation IMapControl3 pMapCtrl = ClsGlobal.GetMapControl(m_hookHelper); if (pMapCtrl == null) { return; } IPoint pPoint = pMapCtrl.ToMapPoint(X, Y); if (m_NewPolygonFeedback != null) { m_NewPolygonFeedback.MoveTo(pPoint); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolRasterEdit.OnMouseDown implementation IMapControl3 pMapCtrl = ClsGlobal.GetMapControl(m_hookHelper); if (pMapCtrl == null) { return; } IPoint pPoint = pMapCtrl.ToMapPoint(X, Y); if (Button == 1) { if (m_NewPolygonFeedback == null) { m_NewPolygonFeedback = new NewPolygonFeedbackClass(); m_NewPolygonFeedback.Display = pMapCtrl.ActiveView.ScreenDisplay; m_NewPolygonFeedback.Start(pPoint); } else { try { object Miss = Type.Missing; m_NewPolygonFeedback.AddPoint(pPoint); } catch (System.Exception ex) { } } } if (Button == 2) { if (m_NewPolygonFeedback != null) { m_NewPolygonFeedback.Stop(); } m_NewPolygonFeedback = null; } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { // TODO: Add CmdChangeAnnotationSymbol.OnClick implementation IMapControl3 pMapCtr = ClsGlobal.GetMapControl(m_hookHelper); if (pMapCtr == null) { return; } ISelection pSelection = pMapCtr.Map.FeatureSelection; FrmAddText pFrmAddText = null; IEnumFeature pEnumFeature = pSelection as IEnumFeature; int selectcount = 0; pEnumFeature.Reset(); IFeature pFeature = null; while ((pFeature = pEnumFeature.Next()) != null) { selectcount++; } pEnumFeature.Reset(); pFeature = null; while ((pFeature = pEnumFeature.Next()) != null) { IAnnotationFeature pAFeature = pFeature as IAnnotationFeature; if (pAFeature != null) { ITextElement pTextElement = pAFeature.Annotation as ITextElement; if (pFrmAddText == null) { pFrmAddText = new FrmAddText(pTextElement, m_hookHelper); if (pFrmAddText.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } } // ( (ITextElement) pAFeature.Annotation ).Symbol= pFrmAddText.pTextElement.Symbol; //ITextElement pTextElement2 = pAFeature.Annotation as ITextElement; //pTextElement2.Symbol = pFrmAddText.pTextElement.Symbol; //pTextElement2.Text = pFrmAddText.pTextElement.Text; //pAFeature.Annotation = pTextElement2 as IElement; ITextElement pTextElement2 = pAFeature.Annotation as ITextElement; pTextElement2.Symbol = pFrmAddText.pTextElement.Symbol; if (selectcount == 1) { pTextElement2.Text = pFrmAddText.pTextElement.Text; } pAFeature.Annotation = pTextElement2 as IElement; pFeature.Store(); } } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolCreateCircle.OnMouseDown implementation if ((m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) == null) { return; } IPoint pPoint = m_pMapCtl.ToMapPoint(X, Y); if (Button == 1) { if (m_NewCircleFeedback == null) { m_NewCircleFeedback = new NewCircleFeedbackClass(); m_NewCircleFeedback.Display = m_pMapCtl.ActiveView.ScreenDisplay; m_NewCircleFeedback.Start(pPoint); m_CenterPoint = pPoint; } else { try { object Miss = Type.Missing; ICircularArc pArc = m_NewCircleFeedback.Stop(); //IGeometry geometry = new PolygonClass(); //geometry = m_pMapCtl.TrackCircle(); IPolygon pPolygon = new PolygonClass(); ISegment pArcC = pArc as ISegment; ISegmentCollection pArcP = pPolygon as ISegmentCollection; pArcP.AddSegment(pArcC, ref Miss, ref Miss); pPolygon.Close(); IFeature pFeature = m_FLayer.FeatureClass.CreateFeature(); pFeature.Shape = pPolygon; pFeature.Store(); m_pMapCtl.Refresh(); m_NewCircleFeedback = null; } catch (System.Exception ex) { } } } if (Button == 2) { double radius = Math.Sqrt((pPoint.X - m_CenterPoint.X) * (pPoint.X - m_CenterPoint.X) + (pPoint.Y - m_CenterPoint.Y) * (pPoint.Y - m_CenterPoint.Y)); FrmDrawCircle frm = new FrmDrawCircle(radius); IConstructCircularArc pArcConstruct = null; if (m_NewCircleFeedback == null) { return; } if (frm.ShowDialog() == DialogResult.OK) { try { pArcConstruct = new CircularArcClass(); pArcConstruct.ConstructCircle(m_CenterPoint, frm.m_radius, false); if (pArcConstruct != null) { IPolygon pPolygon = new PolygonClass(); ISegment pArcC = pArcConstruct as ISegment; ISegmentCollection pArcP = pPolygon as ISegmentCollection; pArcP.AddSegment(pArcC); pPolygon.Close(); IFeature pFeature = m_FLayer.FeatureClass.CreateFeature(); pFeature.Shape = pPolygon; pFeature.Store(); m_pMapCtl.Refresh(); m_NewCircleFeedback.Stop(); m_NewCircleFeedback = null; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); if (m_NewCircleFeedback != null) { m_NewCircleFeedback.Stop(); } m_NewCircleFeedback = null; } } } }