ArcEngine CSharp绘制图形经典代码

//画点
 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();
 }

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值