创建面注记PolygonElement

1.根据4点创建一个面

        /// <summary>

        /// 根据4个点创建图形,点序要顺时针

        /// </summary>

        /// <param name="pnt1">点1</param>

        /// <param name="pnt2">点2</param>

        /// <param name="pnt3">点3</param>

        /// <param name="pnt4">点4</param>

        /// <returns>IPolygon</returns>

        public static IPolygon CreatePolygonBy4Points(IPoint pnt1, IPoint pnt2, IPoint pnt3, IPoint pnt4)

        {

            IPointCollection pPntCol = new PolygonClass();

            object missing = Type.Missing; ////顺时针添加 

            pPntCol.AddPoint(pnt1, ref missing, ref missing);

            pPntCol.AddPoint(pnt2, ref missing, ref missing);

            pPntCol.AddPoint(pnt3, ref missing, ref missing);

            pPntCol.AddPoint(pnt4, ref missing, ref missing);

            pPntCol.AddPoint(pnt1, ref missing, ref missing); //// 为保持首尾相联,故将第一个点再添加一次

            return pPntCol as IPolygon;

        }

2.创建面符号

        /// <summary>

        /// 创建 面 符号

        /// </summary>

        /// <param name="r">The r.</param>

        /// <param name="g">The g.</param>

        /// <param name="b">The b.</param>

        /// <returns>ISimpleFillSymbol</returns>

        public static ISimpleFillSymbol CreateGeoSymbol(int r, int g, int b)

        {

            ISimpleFillSymbol psymbol = new SimpleFillSymbolClass() as ISimpleFillSymbol;

            psymbol.Color = ColorCustom(r, g, b);

            psymbol.Outline.Color = ColorCustom(r, g, b);

            return psymbol;

        } 

3.创建PolygonElement

                                IElement pele = new PolygonElementClass();

                                pele.Geometry = pGeoCol as IGeometry;

                                (pele as IFillShapeElement).Symbol = CreateGeoSymbol(r, gD, b);

                                (pmap as IGraphicsContainer).AddElement(pele, 0);

原文地址:https://www.cnblogs.com/jhlong/p/5394325.html