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 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); //清空点集中所有点 } }
//双击则创建该线,并弹出缓冲窗体 public override void OnDblClick() { //获取折线 并获取当前视图的屏幕显示 if (m_pNewLineFeedback == null) { return; } IPolyline pPolyline = m_pNewLineFeedback.Stop(); m_pNewLineFeedback = null; pPolyline.Project(m_MapControl.Map.SpatialReference); frmBufferSet pFrmBufSet = new frmBufferSet(pPolyline as IGeometry, m_MapControl.Map); IGeometry pGeometry = pFrmBufSet.GetBufferGeometry(); if (pGeometry == null || pFrmBufSet.Res == false) { return; } //================================================================================================== //执行查询数据操作 ModDBOperator.QueryDataByGeometry(pGeometry, m_hook); }
public override void OnMouseMove(int button, int shift, int x, int y, double mapX, double mapY) { // TODO: 添加 DrawRectSide2P.OnMouseMove 实现 base.OnMouseMove(button, shift, x, y, mapX, mapY); m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_pAnchorPoint = m_pPoint; //+++++++++++++开始捕捉+++++++++++++++++++++ //CommonFunction.Snap(m_MapControl,m_App.CurrentConfig.cfgSnapEnvironmentSet,(IGeometry)m_pLastPoint,m_pAnchorPoint); if (m_bInUse == true) { if (m_mouseDownCount == 1) //计数器=1时 { m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_pAnchorPoint = m_pPoint; m_pFeedback.MoveTo(m_pAnchorPoint); } else if (m_mouseDownCount == 2) { m_pLineFeed.Stop(); //if(m_bFixDirection && m_bInputWindowCancel == false) //固定m_pAnchorPoint使其在一个固定方向上 //{ // m_pPoint = Class.Common.GetTwoPoint_FormPointMousePointFixDirection(m_pLastPoint,m_pPoint,m_dblFixDirection); // m_pAnchorPoint = m_pPoint; //} if (!m_bFixSideLength) //获取矩形一边长 { m_dblSideLength = Class.Common.GetRectangleOfSide_Length((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1), m_pAnchorPoint); } //else if (m_bInputWindowCancel == false)//按S键,用户输入边长,修正m_dblSideLength值 //{ // bool bRight;//判断鼠标是否位于P1到P2方向的右边 // bRight = CommonFunction.GetRectP0_Right((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1),m_pAnchorPoint); // if (bRight) m_dblSideLength = - m_dblSideLength;//对输入值反号 //} //获取矩形另两点坐标 m_pSavePointArray.RemoveAll(); m_pSavePointArray = Class.Common.GetPointRectangle2((IPoint)m_pUndoArray.get_Element(0), (IPoint)m_pUndoArray.get_Element(1), m_dblSideLength); Class.Common.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray); //绘制矩形 m_pLineFeed.Start((IPoint)m_pUndoArray.get_Element(1)); m_pLineFeed.AddPoint((IPoint)m_pSavePointArray.get_Element(0)); m_pLineFeed.AddPoint((IPoint)m_pSavePointArray.get_Element(1)); m_pLineFeed.AddPoint((IPoint)m_pUndoArray.get_Element(0)); m_pSavePointArray.Add((IPoint)m_pUndoArray.get_Element(0)); m_pSavePointArray.Add((IPoint)m_pUndoArray.get_Element(1)); m_pSavePointArray.Add((IPoint)m_pSavePointArray.get_Element(0)); }//m_mouseDownCount == 2 } }
/// <summary> /// Resets feedback aka cancels feedback /// </summary> internal void ResetFeedback() { if (feedback == null) { return; } feedback.Stop(); feedback = null; }
/// <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); }
/// <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()); } }
protected override void OnDoubleClick() { base.OnDoubleClick(); try { if (LineFeedBack != null) { trackgeom = LineFeedBack.Stop(); LineFeedBack = null; if (GetDriveCenterlineIntersection(trackgeom)) { if (CalculateHouseNumber()) { SetAttributes(); } } mMap.ClearSelection(); ITopologicalOperator to = SelectedPoint.Shape as ITopologicalOperator; IGeometry g = to.Buffer(10); mMap.SelectByShape(g, ArcMap.ThisApplication.SelectionEnvironment, true); IFeatureSelection fsel = Globals.AddressPointLayer as IFeatureSelection; ArcMap.Document.FocusMap.ClearSelection(); ArcMap.Document.ActiveView.Refresh(); ArcMap.Document.FocusMap.ClearSelection(); } } catch { } }
public override void OnMouseUp(int button, int shift, int x, int y, double mapX, double mapY) { { /*CommonFunction.DrawPointSMSSquareSymbol(m_pMapControl, movePoint); */ m_pNewLineFeedback = new NewLineFeedbackClass(); IGeometry pGeomLn = m_pNewLineFeedback.Stop(); if (pGeomLn != null) { AddCreateElement(pGeomLn, this.m_pMapControl.ActiveView); this.m_pMapControl.ActiveView.Refresh(); } m_pNewLineFeedback = null; } double dblZimuth = CommonFunction.GetAzimuth_P12(downPoint.Y, downPoint.X, movePoint.Y, movePoint.X); dblZimuth = CommonFunction.RadToDeg(dblZimuth); strResult1 = dblZimuth.ToString(".#####") + " (°) "; strResult2 = "X=" + downPoint.X.ToString(".##") + " " + "Y=" + downPoint.Y.ToString(".##"); strResult3 = "X=" + movePoint.X.ToString(".##") + " " + "Y=" + movePoint.Y.ToString(".##"); if (strResult1 != null && strResult2 != null && strResult3 != null) { //FrmAzimuthAngle.instance.SetInfo(); FrmAzimuthAngle.instance.ShowDialog(); } }
public override void OnDblClick() { try { if (_lineFeedback == null) { return; } IPolyline polyline = _lineFeedback.Stop(); if (_lineFeedback != null) { _context.ActiveView.Refresh(); _lineFeedback = null; } if (polyline == null) { return; } //CommonHelper.CreatePointFeatures(_pointFeatureLayer, polyline, true, true, true); CommonHelper.CreateLineFeature(_lineFeatureLayer, polyline); _context.ActiveView.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
/// <summary> /// 鼠标双击,结束本次量测,进行下一次量测 /// </summary> public override void OnDblClick() { //base.OnDblClick(); /* * this.m_GeoMeasure = null; * this.m_Element.Geometry = new PolylineClass(); * this.m_hookHelper.ActiveView.Refresh(); * this.m_FormDis.WriteLabelText(this.m_GeoMeasure); */ //this.m_FormDis.WriteLabelText(null); if (this.m_GeoMeasure == null) { return; } //结果显示窗口 if (this.m_FormDis == null) { this.m_FormDis = new FormDis(MeasureType.Length, this); this.m_FormDis.TopMost = true; //窗口显示位置 this.m_FormDis.Location = new System.Drawing.Point(130, 180); this.m_FormDis.Show(); } this.m_GeoMeasure = m_pNewLineFeed.Stop(); this.m_FormDis.WriteLabelText(this.m_GeoMeasure); this.m_GeoMeasure = null; }
public override void OnDblClick() { try { if (_lineFeedback == null) { return; } IPolyline polyline = _lineFeedback.Stop(); _context.ActiveView.Refresh(); _lineFeedback = null; if (polyline == null) { return; } ISnappingResult snappingResult = _pointSnapper.Snap(polyline.ToPoint); if (snappingResult != null) { IPointCollection pointCollection = polyline as IPointCollection; pointCollection.UpdatePoint(pointCollection.PointCount - 1, snappingResult.Location); } CommonHelper.MovePointWithLine(_pointFeature, _lineFeatures, polyline.ToPoint, _tolerance); _lineFeedback = null; _pointFeature = null; _lineFeatures = null; _context.ActiveView.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
//回退操作 private void Undo() { if (m_pUndoArray.Count > 1) { m_pEnvelope = CommonFunction.GetMinEnvelopeOfTheArray(m_pUndoArray); } else if (m_pUndoArray.Count == 1) { IPoint pTempPoint = new PointClass(); pTempPoint.X = (m_pUndoArray.get_Element(0) as Point).X; pTempPoint.Y = (m_pUndoArray.get_Element(0) as Point).Y; m_pEnvelope.Width = Math.Abs(m_pPoint.X - pTempPoint.X); m_pEnvelope.Height = Math.Abs(m_pPoint.Y - pTempPoint.Y); pTempPoint.X = (pTempPoint.X + m_pPoint.X) / 2; pTempPoint.Y = (pTempPoint.Y + m_pPoint.Y) / 2; m_pEnvelope.CenterAt(pTempPoint); } if (m_pEnvelope != null && !m_pEnvelope.IsEmpty) { m_pEnvelope.Expand(10, 10, false); } ; m_pUndoArray.Remove(m_pUndoArray.Count - 1);//删除数组中最后一个点 m_mouseDownCount--; //屏幕刷新 m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, m_pEnvelope); m_pActiveView.ScreenDisplay.UpdateWindow(); //开始作复位工作 if (m_pUndoArray.Count != 0) { CommonFunction.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray); m_pLastPoint = (IPoint)m_pUndoArray.get_Element(m_pUndoArray.Count - 1); m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (NewLineFeedback)m_pFeedback; m_pLineFeed.Display = m_pActiveView.ScreenDisplay; if (m_pLineFeed != null) { m_pLineFeed.Stop(); } m_pLineFeed.Start(m_pLastPoint); m_MapControl.ActiveView.GraphicsContainer.DeleteAllElements(); CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pLastPoint); m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, m_pEnvelope); //视图刷新 } else { //复位 m_pFeedback.MoveTo(m_pAnchorPoint); Reset(); } }
public override void OnDblClick() { try { if (_lineFeedback == null) { return; } IPolyline polyline = _lineFeedback.Stop(); _context.ActiveView.Refresh(); _lineFeedback = null; if (polyline == null) { return; } ISnappingResult snappingResult = _pointSnapper.Snap(polyline.ToPoint); if (snappingResult != null) { IPointCollection pointCollection = polyline as IPointCollection; pointCollection.UpdatePoint(pointCollection.PointCount - 1, snappingResult.Location); } CommonHelper.MovePointWithLine(_pointFeature, _lineFeatures, polyline.ToPoint, _tolerance); //IPoint linkPoint = _pointFeature.Shape as IPoint; //linkPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y); //_pointFeature.Shape = linkPoint; //_pointFeature.Store(); //foreach (IFeature lineFeature in _lineFeatures) //{ // IPolyline linkPolyline = lineFeature.Shape as IPolyline; // if (linkPolyline == null) // continue; // IPointCollection pointCollection = linkPolyline as IPointCollection; // if (CommonHelper.GetDistance(linkPolyline.FromPoint, polyline.FromPoint) < _tolerance) // { // IPoint fromPoint = pointCollection.Point[0]; // fromPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y); // pointCollection.UpdatePoint(0, fromPoint); // } // else if (CommonHelper.GetDistance(linkPolyline.ToPoint, polyline.FromPoint) < _tolerance) // { // IPoint toPoint = pointCollection.Point[pointCollection.PointCount - 1]; // toPoint.PutCoords(polyline.ToPoint.X, polyline.ToPoint.Y); // pointCollection.UpdatePoint(pointCollection.PointCount - 1, toPoint); // } // lineFeature.Shape = pointCollection as IPolyline; // lineFeature.Store(); //} _lineFeedback = null; _pointFeature = null; _lineFeatures = null; _context.ActiveView.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private IEnvelope pEnv; //记录数据视图的extent private void frmMeasureResult_frmClosed() //委托函数所调用的事件,主要用于结束量算和清空线和面对象 { if (pNewLineFeedback != null) //判断面对象是否为空不为空则清空 { pNewLineFeedback.Stop(); pNewLineFeedback = null; } if (pNewPolygonFeedback != null)//清空面对象 { pNewPolygonFeedback.Stop(); pNewPolygonFeedback = null; pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount); //清空点集中所有点 } axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); //清空量算画的线、面对象 axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; //结束量算功能 mousedownname = ""; }
//双击则创建该线,并弹出缓冲窗体 public override void OnDblClick() { //获取折线 并获取当前视图的屏幕显示 if (m_pNewLineFeedback == null) { return; } IPolyline pPolyline = m_pNewLineFeedback.Stop(); m_pNewLineFeedback = null; pPolyline.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(pPolyline 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 { } }
public void OnDblClick() { IGeometry pResultGeometry = null; if (m_EngineEditLayers == null) { return; } //获取编辑目标图层 IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer; if (pFeatLyr == null) { return; } IFeatureClass pFeatCls = pFeatLyr.FeatureClass; if (pFeatCls == null) { return; } switch (pFeatCls.ShapeType) { case esriGeometryType.esriGeometryPoint: m_newMultPtFeedBack.Stop(); pResultGeometry = m_pointCollection as IGeometry; m_newMultPtFeedBack = null; break; case esriGeometryType.esriGeometryPolyline: IPolyline pPolyline = null; pPolyline = m_newLineFeedBack.Stop(); pResultGeometry = pPolyline as IGeometry; m_newLineFeedBack = null; break; case esriGeometryType.esriGeometryPolygon: IPolygon pPolygon = null; pPolygon = m_newPolyFeedBack.Stop(); pResultGeometry = pPolygon as IGeometry; m_newPolyFeedBack = null; break; } IZAware pZAware = pResultGeometry as IZAware; if (pZAware == null) { return; } pZAware.ZAware = true; //创建新要素 CreateFeature(pResultGeometry); }
public void OnMouseUp(int button, int shift, int x, int y) { if (m_pLinefeedback != null) { IPoint pPoint = m_pScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_pLinefeedback.AddPoint(pPoint); m_pPolyline = m_pLinefeedback.Stop(); m_pLinefeedback = null; AddCallOutElement(m_pPolyline); } }
private void axMapcontrol_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e) { IPoint dblpnt = new PointClass(); dblpnt.PutCoords(e.mapX, e.mapY); switch (pMouseOperate) { case "MeasureLength": if (m_newline != null) { if (dblpnt.IsEmpty || dblpnt == null) { return; } IPolyline polyline = m_newline.Stop(); //绘制路径 DrawElement(polyline as IGeometry); m_newline = null; //显示长度 if (frmMeasureResult != null && !frmMeasureResult.IsDisposed) { //double deltaX = dblpnt.X - Dwnpoint.X; //double deltaY = dblpnt.Y - Dwnpoint.Y; //SegmentLength = Math.Round(Math.Sqrt(deltaX * deltaX + deltaY * deltaY)); ShowResultEvent(new double[] { SegmentLength, TotalLength }, sMapunits, pMouseOperate); //清除绘制要素 this.axMapcontrol.ActiveView.GraphicsContainer.DeleteAllElements(); } } break; case "MeasureArea": if (m_newpolygon != null) { Area_Pocoll.AddPoint(dblpnt, missing, missing); IPolygon polygon = m_newpolygon.Stop() as IPolygon; if (Area_Pocoll.PointCount < 3 || polygon.IsEmpty) { return; } polygon.Close(); IGeometry pGeo = polygon as IGeometry; ITopologicalOperator topo = pGeo as ITopologicalOperator; topo.Simplify(); pGeo.Project(this.axMapcontrol.SpatialReference); IArea area = pGeo as IArea; if (frmMeasureResult != null && !frmMeasureResult.IsDisposed) { ShowResultEvent(new double[] { area.Area, polygon.Length }, sMapunits, pMouseOperate); } } break; } }
private void FrmMeasureResult_frmColsed() { //清空线对象 if (pNewLineFeedback != null) { pNewLineFeedback.Stop(); pNewLineFeedback = null; } //清空面对象 if (pNewPolygonFeedback != null) { pNewPolygonFeedback.Stop(); pNewPolygonFeedback = null; pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //清空点集中所有点 } //清空量算画的线、面对象 axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); //结束量算功能 pMouseOperate = string.Empty; axMapControl1.MousePointer = esriControlsMousePointer.esriPointerDefault; }
public override void OnDblClick() { try { if (_lineFeedback == null) { return; } IPolyline polyline = _lineFeedback.Stop(); _context.ActiveView.Refresh(); _lineFeedback = null; if (polyline == null) { return; } IPointCollection pointCollection = _lineFeature.Shape as IPointCollection; IPointCollection newPointCollection = polyline as IPointCollection; IAnnotationFeature annotationFeature = _annoFeature as IAnnotationFeature; if (annotationFeature == null) { return; } IElement element = annotationFeature.Annotation; IPoint annoPoint = new PointClass(); annoPoint.X = (element.Geometry as IPoint).X + (polyline.ToPoint.X - pointCollection.Point[pointCollection.PointCount - 2].X); annoPoint.Y = (element.Geometry as IPoint).Y + (polyline.ToPoint.Y - pointCollection.Point[pointCollection.PointCount - 2].Y); element.Geometry = annoPoint; annotationFeature.Annotation = element; _annoFeature.Store(); IPoint toPoint = new PointClass(); toPoint.X = newPointCollection.Point[newPointCollection.PointCount - 1].X + (pointCollection.Point[pointCollection.PointCount - 1].X - pointCollection.Point[pointCollection.PointCount - 2].X); toPoint.Y = newPointCollection.Point[newPointCollection.PointCount - 1].Y + (pointCollection.Point[pointCollection.PointCount - 1].Y - pointCollection.Point[pointCollection.PointCount - 2].Y); newPointCollection.AddPoint(toPoint); _lineFeature.Shape = newPointCollection as IPolyline; _lineFeature.Store(); _context.ActiveView.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void EndDrawRectRelative2P() { IGeometry pGeom = null; IPolyline pPolyline; IPolygon pPolygon; IPointCollection pPointCollection; switch (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPolyline: pPolyline = m_pLineFeed.Stop(); pPointCollection = (IPointCollection)pPolyline; pGeom = (IGeometry)pPointCollection; break; case esriGeometryType.esriGeometryPolygon: pPolyline = m_pLineFeed.Stop(); pPolygon = CommonFunction.PolylineToPolygon(pPolyline); pPointCollection = (IPointCollection)pPolygon; pGeom = (IGeometry)pPointCollection; break; default: break; } // end switch m_pEnvelope = pGeom.Envelope; if (m_pEnvelope != null && !m_pEnvelope.IsEmpty) { m_pEnvelope.Expand(10, 10, false); } ; CommonFunction.CreateFeature(m_App.Workbench, pGeom, m_FocusMap, m_CurrentLayer); Reset(); }
public void OnDblClick() { IGeometry resultGeometry = null; if (engineEditLayers == null) { return; } //获取编辑目标图层 IFeatureLayer featureLayer = engineEditLayers.TargetLayer; if (featureLayer == null) { return; } IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass == null) { return; } switch (featureClass.ShapeType) { case esriGeometryType.esriGeometryMultipoint: newMultiPointFeedback.Stop(); resultGeometry = pointCollection as IGeometry; newMultiPointFeedback = null; break; case esriGeometryType.esriGeometryPolyline: IPolyline polyline = null; polyline = newLineFeedback.Stop(); resultGeometry = polyline as IGeometry; newLineFeedback = null; break; case esriGeometryType.esriGeometryPolygon: IPolygon polygon = null; polygon = newPolygonFeedback.Stop(); resultGeometry = polygon as IGeometry; newPolygonFeedback = null; break; } IZAware zaware = resultGeometry as IZAware; zaware.ZAware = true; CreateFeature(resultGeometry);//创建新要素 }
private void DrawLineMouseDown(IPoint pPoint) { if (!m_bInUse) //如果命令没有使用 { m_bInUse = true; m_pUndoArray.Add(pPoint); m_pLastPoint = pPoint; Class.Common.DrawPointSMSSquareSymbol(m_MapControl, pPoint); m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } if (((IFeatureLayer)m_CurrentLayer).FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { //若当前图层是面层,则显示回馈开始点到鼠标点的线段 m_pLastFeedback = new NewLineFeedbackClass(); m_pLastLineFeed = (INewLineFeedback)m_pLastFeedback; m_pLastLineFeed.Start(pPoint); if (m_pLastFeedback != null) { m_pLastFeedback.Display = m_pActiveView.ScreenDisplay; } } } else //若果命令正使用中 { m_pLineFeed.Stop(); m_pLineFeed.Start(pPoint); IPoint tempPoint = new PointClass(); tempPoint.X = pPoint.X; tempPoint.Y = pPoint.Y; m_pUndoArray.Add(tempPoint); m_pLastPoint = m_pAnchorPoint; Class.Common.DisplaypSegmentColToScreen(m_MapControl, ref m_pUndoArray); //可以刷新屏幕了 } }
public override void OnDoubleClick(int button, int shift, int x, int y, double mapX, double mapY) { /* m_pNewLineFeedback = new NewLineFeedbackClass();*/ IGeometry pGeomLn = m_pNewLineFeedback.Stop(); if (pGeomLn != null) { AddCreateElement(pGeomLn, this.m_pActiveView); this.m_pActiveView.Refresh(); strResult = m_dblDistance.ToString(".##") + "米"; app.Current2DMapControl.ActiveView.Refresh(); FrmDistance.Instance().ShowDialog(); } m_pNewLineFeedback = null; }
//鼠标在Map上的双击事件 public override void OnDblClick() { //获取当前所绘形状,将长度或者面积值添加到总和中 // 双击停止feedback if (m_NewLineFeedBack != null) { IPolyline pPolyLine = new PolylineClass(); pPolyLine = m_NewLineFeedBack.Stop(); //进行相关参数设置 frmLineContourCheckSet pFrmLineCheckSet = new frmLineContourCheckSet(_AppHk, pPolyLine); pFrmLineCheckSet.ShowDialog(); m_NewLineFeedBack = null; } }
public override void OnDblClick() { newItem.SubItems.Add(toPoint.X.ToString("f3")); newItem.SubItems.Add(toPoint.Y.ToString("f3")); frmAdjPoint.ToPoint.AddPoint(toPoint, ref obj, ref obj); IGeometry pGeom; pGeom = pLineFeedback.Stop(); pLineFeedback = null; AddLineElement(pGeom, pGraphicsContainer); frmAdjPoint.ListPoint.Items.Add(newItem); pointCount++; //clickCount = 0; newItem = null; }
public void EndSketch() { IGeometry resGeometry = null; IPointCollection pointColl = null; try { if ((MyfeedBack as INewMultiPointFeedback) != null) { INewMultiPointFeedback multiPointFeedback = MyfeedBack as INewMultiPointFeedback; multiPointFeedback.Stop(); } else if ((MyfeedBack as INewLineFeedback) != null) { INewLineFeedback lineFeedback = MyfeedBack as INewLineFeedback; lineFeedback.AddPoint(MycurrentMousePosition); IPolyline polyline = lineFeedback.Stop(); pointColl = polyline as IPointCollection; if (pointColl.PointCount > 1) { resGeometry = pointColl as IGeometry; } } else if ((MyfeedBack as INewPolygonFeedback) != null) { INewPolygonFeedback polygonFeedback = MyfeedBack as INewPolygonFeedback; polygonFeedback.AddPoint(MycurrentMousePosition); IPolygon polygon = polygonFeedback.Stop(); if (polygon != null) { pointColl = polygon as IPointCollection; if (pointColl.PointCount > 2) { resGeometry = pointColl as IGeometry; ITopologicalOperator pTopo = resGeometry as ITopologicalOperator; if (!pTopo.IsKnownSimple) { pTopo.Simplify(); } } } } MyfeedBack = null; If_isInUse = false; } catch { return; } }
public void EndFeedBack() { m_schematicFeature1 = null; m_schematicFeature2 = null; if (m_dockableDigit != null) { m_dockableDigit.SchematicFeature1(m_schematicFeature1); m_dockableDigit.SchematicFeature2(m_schematicFeature2); } if (m_linkFbk != null) { m_linkFbk.Stop(); m_linkFbk = null; } }
private void EndSketch() { IGeometry m_Geometry = null; IPointCollection m_PointCollection = null; if (m_Feedback is INewLineFeedback) { INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback; m_LineFeed.AddPoint(m_PointStop); IPolyline m_PolyLine = m_LineFeed.Stop(); m_PointCollection = (IPointCollection)m_PolyLine; if (m_PointCollection.PointCount < 2) { MessageBox.Show("需要两个点才能生成一条线!", "未能生成线", MessageBoxButtons.OK); return; } else { m_Geometry = (IGeometry)m_PointCollection; } } else if (m_Feedback is INewPolygonFeedback) { INewPolygonFeedback m_PolyFeed = (INewPolygonFeedback)m_Feedback; m_PolyFeed.AddPoint(m_PointStop); IPolygon m_Polygon = m_PolyFeed.Stop(); if (m_Polygon != null) { m_PointCollection = (IPointCollection)m_Polygon; } if (m_PointCollection.PointCount < 3) { MessageBox.Show("需要三个点才能生成一个面!", "未能生成面", MessageBoxButtons.OK); return; } else { m_Geometry = (IGeometry)m_PointCollection; } } CreatFeature(m_Geometry); m_hookHelper.ActiveView.Refresh(); m_Feedback = null; m_bInUse = false; }
public void frmDbClick(ref INewLineFeedback m_FeedbackLine,ref IGeometry m_Geometry) { if (tbtnLine.Checked == true) { if (m_FeedbackLine != null) { pGeometry = m_FeedbackLine.Stop(); m_Geometry = pGeometry; m_FeedbackLine = null; } IPolyline pPolyLine = (IPolyline)pGeometry; SegLength = LastSeg; TotalLength = CntUnit.ConvertUnits(pPolyLine.Length, inUnit.pUnit, outUnit.pUnit); SegLength = CntUnit.ConvertUnits(SegLength, inUnit.pUnit, outUnit.pUnit); m_SegLen.value = SegLength; m_SegLen.units = outUnit.pUnit; m_TotLen.value = TotalLength; m_TotLen.units = outUnit.pUnit; SegLength = Math.Round(SegLength, 6); TotalLength = Math.Round(TotalLength, 6); SumLengths += TotalLength; UnitSumLen = SumLengths; txtMessage.Clear(); txtMessage.Text = "测量线"+"\r\n线段的长度是:" + SegLength+outUnit.UnitName + "\r\n总长度是:" + TotalLength+outUnit.UnitName; if(tbtnSum.Checked==true) txtMessage.Text+="\r\n"+"\r\n线段长度之和是:"+ SumLengths+outUnit.UnitName; } //重新初始化 TotalLength = 0.0; SegLength = 0.0; TotalAreaLength = 0.0; SegAreaLength = 0.0; myArea = 0.0; Perimeter = 0.0; pCollection = new MultipointClass(); pGeometry = null; }