添加线标注ILineElement
1 private void AddLineElement(IPolyline polyline) 2 { 3 try 4 { 5 IPolyline pPolyline = polyline; 6 IRgbColor pLineRgbColor = null; 7 ISimpleLineSymbol pSimpleLineSymbol = null; 8 ILineElement pFillShapeElement = null; 9 IElement pElement; 10 if (pPolyline != null) 11 { 12 pLineRgbColor = new RgbColorClass(); 13 pLineRgbColor.Red = 255; 14 15 pSimpleLineSymbol = new SimpleLineSymbolClass(); 16 pSimpleLineSymbol.Color = pLineRgbColor; 17 double with = 72 / this.axMapControl1.MapScale; 18 if (with >= 0.002) 19 with = 0.002; 20 pSimpleLineSymbol.Width = with; 21 22 23 pFillShapeElement = new LineElementClass(); 24 pFillShapeElement.Symbol = pSimpleLineSymbol; 25 pElement = pFillShapeElement as IElement; 26 pPolyline.SpatialReference = this.axMapControl1.SpatialReference; 27 pElement.Geometry = pPolyline as IGeometry; 28 29 this.axMapControl1.ActiveView.GraphicsContainer.AddElement(pElement, 0); 30 this.axMapControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, this.axMapControl1.ActiveView.Extent); 31 32 } 33 } 34 catch (Exception ee) 35 { 36 System.Windows.Forms.MessageBox.Show(ee.Message, "添加线标注"); 37 } 38 }