public override void OnMouseDown(int Button, int int_1, int int_2, int int_3) { if (Button == 1) { IActiveView activeView = (IActiveView)this._context.FocusMap; IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3); if (this.idisplayFeedback_0 == null) { this.idisplayFeedback_0 = new NewCircleFeedback(); this.idisplayFeedback_0.Display = activeView.ScreenDisplay; (this.idisplayFeedback_0 as INewCircleFeedback).Start(point); } else { try { ICircularArc circularArc = (this.idisplayFeedback_0 as INewCircleFeedback).Stop(); this.idisplayFeedback_0 = null; ISegmentCollection segmentCollection = new Polygon() as ISegmentCollection; object value = Missing.Value; segmentCollection.AddSegment(circularArc as ISegment, ref value, ref value); (segmentCollection as IGeometry).SpatialReference = this._context.FocusMap.SpatialReference; this._context.FocusMap.ClipGeometry = (segmentCollection as IGeometry); (this._context.FocusMap as IActiveView).Extent = (segmentCollection as IGeometry).Envelope; this._context.ActiveView.Refresh(); } catch (Exception) { } } } }
private void method_9(IActiveView pView, IPoint point, double num, bool flag, IRgbColor color) { this.method_8(point, num, flag); ISegmentCollection segmentCollection = new Polygon() as ISegmentCollection; ICircularArc circularArc = this.method_8(point, num, flag); object missing = Type.Missing; segmentCollection.AddSegment(circularArc as ISegment, ref missing, ref missing); ICircleElement circleElement = new CircleElement() as ICircleElement; IElement element = (IElement)circleElement; element.Geometry = (segmentCollection as IGeometry); IFillShapeElement fillShapeElement = (IFillShapeElement)circleElement; ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); simpleLineSymbol.Color = (color); simpleLineSymbol.Width = (2.0); simpleLineSymbol.Style = (0); simpleFillSymbol.Color = (color); simpleFillSymbol.Style = (esriSimpleFillStyle)(1); simpleFillSymbol.Outline = (simpleLineSymbol); fillShapeElement.Symbol = (simpleFillSymbol); IGraphicsContainer graphicsContainer = (IGraphicsContainer)pView; graphicsContainer.AddElement((IElement)circleElement, 0); }
/// <summary> /// 转换椭圆线为椭圆面几何形状 /// </summary> /// <param name="geometry">ESRI几何形状接口</param> /// <returns>椭圆面几何形状的ESRI几何形状接口</returns> public static IGeometry ConvertEllipticArcToPolygon(IGeometry geometry) { if ((IsValidGeometry(geometry)) && (geometry is ISegment)) { ISegmentCollection segmentCollecttion = new Polygon() as ISegmentCollection; object Missing = Type.Missing; segmentCollecttion.AddSegment((ISegment)geometry, ref Missing, ref Missing); return((IGeometry)segmentCollecttion); } else { return(null); } }
/// <summary> /// 生成椭圆 /// </summary> public IEllipticArc GenerateEllipticArc(IPoint pCenterPoint, double rotationAngle, double Descripe, double Seismic) { Core.DAL.DisaParameter disapara = new DAL.DisaParameter(); List <Core.Model.DisaParameter> listdisapara = new List <Model.DisaParameter>(); listdisapara = disapara.GetList();//读取灾区范围参数 double MajorAxis = 0; double MinorAxis = 0; for (int i = 0; i < listdisapara.Count; i++) { if (listdisapara[i].isMajorAxis) { //根据地震等级和烈度计算出长短轴 MajorAxis = System.Math.Pow(10, (listdisapara[i].A + listdisapara[i].B * Convert.ToDouble(Descripe) - Seismic) / listdisapara[i].C) - listdisapara[i].D;//长半轴 } else { MinorAxis = System.Math.Pow(10, (listdisapara[i].A + listdisapara[i].B * Convert.ToDouble(Descripe) - Seismic) / listdisapara[i].C) - listdisapara[i].D;//短半轴 } } if (MajorAxis <= 0 || MinorAxis <= 0) { MessageBox.Show("输入烈度过大!"); return(null); } double ratio; if (MajorAxis > MinorAxis) { ratio = MinorAxis / MajorAxis; } else { ratio = MajorAxis / MinorAxis; } IEllipticArc ellipticArc = new EllipticArcClass(); //ellipticArc.PutCoordsByAngle(基准,中心点,起点角度,椭圆圆心角,旋转角度,长轴,长短轴之比);轴长单位为米,角度单位为弧度 ellipticArc.PutCoordsByAngle(false, pCenterPoint, 0, 2 * Math.PI, rotationAngle * Math.PI / 180, (double)MajorAxis / Core.Generic.SysEnviriment.LengthPerRad * 2, ratio); ISegment segment = ellipticArc as ISegment; ISegmentCollection polygon = new Polygon() as ISegmentCollection; object Missing = Type.Missing; polygon.AddSegment(segment, ref Missing, ref Missing); //图上显示 Color color = Color.Red; ISymbol symbol = CreateSimpleFillSymbol(color, 1, esriSimpleFillStyle.esriSFSHollow); AddElement(polygon as IGeometry, symbol, "result"); IEnvelope envelope; envelope = ellipticArc.Envelope; if (!envelope.IsEmpty) { envelope.Expand(1, 1, true); } mapControl.Extent = envelope; this.mapControl.Refresh(); return(ellipticArc); }
private void drawCircleGraphic(double Size) { IMxDocument pMxDoc = m_pDoc; IActiveView pActiveView; IScreenDisplay pScreenDisplay; IEnvelope pEnv; IPoint pCenterPoint; IDisplayTransformation pTransform; pActiveView = pMxDoc.FocusMap as IActiveView; pScreenDisplay = pActiveView.ScreenDisplay; pTransform = pScreenDisplay.DisplayTransformation; pEnv = pTransform.FittedBounds; pCenterPoint = new Point(); pCenterPoint.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2); IConstructCircularArc pCircle = new CircularArc() as IConstructCircularArc; ISegmentCollection pPolygon = new Polygon() as ISegmentCollection; Size *= 10000; Size = Math.Sqrt(Size / 3.1416); pCircle.ConstructCircle(pCenterPoint, Size, true); pPolygon.AddSegment(pCircle as ISegment); IPolygon pFinalPolygon; pFinalPolygon = pPolygon as IPolygon; pFinalPolygon.Close(); IRgbColor pLineColor = new RgbColor(); pLineColor.Red = 255; // A CHANGER!!! addGraphicToMap(pMxDoc.FocusMap, pFinalPolygon, pLineColor, pLineColor); }