Beispiel #1
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 #2
0
        /// <summary>
        /// 获取简单的线符号SimpleLineSymbol
        /// </summary>
        /// <param name="color">线条的颜色</param>
        /// <param name="lineWidth">线条的宽度</param>
        /// <param name="style">线条样式,默认为实线</param>
        /// <returns></returns>
        public static ISimpleLineSymbol GetSimpleLineSymbol(IColor color, double lineWidth = 1,
                                                            esriSimpleLineStyle style      = esriSimpleLineStyle.esriSLSSolid)
        {
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();

            simpleLineSymbol.Color = color ?? ColorCreate.GetIColor(128, 138, 135);
            simpleLineSymbol.Width = lineWidth;                        //设置线宽
            simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; //设置线型
            return(simpleLineSymbol);
        }
Beispiel #3
0
        /// <summary>
        /// 获取文本符号ITextSymbol
        /// </summary>
        /// <param name="colorRrggbbtt">文本颜色,6位颜色值RRGGBB,如"ff0000"为红色;
        /// 或8位颜色值RRGGBBTT,如"ff0000ff"为红色不透明(最后两位00表示透明,ff表示不透明)</param>
        /// <param name="fontName"></param>
        /// <param name="fontSize"></param>
        /// <returns></returns>
        public static ITextSymbol GetTextSymbol(string colorRrggbbtt, string fontName, double fontSize)
        {
            ITextSymbol textSymbol = new TextSymbolClass();

            textSymbol.Font = new StdFontClass {
                Name = fontName
            } as IFontDisp;
            textSymbol.Size  = fontSize;
            textSymbol.Color = ColorCreate.GetIColor(colorRrggbbtt);
            return(textSymbol);
        }
Beispiel #4
0
        /// <summary>
        /// BarChartRenderer柱状图渲染:根据一个或多个数字字段的值配置柱状图渲染图层
        /// </summary>
        /// <param name="geoFeatureLayer"></param>
        /// <param name="fieldNameColorDict"></param>
        public static void SetBarCharRenderer(this IGeoFeatureLayer geoFeatureLayer, Dictionary <string, IColor> fieldNameColorDict)
        {
            //创建柱状符号
            IBarChartSymbol barChartSymbol = new BarChartSymbolClass {
                Width = 12
            };

            //获取两个字段的最大值,设置柱状图各柱状符号
            double       maxValue    = 0;
            ISymbolArray symbolArray = (ISymbolArray)barChartSymbol;

            foreach (var pair in fieldNameColorDict)
            {
                var value = geoFeatureLayer.FeatureClass.Statistics(pair.Key, null, EStatisticsType.Maximum);
                if (value > maxValue)
                {
                    maxValue = value;
                }

                IFillSymbol fillSymbol = new SimpleFillSymbol {
                    Color = pair.Value
                };
                symbolArray.AddSymbol((ISymbol)fillSymbol);
            }

            //设置ChartSymbol的最大值,以及符号尺寸最大值(像素单位)
            IChartSymbol  chartSymbol  = (IChartSymbol)barChartSymbol;
            IMarkerSymbol markerSymbol = (IMarkerSymbol)barChartSymbol;

            chartSymbol.MaxValue = maxValue;
            markerSymbol.Size    = 60;

            //设置字段,依据字段的数据值,创建柱状图
            IChartRenderer  chartRenderer  = new ChartRendererClass();
            IRendererFields rendererFields = (IRendererFields)chartRenderer;

            foreach (var pair in fieldNameColorDict)
            {
                rendererFields.AddField(pair.Key, pair.Key);
            }

            //设置图层的背景颜色
            chartRenderer.ChartSymbol = (IChartSymbol)barChartSymbol;
            chartRenderer.BaseSymbol  = new SimpleFillSymbolClass {
                Color = ColorCreate.GetIColor(239, 228, 190)
            };

            //设置其他属性
            chartRenderer.UseOverposter = false;
            chartRenderer.CreateLegend();//创建符号图例
            chartRenderer.Label = "";

            geoFeatureLayer.Renderer = chartRenderer as IFeatureRenderer;
        }
Beispiel #5
0
        /// <summary>
        /// 获取简单点符号SimpleMarkerSymbol
        /// </summary>
        /// <param name="color">点内部颜色</param>
        /// <param name="outlineColor">点符号的边线</param>
        /// <param name="pointSize">点样式的大小</param>
        /// <param name="markerStyle">设置符号样式:默认为菱形形状</param>
        /// <returns></returns>
        public static ISimpleMarkerSymbol GetSimpleMarkerSymbol(IColor color, IColor outlineColor = null,
                                                                double pointSize = 6, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSDiamond)
        {
            ISimpleMarkerSymbol markerSymbol = new SimpleMarkerSymbolClass();

            markerSymbol.Style        = markerStyle;
            markerSymbol.Color        = color;
            markerSymbol.Size         = pointSize;
            markerSymbol.Outline      = true;
            markerSymbol.OutlineColor = outlineColor ?? ColorCreate.GetIColor(128, 138, 135);
            markerSymbol.OutlineSize  = 1;
            return(markerSymbol);
        }
