public override void OnMouseMove(int button, int shift, int x, int y) { if (!this._areaMeasureDlg.Visible && this._polygonFeedback != null) { this._polygonFeedback.Stop(); this._polygonFeedback = null; int pointCount = this._pointCollection.PointCount; this._pointCollection.RemovePoints(0, pointCount); } else { IPoint point = _context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); object missing = Type.Missing; this._pointCollection.AddPoint(point, ref missing, ref missing); if (this._polygonFeedback != null) { this._polygonFeedback.MoveTo(point); } this._pointCollection.AddPoint(this._pointCollection.get_Point(0), ref missing, ref missing); IPolygon polygon = (IPolygon)this._pointCollection; double length = polygon.Length; IArea area = (IArea)polygon; double curArea = Math.Abs(area.Area); if (this._pointCollection.PointCount > 2) { this._areaMeasureDlg.CurArea = curArea; this._areaMeasureDlg.CurPerimeter = length; } this._pointCollection.RemovePoints(this._pointCollection.PointCount - 1, 1); int pointCount2 = this._pointCollection.PointCount; this._pointCollection.RemovePoints(pointCount2 - 1, 1); } }
//双击则创建该线,并弹出缓冲窗体 public override void OnDblClick() { //获取折线 并获取当前视图的屏幕显示 if (m_pNewPolygonFeedback == null) { return; } IPolygon pPolygon = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; //不存在,为空。尺寸不够均退出 if (pPolygon == null || pPolygon.IsEmpty) { return; } if (pPolygon.Envelope.Width < 0.01 || pPolygon.Envelope.Height < 0.01) { return; } //创建Topo对象,简化后统一空间参考 ITopologicalOperator pTopo = (ITopologicalOperator)pPolygon; pTopo.Simplify(); pPolygon.Project(m_MapControl.Map.SpatialReference); if (m_frmQuery == null) { m_frmQuery = new frmQuery(m_MapControl, m_enumQueryMode); m_frmQuery.Owner = m_mainFrm; m_frmQuery.FormClosed += new FormClosedEventHandler(frmQuery_FormClosed); } frmBufferSet pFrmBufSet = new frmBufferSet(pPolygon as IGeometry, m_MapControl.Map, m_frmQuery); IGeometry pGeometry = pFrmBufSet.GetBufferGeometry(); if (pGeometry == null || pFrmBufSet.Res == false) { return; } // m_frmQuery.Show(); //m_frmQuery.FillData(m_MapControl.ActiveView.FocusMap, pGeometry); _QuerBar.m_pMapControl = m_MapControl; _QuerBar.EmergeQueryData(m_MapControl.ActiveView.FocusMap, pGeometry, pFrmBufSet.pesriSpatialRelEnum); try { DevComponents.DotNetBar.Bar pBar = _QuerBar.Parent.Parent as DevComponents.DotNetBar.Bar; if (pBar != null) { pBar.AutoHide = false; //pBar.SelectedDockTab = 1; int tmpindex = pBar.Items.IndexOf("dockItemDataCheck"); pBar.SelectedDockTab = tmpindex; } } catch { } m_frmQuery = null; }
public override void OnDblClick() { if (this.inewPolygonFeedback_0 != null) { IPolygon geometry = this.inewPolygonFeedback_0.Stop(); this.inewPolygonFeedback_0 = null; IElement element = new PolygonElement { Geometry = geometry }; INewElementOperation operation = new NewElementOperation { ActiveView = this._context.ActiveView, Element = element, ContainHook = this.method_0() }; this._context.OperationStack.Do(operation); //if (this._context.Hook is IApplication) //{ // if ((this._context.Hook as IApplication).ContainerHook != null) // { // DocumentManager.DocumentChanged((this._context.Hook as IApplication).ContainerHook); // } // else // { // DocumentManager.DocumentChanged((this._context.Hook as IApplication).Hook); // } //} //else //{ // DocumentManager.DocumentChanged(this._context.Hook); //} } }
public override void OnMouseDown(int button, int shift, int x, int y) { if (button != 1) { return; } if (this._context.ActiveView is IPageLayout) { IPoint location = this._context.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IMap map = this._context.ActiveView.HitTestMap(location); if (map == null) { return; } if (map != this._context.FocusMap) { this._context.ActiveView.FocusMap = map; this._context.ActiveView.Refresh(); } } IPoint point = ((IActiveView)this._context.FocusMap).ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); if (inewPolygonFeedback_0 == null) { inewPolygonFeedback_0 = new NewPolygonFeedback(); inewPolygonFeedback_0.Display = ((IActiveView)this._context.FocusMap).ScreenDisplay; inewPolygonFeedback_0.Start(point); return; } inewPolygonFeedback_0.AddPoint(point); }
public override void OnKeyDown(int keyCode, int Shift) { if (keyCode == 27) { EnumDrawType drawType = this.DrawType; if (drawType != EnumDrawType.circle) { if (drawType == EnumDrawType.polygon) { if (this.m_polygonFeedback != null) { this.m_polygonFeedback.Stop(); } this.m_polygonFeedback = null; } } else { if (this.m_circleFeedback != null) { this.m_circleFeedback.Stop(); } this.m_circleFeedback = null; } this.m_mapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } }
private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e) { switch (mousedownname) { case "MeasureLength": if (frmMeasureresult != null) { frmMeasureresult.label2.Text = "线段总长度为:" + dToltaLength + sMapUnit; } if (pNewLineFeedback != null) { pNewLineFeedback.Stop(); pNewLineFeedback = null; //清空线对象 axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); } dToltaLength = 0; dSegmentLength = 0; break; case "MeasureArea": if (pNewPolygonFeedback != null) { pNewPolygonFeedback.Stop(); pNewPolygonFeedback = null; axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); //清空面对象 } pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount); //清空点集中所有点 break; } }
private void buttonItem22_Click(object sender, EventArgs e) { //删除所选要素(单选): m_sketchshape = "featuredelete"; m_NewPolygonFeedback = null; IFeatureLayer iCheckLayer = m_MapCtrls.ActiveView.FocusMap.get_Layer(0) as IFeatureLayer; IFeatureSelection CurrentSelection = iCheckLayer as IFeatureSelection; int OID = 0; if (CurrentSelection.SelectionSet.Count == 1) { OID = CurrentSelection.SelectionSet.IDs.Next(); } if (OID > 0) { IFeatureWorkspace checkWorkspace = m_GlobalWorkspace as IFeatureWorkspace; IFeatureClass checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea"); if (!(m_EditWorkspace.IsBeingEdited())) { m_EditWorkspace.StartEditing(false); } m_EditWorkspace.StartEditOperation(); CheckFeatueEditor.DeleteCheckArea(OID, checkFeatureClass); m_EditWorkspace.StopEditOperation(); MessageBox.Show("删除成功!"); //清除选择要素: CurrentSelection.Clear(); m_MapCtrls.ActiveView.Refresh(); } }
private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e) //地图双击 { #region 长度量算 if (pMouseOperate == "MeasureLength") { if (frmMeasureResult != null) { frmMeasureResult.lblMeasureResult.Text = "量测的总路线距离为:" + dToltalLength + sMapUnits; } if (pNewLineFeedback != null) { pNewLineFeedback.Stop(); pNewLineFeedback = null; //清空所画的线对象 (axMapControl1.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); } dToltalLength = 0; dSegmentLength = 0; } #endregion #region 面积量算 if (pMouseOperate == "MeasureArea") { if (pNewPolygonFeedback != null) { pNewPolygonFeedback.Stop(); pNewPolygonFeedback = null; //清空所画的线对象 (axMapControl1.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); } pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点 } #endregion }
private void OnOnDoubleClick(int button, int shift, int i, int i1, double mapX, double mapY) { if (button == 2) { return; } if (_polygonFeedback == null) { return; } IPoint point = new PointClass(); point.PutCoords(mapX, mapY); _polygonFeedback.AddPoint(point); _polygon = _polygonFeedback.Stop(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = (0); rgbColorClass.Green = (255); rgbColorClass.Blue = (255); ISimpleFillSymbol simpleFillSymbolClass = new SimpleFillSymbol(); ((ISymbol)simpleFillSymbolClass).ROP2 = (esriRasterOpCode)(10); simpleFillSymbolClass.Color = (rgbColorClass); IElement element = new PolygonElement(); element.Geometry = _polygon; ((IFillShapeElement)element).Symbol = simpleFillSymbolClass; _graphicsContainer.DeleteAllElements(); _graphicsContainer.AddElement(element, 100); _context.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); OnDrawCompleteEvent(); //_polygon = null; _polygonFeedback = null; }
public override bool Deactivate() { frmAddTINPlane.Hide(); frmAddTINPlane.setButtonOkEnable(false); mNewPolygonFeedback = null; return(base.Deactivate()); }
/// <summary> /// Occurs when this tool is clicked /// </summary> public override void OnClick() { pMap = m_hookHelper.FocusMap; pActiveView = m_hookHelper.ActiveView; pMap.ClearSelection(); pActiveView.Refresh(); // TODO: Add Tool1.OnClick implementation if (isSketching != true) { this.fb = new NewPolygonFeedbackClass(); this.fb.Display = m_hookHelper.ActiveView.ScreenDisplay; ISimpleFillSymbol sym = new SimpleFillSymbolClass(); IRgbColor color = new RgbColorClass(); color.Red = 0; color.Green = 0; color.Blue = 255; ISimpleLineSymbol ln_sym = new SimpleLineSymbolClass(); ln_sym.Color = color as IColor; ln_sym.Width = 2; sym.Outline = ln_sym as ILineSymbol; sym.Style = esriSimpleFillStyle.esriSFSNull; this.fb.Symbol = sym as ISymbol; } else { this.fb.Refresh(m_hookHelper.ActiveView.ScreenDisplay.hDC); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add AreaPrintMapClass.OnMouseDown implementation if (Button == 1) { if (m_InUse == true) { m_ActiveView = m_hookHelper.ActiveView; m_ScreenDisplay = m_ActiveView.ScreenDisplay; IMap pMap = m_ActiveView.FocusMap; IPoint pPoint; pPoint = (IPoint)m_ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_NewPolygonFeedback == null) { m_NewPolygonFeedback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSlnSym; IRgbColor pRGB = new RgbColorClass(); pSlnSym = (ISimpleLineSymbol)m_NewPolygonFeedback.Symbol; pRGB.Red = 225; pRGB.Green = 0; pRGB.Blue = 0; pSlnSym.Color = pRGB; pSlnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSlnSym.Width = 2; m_NewPolygonFeedback.Display = m_ScreenDisplay; m_NewPolygonFeedback.Start(pPoint); } else { m_NewPolygonFeedback.AddPoint(pPoint); } } } }
public override void OnDblClick() { //base.OnDblClick(); if (m_pNewPolygonFeedback != null) { m_pPolygon = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; } ISimpleFillSymbol pSimFillSym; IRgbColor pRGB; pSimFillSym = new SimpleFillSymbolClass(); pRGB = new RgbColorClass(); pRGB.Red = 255; pRGB.Green = 50; pRGB.Blue = 50; pRGB.Transparency = 0; pSimFillSym.Color = pRGB; if (m_pPolygon != null) { m_pScreenDisplay.StartDrawing(m_pScreenDisplay.hDC, -1); m_pScreenDisplay.SetSymbol((ISymbol)pSimFillSym); m_pScreenDisplay.DrawPolygon(m_pPolygon); m_pScreenDisplay.FinishDrawing(); } }
/// <summary> /// 完成新建对象,取得绘制的对象,并添加到图层中 /// 建议在Map.DblClick或Map.MouseDown(Button = 2)事件中调用本方法 /// </summary> public void NewFeatureEnd() { IGeometry pGeom = null; IPointCollection pPointCollection; try { if (m_pFeedback is INewMultiPointFeedback) { INewMultiPointFeedback pMPFeed = (INewMultiPointFeedback)m_pFeedback; pMPFeed.Stop(); pGeom = (IGeometry)m_pPointCollection; } else if (m_pFeedback is INewLineFeedback) { INewLineFeedback pLineFeed = (INewLineFeedback)m_pFeedback; pLineFeed.AddPoint(m_pPoint); IPolyline pPolyLine = pLineFeed.Stop(); pPointCollection = (IPointCollection)pPolyLine; if (pPointCollection.PointCount < 2) { MessageBox.Show("至少输入两个节点"); } else { pGeom = (IGeometry)pPointCollection; } } else if (m_pFeedback is INewPolygonFeedback) { INewPolygonFeedback pPolyFeed = (INewPolygonFeedback)m_pFeedback; pPolyFeed.AddPoint(m_pPoint); IPolygon pPolygon; pPolygon = pPolyFeed.Stop(); if (pPolygon != null) { pPointCollection = (IPointCollection)pPolygon; if (pPointCollection.PointCount < 3) { MessageBox.Show("至少输入三个节点"); } else { pGeom = (IGeometry)pPointCollection; } } } CreateFeature(pGeom); m_pFeedback = null; m_bInUse = false; } catch (Exception e) { Console.WriteLine(e.Message.ToString()); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button != 1) { return; } IPoint pPoint = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewPolygonFeedback == null) //第一次按下 { IRgbColor pRGB = new RgbColorClass(); ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pRGB.Red = 15; pRGB.Blue = 15; pRGB.Green = 0; pSimpleFillSymbol.Color = pRGB; pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; m_pNewPolygonFeedback = new NewPolygonFeedbackClass(); m_pNewPolygonFeedback.Symbol = pSimpleFillSymbol as ISymbol; m_pNewPolygonFeedback.Display = m_MapControl.ActiveView.ScreenDisplay; m_pNewPolygonFeedback.Start(pPoint); } else //将点加入 { m_pNewPolygonFeedback.AddPoint(pPoint); } }
private void MainMapControl_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e) { if (pMouseOperate == "MeasureLength") { if (frmMeasureResult != null) { frmMeasureResult.label2.Text = "线段总长度为:" + dToltalLength + sMapUnits; } if (pNewLineFeedback != null) { pNewLineFeedback.Stop(); pNewLineFeedback = null; //清空所画的线对象 (mainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); } dToltalLength = 0; dSegmentLength = 0; } else if (pMouseOperate == "MeasureArea") { if (pNewPolygonFeedback != null) { pNewPolygonFeedback.Stop(); pNewPolygonFeedback = null; //清空所画的线对象 (mainMapControl.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); } pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点 } }
/// <summary> /// 结束当前的测量,返回进行量算时在地图上绘的图形对象 /// 建议在Map的DoubleClick事件或MouseDown(右键)事件中调用本方法 /// 将返回对象用map.DrawShape方法绘在地图临时层上 /// </summary> /// <param name="point">终点</param> /// <returns>地图上绘的图形对象</returns> public IGeometry SurveyEnd(IPoint point) { IGeometry geometry = null; if (_eMeasureType == EMeasureType.Distance || _eMeasureType == EMeasureType.Angle) { if (_newLineFeedback != null) { _newLineFeedback.AddPoint(point); geometry = _newLineFeedback.Stop(); _newLineFeedback = null; } } else if (_eMeasureType == EMeasureType.Area) { if (_newPolygonFeedback != null) { _newPolygonFeedback.AddPoint(point); geometry = _newPolygonFeedback.Stop(); _newPolygonFeedback = null; } } _pointCollection = null; IsSurveying = false; return(geometry); }
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 OnKeyDown(int button, int shift) { if (button == 27) { this.inewPolygonFeedback_0 = null; this._context.ActiveView.Refresh(); } }
private void buttonItem19_Click(object sender, EventArgs e) { m_sketchshape = "rectangle"; m_NewPolygonFeedback = null; m_RecFeedback = null; m_MapCtrls.CurrentTool = null; m_MapCtrls.ActiveView.Refresh(); }
private void buttonItem21_Click(object sender, EventArgs e) { m_sketchshape = "featureselect"; m_NewPolygonFeedback = null; ESRI.ArcGIS.SystemUI.ICommand selectCommand = new ControlsSelectFeaturesToolClass(); selectCommand.OnCreate(m_MapCtrls.Object); m_MapCtrls.CurrentTool = selectCommand as ITool; }
public override void OnClick() { _polygon = null; _drawStart = true; (myHook.Hook as IMapControl3).CurrentTool = this; _polyFeedback = new NewPolygonFeedbackClass(); }
/// <summary> /// 回收变量 /// </summary> public void Recycle() { m_NewPolygonFeedback = null; m_ptCollection.RemovePoints(0, m_ptCollection.PointCount); m_ptCollection = null; m_TracePolygon = null;//20140218 lyf m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_hookHelper.ActiveView.Extent); }
public override void OnKeyDown(int keyCode, int Shift) { if (_inLine && keyCode == 27) { _polyFeedback = null; _inLine = false; } }
public void Relealse() { m_HookHelper = null; m_Cursor = null; m_pNewPolygonFeedback = null; mGeomln = null; pFirstGeom = null; }
public override void OnKeyDown(int keyCode, int Shift) { if (keyCode.Equals(27)) { m_GeoMeasure = null; m_pNewPolygonFeed = null; m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, m_hookHelper.ActiveView.Extent); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add CreatShape.OnMouseDown implementation if (Button == 1) { IFeatureLayer m_FeatureLayer = (IFeatureLayer)m_CurrentLayer; if (m_FeatureLayer.FeatureClass == null) { return; } IActiveView m_ActiveView = m_hookHelper.ActiveView; IPoint m_PointMousedown = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); m_PointStop = m_PointMousedown; if (!m_bInUse) { switch (m_FeatureLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: //点类型 CreatFeature(m_PointMousedown); m_hookHelper.ActiveView.Refresh(); break; case esriGeometryType.esriGeometryPolyline: //线类型 m_bInUse = true; m_Feedback = new NewLineFeedback(); INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback; m_LineFeed.Start(m_PointMousedown); break; case esriGeometryType.esriGeometryPolygon: m_bInUse = true; m_Feedback = new NewPolygonFeedback(); INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback; m_PolyFeed.Start(m_PointMousedown); break; } if (m_Feedback != null) { m_Feedback.Display = m_ActiveView.ScreenDisplay; } } else { if (m_Feedback is INewLineFeedback) { INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback; m_LineFeed.AddPoint(m_PointMousedown); } else if (m_Feedback is INewPolygonFeedback) { INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback; m_PolyFeed.AddPoint(m_PointMousedown); } } } }
private void buttonItem3_Click(object sender, EventArgs e) { //点击identify工具: m_sketchshape = "identify"; m_NewPolygonFeedback = null; ESRI.ArcGIS.SystemUI.ICommand panCommand = new ControlsMapIdentifyToolClass(); panCommand.OnCreate(m_MapCtrls.Object); m_MapCtrls.CurrentTool = panCommand as ITool; }
/// <summary> /// 测量工具 /// </summary> internal MeasureTools(AxMapControl mapCtrl) { MapCtrl = mapCtrl; _pointCollection = null; _newPolygonFeedback = null; _newLineFeedback = null; _eMeasureType = 0; IsSurveying = false; }
private void buttonItem27_Click(object sender, EventArgs e) { //设置为缩小Icommand,Zoom out: m_sketchshape = "zoomout"; m_NewPolygonFeedback = null; ESRI.ArcGIS.SystemUI.ICommand panCommand = new ControlsMapZoomOutToolClass(); panCommand.OnCreate(m_MapCtrls.Object); m_MapCtrls.CurrentTool = panCommand as ITool; }
public override void OnDblClick() { base.OnDblClick (); IPolygon thePoly = this._Feedback.Stop(); this._Feedback = null; // Check that the polygon is okay bool bOK = false; if (thePoly != null && thePoly.IsEmpty == false) { thePoly.Close(); thePoly.SimplifyPreserveFromTo(); IArea theArea = (IArea)thePoly; if (theArea.Area > 0) { bOK = true; } } if (!bOK) { MessageBox.Show("Resultant polygon was not valid. Please try again."); return; } // Select features based on the polygon IMxApplication theMxApp = (IMxApplication)this._App; IMap theMap = this.Extension.FocusMap; thePoly.Project(theMap.SpatialReference); // Hold onto the original method for selection so we can set it back afterwards esriSpatialRelEnum theOriginalAreaMethod = theMxApp.SelectionEnvironment.AreaSelectionMethod; esriSpatialRelEnum theOriginalLineMethod = theMxApp.SelectionEnvironment.LinearSelectionMethod; esriSpatialRelEnum theOriginalPointMethod = theMxApp.SelectionEnvironment.PointSelectionMethod; if (this._Form.SelectType == SelectByPolygonForm.selectByPolyType.selectInside) { theMxApp.SelectionEnvironment.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelContains; theMxApp.SelectionEnvironment.LinearSelectionMethod = esriSpatialRelEnum.esriSpatialRelContains; theMxApp.SelectionEnvironment.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelContains; theMap.SelectByShape(thePoly, theMxApp.SelectionEnvironment, false); theMxApp.SelectionEnvironment.AreaSelectionMethod = theOriginalAreaMethod; theMxApp.SelectionEnvironment.LinearSelectionMethod = theOriginalLineMethod; theMxApp.SelectionEnvironment.PointSelectionMethod = theOriginalPointMethod; } else if (this._Form.SelectType == SelectByPolygonForm.selectByPolyType.selectInsideOrIntersecting) { theMxApp.SelectionEnvironment.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects; theMxApp.SelectionEnvironment.LinearSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects; theMxApp.SelectionEnvironment.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects; theMap.SelectByShape(thePoly, theMxApp.SelectionEnvironment, false); theMxApp.SelectionEnvironment.AreaSelectionMethod = theOriginalAreaMethod; theMxApp.SelectionEnvironment.LinearSelectionMethod = theOriginalLineMethod; theMxApp.SelectionEnvironment.PointSelectionMethod = theOriginalPointMethod; } else { // This one is not straightforward and we need to manipulate the polygon shape // Take the rings and buffer them by the pixel tolerance and then pass to ArcMap double pixelTol = theMxApp.SelectionEnvironment.SearchTolerance; double theBufferDistance = this.CalculateMapDistance(theMap, Convert.ToInt32(pixelTol)); IPolyline theOutline = new PolylineClass(); ISegmentCollection theSColl = (ISegmentCollection)thePoly; for (int i = 0; i < theSColl.SegmentCount; i++) ((ISegmentCollection)theOutline).AddSegment(theSColl.get_Segment(i), ref _missing, ref _missing); theOutline.Project(theMap.SpatialReference); IPolygon theBuffer = (IPolygon)((ITopologicalOperator)theOutline).Buffer(theBufferDistance); theMxApp.SelectionEnvironment.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects; theMxApp.SelectionEnvironment.LinearSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects; theMxApp.SelectionEnvironment.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects; theMap.SelectByShape(theBuffer, theMxApp.SelectionEnvironment, false); theMxApp.SelectionEnvironment.AreaSelectionMethod = theOriginalAreaMethod; theMxApp.SelectionEnvironment.LinearSelectionMethod = theOriginalLineMethod; theMxApp.SelectionEnvironment.PointSelectionMethod = theOriginalPointMethod; } // Refresh the map IActiveView theAV = (IActiveView)theMap; theAV.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, theAV.Extent); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { base.OnMouseDown (Button, Shift, X, Y); IScreenDisplay theDisplay = ((IActiveView)this.Extension.FocusMap).ScreenDisplay; IPoint thePoint = theDisplay.DisplayTransformation.ToMapPoint(X, Y); if (this._Feedback == null) { this._Feedback = new NewPolygonFeedbackClass(); this._Feedback.Display = theDisplay; this._Feedback.Start(thePoint); } else { this._Feedback.AddPoint(thePoint); } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //m_Cursor = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "AopenMap.cur")); if (Button == 1) { if (m_InUse == true) { m_pAV = m_HookHelper.ActiveView; m_pScrD = m_pAV.ScreenDisplay; IMap pMap = m_HookHelper.FocusMap; IPoint pPnt; pPnt = (IPoint)m_pScrD.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewPolygonFeedback == null) { m_pNewPolygonFeedback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)m_pNewPolygonFeedback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; m_pNewPolygonFeedback.Display = m_pScrD; m_pNewPolygonFeedback.Start(pPnt); } else { m_pNewPolygonFeedback.AddPoint(pPnt); } } } else if (Button == 2) { IPolygon pGeomLn; pGeomLn = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; IMap pMap = m_HookHelper.FocusMap; ISpatialReference spatialReference = pMap.SpatialReference; //IBorder pBorder = new SymbolBorderClass(); //*****************************************88888888 if (pFirstGeom == null) { pFirstGeom = pGeomLn; } if (mGeomln != null) { pFirstGeom = mGeomln; } if (pFirstGeom != pGeomLn) { IPolygon mFirstGeom; mFirstGeom = pFirstGeom; IRelationalOperator pROperator = (IRelationalOperator)mFirstGeom; if (pROperator.Disjoint((IGeometry)pGeomLn) == false) { //先定义一个IGeometrycollection的多边形,将每个画出来的IgeometryCollection添加进去 //先添一个构成一个IPolygon,转化为ITopo_ ,再同样构成另一个,进行Union IGeometryCollection pcGeometry = new PolygonClass(); object o = System.Type.Missing; IPolygon cFirstGeom = new PolygonClass(); cFirstGeom = pFirstGeom; ITopologicalOperator tempTopo = (ITopologicalOperator)cFirstGeom; tempTopo.Simplify(); ITopologicalOperator pTopo = (ITopologicalOperator)pGeomLn; pTopo.Simplify(); IGeometry kGeom; kGeom = pTopo.Union((IGeometry)cFirstGeom); mGeomln = (IPolygon)kGeom; mGeomln.SpatialReference = spatialReference; m_pAV.FocusMap.ClipGeometry = mGeomln; //IBorder pBorder = new SymbolBorderClass(); //m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = mGeomln.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; //layVisbleExceptMap(); } } else { //*************************************************8 //mGeomln = pGeomLn; pGeomLn.SpatialReference = spatialReference; LayerControl.LyrPolygon = pGeomLn; m_HookHelper.FocusMap.ClipGeometry = pGeomLn; IBorder pBorder = new SymbolBorderClass(); m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = pGeomLn.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; pGeomLn = null; } } }
public void frmMove(ref IPoint pPoint, ref INewPolygonFeedback m_FeedbackPolygon) { if (tbtnArea.Checked == true) { IPoint pPnt = pPoint; m_CurPoint = pPnt; if (m_FeedbackPolygon != null) { m_FeedbackPolygon.MoveTo(pPnt); double MoveArea = 0.0; double MoveLength = 0.0; double tempLegth = 0.0; IPoint LastPoint = pCollection.get_Point(pCollection.PointCount - 1); IPoint CurPoint = m_CurPoint; IPoint FirstPoint = pCollection.get_Point(0); SegAreaLength = Math.Sqrt(Math.Pow((LastPoint.X - CurPoint.X), 2) + Math.Pow((LastPoint.Y - CurPoint.Y), 2)); tempLegth = Math.Sqrt(Math.Pow((CurPoint.X - FirstPoint.X), 2) + Math.Pow((CurPoint.Y - FirstPoint.Y), 2)); MoveLength = TotalAreaLength + SegAreaLength + tempLegth; double CntMoveLength = CntUnit.ConvertUnits(MoveLength, inUnit.pUnit, outUnit.pUnit); double CntSegAreaLength = CntUnit.ConvertUnits(SegAreaLength, inUnit.pUnit, outUnit.pUnit); MoveArea = CaculateArea(pPnt); double CntMoveArea; string AreaUnitMess; CntMoveArea=ConvertToArea( MoveArea, inAreaUnit.UnitName , outAreaUnit.UnitName); if (outAreaUnit.UnitName == "Unkown Units") AreaUnitMess = outAreaUnit.UnitName; else AreaUnitMess = "Square " + outAreaUnit.UnitName; m_SegLen.value = CntSegAreaLength; m_SegLen.units = outUnit.pUnit; m_TotLen.value = CntMoveLength; m_TotLen.units = outUnit.pUnit; m_Area.value = CntMoveArea; m_Area.units = outAreaUnit.pUnit; CntMoveLength = Math.Round(CntMoveLength, 6); CntMoveArea = Math.Round(CntMoveArea, 6); CntSegAreaLength = Math.Round(CntSegAreaLength, 6); double tempSumPeri = SumPerimeters + CntMoveLength; double tempSumAreas = SumAreas + CntMoveArea; UnitSumPeri = tempSumPeri; UnitSumArea = tempSumAreas; txtMessage.Text ="测量面" +"\r\n线段长是" + CntSegAreaLength + outUnit.UnitName + "\r\n周长是:" +CntMoveLength + outUnit.UnitName + "\r\n面积是:" + CntMoveArea + AreaUnitMess; if (tbtnSum.Checked == true) txtMessage.Text += "\r\n" + "\r\n周长长度之和是:" +tempSumPeri+ outUnit.UnitName + "\r\n面积之和是:" + tempSumAreas+ AreaUnitMess; } } }
public override bool Deactivate() { if (m_polygonFeedback != null) { m_polygonFeedback.Stop(); m_polygonFeedback = null; } m_screenDisplay = null; return true; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //���ӵ����Ҽ��������� �ᄃ���20081028 if (Button == 2) { OnDblClick(); return; } IActiveView ipAV = this.m_hookHelper.ActiveView; ///////////�����µ�/////////////// IPoint ipPt = new PointClass(); ipPt = ipAV.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); SnapPoint(ipPt); ////////////�������/////////////// //if (this.m_FormDis == null) //{ // MeasureType type = MeasureType.Area; // this.m_FormDis = new FormDis(type, this); // this.m_FormDis.TopMost = true; // this.m_FormDis.Show(); //} if (this.m_GeoMeasure == null) { m_pNewPolygonFeed = new NewPolygonFeedbackClass(); IScreenDisplay pScreen = ipAV.ScreenDisplay; m_pNewPolygonFeed.Display = pScreen; m_pNewPolygonFeed.Start(ipPt); this.m_GeoMeasure = new PolylineClass(); } else { m_pNewPolygonFeed.AddPoint(ipPt); } /* /////////����ʵ��/////////// object obj = Type.Missing; if (this.m_GeoMeasure == null) { this.m_GeoMeasure = new PolygonClass(); IGeometryCollection ipGeoCol = this.m_GeoMeasure as IGeometryCollection; ISegmentCollection ipSelCol = new RingClass(); ILine ipLine = new LineClass(); ipLine.PutCoords(ipPt, ipPt); ipSelCol.AddSegment(ipLine as ISegment, ref obj, ref obj); ipSelCol.AddSegment(ipLine as ISegment, ref obj, ref obj); ipGeoCol.AddGeometry(ipSelCol as IGeometry, ref obj, ref obj); } else { IGeometryCollection ipGeoCol = this.m_GeoMeasure as IGeometryCollection; ISegmentCollection ipSelCol = ipGeoCol.get_Geometry(0) as ISegmentCollection; ipSelCol.RemoveSegments(ipSelCol.SegmentCount - 1, 1, false); ILine ipLine = new LineClass(); ipLine.PutCoords(ipSelCol.get_Segment(ipSelCol.SegmentCount - 1).ToPoint, ipPt); ISegment ipSeg = ipLine as ISegment; ipSelCol.AddSegment(ipSeg, ref obj, ref obj); ipLine = new LineClass(); ipLine.PutCoords(ipPt, ipSelCol.get_Segment(0).FromPoint); ipSeg = ipLine as ISegment; ipSelCol.AddSegment(ipSeg, ref obj, ref obj); } ////////��ʾ///////////// IClone ipClone = this.m_GeoMeasure as IClone; IGeometry ipGeo = ipClone.Clone() as IGeometry; this.m_Element.Geometry = ipGeo; //�ֲ�ˢ�� ipAV.PartialRefresh(esriViewDrawPhase.esriViewGraphics, ipGeo, null); //ipAV.Refresh(); this.m_FormDis.WriteLabelText(ipGeo); this.m_FormDis.m_timer.Start(); */ }
public override void OnKeyDown(int keyCode, int Shift) { if (keyCode == (int)Keys.Escape) { if (m_FeedbackLine != null) { m_FeedbackLine.Stop(); m_FeedbackLine = null; } if (m_FeedbackPolygon != null) { m_FeedbackPolygon.Stop(); m_FeedbackPolygon = null; } m_Geometry = null; } }
private void btnOpnMap_Click(object sender, EventArgs e) { double dobX, dobY; string txtCoodX, txtCoodY; if (lstVwCood.Items.Count < 3) { MessageBox.Show("请输入三个以上的点!"); return; } else { for (int i = 0; i < lstVwCood.Items.Count; i++) { txtCoodX = lstVwCood.Items[i].SubItems[1].Text; txtCoodY = lstVwCood.Items[i].SubItems[2].Text; dobX = Convert.ToDouble(txtCoodX); dobY = Convert.ToDouble(txtCoodY); pPnt.PutCoords(dobX, dobY); if (pNPolFeback == null) { pNPolFeback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)pNPolFeback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; pNPolFeback.Display = pScreen; pNPolFeback.Start(pPnt); } else { pNPolFeback.AddPoint(pPnt); } } pActivew = pMapControl.ActiveView; pScreen = pActivew.ScreenDisplay; IGeometry pGeomLn; pGeomLn = (IGeometry)pNPolFeback.Stop(); IMap pMap = pMapControl.Map; ISpatialReference spatialReference = pMap.SpatialReference; pGeomLn.SpatialReference = spatialReference; IBorder pBorder = new SymbolBorderClass(); LayerControl.LyrPolygon = pGeomLn; pMapControl.Map.ClipBorder = pBorder; pMapControl.Map.ClipGeometry = pGeomLn; pActivew.Extent = pGeomLn.Envelope; //pActivew.Refresh(); this.DialogResult = DialogResult.OK; ////打开地形图图层 //layVisbleExceptMap(); this.Close(); pActivew.Refresh(); } }
/// <summary> /// ���ձ��� /// </summary> public void Recycle() { m_NewPolygonFeedback = null; m_ptCollection.RemovePoints(0, m_ptCollection.PointCount); m_ptCollection = null; m_TracePolygon = null;//20140218 lyf m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, m_hookHelper.ActiveView.Extent); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button == 2) return; IPoint pt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); pt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pt); IGraphicsContainer graphicContainer = m_hookHelper.ActiveView.GraphicsContainer; IEnvelope pEnvBounds = null; //��ȡ��һ�ι켣�ߵķ�Χ,�Ա�ȷ��ˢ�·�Χ try { if (m_TracePolygon != null) { m_TracePolygon.QueryEnvelope(pEnvBounds); pEnvBounds.Expand(4, 4, true); //���ο�����������4��(����2������),Ŀ����Ϊ�˱�֤�г����ˢ������ } else pEnvBounds = m_hookHelper.ActiveView.Extent; } catch { pEnvBounds = m_hookHelper.ActiveView.Extent; } #region ������� if (m_NewPolygonFeedback == null) { //�Ƴ�element RemoveElements(); //ˢ�� m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); Application.DoEvents(); m_NewPolygonFeedback = new NewPolygonFeedbackClass(); //�����ȵõ�symbol,������symbol ISimpleLineSymbol simpleLineSymbol = m_NewPolygonFeedback.Symbol as ISimpleLineSymbol; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 2; simpleLineSymbol.Color = TransColorToAEColor(Color.Blue); m_simpleFillSymbol.Outline = simpleLineSymbol; m_NewPolygonFeedback.Display = m_hookHelper.ActiveView.ScreenDisplay; m_NewPolygonFeedback.Start(pt); } else { m_NewPolygonFeedback.AddPoint(pt); } if (m_ptCollection == null) { m_ptCollection = new PolylineClass(); } //��¼�ڵ� object obj = Type.Missing; m_ptCollection.AddPoint(pt, ref obj, ref obj); #endregion #region ���ƽ�� try { IElement vertexElement = createElement_x(pt); // graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer; //g.AddElement(vertexElement, 0); //g.MoveElementToGroup(vertexElement, m_VertexElement); m_VertexElement.AddElement(vertexElement); //ˢ�� m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, vertexElement, pEnvBounds); } catch { } #endregion try { if (m_ptCollection.PointCount >= 2) { IPoint fromPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 2); //�����ڶ����� IPoint toPt = m_ptCollection.get_Point(m_ptCollection.PointCount - 1); //����һ���� ILine line = new LineClass(); line.PutCoords(fromPt, toPt); #region ���ƹ켣�� try { object missing = Type.Missing; ISegmentCollection segColl = new PolylineClass(); segColl.AddSegment(line as ISegment, ref missing, ref missing); IPolyline polyline = new PolylineClass(); polyline = segColl as IPolyline; IElement traceElement = createElement_x(polyline); //graphicContainer = m_hookHelper.ActiveView as IGraphicsContainer; m_TraceElement.AddElement(traceElement); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, traceElement, pEnvBounds); } catch { } #endregion #region ���㵥�ߵij���,���������ʾ�ڵ����е�ƫ������ //try //{ // double angle = line.Angle; // if ((angle > (Math.PI / 2) && angle < (Math.PI)) || (angle > -Math.PI && angle < -(Math.PI / 2))) // ����90��С�ڵ���180 // angle += Math.PI; // //��ע��Yֵƫ���� // double d_OffsetY = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.FromPoints(9); // //��ע�� // double d_CenterX = (fromPt.X + toPt.X) / 2; // double d_CenterY = (fromPt.Y + toPt.Y) / 2 + d_OffsetY; //����ƫ�� // IPoint labelPt = new PointClass(); // labelPt.PutCoords(d_CenterX, d_CenterY); // ITextElement txtElement = CreateTextElement(line.Length.ToString("0.00")); // IElement labelelement = txtElement as IElement; // labelelement.Geometry = labelPt; // object oElement = (object)labelelement; // //���ݽǶ���ת // TransformByRotate(ref oElement, labelPt, angle); // ////��ӵ�GraphicsContainer // //g.AddElement(labelelement, 0); // ////�Ƶ�m_LabelElement���� // //g.MoveElementToGroup(labelelement, m_LabelElement); // //��ӵ��� // m_LabelElement.AddElement(labelelement); // //ˢ�� // m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, labelelement, pEnvBounds); //} //catch //{ } #endregion } } catch { } m_frmMeasureResult.PolygonResultChange(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add MeasureDisTool.OnMouseDown implementation frm = GetFrm(); frm.Show(); frm.TopMost = true; IPoint pPnt; IMap pMap = m_hookHelper.FocusMap; IActiveView pActView = m_hookHelper.ActiveView; if (Button == 1) { pPnt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (frm.CheckedBtn == 1) { if (m_FeedbackLine == null) { m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); m_FeedbackLine = new NewLineFeedbackClass(); m_FeedbackLine.Display = m_hookHelper.ActiveView.ScreenDisplay; m_FeedbackLine.Start(pPnt); } else m_FeedbackLine.AddPoint(pPnt); frm.frmLineDown(ref pPnt); } if (frm.CheckedBtn == 2) { if (m_FeedbackPolygon == null) { m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); m_FeedbackPolygon = new NewPolygonFeedbackClass(); m_FeedbackPolygon.Display = m_hookHelper.ActiveView.ScreenDisplay; m_FeedbackPolygon.Start(pPnt); } else m_FeedbackPolygon.AddPoint(pPnt); frm.frmAreaDown(ref pPnt); } if(frm.CheckedBtn==3) frm.frmFeatDown(ref pMap, ref pPnt,pActView); } }
public void frmDbClick(ref INewPolygonFeedback m_FeedbackPolygon, ref IGeometry m_Geometry) { if (tbtnArea.Checked == true) { if (m_FeedbackPolygon != null) { pGeometry = m_FeedbackPolygon.Stop(); m_Geometry = pGeometry; m_FeedbackPolygon = null; } IPolygon pPloygon = (IPolygon)pGeometry; Perimeter = pPloygon.Length; Perimeter = CntUnit.ConvertUnits(Perimeter, inUnit.pUnit, outUnit.pUnit); m_TotLen.value = Perimeter; m_TotLen.units = outUnit.pUnit; SegAreaLength = LastSegArea; double CntSegAreaLength = CntUnit.ConvertUnits(SegAreaLength, inUnit.pUnit, outUnit.pUnit); m_SegLen.value = CntSegAreaLength; m_SegLen.units = outUnit.pUnit; pArea = (IArea)pPloygon; myArea =Math.Abs( pArea.Area); double CntmyArea = myArea; CntmyArea=ConvertToArea( CntmyArea, inAreaUnit.UnitName, outAreaUnit.UnitName); m_Area.value = CntmyArea; m_Area.units = outAreaUnit.pUnit; string AreaUnitMess; if (outAreaUnit.UnitName == "Unkown Units") AreaUnitMess = outAreaUnit.UnitName; else AreaUnitMess = "Square " + outAreaUnit.UnitName; Perimeter = Math.Round(Perimeter, 6); SumPerimeters += Perimeter; CntSegAreaLength = Math.Round(CntSegAreaLength, 6); CntmyArea = Math.Round(CntmyArea, 6); SumAreas += CntmyArea; UnitSumArea = SumAreas; UnitSumPeri = SumPerimeters; txtMessage.Text = "测量面"+"\r\n线段长是" + CntSegAreaLength + outUnit.UnitName + "\r\n周长是:" + Perimeter + outUnit.UnitName + "\r\n面积是:" + CntmyArea + AreaUnitMess; if(tbtnSum.Checked==true) txtMessage.Text+="\r\n"+"\r\n周长长度之和是:"+ SumPerimeters+outUnit.UnitName +"\r\n面积之和是:"+SumAreas+AreaUnitMess ; } TotalLength = 0.0; SegLength = 0.0; TotalAreaLength = 0.0; SegAreaLength = 0.0; myArea = 0.0; Perimeter = 0.0; pCollection = new MultipointClass(); pGeometry = null; }
public override bool Deactivate() { base.Deactivate(); if (this._Form != null) { this._allowFormClose = true; this._Form.Close(); this._Form.Dispose(); this._Form = null; } if (this._Feedback != null) { IPolygon thePoly = this._Feedback.Stop(); this._Feedback = null; } return true; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (Button == 1) { IPoint cursorPoint = m_screenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_polygonFeedback == null) { m_currentSides = 0; m_polygonFeedback = new NewPolygonFeedbackClass(); m_polygonFeedback.Display = m_screenDisplay; m_polygonFeedback.Start(cursorPoint); } else { m_polygonFeedback.AddPoint(cursorPoint); } m_currentSides++; if (m_currentSides == m_maxSides) //Finish { IPolygon polygon = m_polygonFeedback.Stop(); //Report area on status bar IArea feedBackArea = polygon as IArea; m_application.StatusBar.set_Message(0, "Feedback: area = " + Math.Abs(feedBackArea.Area).ToString()); m_polygonFeedback = null; } else { //Report vertex remaining m_application.StatusBar.set_Message(0, string.Format("Feedback: {0} point(s) remaining", m_maxSides - m_currentSides)); } } }