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.创建线符号
/// <summary>
/// 创建 线 符号
/// </summary>
/// <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);