1.根據2點建立一條線
/// <summary>
/// 建立線
/// </summary>
/// <param name="pnt1">The PNT1.</param>
/// <param name="pnt2">The PNT2.</param>
public static void CreateLine( IPoint pnt1, IPoint pnt2)
{
IPolyline pline = new PolylineClass();
pline.FromPoint = pnt1;
pline.ToPoint = pnt2;
}
2.建立線符号
/// 建立 線 符号
/// <param name="r">The r.</param>
/// <param name="g">The g.</param>
/// <param name="b">The b.</param>
/// <returns>ILineSymbol</returns>
/// <remarks></remarks>
private static ILineSymbol CreateLineSymbol(int r, int g, int b)
ILineSymbol psymbol = new SimpleLineSymbolClass() as ILineSymbol;
psymbol.Color = ColorCustom(r, g, b);
psymbol.Width = 1;
return psymbol;
3.建立線注記
IElement pele = new LineElementClass();
pele.Geometry = pPolyline as IGeometry;
(pele as ILineElement).Symbol = CreateLineSymbol(r, g, b);
(pmap as IGraphicsContainer).AddElement(pele, 0);