Beispiel #6
0
 /// <summary>
 /// 获取简单的线符号SimpleLineSymbol
 /// </summary>
 /// <param name="rrggbbtt">线条的颜色字符串RRGGBB,如"ff0000"为红色</param>
 /// <param name="lineWidth">线条的宽度</param>
 /// <param name="style">线条样式,默认为实线</param>
 /// <returns></returns>
 public static ISimpleLineSymbol GetSimpleLineSymbol(string rrggbbtt, double lineWidth = 1,
                                                     esriSimpleLineStyle style         = esriSimpleLineStyle.esriSLSSolid)
 {
     return(GetSimpleLineSymbol(ColorCreate.GetIColor(rrggbbtt), lineWidth, style));
 }
Beispiel #7
0
 /// <summary>
 /// 获取简单点符号SimpleMarkerSymbol
 /// </summary>
 /// <param name="rrggbbtt">点符号的颜色,6位颜色值RRGGBB,如"ff0000"为红色;
 /// 或8位颜色值RRGGBBTT,如"ff0000ff"为红色不透明(最后两位00表示透明,ff表示不透明)</param>
 /// <param name="outlineColorRrggbbtt">点符号的边线颜色,6位颜色值RRGGBB,如"ff0000"为红色;
 /// 或8位颜色值RRGGBBTT,如"ff0000ff"为红色不透明(最后两位00表示透明,ff表示不透明)</param>
 /// <param name="pointSize">点的大小</param>
 /// <param name="markerStyle">设置符号样式:默认为菱形形状</param>
 /// <returns></returns>
 public static ISimpleMarkerSymbol GetSimpleMarkerSymbol(string rrggbbtt, string outlineColorRrggbbtt = null,
                                                         double pointSize = 6, esriSimpleMarkerStyle markerStyle = esriSimpleMarkerStyle.esriSMSDiamond)
 {
     return(GetSimpleMarkerSymbol(ColorCreate.GetIColor(rrggbbtt), ColorCreate.GetIColor(outlineColorRrggbbtt), pointSize, markerStyle));
 }
Beispiel #8
0
 /// <summary>
 /// 获取简单的填充符号ISimpleFillSymbol
 /// </summary>
 /// <param name="fillColorRrggbbtt">填充色,6位颜色值RRGGBB,如"ff0000"为红色;
 /// 或8位颜色值RRGGBBTT,如"ff0000ff"为红色不透明(最后两位00表示透明,ff表示不透明)</param>
 /// <param name="lineColorRrggbbtt">边线色,6位颜色值RRGGBB,如"ff0000"为红色;
 /// 或8位颜色值RRGGBBTT,如"ff0000ff"为红色不透明(最后两位00表示透明,ff表示不透明)</param>
 /// <param name="lineWidth">边线的宽度</param>
 /// <returns></returns>
 public static ISimpleFillSymbol GetSimpleFillSymbol(string fillColorRrggbbtt, string lineColorRrggbbtt, double lineWidth = 1, esriSimpleFillStyle style = esriSimpleFillStyle.esriSFSSolid)
 {
     return(GetSimpleFillSymbol(ColorCreate.GetIColor(fillColorRrggbbtt), ColorCreate.GetIColor(lineColorRrggbbtt), lineWidth, style));
 }
Beispiel #9
0
        /// <summary>
        ///  用指定填充颜色字符串RRGGBB渲染图层,使用默认的边线颜色(灰色),可设置透明度
        /// </summary>
        /// <param name="geoLayer">图层</param>
        /// <param name="mainColorStr">主颜色字符串RRGGBB,如"ff0000"为红色,主颜色即多边形图层的填充颜色,线图层的线条颜色,点图层的符号颜色</param>
        /// <param name="outlineColorStr">面或点的边线颜色,若为null,则设置边线颜色为RGB:128, 138, 135</param>
        /// <param name="transparency">图层的透明度,0为不透明,100为全透明</param>
        /// <param name="widthOrSize">面/线图层的线宽,或点图层点的大小</param>
        public static void SetSimpleRenderer(this IGeoFeatureLayer geoLayer, string mainColorStr, string outlineColorStr = null, short transparency = 0, double widthOrSize = 1)
        {
            IColor lineColor = outlineColorStr == null?ColorCreate.GetIColor(128, 138, 135) : ColorCreate.GetIColor(outlineColorStr);

            SetSimpleRenderer(geoLayer, ColorCreate.GetIColor(mainColorStr), lineColor, transparency, widthOrSize);
        }