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 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); } }
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 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); } } } }
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); } } }
/// <summary> /// 启动面积测量,point为多边形起点,测量结果为 /// Area:多边形面积 /// 在Map的MouseDown事件中调用本方法 /// </summary> /// <param name="point">测量起点</param> public void AreaStart(IPoint point) { _eMeasureType = EMeasureType.Area; _newPolygonFeedback = new NewPolygonFeedbackClass { Display = MapCtrl.ActiveView.ScreenDisplay }; _newPolygonFeedback.Start(point); _pointCollection = new PolygonClass(); object ep = System.Reflection.Missing.Value; _pointCollection.AddPoint(point, ref ep, ref ep); IsSurveying = true; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //获得鼠标在控件上点击的位置,产生一个点对象 IPoint pPt = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (pPolygonFeedback == null) { pPolygonFeedback = new NewPolygonFeedbackClass(); pPolygonFeedback.Display = m_ActiveView.ScreenDisplay; pPolygonFeedback.Start(pPt); } else { pPolygonFeedback.AddPoint(pPt); } }
/// <summary> /// 单机时运行 /// </summary> /// <param name="clickPT">单机的地图点</param> public void OnMouseDownRun(IPoint clickPT) { if (polygonFeedback == null) { polygonFeedback = new NewPolygonFeedbackClass(); polygonFeedback.Display = (mapControl.Map as IActiveView).ScreenDisplay; pointCollection.RemovePoints(0, pointCollection.PointCount); polygonFeedback.Start(clickPT); pointCollection.AddPoint(clickPT, Type.Missing, Type.Missing); } else { polygonFeedback.AddPoint(clickPT); pointCollection.AddPoint(clickPT, Type.Missing, Type.Missing); } }
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; } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add ToolDeleteNodeByArea.OnMouseDown implementation IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { IPoint mapPoint = pMapCtr.ToMapPoint(X, Y); if (mNewPolygonFeedback == null) { mNewPolygonFeedback = new NewPolygonFeedbackClass(); mNewPolygonFeedback.Display = pMapCtr.ActiveView.ScreenDisplay; mNewPolygonFeedback.Start(mapPoint); } else { mapPoint = pMapCtr.ToMapPoint(X, Y); mNewPolygonFeedback.AddPoint(mapPoint); } } }
public override void OnKeyUp(int keyCode, int Shift) { if (Shift != 2 && keyCode != 90) { return; } if (m_pNewPolygonFeedback == null) { return; } IPolygon pPolygon = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; if (pPolygon == null) { return; } IPointCollection pntCol = pPolygon as IPointCollection; 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(pntCol.get_Point(0)); for (int i = 1; i < pntCol.PointCount - 2; i++) { m_pNewPolygonFeedback.AddPoint(pntCol.get_Point(i)); } m_pNewPolygonFeedback.MoveTo(pntCol.get_Point(pntCol.PointCount - 1)); }
private void OnOnMouseDown(int button, int shift, int i, int i1, double mapX, double mapY) { if (button == 2) { return; } IActiveView activeView = _context.ActiveView; IPoint point = new PointClass(); point.PutCoords(mapX, mapY); if (_polygonFeedback == null) { _polygonFeedback = new NewPolygonFeedback() { Display = activeView.ScreenDisplay }; _polygonFeedback.Start(point); } else { _polygonFeedback.AddPoint(point); } }
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)); } } }
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(); } }
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) { //���ӵ����Ҽ��������� �ᄃ���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(); */ }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) {//屏幕坐标点转化为地图坐标点 pPointPt = (axMapControl1.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) { IActiveView pActiveView = axMapControl1.ActiveView; IEnvelope pEnvelope = new EnvelopeClass(); switch (pMouseOperate) { #region 拉框放大 case "ZoomIn": pEnvelope = axMapControl1.TrackRectangle(); //如果拉框范围为空则返回 if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0) { return; } //如果有拉框范围,则放大到拉框范围 pActiveView.Extent = pEnvelope; pActiveView.Refresh(); //刷新地图显示 break; #endregion ; case "Pan": axMapControl1.Pan(); break; case "MeasureLength": //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点 if (pNewLineFeedback == null) { //实例化追踪线对象 pNewLineFeedback = new NewLineFeedbackClass(); pNewLineFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay; //设置起点,开始动态线绘制 pNewLineFeedback.Start(pPointPt); dToltalLength = 0; } else //如果追踪线对象不为空,则添加当前鼠标点 { pNewLineFeedback.AddPoint(pPointPt); } //pGeometry = m_PointPt; if (dSegmentLength != 0) { dToltalLength = dToltalLength + dSegmentLength; } break; case "MeasureArea": if (pNewPolygonFeedback == null) { //实例化追踪面对象 pNewPolygonFeedback = new NewPolygonFeedback(); pNewPolygonFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay; ; pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //开始绘制多边形 pNewPolygonFeedback.Start(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } else { pNewPolygonFeedback.AddPoint(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } break; } } }
/// <summary> /// 地图中鼠标按下事件监听 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { //屏幕坐标点转化为地图坐标点 pPointPt = (MainMapControl.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) { IActiveView pActiveView = MainMapControl.ActiveView; IEnvelope pEnvelope = new EnvelopeClass(); switch (pMouseOperate) { case "ZoomIn": pEnvelope = MainMapControl.TrackRectangle(); // 如果拉框范围为空则返回 if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0) { return; } // 如果拉框有范围,则拉大到拉框范围 MainMapControl.ActiveView.Extent = pEnvelope; MainMapControl.ActiveView.Refresh(); break; case "ZoomOut": pEnvelope = MainMapControl.TrackRectangle(); // 如果拉框范围为空则返回 if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0) { return; } else { double dWidth = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnvelope.Width; double dHeight = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnvelope.Height; double dXmin = pActiveView.Extent.XMin - ((pEnvelope.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width / pEnvelope.Width); double dYmin = pActiveView.Extent.YMin - ((pEnvelope.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height / pEnvelope.Height); double dXmax = dXmin + dWidth; double dYmax = dYmin + dHeight; pEnvelope.PutCoords(dXmin, dYmin, dXmax, dYmax); } pActiveView.Extent = pEnvelope; pActiveView.Refresh(); break; case "Pan": MainMapControl.Pan(); break; case "MeasureLength": //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点 if (pNewLineFeedback == null) { //实例化追踪线对象 pNewLineFeedback = new NewLineFeedbackClass(); pNewLineFeedback.Display = (MainMapControl.Map as IActiveView).ScreenDisplay; //设置起点,开始动态线绘制 pNewLineFeedback.Start(pPointPt); dToltalLength = 0; } else //如果追踪线对象不为空,则添加当前鼠标点 { pNewLineFeedback.AddPoint(pPointPt); } //pGeometry = m_PointPt; if (dSegmentLength != 0) { dToltalLength = dToltalLength + dSegmentLength; } break; case "MeasureArea": if (pNewPolygonFeedback == null) { //实例化追踪面对象 pNewPolygonFeedback = new NewPolygonFeedback(); pNewPolygonFeedback.Display = (MainMapControl.Map as IActiveView).ScreenDisplay; ; pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //开始绘制多边形 pNewPolygonFeedback.Start(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } else { pNewPolygonFeedback.AddPoint(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } break; case "SelFeature": IEnvelope pEnv = MainMapControl.TrackRectangle(); IGeometry pGeo = pEnv as IGeometry; // 矩形框若为空,即为点选时,对点的范围进行扩展 if (pEnv.IsEmpty == true) { tagRECT r; r.left = e.x - 5; r.top = e.y - 5; r.right = e.x + 5; r.bottom = e.y + 5; pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4); pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference; } pGeo = pEnv as IGeometry; MainMapControl.Map.SelectByShape(pGeo, null, false); MainMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //IEnvelope pEnv = MainMapControl.TrackRectangle(); //IGeometry pGeo = pEnv as IGeometry; ////矩形框若为空,即为点选时,对点范围进行扩展 //if (pEnv.IsEmpty == true) //{ // tagRECT r; // r.left = e.x - 5; // r.top = e.y - 5; // r.right = e.x + 5; // r.bottom = e.y + 5; // pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4); // pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference; //} //pGeo = pEnv as IGeometry; //MainMapControl.Map.SelectByShape(pGeo, null, false); //MainMapControl.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); break; case "ExportRegion": // 删除视图中的数据 MainMapControl.ActiveView.GraphicsContainer.DeleteAllElements(); MainMapControl.ActiveView.Refresh(); IPolygon polygon = DrawPolygon(MainMapControl); if (polygon == null) { return; } ExportMap.AddElement(polygon, MainMapControl.ActiveView); if (FrmExpMap == null || FrmExpMap.IsDisposed) { FrmExpMap = new FormExportMap(MainMapControl); } FrmExpMap.IsRegion = true; FrmExpMap.GetGometry = polygon as IGeometry; FrmExpMap.Show(); FrmExpMap.Activate(); break; case "TxtSymbol": TxtSymbol(e); break; default: break; } } else if (e.button == 2) { pMouseOperate = ""; MainMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault; } }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { #region 处理各种交互情况 switch (m_sketchshape) { case "polygon": { IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay; IPoint newPoint = new PointClass(); newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) { //左单击画多边形添加点: if (m_NewPolygonFeedback == null) { m_NewPolygonFeedback = new NewPolygonFeedbackClass(); m_NewPolygonFeedback.Display = iSDisplay; m_NewPolygonFeedback.Start(newPoint); } else { m_NewPolygonFeedback.AddPoint(newPoint); } } if (e.button == 2) { if (m_NewPolygonFeedback == null) { return; } //右键结束绘制: m_NewPolygonFeedback.AddPoint(newPoint); m_NewPolygon = m_NewPolygonFeedback.Stop(); //若是逆时针创建,反转一下,变为顺时针: IArea feedBackArea = m_NewPolygon as IArea; if (feedBackArea.Area < 0) { m_NewPolygon.ReverseOrientation(); } IGeometry newGeometry = m_NewPolygon as IGeometry; IFeatureWorkspace checkWorkspace = m_GlobalWorkspace as IFeatureWorkspace; IFeatureClass checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea"); if (!(m_EditWorkspace.IsBeingEdited())) { m_EditWorkspace.StartEditing(false); } m_EditWorkspace.StartEditOperation(); int OID = CheckFeatueEditor.InsertNewFeature(newGeometry, checkFeatureClass, AppManager.GetInstance().TaskName); m_EditWorkspace.StopEditOperation(); //ISelectionEnvironment selectionEnv = new SelectionEnvironmentClass(); //selectionEnv.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelOverlaps; //selectionEnv.CombinationMethod = esriSelectionResultEnum.esriSelectionResultNew; //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, null, true); //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, selectionEnv, true); //m_MapCtrls.Map.SelectByShape(m_NewPolygon, null, true); ILayer iLayer = m_MapCtrls.Layer[0]; IFeature iFeature = checkFeatureClass.GetFeature(OID); clearFeatureSelection(); m_MapCtrls.Map.SelectFeature(iLayer, iFeature); m_NewPolygonFeedback = null; m_MapCtrls.ActiveView.Refresh(); } break; } case "rectangle": { IScreenDisplay iSDisplay = m_MapCtrls.ActiveView.ScreenDisplay; IPoint newPoint = new PointClass(); newPoint = iSDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) { if (m_RecFeedback == null) { m_RecFeedback = new NewRectangleFeedbackClass(); m_RecFeedback.Display = iSDisplay; m_RecFeedback.Angle = 90; m_RecFeedback.Start(newPoint); newPoint.Y = newPoint.Y + 20; m_RecFeedback.SetPoint(newPoint); } else { m_RecFeedback.SetPoint(newPoint); } } if (e.button == 2) { if (m_RecFeedback != null) { m_NewPolygon = m_RecFeedback.Stop(newPoint) as IPolygon; //若是逆时针创建,反转一下,变为顺时针: IArea feedBackArea = m_NewPolygon as IArea; if (feedBackArea.Area < 0) { m_NewPolygon.ReverseOrientation(); } IGeometry newGeometry = m_NewPolygon as IGeometry; IFeatureWorkspace checkWorkspace = m_GlobalWorkspace as IFeatureWorkspace; IFeatureClass checkFeatureClass = checkWorkspace.OpenFeatureClass("CheckArea"); if (!(m_EditWorkspace.IsBeingEdited())) { m_EditWorkspace.StartEditing(false); } m_EditWorkspace.StartEditOperation(); int OID = CheckFeatueEditor.InsertNewFeature(newGeometry, checkFeatureClass, AppManager.GetInstance().TaskName); m_EditWorkspace.StopEditOperation(); ILayer iLayer = m_MapCtrls.Layer[0]; IFeature iFeature = checkFeatureClass.GetFeature(OID); clearFeatureSelection(); m_MapCtrls.Map.SelectFeature(iLayer, iFeature); m_MapCtrls.ActiveView.Refresh(); m_RecFeedback = null; } } break; } } #endregion }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (m_hookHelper != null) { object Missing = Type.Missing; object Missing1 = Type.Missing; if (Button == 1) { IPoint pPoint; pPoint = m_pScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewPolygonFeedback == null) { m_pActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null); m_pNewPolygonFeedback = new NewPolygonFeedbackClass(); m_pNewPolygonFeedback.Display = m_pScreenDisplay; m_pPointCol = new PolygonClass(); if (m_blnSnap == true) { m_pNewPolygonFeedback.Start(m_pSnapPoint); m_pPointCol.AddPoint(ClsDeclare.g_UnitConverter.ConvertPointCoordinate(m_pSnapPoint), ref Missing, ref Missing1); } else { m_pNewPolygonFeedback.Start(pPoint); m_pPointCol.AddPoint(ClsDeclare.g_UnitConverter.ConvertPointCoordinate(pPoint), ref Missing, ref Missing1); } } else { if (m_blnSnap == true) { m_pNewPolygonFeedback.AddPoint(m_pSnapPoint); m_pPointCol.AddPoint(ClsDeclare.g_UnitConverter.ConvertPointCoordinate(m_pSnapPoint), ref Missing, ref Missing1); } else { m_pNewPolygonFeedback.AddPoint(pPoint); m_pPointCol.AddPoint(ClsDeclare.g_UnitConverter.ConvertPointCoordinate(pPoint), ref Missing, ref Missing1); } } IPointCollection pPointCol; IPolygon pPolygon; IGeometry pGeometry; IArea pArea; ITopologicalOperator pTopo; pPointCol = new PolygonClass(); for (int i = 0; i < m_pPointCol.PointCount; i++) { pPointCol.AddPoint(m_pPointCol.get_Point(i), ref Missing, ref Missing1); } if (pPointCol.PointCount < 3) { return; } pPolygon = (IPolygon)pPointCol; if (pPolygon != null) { pPolygon.Close(); pGeometry = (IGeometry)pPolygon; pTopo = (ITopologicalOperator)pGeometry; pTopo.Simplify(); pGeometry.Project(ClsDeclare.g_pMap.SpatialReference); pArea = (IArea)pGeometry; if (ClsDeclare.g_UnitConverter.CurrentUnitName == "度") { ClsDeclare.g_UnitConverter.SetCurrentMapUnit(ClsDeclare.g_UnitConverter.DefaultMapUnit); } ClsDeclare.g_strUnit = ClsDeclare.g_UnitConverter.CurrentUnitName; ClsDeclare.g_txtMeasure.Clear(); ClsDeclare.g_txtMeasure.Text = "面积量算" + "\r" + "\n" + "总面积:" + string.Format("{0,10:#######0.00}", Math.Abs(pArea.Area)); pPolygon = null; } } } else if (m_sceneHookHelper != null) { } else if (m_globeHookHelper != null) { } }
/// <summary> ///鼠标点击操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void axMapcontrol_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { Dwnpoint = new PointClass(); Dwnpoint = this.axMapcontrol.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button != 1) { return; } #region 地图操作 switch (pMouseOperate) { case "区域导出": //删除绘制的图片 this.axMapcontrol.ActiveView.GraphicsContainer.DeleteAllElements(); this.axMapcontrol.ActiveView.Refresh(); IPolygon polygon = DrawPolygon(this.axMapcontrol); if (polygon == null) { return; } ExportMap.AddElement(polygon, this.axMapcontrol.ActiveView); if (polygon == null) { return; } if (exportmapFrm == null || exportmapFrm.IsDisposed) { exportmapFrm = new ExportMapFrm(this.axMapcontrol); exportmapFrm.IsRgion = true; exportmapFrm.GetGeometry = polygon as IGeometry; exportmapFrm.Show(); } exportmapFrm.GetGeometry = polygon; exportmapFrm.IsRgion = true; //获取当前控件焦点 exportmapFrm.Activate(); break; case "MeasureLength": if (m_newline == null) { m_newline = new NewLineFeedbackClass(); m_newline.Display = this.axMapcontrol.ActiveView.ScreenDisplay; m_newline.Start(Dwnpoint); TotalLength = 0; } else { TotalLength += SegmentLength; m_newline.AddPoint(Dwnpoint); } break; case "MeasureArea": if (m_newpolygon == null || Area_Pocoll == null) { m_newpolygon = new NewPolygonFeedbackClass(); Area_Pocoll = new PolygonClass(); m_newpolygon.Display = this.axMapcontrol.ActiveView.ScreenDisplay; m_newpolygon.Start(Dwnpoint); Area_Pocoll.AddPoint(Dwnpoint); TotalLength = 0; } else { m_newpolygon.AddPoint(Dwnpoint); Area_Pocoll.AddPoint(Dwnpoint); TotalLength += SegmentLength; } break; } #endregion }
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; } } }
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { IActiveView pActiveview = axMapControl1.ActiveView; IEnvelope envelope = new EnvelopeClass(); pPointPt = axMapControl1.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); switch (mousedownname) { case "": break; case "zoomin": //拉框放大 envelope = axMapControl1.TrackRectangle(); //获取拉框信息 if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0) //判断是否为空框 { return; } pActiveview.Extent = envelope; pActiveview.Refresh(); break; case "zoomout": //拉框缩小 envelope = axMapControl1.TrackRectangle(); if (envelope == null || envelope.IsEmpty || envelope.Height == 0 || envelope.Width == 0) { return; } double dwidth = pActiveview.Extent.Width * pActiveview.Extent.Width / envelope.Width; double dheight = pActiveview.Extent.Height * pActiveview.Extent.Height / envelope.Height; double dXmin = pActiveview.Extent.XMin - ((envelope.XMin - pActiveview.Extent.XMin) * pActiveview.Extent.Width / envelope.Width); double dYmin = pActiveview.Extent.YMin - ((envelope.YMin - pActiveview.Extent.YMin) * pActiveview.Extent.Height / envelope.Height); double dxMAX = dXmin + dwidth; double dyMAX = dYmin + dheight; envelope.PutCoords(dXmin, dYmin, dxMAX, dyMAX); pActiveview.Extent = envelope; pActiveview.Refresh(); break; case "manyou": //漫游 axMapControl1.Pan(); break; case "MeasureLength": //长度量测 if (pNewLineFeedback == null) { pNewLineFeedback = new NewLineFeedback { Display = pActiveview.ScreenDisplay }; //实例化追踪线对象 pNewLineFeedback.Start(pPointPt); //设置起点,开始动态绘制 dToltaLength = 0; } else //如果追踪线对象不为空,则添加当前鼠标点 { pNewLineFeedback.AddPoint(pPointPt); } if (dSegmentLength != 0) { dToltaLength = dToltaLength + dSegmentLength; } break; case "MeasureArea": //面积量测 if (pNewPolygonFeedback == null) { pNewPolygonFeedback = new NewPolygonFeedback { Display = pActiveview.ScreenDisplay }; //实例化面对象 pAreaPointCollection.RemovePoints(0, pAreaPointCollection.PointCount); //清空点集 pNewPolygonFeedback.Start(pPointPt); //开始绘制多边形 pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing); } else { pNewPolygonFeedback.AddPoint(pPointPt); pAreaPointCollection.AddPoint(pPointPt, ref missing, ref missing); } break; case "selectfeature": //要素选择 IEnvelope pEnv = axMapControl1.TrackRectangle(); IGeometry pGeo = pEnv; if (pEnv.IsEmpty) //若为空则在鼠标当前点进行选择部分区域作为框 { tagRECT r; r.left = e.x - 5; r.top = e.y - 5; r.right = e.x + 5; r.bottom = e.y + 5; pActiveview.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4); pEnv.SpatialReference = pActiveview.FocusMap.SpatialReference; } pGeo = pEnv; axMapControl1.Map.SelectByShape(pGeo, null, false); axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); break; case "ExportRegion": pActiveview.GraphicsContainer.DeleteAllElements(); pActiveview.Refresh(); IPolygon pPolygon = ExportMap.DrawPolygon(axMapControl1); if (pPolygon == null) { return; } ExportMap.AddElement(pPolygon, pActiveview); if (frmExpMap == null || frmExpMap.IsDisposed) { frmExpMap = new mapexport(axMapControl1); } frmExpMap.isRegion = true; frmExpMap.geometry = pPolygon; frmExpMap.Show(); frmExpMap.Activate(); break; } }
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 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); } }
//拉框选择 private void mainMapControl_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { if (flag == 1) { baseOrder.box_select(e); } //屏幕坐标点转化为地图坐标点 pPointPt = (mainMapControl.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) { IActiveView pActiveView = mainMapControl.ActiveView; IEnvelope pEnvelope = new EnvelopeClass(); if (pMouseOperate == "MeasureLength") { //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点 if (pNewLineFeedback == null) { //实例化追踪线对象 pNewLineFeedback = new NewLineFeedbackClass(); pNewLineFeedback.Display = (mainMapControl.Map as IActiveView).ScreenDisplay; //设置起点,开始动态线绘制 pNewLineFeedback.Start(pPointPt); dToltalLength = 0; } else //如果追踪线对象不为空,则添加当前鼠标点 { pNewLineFeedback.AddPoint(pPointPt); } //pGeometry = m_PointPt; if (dSegmentLength != 0) { dToltalLength = dToltalLength + dSegmentLength; } } else if (pMouseOperate == "MeasureArea") { if (pNewPolygonFeedback == null) { //实例化追踪面对象 pNewPolygonFeedback = new NewPolygonFeedback(); pNewPolygonFeedback.Display = (mainMapControl.Map as IActiveView).ScreenDisplay; ; pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //开始绘制多边形 pNewPolygonFeedback.Start(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } else { pNewPolygonFeedback.AddPoint(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } } } else if (e.button == 2) { pMouseOperate = ""; mainMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault; } if (flag == 0) { mainMapControl.CurrentTool = null; if (e.button != 2) { flag = 999; return; } IPoint point = new PointClass(); point = mainMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); //设置文本格式 ITextSymbol textSymbol = new TextSymbolClass(); StdFont stdFont = new stdole.StdFontClass(); stdFont.Name = "宋体"; stdFont.Size = 24; textSymbol.Font = (IFontDisp)stdFont; textSymbol.Angle = 0; textSymbol.RightToLeft = false; //垂直方向基线对齐 textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline; //文本两端对齐 textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull; textSymbol.Text = C.Text; ITextElement textElement = new TextElementClass(); textElement.Symbol = textSymbol; textElement.Text = textSymbol.Text; //获取坐标,添加文本 IElement element = (IElement)textElement; element.Geometry = point; mainMapControl.ActiveView.GraphicsContainer.AddElement(element, 0); mainMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, element, null); } if (flag == 66) {//画线 IGeometry pGeom; pGeom = (IGeometry)mainMapControl.TrackLine(); IGraphicsContainer pGraphicsContainer = mainMapControl.Map as IGraphicsContainer; baseOrder.AddLineElement(pGeom, pGraphicsContainer); } if (flag == 77) {//闪 IMap pMap = mainMapControl.Map; IActiveView pActiveView = pMap as IActiveView; IPoint pt = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); ITopologicalOperator pTopo = pt as ITopologicalOperator; IGeometry pGeo = pTopo.Buffer(100); IColor pColor = new RgbColorClass(); pColor.RGB = 2556; SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = pColor; ISymbol symbol = simpleFillSymbol as ISymbol; pActiveView.ScreenDisplay.SetSymbol(symbol); pActiveView.ScreenDisplay.DrawPolygon(pGeo); pMap.SelectByShape(pGeo, null, false); mainMapControl.FlashShape(pGeo, 25, 200, symbol); mainMapControl.ActiveView.Refresh(); } }
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 计算单线的长度,并将结果显示在单线中点偏上上面 //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(); }
private void AxMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) { //屏幕坐标点转化为地图坐标点 pPointPt = (axMapControl1.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) { IActiveView pActiveView = axMapControl1.ActiveView; IEnvelope pEnvelope = new EnvelopeClass(); switch (pMouseOperate) { #region 拉框放大 case "ZoomIn": pEnvelope = axMapControl1.TrackRectangle(); //如果拉框范围为空则返回 if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0) { return; } //如果有拉框范围,则放大到拉框范围 pActiveView.Extent = pEnvelope; pActiveView.Refresh(); break; #endregion #region 拉框缩小 case "ZoomOut": pEnvelope = axMapControl1.TrackRectangle(); //如果拉框范围为空则退出 if (pEnvelope == null || pEnvelope.IsEmpty || pEnvelope.Height == 0 || pEnvelope.Width == 0) { return; } //如果有拉框范围,则以拉框范围为中心,缩小倍数为:当前视图范围/拉框范围 else { double dWidth = pActiveView.Extent.Width * pActiveView.Extent.Width / pEnvelope.Width; double dHeight = pActiveView.Extent.Height * pActiveView.Extent.Height / pEnvelope.Height; double dXmin = pActiveView.Extent.XMin - ((pEnvelope.XMin - pActiveView.Extent.XMin) * pActiveView.Extent.Width / pEnvelope.Width); double dYmin = pActiveView.Extent.YMin - ((pEnvelope.YMin - pActiveView.Extent.YMin) * pActiveView.Extent.Height / pEnvelope.Height); double dXmax = dXmin + dWidth; double dYmax = dYmin + dHeight; pEnvelope.PutCoords(dXmin, dYmin, dXmax, dYmax); } pActiveView.Extent = pEnvelope; pActiveView.Refresh(); break; #endregion #region 漫游 case "Pan": axMapControl1.Pan(); break; #endregion #region 择要素 case "SelFeature": IEnvelope pEnv = axMapControl1.TrackRectangle(); IGeometry pGeo = pEnv as IGeometry; //矩形框若为空,即为点选时,对点范围进行扩展 if (pEnv.IsEmpty == true) { tagRECT r; r.left = e.x - 5; r.top = e.y - 5; r.right = e.x + 5; r.bottom = e.y + 5; pActiveView.ScreenDisplay.DisplayTransformation.TransformRect(pEnv, ref r, 4); pEnv.SpatialReference = pActiveView.FocusMap.SpatialReference; } pGeo = pEnv as IGeometry; axMapControl1.Map.SelectByShape(pGeo, null, false); axMapControl1.Refresh(esriViewDrawPhase.esriViewGeoSelection, null, null); break; #endregion #region 要素选择 case "SelectFeature": IPoint point = new PointClass(); IGeometry pGeometry = point as IGeometry; axMapControl1.Map.SelectByShape(pGeometry, null, false); axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); break; #endregion #region 距离量算 case "MeasureLength": //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点 if (pNewLineFeedback == null) { //实例化追踪线对象 pNewLineFeedback = new NewLineFeedbackClass(); pNewLineFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay; //设置起点,开始动态线绘制 pNewLineFeedback.Start(pPointPt); dToltalLength = 0; } else //如果追踪线对象不为空,则添加当前鼠标点 { pNewLineFeedback.AddPoint(pPointPt); } //pGeometry = m_PointPt; if (dSegmentLength != 0) { dToltalLength = dToltalLength + dSegmentLength; } break; #endregion #region 面积量算 case "MeasureArea": if (pNewPolygonFeedback == null) { //实例化追踪面对象 pNewPolygonFeedback = new NewPolygonFeedback(); pNewPolygonFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay; ; pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //开始绘制多边形 pNewPolygonFeedback.Start(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } else { pNewPolygonFeedback.AddPoint(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } break; #endregion #region 添加文字 case "AddCharacters": { //本例的实现类似于前面测量工具的实现 //在工具条添加自定义的工具之后,在其Click事件中用m_flag变量记录操作 //然后在MapControl的OnMouseDown事件的适当位置添加如下代码: IFontDisp font = new StdFontClass() as IFontDisp; font.Bold = true; font.Name = "Arial"; font.Size = 20; IColor pColor = new RgbColorClass(); pColor.RGB = 0; ITextSymbol pTextSymbol = new TextSymbolClass(); pTextSymbol.Size = 200; pTextSymbol.Font = font; pTextSymbol.Color = pColor; IPoint pPoint = new PointClass(); pPoint.PutCoords(e.mapX, e.mapY); ITextElement pTextElement = new TextElementClass(); pTextElement.Symbol = pTextSymbol; pTextElement.Text = toolStripTextBox1.Text; IElement pElement = pTextElement as IElement; pElement.Geometry = pPoint as IGeometry; axMapControl1.ActiveView.GraphicsContainer.AddElement(pElement, 3); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } break; #endregion #region 添加线型元素 case "AddLine": IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer; IActiveView pAv = pGra as IActiveView; IGeometry pgeo = axMapControl1.TrackLine(); AddLineElement(pgeo, pGra); break; #endregion #region 缓冲区闪烁 case "Buffer": //IMap pMap = axMapControl1.Map; IPoint pt = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); ITopologicalOperator pTopo = pt as ITopologicalOperator; IGeometry pGeo1 = pTopo.Buffer(50); IColor pColor1 = new RgbColorClass(); pColor1.RGB = 2556; SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = pColor1; ISymbol symbol = simpleFillSymbol as ISymbol; pActiveView.ScreenDisplay.SetSymbol(symbol); pActiveView.ScreenDisplay.DrawPolygon(pGeo1); //pMap.SelectByShape(pGeo1, null, false); //闪动 axMapControl1.FlashShape(pGeo1, 26, 200, symbol); //ThreadInfo threadInfo = new ThreadInfo(); //threadInfo.pActiveView = pActiveView; //GPU并行 //threadInfo.e = e; //ThreadPool.QueueUserWorkItem(new WaitCallback(processfile), threadInfo); axMapControl1.ActiveView.Refresh(); break; #endregion default: break; } } }
public void OnMouseDown(int button, int shift, int x, int y) { try { IPoint pPt = m_activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); if (m_EngineEditor == null) { return; } if (m_EngineEditor.EditState != esriEngineEditState.esriEngineStateEditing) { return; } if (m_EngineEditLayers == null) { return; } IFeatureLayer pFeatLyr = m_EngineEditLayers.TargetLayer; if (pFeatLyr == null) { return; } IFeatureClass pFeatCls = pFeatLyr.FeatureClass; if (pFeatCls == null) { return; } //解决编辑要素的Z值问题 IZAware pZAware = pPt as IZAware; pZAware.ZAware = true; pPt.Z = 0; object missing = Type.Missing; m_Map.ClearSelection(); switch (pFeatCls.ShapeType) { case esriGeometryType.esriGeometryPoint: //当为点层时,直接创建要素 CreateFeature(pPt as IGeometry); break; case esriGeometryType.esriGeometryMultipoint: //点集的处理方式 if (m_pointCollection == null) { m_pointCollection = new MultipointClass(); } else { m_pointCollection.AddPoint(pPt, ref missing, ref missing); } if (m_newMultPtFeedBack == null) { m_newMultPtFeedBack = new NewMultiPointFeedbackClass(); m_newMultPtFeedBack.Display = m_activeView.ScreenDisplay; m_newMultPtFeedBack.Start(m_pointCollection, pPt); } break; case esriGeometryType.esriGeometryPolyline: //多义线处理方式 if (m_newLineFeedBack == null) { m_newLineFeedBack = new NewLineFeedbackClass(); m_newLineFeedBack.Display = m_activeView.ScreenDisplay; m_newLineFeedBack.Start(pPt); } else { m_newLineFeedBack.AddPoint(pPt); } break; case esriGeometryType.esriGeometryPolygon: //多边形处理方式 if (m_newPolyFeedBack == null) { m_newPolyFeedBack = new NewPolygonFeedbackClass(); m_newPolyFeedBack.Display = m_activeView.ScreenDisplay; m_newPolyFeedBack.Start(pPt); } else { m_newPolyFeedBack.AddPoint(pPt); } break; } } catch (Exception ex) { //SysLogHelper.WriteOperationLog("要素创建错误", ex.Source, "数据编辑"); } }
public void SketchMouseDown(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; } IPoint point = MyMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); INewLineFeedback lineFeedback = null; INewPolygonFeedback polygonFeedback = null; try { if (!If_isInUse) { switch (featureClass.ShapeType) { case esriGeometryType.esriGeometryPoint: break; case esriGeometryType.esriGeometryMultipoint: If_isInUse = true; MyfeedBack = new NewMultiPointFeedbackClass(); INewMultiPointFeedback multiPointFeedback = MyfeedBack as INewMultiPointFeedback; MypointCollection = new MultipointClass(); multiPointFeedback.Start(MypointCollection, point); break; case esriGeometryType.esriGeometryPolyline: If_isInUse = true; MyfeedBack = new NewLineFeedbackClass(); lineFeedback = MyfeedBack as INewLineFeedback; lineFeedback.Start(point); break; case esriGeometryType.esriGeometryPolygon: If_isInUse = true; MyfeedBack = new NewPolygonFeedbackClass(); polygonFeedback = MyfeedBack as INewPolygonFeedback; polygonFeedback.Start(point); break; default: break; } } else { if ((MyfeedBack as INewMultiPointFeedback) != null) { object missing = Type.Missing; MypointCollection.AddPoint(point, ref missing, ref missing); } else if ((MyfeedBack as INewLineFeedback) != null) { lineFeedback = MyfeedBack as INewLineFeedback; lineFeedback.AddPoint(point); } else if ((MyfeedBack as INewPolygonFeedback) != null) { polygonFeedback = MyfeedBack as INewPolygonFeedback; polygonFeedback.AddPoint(point); } } } catch { return; } }
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e) //地图单击 { //屏幕坐标点转化为地图坐标点 pPointPt = (axMapControl1.Map as IActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y); if (e.button == 1) //左键 { IActiveView pActiveView = axMapControl1.ActiveView; IEnvelope pEnvelope = new EnvelopeClass(); switch (pMouseOperate) { #region 距离量算 case "MeasureLength": //判断追踪线对象是否为空,若是则实例化并设置当前鼠标点为起始点 if (pNewLineFeedback == null) { //实例化追踪线对象 pNewLineFeedback = new NewLineFeedbackClass(); pNewLineFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay; //设置起点,开始动态线绘制 pNewLineFeedback.Start(pPointPt); dToltalLength = 0; } else //如果追踪线对象不为空,则添加当前鼠标点 { pNewLineFeedback.AddPoint(pPointPt); } if (dSegmentLength != 0) { dToltalLength = dToltalLength + dSegmentLength; } break; #endregion #region 面积量算 case "MeasureArea": if (pNewPolygonFeedback == null) { //实例化追踪面对象 pNewPolygonFeedback = new NewPolygonFeedback(); pNewPolygonFeedback.Display = (axMapControl1.Map as IActiveView).ScreenDisplay; pAreaPointCol.RemovePoints(0, pAreaPointCol.PointCount); //开始绘制多边形 pNewPolygonFeedback.Start(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } else { pNewPolygonFeedback.AddPoint(pPointPt); pAreaPointCol.AddPoint(pPointPt, ref missing, ref missing); } break; #endregion #region 其他 case "SelFeature": ////////// #endregion default: break; } } else if (e.button == 2) //右键 { } }
public void set_polyFeedback(IPoint point) { _polyFeedback.Start(point); }
public void OnMouseDown(int button, int shift, int x, int y) { try { IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); if (engineEditor == null) { return; } if (engineEditor.EditState != esriEngineEditState.esriEngineStateEditing) { return; } if (engineEditLayers == null) { return; } IFeatureLayer featureLayer = engineEditLayers.TargetLayer; if (featureLayer == null) { return; } IFeatureClass featureClass = featureLayer.FeatureClass; if (featureClass == null) { return; } //解决编辑要素的Z值问题 IZAware zaware = point as IZAware; zaware.ZAware = true; point.Z = 0; object missing = Type.Missing; map.ClearSelection(); switch (featureClass.ShapeType) { //当为点层时,直接创建要素 case esriGeometryType.esriGeometryPoint: CreateFeature(point as IGeometry); break; //点集的处理方式 case esriGeometryType.esriGeometryMultipoint: if (pointCollection == null) { pointCollection = new MultipointClass(); } else { pointCollection.AddPoint(point, ref missing, ref missing); } if (newMultiPointFeedback == null) { newMultiPointFeedback = new NewMultiPointFeedbackClass(); newMultiPointFeedback.Display = activeView.ScreenDisplay; newMultiPointFeedback.Start(pointCollection, point); } break; //多段线处理方式 case esriGeometryType.esriGeometryPolyline: if (newLineFeedback == null) { newLineFeedback = new NewLineFeedbackClass(); newLineFeedback.Display = activeView.ScreenDisplay; newLineFeedback.Start(point); } else { newLineFeedback.AddPoint(point); } break; //多边形处理方式 case esriGeometryType.esriGeometryPolygon: if (newPolygonFeedback == null) { newPolygonFeedback = new NewPolygonFeedbackClass(); newPolygonFeedback.Display = activeView.ScreenDisplay; newPolygonFeedback.Start(point); } else { newPolygonFeedback.AddPoint(point); } break; } } catch (Exception exception) {} }