protected override void OnMouseDown(MouseEventArgs arg) { base.OnMouseDown(arg); if (Painter.ActiveLayer != null && arg.Button == MouseButtons.Left) { try { ValueSymbolForm valueSymbolForm = AddIn.FromID <ValueSymbolForm.AddinImpl>(ThisAddIn.IDs.ValueSymbolForm).UI; selectedValue = valueSymbolForm.SelectedValue; selectedColor = valueSymbolForm.SelectedColor; IPoint startCoor = Raster.ScreenCoor2MapCoor(arg.X, arg.Y); if (!isDrawing) { newLineFeedback = new NewLineFeedback(); newLineFeedback.Display = ArcMap.Document.ActiveView.ScreenDisplay; newLineFeedback.Symbol = (ISymbol)Display.GetDefaultSelectLineSymbol(); newLineFeedback.Start(startCoor); } newLineFeedback.AddPoint(startCoor); } catch (Exception ex) { MessageBox.Show(string.Format("Unfortunately, the application meets an error.\n\nSource: {0}\nSite: {1}\nMessage: {2}", ex.Source, ex.TargetSite, ex.Message), "Error"); } } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { downPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); if (button == 1 && ptCount == 0 && m_pNewLineFeedback == null) { ISimpleLineSymbol pSLnSym; m_pNewLineFeedback = new NewLineFeedbackClass(); pSLnSym = (ISimpleLineSymbol)m_pNewLineFeedback.Symbol; Color color = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; pSLnSym.Color = pColor; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; m_pNewLineFeedback.Display = this.m_pMapControl.ActiveView.ScreenDisplay; m_pNewLineFeedback.Constraint = esriLineConstraints.esriLineConstraintsVertical; m_pNewLineFeedback.Start(downPoint); ptCount++; mapControlEvents.OnMouseDown -= new IMapControlEvents2_OnMouseDownEventHandler(map2DCommand.OnMouseDown); mapControlEvents.OnMouseUp += new IMapControlEvents2_OnMouseUpEventHandler(map2DCommand.OnMouseUp); } else if (button == 1 && m_pNewLineFeedback != null && ptCount > 0) { m_pNewLineFeedback.AddPoint(downPoint); ptCount++; } }
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 } }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { if (m_hookHelper != null) { if (Button == 1) { m_blnInMouseDown = true; m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); //此处可能要加m_blnSnap=false; if (m_pNewLineFeedback == null) { m_pNewLineFeedback = new NewLineFeedback(); m_pNewLineFeedback.Display = m_pScreenDisplay; m_douTotal = 0d; if (m_blnSnap == true) { m_pNewLineFeedback.Start(m_pSnapPoint); } else { m_pNewLineFeedback.Start(m_pPoint); } } else { if (m_blnSnap == true) { m_pNewLineFeedback.AddPoint(m_pSnapPoint); } else { m_pNewLineFeedback.AddPoint(m_pPoint); } } m_pGeometry = m_pPoint; if (m_douDistance != 0d) { m_douTotal = m_douTotal + m_douDistance; } } else if (Button == 2) { m_blnInMouseDown = false; } } else if (m_sceneHookHelper != null) { } else if (m_globeHookHelper != null) { } }
/// <summary> /// 向折线或多边形上添加节点 /// 在Map的MouseDown事件中调用本方法,将当前光标位置作为节点 /// 添加到折线或多边形上 /// </summary> /// <param name="point">拐点</param> public void AddPoint(IPoint point) { if (_eMeasureType == EMeasureType.Distance || _eMeasureType == EMeasureType.Angle) { _newLineFeedback.AddPoint(point); } else if (_eMeasureType == EMeasureType.Area) { _newPolygonFeedback.AddPoint(point); } object ep = System.Reflection.Missing.Value; _pointCollection.AddPoint(point, ref ep, ref ep); }
/// <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 pPnt = m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewLineFeedback == null) //第一次按下 { m_pNewLineFeedback = new NewLineFeedbackClass(); IRgbColor pRGB = new RgbColorClass(); ISimpleLineSymbol pSLnSym = m_pNewLineFeedback.Symbol as ISimpleLineSymbol; pRGB.Red = 255; pRGB.Blue = 0; pRGB.Green = 0; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; m_pNewLineFeedback.Display = m_MapControl.ActiveView.ScreenDisplay; m_pNewLineFeedback.Start(pPnt); } else //将点加入到工具中去 { m_pNewLineFeedback.AddPoint(pPnt); } }
//鼠标在Map的事件 public override void OnMouseDown(int Button, int Shift, int X, int Y) { IPoint pPt = m_ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (m_NewLineFeedBack == null) { m_NewLineFeedBack = new NewLineFeedbackClass(); ISimpleLineSymbol pSimLineSymbol = null; IRgbColor pRGBColor = null; pSimLineSymbol = m_NewLineFeedBack.Symbol as ISimpleLineSymbol; pRGBColor = new RgbColorClass(); pRGBColor.Red = 255; pRGBColor.Blue = 0; pRGBColor.Green = 0; pSimLineSymbol.Color = pRGBColor as IColor; pSimLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; m_NewLineFeedBack.Display = m_ScreenDisplay; m_NewLineFeedBack.Start(pPt); } else { m_NewLineFeedBack.AddPoint(pPt); } }
public override void OnMouseDown(int button, int shift, int x, int y) { if (button != 1) { return; } IActiveView activeView = _context.ActiveView; IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); ISnappingResult snappingResult = _pointSnapper.Snap(point); if (snappingResult != null) { point = snappingResult.Location; } if (_lineFeedback == null) { _lineFeedback = new NewLineFeedbackClass() { Display = activeView.ScreenDisplay }; _lineFeedback.Start(point); } else { _lineFeedback.AddPoint(point); } }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { downPoint = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); if (m_pNewLineFeedback == null) { ISimpleLineSymbol pSLnSym; m_pNewLineFeedback = new NewLineFeedbackClass(); pSLnSym = (ISimpleLineSymbol)m_pNewLineFeedback.Symbol; Color color = ColorTranslator.FromHtml(SystemInfo.Instance.LineColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; pSLnSym.Color = pColor; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; m_pNewLineFeedback.Display = this.m_pMapControl.ActiveView.ScreenDisplay; m_pNewLineFeedback.Start(downPoint); } else { m_pNewLineFeedback.AddPoint(downPoint); } m_pRecordPointArray.Add(downPoint); base.OnMouseDown(button, shift, x, y, mapX, mapY); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //获得鼠标在控件上点击的位置,产生一个点对象 IPoint pPt = m_ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (pLineFeedback == null) { pLineFeedback = new NewLineFeedbackClass(); pLineFeedback.Display = m_ActiveView.ScreenDisplay; pLineFeedback.Start(pPt); } else { pLineFeedback.AddPoint(pPt); } }
private void CalculateCornerMouseDown(IPoint pPoint) { IGeometry pGeom = null; if (!m_bInUse) //如果命令没有使用 { m_pPoint1 = pPoint; m_pLastPoint = pPoint; m_pRecordPointArray.Add(m_pPoint1); m_bInUse = true; m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint1); } else //如果命令正在使用 { m_pPoint2 = pPoint; m_pRecordPointArray.Add(pPoint); m_bInUse = true; m_pLineFeed.AddPoint(pPoint); CommonFunction.DrawPointSMSSquareSymbol(m_MapControl, m_pPoint2); if (m_pRecordPointArray.Count > 2) { IPolyline pPolyline; pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray); pGeom = (IGeometry)pPolyline; CommonFunction.AddElement(m_MapControl, pGeom); double dblZimuth = CommonFunction.GetAngleZuo_P123(m_pPoint1, (IPoint)m_pRecordPointArray.get_Element(1), m_pPoint2); dblZimuth = CommonFunction.RadToDeg(dblZimuth); System.Windows.Forms.DialogResult result; string strResult = "三点夹角:" + dblZimuth.ToString(".#####") + "(°′″)"; strResult = strResult + CRLF; strResult = strResult + "第一点坐标 X=" + m_pPoint1.X.ToString(".###") + "Y=" + m_pPoint1.Y.ToString(".###"); strResult = strResult + CRLF; strResult = strResult + "第二点坐标 X=" + ((IPoint)m_pRecordPointArray.get_Element(1)).X.ToString(".###") + "Y=" + ((IPoint)m_pRecordPointArray.get_Element(1)).Y.ToString(".###"); strResult = strResult + CRLF; strResult = strResult + "第三点坐标 X=" + m_pPoint2.X.ToString(".###") + "Y=" + m_pPoint2.Y.ToString(".###"); result = MessageBox.Show(strResult, "三点夹角计算", MessageBoxButtons.OK, MessageBoxIcon.Information); if (result == DialogResult.OK) { Reset(); //复位; } } } }
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 EndSketch(AxMapControl m_MapControl) //结束一次画图操作 { IGeometry m_Geometry = null; IPointCollection m_PointCollection = null; if (m_pNewLineFeedback != null) //线对象有效 { //INewLineFeedback m_LineFeed = (INewLineFeedback)m_Feedback; m_pNewLineFeedback.AddPoint(m_PointStop); IPolyline m_PolyLine = m_pNewLineFeedback.Stop(); m_PointCollection = (IPointCollection)m_PolyLine; if (m_PointCollection.PointCount < 2) { MessageBoxEx.Show("需要两个点才能生成一条线!", "未能生成线", MessageBoxButtons.OK); return; } else { m_Geometry = (IGeometry)m_PointCollection; } } else if (m_pPlygonFeadback != null) //多边形对象有效 { m_pPlygonFeadback.AddPoint(m_PointStop); IPolygon m_Polygon = m_pPlygonFeadback.Stop(); if (m_Polygon != null) { m_PointCollection = (IPointCollection)m_Polygon; } if (m_PointCollection.PointCount < 3) { MessageBoxEx.Show("需要三个点才能生成一个面!", "未能生成面", MessageBoxButtons.OK); return; } else { m_Geometry = (IGeometry)m_PointCollection; } } CreateFeature(m_Geometry); m_pPlygonFeadback = null; m_pNewLineFeedback = null; m_bInUse = false; }
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 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); } }
/// <summary> /// Gets a polyline from the feedback object /// startPoint is where it will restart from /// endPoint is where you want it to end for the return of the polyline /// </summary> /// <param name="startPoint">startPoint is where it will restart from</param> /// <param name="endPoint">endPoint is where you want it to end for the return of the polyline</param> /// <returns></returns> internal IPolyline GetPolylineFromFeedback(IPoint startPoint, IPoint endPoint) { if (feedback == null) { return(null); } feedback.AddPoint(endPoint); var polyline = feedback.Stop(); // restart feedback feedback.Start(startPoint); return(polyline); }
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; } }
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 override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { base.OnMouseDown(button, shift, x, y, mapX, mapY); m_CurrentLayer = m_App.CurrentEditLayer; m_bIsSelect = true; if (button == 2 && !m_bBeginDrawLineFeed) //右键单击,开始绘制分割线 { if (m_OriginFeatureArray.Count == 0) { return; } m_bBeginDrawLineFeed = true; return; } if (button != 2 && m_bBeginDrawLineFeed) //绘制分割线(“剪刀”)工作 { if (!m_bIsDrawLineFeed) //第1个点 { m_bIsDrawLineFeed = true; m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(m_pPoint); if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } } else //第2、3个点 { m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.AddPoint(m_pPoint); } } if (button == 2 && m_bBeginDrawLineFeed) //执行分割操作 { DoSplit(); } }
private void DrawRectSide2PMouseDown(IPoint pPoint) { IPoint tempPoint = new PointClass(); m_mouseDownCount = m_mouseDownCount + 1; if (m_mouseDownCount < 3) //点击鼠标次数小于3时 { //绘制线 if (m_bInUse == false) { m_pFeedback = new NewLineFeedbackClass(); m_pLineFeed = (INewLineFeedback)m_pFeedback; m_pLineFeed.Start(pPoint); tempPoint.X = pPoint.X; tempPoint.Y = pPoint.Y; Class.Common.DrawPointSMSSquareSymbol(m_MapControl, pPoint); m_pUndoArray.Add(tempPoint);//将第一个点保存到变量 m_pLastPoint = pPoint; m_bInUse = true; } else { m_pLineFeed = (INewLineFeedback)m_pFeedback; tempPoint.X = m_pAnchorPoint.X; tempPoint.Y = m_pAnchorPoint.Y; m_pLineFeed.AddPoint(tempPoint); Class.Common.DrawPointSMSSquareSymbol(m_MapControl, tempPoint); m_pUndoArray.Add(tempPoint);; //将第二个点保存到变量 } if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } } else if (m_mouseDownCount == 3) //点击鼠标次数等于3后,停止绘制 { EndDrawRectSide2P(); } }
/// <summary> /// 鼠标落下时运行 /// </summary> /// <param name="clickPT">地图点</param> public void OnMouseDownRun(IPoint clickPT) { if (lineFeedback == null) { lineFeedback = new NewLineFeedbackClass(); lineFeedback.Display = (mapControl.Map as IActiveView).ScreenDisplay; lineFeedback.Start(clickPT); // 长度计算 currentLength = 0; totalLength = 0; } else { lineFeedback.AddPoint(clickPT); // 长度计算 totalLength += Math.Round(Math.Sqrt(Math.Pow(tempPT.X - clickPT.X, 2) + Math.Pow(tempPT.Y - clickPT.Y, 2)), 3); } tempPT = clickPT; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add SelectPoint.OnMouseDown implementation pActiveView = m_hookHelper.ActiveView; pMap = m_hookHelper.FocusMap; pGraphicsContainer = pMap as IGraphicsContainer; IPoint pPt = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); if (newItem == null) { newItem = new ListViewItem(pointCount.ToString()); newItem.SubItems.Add(pPt.X.ToString("f3")); newItem.SubItems.Add(pPt.Y.ToString("f3")); frmAdjPoint.FromPoint.AddPoint(pPt, ref obj, ref obj); } /*if (clickCount == 2&&newItem.SubItems.Count<=4) * { * newItem.SubItems.Add(pPt.X.ToString("f3")); * newItem.SubItems.Add(pPt.Y.ToString("f3")); * frmAdjPoint.ToPoint.AddPoint(pPt, ref obj, ref obj); * clickCount++; * }*/ AddPointElement((IGeometry)pPt, pGraphicsContainer); if (pLineFeedback == null) { pLineFeedback = new NewLineFeedbackClass(); pLineFeedback.Display = pActiveView.ScreenDisplay; pLineFeedback.Start(pPt); } else { pLineFeedback.AddPoint(pPt); } }
public override void OnKeyUp(int keyCode, int Shift) { if (Shift != 2 && keyCode != 90) { return; } if (m_pNewLineFeedback == null) { return; } IPolyline pPolyline = m_pNewLineFeedback.Stop(); m_pNewLineFeedback = null; if (pPolyline == null) { return; } IPointCollection pntCol = pPolyline as IPointCollection; m_pNewLineFeedback = new NewLineFeedbackClass(); IRgbColor pRGB = new RgbColorClass(); ISimpleLineSymbol pSLnSym = m_pNewLineFeedback.Symbol as ISimpleLineSymbol; pRGB.Red = 255; pRGB.Blue = 0; pRGB.Green = 0; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; m_pNewLineFeedback.Display = m_MapControl.ActiveView.ScreenDisplay; m_pNewLineFeedback.Start(pntCol.get_Point(0)); for (int i = 1; i < pntCol.PointCount - 1; i++) { m_pNewLineFeedback.AddPoint(pntCol.get_Point(i)); } }
public override void OnMouseDown(int button, int Shift, int x, int y) { if (button == 2) { return; } this._iPoint = (_context.ActiveView).ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); IActiveView focusMap = (IActiveView)_context.ActiveView; if (_lineFeedback == null) { _lineFeedback = new NewLineFeedback() { Display = focusMap.ScreenDisplay }; _lineFeedback.Start(_iPoint); this.m_cursor = this._cursor1; _inLine = true; return; } if (this._inLine) { this.m_cursor = this._cursor; this._inLine = false; if (this._lineFeedback != null) { _lineFeedback.AddPoint(_iPoint); IPolyline line = this._lineFeedback.Stop(); if (line.Length > 0) { //开始启动断面分析 _sectLine = line; StartSection(); } } } }
protected override void OnMouseUp(MouseEventArgs arg) { base.OnMouseUp(arg); try { IPoint p = mDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(arg.X, arg.Y); if (LineFeedBack == null) { ITopologicalOperator to = (ITopologicalOperator)p; double buffsize = .01 * mMap.MapScale; IGeometry g = to.Buffer(buffsize); FlashGeometry(g); mMap.SelectByShape(g, ArcMap.ThisApplication.SelectionEnvironment, true); if (mMap.SelectionCount > 0) { IFeatureSelection fsel = Globals.AddressPointLayer as IFeatureSelection; ISelectionSet selset = fsel.SelectionSet; if (selset.Count == 1) { IEnumIDs pEnum = selset.IDs; int oid = pEnum.Next(); SelectedPoint = Globals.AddressPointLayer.FeatureClass.GetFeature(oid); mDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //IPolyline pline = GetPolylineFromMouseClicks(); LineFeedBack = CreateLineFeedBack(); LineFeedBack.Start(p); //if (GetDriveCenterlineIntersection(pline)) //{ // if (CalculateHouseNumber()) // { // SetAttributes(); // } //} } //mMap.ClearSelection(); //mMap.SelectByShape(g, ArcMap.ThisApplication.SelectionEnvironment, true); //mDoc.ActiveView.Refresh(); } else { if (arg.ModifierKeys == Keys.Control) { IFeature fx1 = Globals.AddressPointLayer.FeatureClass.CreateFeature(); fx1.Shape = p; fx1.Store(); int fxOID = fx1.OID; ArcMap.Document.ActiveView.Selection.Clear(); mMap.SelectFeature(Globals.AddressPointLayer as ILayer, fx1); SelectedPoint = Globals.AddressPointLayer.FeatureClass.GetFeature(fxOID); mDoc.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, null); //IPolyline pline = GetPolylineFromMouseClicks(); LineFeedBack = CreateLineFeedBack(); LineFeedBack.Start(p); } } } else { LineFeedBack.AddPoint(p); } } catch { } }
/// <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; } }
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; } }
public override void OnMouseMove(int button, int shift, int x, int y, double mapX, double mapY) { // TODO: 添加 DrawArc3P.OnMouseMove 实现 base.OnMouseMove(button, shift, x, y, mapX, mapY); m_pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); m_pAnchorPoint = m_pPoint; //+++++++++++++开始捕捉+++++++++++++++++++++ bool flag = CommonFunction.Snap(m_MapControl, m_App.CurrentConfig.cfgSnapEnvironmentSet, null, m_pAnchorPoint); if (m_pLastPoint != null) { //########################平行尺######################## CommonFunction.ParallelRule(ref m_bKeyCodeP, m_pActiveView, m_dblTolerance, ref m_pSegment, m_pLastPoint, m_pPoint, ref m_pAnchorPoint); //&&&&&&&&&&&&&&&&&&&&&&&& 正 交 &&&&&&&&&&&&&&&&&&&&&&& CommonFunction.PositiveCross(m_pLastPoint, ref m_pAnchorPoint, m_App.CurrentConfig.cfgPositiveCross.IsPositiveCross); } if (pLineArray.Count >= 1) { if (m_pFeedback != null) { m_pFeedback.Display = m_pActiveView.ScreenDisplay; } m_pFeedback.MoveTo(m_pAnchorPoint); } if (m_bInUse) { pLineArray.Add(m_pAnchorPoint); if (pLineArray.Count >= 3) { IPoint pPoint1 = (IPoint)pLineArray.get_Element(0); IPoint pPoint2 = (IPoint)pLineArray.get_Element(1); IPoint pPoint3 = (IPoint)pLineArray.get_Element(pLineArray.Count - 1); //计算圆心坐标 和 半径 double R; m_pCenterPoint = CommonFunction.GetCenter_P123(pPoint1, pPoint2, pPoint3); R = CommonFunction.GetDistance_P12(pPoint1, m_pCenterPoint); //计算m_pCenterPoint到起点p1的方位角和到端点的方位角 double Ap01; double Ap03; double Ap12; double Ap13; Ap01 = CommonFunction.GetAzimuth_P12(m_pCenterPoint, pPoint1); Ap03 = CommonFunction.GetAzimuth_P12(m_pCenterPoint, pPoint3); Ap12 = CommonFunction.GetAzimuth_P12(pPoint1, pPoint2); Ap13 = CommonFunction.GetAzimuth_P12(pPoint1, pPoint3); //计算圆心角 double dA; dA = Ap13 - Ap12; if (dA < 0) { dA = dA + Math.PI * 2; } if (dA >= 0 && dA < Math.PI) { m_Ca = Ap03 - Ap01; } else if (dA >= Math.PI && dA < Math.PI * 2) { m_Ca = Ap01 - Ap03; } if (m_Ca < 0) { m_Ca = m_Ca + 2 * Math.PI; } m_pLineFeed.Stop(); m_pLineFeed.Start(pPoint1); IPoint pm = new PointClass(); if (dA >= 0 && dA < Math.PI) { for (int i = 0; i <= m_Ca / CommonFunction.DegToRad(5) - 1; i++) { pm.X = m_pCenterPoint.X + R * Math.Cos(Ap01 + CommonFunction.DegToRad(5 * (i + 1))); pm.Y = m_pCenterPoint.Y + R * Math.Sin(Ap01 + CommonFunction.DegToRad(5 * (i + 1))); m_pLineFeed.AddPoint(pm); } } else if (dA >= Math.PI && dA < Math.PI * 2) { for (int i = 0; i <= m_Ca / CommonFunction.DegToRad(5) - 1; i++) { pm.X = m_pCenterPoint.X + R * Math.Cos(Ap01 - CommonFunction.DegToRad(5 * (i + 1))); pm.Y = m_pCenterPoint.Y + R * Math.Sin(Ap01 - CommonFunction.DegToRad(5 * (i + 1))); m_pLineFeed.AddPoint(pm); } } m_pLineFeed.AddPoint(pPoint3); } } }
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; } } }