public IGeometry DrawPolyline(ESRI.ArcGIS.Carto.IActiveView activeView) { if (activeView == null) { return(null); } ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay; // Constant screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColor(); rgbColor.Red = 255; ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast ESRI.ArcGIS.Display.ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); simpleLineSymbol.Color = color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDot; ESRI.ArcGIS.Display.ISymbol symbol = (ESRI.ArcGIS.Display.ISymbol)simpleLineSymbol; // Explicit Cast ESRI.ArcGIS.Display.IRubberBand rubberBand = new RubberLine(); ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol); screenDisplay.SetSymbol(symbol); screenDisplay.DrawPolyline(geometry); screenDisplay.FinishDrawing(); return(geometry); }
//绘制单个点操作 public void DrawPoint(IActiveView activeView, IPoint p, bool red) { if (activeView == null) { return; } ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay; screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = ESRI.ArcGIS.Display.esriSimpleMarkerStyle.esriSMSCross; simpleMarkerSymbol.Size = 15; if (red) { simpleMarkerSymbol.Color = redColor; } else { simpleMarkerSymbol.Color = greenColor; } ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic cast. screenDisplay.SetSymbol(symbol); ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation; screenDisplay.DrawPoint(p); screenDisplay.FinishDrawing(); }
public ESRI.ArcGIS.Geometry.IEnvelope DrawRectangle(ESRI.ArcGIS.Carto.IActiveView activeView) { if (activeView == null) { return(null); } else { ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay; // Constant screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast //ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass(); //rgbColor.Red = 255; //ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass(); //simpleFillSymbol.Color = color; simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow; ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberEnvelopeClass(); ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol); screenDisplay.SetSymbol(symbol); ESRI.ArcGIS.Geometry.IEnvelope pEnvelope = geometry as ESRI.ArcGIS.Geometry.IEnvelope; screenDisplay.DrawRectangle(pEnvelope); // Dynamic Cast screenDisplay.FinishDrawing(); return(pEnvelope); } }
public void DrawPolygon(ESRI.ArcGIS.Carto.IActiveView activeView) { if (activeView == null) { return; } ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay; screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast ESRI.ArcGIS.Display.IRgbColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass(); rgbColor.Red = 255; ESRI.ArcGIS.Display.IColor color = rgbColor; // Implicit Cast ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass(); simpleFillSymbol.Color = color; ESRI.ArcGIS.Display.ISymbol symbol = simpleFillSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast ESRI.ArcGIS.Display.IRubberBand rubberBand = new ESRI.ArcGIS.Display.RubberPolygonClass(); ESRI.ArcGIS.Geometry.IGeometry geometry = rubberBand.TrackNew(screenDisplay, symbol); screenDisplay.SetSymbol(symbol); screenDisplay.DrawPolygon(geometry); screenDisplay.FinishDrawing(); }
//绘制线操作 public void DrawLine(IActiveView activeView, IPoint fromP, IPoint toP) { if (activeView == null) { return; } IPolyline polyline = new PolylineClass(); polyline.FromPoint = fromP; polyline.ToPoint = toP; ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay; screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); ILineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = blackColor; lineSymbol.Width = 1; ESRI.ArcGIS.Display.ISymbol symbol = lineSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic cast. screenDisplay.SetSymbol(symbol); ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation; IGeometry pGeo = polyline; screenDisplay.DrawPolyline(pGeo); screenDisplay.FinishDrawing(); }
public void DrawPoint(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 x, System.Int32 y) { if (activeView == null) { return; } ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay; // Constant screenDisplay.StartDrawing(screenDisplay.hDC, (System.Int16)ESRI.ArcGIS.Display.esriScreenCache.esriNoScreenCache); // Explicit Cast ESRI.ArcGIS.Display.ISimpleMarkerSymbol simpleMarkerSymbol = new ESRI.ArcGIS.Display.SimpleMarkerSymbolClass(); ESRI.ArcGIS.Display.ISymbol symbol = simpleMarkerSymbol as ESRI.ArcGIS.Display.ISymbol; // Dynamic Cast screenDisplay.SetSymbol(symbol); ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation; // x and y are in device coordinates ESRI.ArcGIS.Geometry.IPoint point = displayTransformation.ToMapPoint(x, y); screenDisplay.DrawPoint(point); screenDisplay.FinishDrawing(); }