ArcEngine CSharp绘制图形经典代码

来源:互联网 发布:通达信 源码 建仓资金 编辑:程序博客网 时间:2024/05/17 06:30
//画点 public void OnMouseDown(int Button, int Shift, int X, int Y) {   IMxDocument mxDoc = m_App.Document as IMxDocument;   IActiveView activeView = mxDoc.FocusMap as IActiveView;   IScreenDisplay screenDisplay = activeView.ScreenDisplay;   screenDisplay.StartDrawing(screenDisplay.hDC, (short)  esriScreenCache.esriNoScreenCache);   screenDisplay.SetSymbol(new SimpleMarkerSymbolClass());   screenDisplay.DrawPoint(mxDoc.CurrentLocation);   screenDisplay.FinishDrawing(); }//画线public void OnMouseDown(int Button, int Shift, int X, int Y) {   IMxDocument mxDoc = m_App.Document as IMxDocument;   IActiveView activeView = mxDoc.FocusMap as IActiveView;   IScreenDisplay screenDisplay = activeView.ScreenDisplay;   ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass();   IRgbColor rgbColor = new RgbColorClass();   rgbColor.Red = 255;   lineSymbol.Color = rgbColor;   IRubberBand rubberLine = new RubberLineClass();   IPolyline newPolyline = (IPolyline)rubberLine.TrackNew(screenDisplay, (ISymbol)lineSymbol);   screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);   screenDisplay.SetSymbol((ISymbol)lineSymbol);   screenDisplay.DrawPolyline(newPolyline);   screenDisplay.FinishDrawing(); }//画线2 {         ICartographicLineSymbol pCartoLineSyl;                                 pCartoLineSyl = new CartographicLineSymbolClass();                                 pCartoLineSyl.Color = getRGB(255, 110, 210);                                 pCartoLineSyl.Cap = esriLineCapStyle.esriLCSButt;                                 pCartoLineSyl.Join = esriLineJoinStyle.esriLJSBevel;                                 pCartoLineSyl.Width=4;                                 pCartoLineSyl.MiterLimit=4;                         ILineProperties pLinePro ;                                 pLinePro = pCartoLineSyl as ILineProperties;//取地址                        ISimpleLineDecorationElement pSimpleLineDecoEle;                                 pSimpleLineDecoEle = new SimpleLineDecorationElementClass();                                 pSimpleLineDecoEle.FlipAll = true;                                 pSimpleLineDecoEle.FlipFirst = true;                         ILineDecoration pLineDeco;                                 pLineDeco = new LineDecorationClass();                                 pLineDeco.AddElement(pSimpleLineDecoEle);                                         pLinePro.LineDecoration = pLineDeco;                                         pLinePro.DecorationOnTop=true;                         IGeometry pGeo;                                 pGeo = axMapControl2.TrackLine();                         object oLineSymbol = pCartoLineSyl;                         axMapControl2.DrawShape(pGeo, ref oLineSymbol); }//画线3 private void axMapControl2_OnMouseDown(object sender, AxESRI.ArcGIS.MapControl.IMapControlEvents2_OnMouseDownEvent e)                 {         //                        ISimpleLineSymbol pLineSyl; //                                pLineSyl = new SimpleLineSymbolClass(); //                                pLineSyl.Color = getRGB(30, 60, 90); //                                pLineSyl.Width = 4; //                                pLineSyl.Style = esriSimpleLineStyle.esriSLSDashDot;                         ICartographicLineSymbol pCartoLineSyl;                                 pCartoLineSyl = new CartographicLineSymbolClass();                                 //pCartoLineSyl.Color = getRGB(255, 110, 210);                                 pCartoLineSyl.Cap = esriLineCapStyle.esriLCSButt;                                 pCartoLineSyl.Join = esriLineJoinStyle.esriLJSBevel;                                 pCartoLineSyl.Width=10;                                 pCartoLineSyl.MiterLimit=4;                         ILineProperties pLinePro ;                                 pLinePro = pCartoLineSyl as ILineProperties;//取地址                        ISimpleLineDecorationElement pSimpleLineDecoEle;                                 pSimpleLineDecoEle = new SimpleLineDecorationElementClass();                                 pSimpleLineDecoEle.FlipAll = true;                                 pSimpleLineDecoEle.FlipFirst = true;                         ILineDecoration pLineDeco;                                 pLineDeco = new LineDecorationClass();                                 pLineDeco.AddElement(pSimpleLineDecoEle);                                         pLinePro.LineDecoration = pLineDeco;                                         pLinePro.DecorationOnTop=true;                         ILineFillSymbol pLineFillSymbol =new LineFillSymbolClass();                                 pLineFillSymbol.Offset=3;                                 pLineFillSymbol.Angle=45;                                 pLineFillSymbol.Offset=10;                         IFillSymbol pFillSymbol =pLineFillSymbol as IFillSymbol;                                 pFillSymbol.Color=getRGB(0,0,200);                                 pFillSymbol.Outline=pCartoLineSyl;                         ICharacterMarkerSymbol pCharacterMarkerSymbol;                                 pCharacterMarkerSymbol = new CharacterMarkerSymbolClass();                                 //设置它的字符,114为‘r’                                pCharacterMarkerSymbol.CharacterIndex = 114;                         IMarkerFillSymbol pMarkerFillSymbol =new MarkerFillSymbolClass();                                 pMarkerFillSymbol.Outline=pCartoLineSyl;                                 pMarkerFillSymbol.Style=esriMarkerFillStyle.esriMFSRandom;                                 pMarkerFillSymbol.MarkerSymbol=pCharacterMarkerSymbol;                                 pMarkerFillSymbol.GridAngle=45;                                 pMarkerFillSymbol.Color=getRGB(0,255,255);                         IGeometry pGeo;                         pGeo = axMapControl2.TrackLine();                         object oLineSymbol = pCartoLineSyl;                                                  axMapControl2.DrawShape(pGeo, ref oLineSymbol);                                                   }//画面public void OnMouseDown(int Button, int Shift, int X, int Y) {   IMxDocument mxDoc = m_App.Document as IMxDocument;   IActiveView activeView = mxDoc.FocusMap as IActiveView;   IScreenDisplay screenDisplay = activeView.ScreenDisplay;   ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass();   IRgbColor rgbColor = new RgbColorClass();   rgbColor.Red = 255;   fillSymbol.Color = rgbColor;   IRubberBand rubberPolygon = new RubberPolygonClass();   IPolygon newPolygon = (IPolygon)rubberPolygon.TrackNew(screenDisplay, (ISymbol)fillSymbol);   screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);   screenDisplay.SetSymbol((ISymbol)fillSymbol);   screenDisplay.DrawPolygon(newPolygon);   screenDisplay.FinishDrawing(); }//画矩形public void OnMouseDown(int Button, int Shift, int X, int Y) {   IMxDocument mxDoc = m_App.Document as IMxDocument;   IActiveView activeView = mxDoc.FocusMap as IActiveView;   IScreenDisplay screenDisplay = activeView.ScreenDisplay;   ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass();   IRgbColor rgbColor = new RgbColorClass();   rgbColor.Red = 255;   fillSymbol.Color = rgbColor;   IRubberBand rubberEnv = new RubberEnvelopeClass();   IEnvelope newEnvelope = (IEnvelope)rubberEnv.TrackNew(screenDisplay, (ISymbol)fillSymbol);   screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);   screenDisplay.SetSymbol((ISymbol)fillSymbol);   screenDisplay.DrawRectangle(newEnvelope);   screenDisplay.FinishDrawing(); }

1 0