public static void NewPointElement(IMap pMap, IPoint pPoint) { IActiveView pActiveView = pMap as IActiveView; IGraphicsContainer activeView = (IGraphicsContainer)pActiveView; RubberPoint rubberPointClass = new RubberPoint(); ISimpleMarkerSymbol simpleMarkerSymbolClass = new SimpleMarkerSymbol(); IRgbColor rgbColorClass = new RgbColor(); rgbColorClass.Red = (0); rgbColorClass.Green = (255); rgbColorClass.Blue = (255); simpleMarkerSymbolClass.Color = (rgbColorClass); simpleMarkerSymbolClass.Size = (8); simpleMarkerSymbolClass.Style = (0); LineElement lineElementClass = new LineElement(); ((IElement)lineElementClass).Geometry = (pPoint); activeView.AddElement(lineElementClass, 0); pActiveView.Refresh(); }
/// <summary> /// 屏幕上绘画几何形状 /// </summary> /// <param name="screenDisplay">ESRI屏幕显示接口</param> /// <param name="geomType">几何形状类型的枚举类</param> /// <returns>ESRI几何形状接口</returns> public static IGeometry ScreenTrackGeometry(IScreenDisplay screenDisplay, DsGeometryType geomType) { IGeometry trackGeom = null; if (screenDisplay != null) { IRubberBand rubberBand = null; switch (geomType) { case DsGeometryType.dsGTPoint: rubberBand = new RubberPoint(); break; case DsGeometryType.dsGTLine: rubberBand = new RubberLine(); break; case DsGeometryType.dsGTPolyline: rubberBand = new RubberLine(); break; case DsGeometryType.dsGTRectangle: rubberBand = new RubberEnvelope(); break; case DsGeometryType.dsGTCircle: rubberBand = new RubberCircle(); break; case DsGeometryType.dsGTEllipse: rubberBand = new RubberEnvelope(); break; case DsGeometryType.dsGTPolygon: rubberBand = new RubberPolygon(); break; case DsGeometryType.dsGTRectangularPolygon: rubberBand = new RubberRectangularPolygon(); break; default: break; } if (rubberBand != null) { trackGeom = rubberBand.TrackNew(screenDisplay, null); } if (geomType == DsGeometryType.dsGTEllipse) { trackGeom = ConvertEnvelopeToEllipticArc(trackGeom); } else if ((geomType == DsGeometryType.dsGTLine) || (geomType == DsGeometryType.dsGTPolyline) || (geomType == DsGeometryType.dsGTPolygon)) { if (trackGeom is ITopologicalOperator) { (trackGeom as ITopologicalOperator).Simplify(); } } } return(trackGeom); }