Beispiel #1
0
        /// <summary>
        /// 用指定填充颜色和边线颜色渲染图层
        /// </summary>
        /// <param name="geoLayer">图层</param>
        /// <param name="mainColor">主颜色,即面图层的填充颜色,线图层的线条颜色,点图层的符号内部颜色</param>
        /// <param name="outlineColor">面或点的边线颜色,若为null,则设置边线颜色为RGB:128, 138, 135</param>
        /// <param name="transparency">图层的透明度,0为不透明,100为全透明</param>
        /// <param name="widthOrSize">面/线图层的线宽,或点图层点的大小</param>
        public static void SetSimpleRenderer(this IGeoFeatureLayer geoLayer, IColor mainColor, IColor outlineColor = null, short transparency = 0, double widthOrSize = 1)
        {
            ISymbol symbol = null;

            switch (geoLayer.FeatureClass.ShapeType)
            {
            case esriGeometryType.esriGeometryPolygon:
                symbol = (ISymbol)SymbolCreate.GetSimpleFillSymbol(mainColor, outlineColor, widthOrSize);
                break;

            case esriGeometryType.esriGeometryPoint:
            case esriGeometryType.esriGeometryMultipoint:
                symbol = (ISymbol)SymbolCreate.GetSimpleMarkerSymbol(mainColor, outlineColor, widthOrSize);
                break;

            case esriGeometryType.esriGeometryLine:
            case esriGeometryType.esriGeometryPolyline:
                symbol = (ISymbol)SymbolCreate.GetSimpleLineSymbol(mainColor, widthOrSize);
                break;
            }
            geoLayer.Renderer = new SimpleRendererClass {
                Symbol = symbol
            };

            ILayerEffects layerEffects = (ILayerEffects)geoLayer;

            layerEffects.Transparency = transparency;
        }
Beispiel #2
0
        /// <summary>
        /// ClassBreakRender分级渲染:根据数字字段的值分组渲染图层
        /// </summary>
        /// <param name="geoFeatureLayer">操作图层</param>
        /// <param name="fieldName">操作字段名</param>
        /// <param name="breakCount">分级数量</param>
        /// <param name="outLineColor">分组符号的外框颜色</param>
        public static void SetClassBreakRenderer(this IGeoFeatureLayer geoFeatureLayer, string fieldName, int breakCount, IColor outLineColor)
        {
            //获取该字段的最大值、最小值
            var    statisticsResults = geoFeatureLayer.FeatureClass.Statistics(fieldName, null);
            double max = statisticsResults.Maximum;
            double min = statisticsResults.Minimum;

            //设置分级数,字段
            IClassBreaksRenderer cbRender = new ClassBreaksRendererClass();

            cbRender.MinimumBreak = min;        //最小值
            cbRender.Field        = fieldName;  //分级字段
            cbRender.BreakCount   = breakCount; //分级数量

            //设置每一级的分段范围,符号
            var lineSymbol = SymbolCreate.GetSimpleLineSymbol(outLineColor);//新建边线符号

            for (int i = 0; i < breakCount; i++)
            {
                var color = ColorCreate.GetIColor(0, 250 / breakCount * (breakCount - i), 0);
                cbRender.set_Break(i, (max - min) * (i + 1) / breakCount + min);
                cbRender.set_Symbol(i, new SimpleFillSymbolClass {
                    Outline = lineSymbol, Color = color
                });
            }
            geoFeatureLayer.Renderer = (IFeatureRenderer)cbRender;
        }
Beispiel #3
0
        /// <summary>
        /// 获取默认符号
        /// </summary>
        /// <param name="geometryType"></param>
        /// <param name="color"></param>
        /// <returns></returns>
        private static ISymbol GetDefaultSymbol(esriGeometryType geometryType, IColor color)
        {
            switch (geometryType)
            {
            case esriGeometryType.esriGeometryLine:
            case esriGeometryType.esriGeometryPolyline:
                return(SymbolCreate.GetSimpleLineSymbol(color, 3) as ISymbol);

            case esriGeometryType.esriGeometryPoint:
                return(SymbolCreate.GetSimpleMarkerSymbol(color, null, 6, esriSimpleMarkerStyle.esriSMSCircle) as ISymbol);

            case esriGeometryType.esriGeometryPolygon:
                return(SymbolCreate.GetSimpleFillSymbol(color) as ISymbol);
            }
            return(null);
        }