/// <summary> /// 更新半径 千米 /// </summary> /// <param name="radius"></param> public void UpdatePosition(double radius) { this.Dosomething((Action) delegate() { pRadius = radius; MapLngLat center = new MapLngLat(centerPoint.X, centerPoint.Y); MapLngLat around = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)radius, center, 180); INewLineFeedback backline = new NewLineFeedbackClass(); centerPoint = new PointClass() { X = center.Lng, Y = center.Lat }; IPoint aroundPoint = new PointClass() { X = around.Lng, Y = around.Lat }; backline.Start(centerPoint); backline.AddPoint(aroundPoint); var geo = backline.Stop(); iSeg.SetCircle(centerPoint, geo.Length); object o = System.Type.Missing; pRing = iSeg as IRing; pRing.Close(); pGeometryColl = new PolygonClass(); pGeometryColl.AddGeometry(pRing, ref o, ref o); pGeometry = pGeometryColl as IGeometry; base.Symbol = fillSymbol; base.Geometry = pGeometry; }, true); Update(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="_mapControl"></param> /// <param name="circle"></param> public Circle_ArcMap(AxMapControl _mapControl, KmlCircle circle, FactoryArcMap facArc) { this.mapControl = _mapControl; this.factoryArcMap = facArc; Dosomething(new Action(delegate { lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = new RgbColorClass() { Red = circle.StrokeColor.R, Green = circle.StrokeColor.B, Blue = circle.StrokeColor.B }; lineSymbol.Width = circle.StrokeWidth; fillSymbol = new SimpleFillSymbol(); fillSymbol.Outline = lineSymbol; //填充色 IColor fillColor = new RgbColorClass() { Transparency = circle.FillColor.A, Red = circle.FillColor.R, Green = circle.FillColor.G, Blue = circle.FillColor.B }; fillSymbol.Color = fillColor; base.Symbol = fillSymbol;//颜色和风格 iSeg = new RingClass(); centerPoint = new PointClass();//圆心坐标 centerPoint.PutCoords(circle.Position.Lng, circle.Position.Lat); MapLngLat around = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)circle.Radius, circle.Position, 180); INewLineFeedback backline = new NewLineFeedbackClass(); IPoint aroundPoint = new PointClass() { X = around.Lng, Y = around.Lat }; backline.Start(centerPoint); backline.AddPoint(aroundPoint); var geo = backline.Stop(); iSeg.SetCircle(centerPoint, geo.Length); object o = System.Type.Missing; pRing = iSeg as IRing; pRing.Close(); pGeometryColl = new PolygonClass(); pGeometryColl.AddGeometry(pRing, ref o, ref o); pGeometry = pGeometryColl as IGeometry; base.Geometry = pGeometry; }), true); pRadius = circle.Radius; bOutLineColor = circle.StrokeColor; bFillColor = circle.FillColor; bWidth = circle.StrokeWidth; flashTimer = new Timer(); flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed); #region MyRegion //if (mapControl.InvokeRequired) //{ // mapControl.Invoke((Action)delegate() // { // lineSymbol = new SimpleLineSymbolClass(); // lineSymbol.Color = new RgbColorClass() // { // Red = circle.StrokeColor.R, // Green = circle.StrokeColor.B, // Blue = circle.StrokeColor.B // }; // lineSymbol.Width = circle.StrokeWidth; // fillSymbol = new SimpleFillSymbol(); // fillSymbol.Outline = lineSymbol; // //填充色 // IColor fillColor = new RgbColorClass() // { // Transparency = circle.FillColor.A, // Red = circle.FillColor.R, // Green = circle.FillColor.G, // Blue = circle.FillColor.B // }; // fillSymbol.Color = fillColor; // base.Symbol = fillSymbol;//颜色和风格 // iSeg = new RingClass(); // centerPoint = new PointClass();//圆心坐标 // centerPoint.PutCoords(circle.Position.Lng, circle.Position.Lat); // //MapFrame.Core.Model.MapLngLat around = GetPointByDistanceAndAngle(circle.Radius, circle.Position); // MapLngLat around = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)circle.Radius, circle.Position, 180); // INewLineFeedback backline = new NewLineFeedbackClass(); // IPoint aroundPoint = new PointClass() { X = around.Lng, Y = around.Lat }; // backline.Start(centerPoint); // backline.AddPoint(aroundPoint); // var geo = backline.Stop(); // iSeg.SetCircle(centerPoint, geo.Length); // object o = System.Type.Missing; // pRing = iSeg as IRing; // pRing.Close(); // pGeometryColl = new PolygonClass(); // pGeometryColl.AddGeometry(pRing, ref o, ref o); // pGeometry = pGeometryColl as IGeometry; // base.Geometry = pGeometry; // }); //} //else //{ // lineSymbol = new SimpleLineSymbolClass(); // lineSymbol.Color = new RgbColorClass() // { // Red = circle.StrokeColor.R, // Green = circle.StrokeColor.B, // Blue = circle.StrokeColor.B // }; // lineSymbol.Width = circle.StrokeWidth; // fillSymbol = new SimpleFillSymbol(); // fillSymbol.Outline = lineSymbol; // //填充色 // IColor fillColor = new RgbColorClass() // { // Transparency = circle.FillColor.A, // Red = circle.FillColor.R, // Green = circle.FillColor.G, // Blue = circle.FillColor.B // }; // fillSymbol.Color = fillColor; // base.Symbol = fillSymbol;//颜色和风格 // iSeg = new RingClass(); // centerPoint = new PointClass();//圆心坐标 // centerPoint.PutCoords(circle.Position.Lng, circle.Position.Lat); // //MapFrame.Core.Model.MapLngLat around = GetPointByDistanceAndAngle(circle.Radius, circle.Position); // MapLngLat around = MapFrame.Core.Common.Utils.GetPointByDistanceAndAngle((float)circle.Radius, circle.Position, 180); // INewLineFeedback backline = new NewLineFeedbackClass(); // IPoint aroundPoint = new PointClass() { X = around.Lng, Y = around.Lat }; // backline.Start(centerPoint); // backline.AddPoint(aroundPoint); // var geo = backline.Stop(); // iSeg.SetCircle(centerPoint, geo.Length); // object o = System.Type.Missing; // pRing = iSeg as IRing; // pRing.Close(); // pGeometryColl = new PolygonClass(); // pGeometryColl.AddGeometry(pRing, ref o, ref o); // pGeometry = pGeometryColl as IGeometry; // base.Geometry = pGeometry; //} #endregion }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { IGeometry Geom = null; if (!m_bInUse) { downPoint = m_pAnchorPoint; m_pRecordPointArray.Add(downPoint); m_pCircleFeed = new NewCircleFeedbackClass(); m_bInUse = true; m_pCircleFeed.Display = m_pActiveView.ScreenDisplay; m_pLineFeed = new NewLineFeedbackClass(); m_pLineFeed.Start(downPoint); m_pCircleFeed.Start(downPoint); } else //如果命令正在使用 { if (pGraphicsContainer != null) { pGraphicsContainer.DeleteAllElements(); } movePoint = m_pAnchorPoint; //画半径线 m_pRecordPointArray.Add(movePoint); IPolyline pPolyline; pPolyline = (IPolyline)CommonFunction.MadeSegmentCollection(ref m_pRecordPointArray); Geom = (IGeometry)pPolyline; CommonFunction.AddElement(m_pMapControl, Geom); m_radius = CommonFunction.GetDistance_P12(downPoint, movePoint); //半径 //m_radius = Math.Round( m_radius,1,MidpointRounding.AwayFromZero);//保留一位小数 //缓冲半径文本 ITextElement iTextElement = new TextElementClass(); iTextElement.Text = m_radius.ToString(".##") + "米"; ITextSymbol sce = new TextSymbolClass(); sce.Size = 15 /*SystemInfo.Instance.TextSize*/; Color color = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; sce.Color = pColor; iTextElement.Symbol = sce; IElement iElement = (IElement)iTextElement; iElement.Geometry = Geom; this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(iElement, 0); this.m_pMapControl.ActiveView.Refresh(); //画圆 pSegmentCollection = new PolygonClass(); pSegmentCollection.SetCircle(downPoint, m_radius); pGeom = pSegmentCollection as IGeometry; if (pGeom != null) { AddCreateCircleElement(pGeom, this.m_pMapControl.ActiveView); this.m_pMapControl.ActiveView.Refresh(); GetPipeInfo(); } if (m_pRecordPointArray.Count != 0) { m_pRecordPointArray.RemoveAll(); } m_bInUse = false; } }