Example #1
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add DotDensityRender.OnClick implementation
            string              strPopField         = "value";
            IActiveView         pActiveView         = m_HookHelper.ActiveView;
            IMap                pMap                = m_HookHelper.FocusMap;
            IGeoFeatureLayer    pGeoFeatureLayer    = pMap.get_Layer(0) as IGeoFeatureLayer;
            IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass();
            IRendererFields     pRendererFields     = (IRendererFields)pDotDensityRenderer;

            pRendererFields.AddField(strPopField, strPopField);
            IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass();

            pDotDensityFillSymbol.DotSize         = 5;
            pDotDensityFillSymbol.Color           = GetRGB(0, 0, 0);
            pDotDensityFillSymbol.BackgroundColor = GetRGB(239, 228, 190);
            ISymbolArray        pSymbolArray        = (ISymbolArray)pDotDensityFillSymbol;
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();

            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSimpleMarkerSymbol.Size  = 5;
            pSimpleMarkerSymbol.Color = GetRGB(128, 128, 255);
            pSymbolArray.AddSymbol((ISymbol)pSimpleMarkerSymbol);
            pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol;
            pDotDensityRenderer.DotValue         = 0.5;
            pDotDensityRenderer.CreateLegend();
            pGeoFeatureLayer.Renderer = (IFeatureRenderer)pDotDensityRenderer;
            pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Example #2
0
        private IDotDensityRenderer CreateRenderer()
        {
            IDotDensityRenderer   pDotDensityRenderer = new DotDensityRendererClass();
            IRendererFields       pRendererFields     = (IRendererFields)pDotDensityRenderer;
            IDotDensityFillSymbol pDotDensityFillS    = new DotDensityFillSymbolClass();

            //pDotDensityFillS.DotSize = 2 * dotSize;
            //pDotDensityFillS.Color = getRGB(0, 0, 0);
            if (gColor != null)
            {
                pDotDensityFillS.BackgroundColor = gColor;
            }
            ISymbolArray pSymbolArray = (ISymbolArray)pDotDensityFillS;
            string       strField     = string.Empty;

            foreach (System.Collections.DictionaryEntry de in fieldSymbolHashTable)
            {
                strField = de.Key.ToString();;
                ISymbol symbol = de.Value as ISymbol;
                pRendererFields.AddField(strField, strField);
                IMarkerSymbol pMarkerSymbol = symbol as IMarkerSymbol;
                pMarkerSymbol.Size = dotSize;
                pSymbolArray.AddSymbol(symbol);
            }
            pDotDensityRenderer.DotDensitySymbol = pDotDensityFillS;
            pDotDensityRenderer.DotValue         = dotValue;
            pDotDensityRenderer.CreateLegend();

            return(pDotDensityRenderer);
        }
Example #3
0
        //DotDensityFillSymbol
        private void button8_Click(object sender, EventArgs e)
        {
            IGeoFeatureLayer      geoFeatureLayer;
            IDotDensityFillSymbol dotDensityFillSymbol;
            IDotDensityRenderer   dotDensityRenderer;

            //获取渲染图层
            geoFeatureLayer    = getGeoLayer("Continents");
            dotDensityRenderer = new DotDensityRendererClass();
            IRendererFields rendererFields = dotDensityRenderer as IRendererFields;
            //设置渲染字段
            string field1 = "sqmi";

            rendererFields.AddField(field1, field1);
            //设置填充颜色和背景色
            dotDensityFillSymbol                 = new DotDensityFillSymbolClass();
            dotDensityFillSymbol.DotSize         = 3;
            dotDensityFillSymbol.Color           = getRGB(255, 0, 0);
            dotDensityFillSymbol.BackgroundColor = getRGB(0, 255, 0);
            //设置渲染符号
            ISymbolArray        symbolArray        = dotDensityFillSymbol as ISymbolArray;
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();

            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            simpleMarkerSymbol.Size  = 2;
            simpleMarkerSymbol.Color = getRGB(0, 0, 255);
            symbolArray.AddSymbol(simpleMarkerSymbol as ISymbol);
            dotDensityRenderer.DotDensitySymbol = dotDensityFillSymbol;
            //设置渲染密度
            dotDensityRenderer.DotValue = 50000;
            //创建图例
            dotDensityRenderer.CreateLegend();
            geoFeatureLayer.Renderer = dotDensityRenderer as IFeatureRenderer;
            this.axMapControl1.Refresh();
        }
Example #4
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         ISymbolArray chartSymbol = this.ichartRenderer_0.ChartSymbol as ISymbolArray;
         string[]     strArray    = new string[2];
         for (int i = this.FieldsListBoxCtrl.SelectedIndices.Count - 1; i >= 0; i--)
         {
             int       index = this.FieldsListBoxCtrl.SelectedIndices[i];
             FieldWrap wrap  = this.FieldsListBoxCtrl.Items[index] as FieldWrap;
             (this.ichartRenderer_0 as IRendererFields).AddField(wrap.Name, wrap.ToString());
             IColor color = this.ienumColors_0.Next();
             if (color == null)
             {
                 this.ienumColors_0.Reset();
                 color = this.ienumColors_0.Next();
             }
             ISymbol symbol = this.method_5(color);
             strArray[0] = "";
             strArray[1] = wrap.ToString();
             ListViewItemEx ex = new ListViewItemEx(strArray)
             {
                 Style = symbol,
                 Tag   = wrap
             };
             this.SelectFieldslistView.Add(ex);
             chartSymbol.AddSymbol(symbol);
             this.FieldsListBoxCtrl.Items.RemoveAt(index);
         }
     }
     catch
     {
     }
     this.btnUnSelectAll.Enabled = true;
 }
 /// <summary>
 ///  Creates an accessor.
 /// </summary>
 /// <param name="indexer"> indexer Indexer used to index symbols in the symbol array.</param>
 /// <param name="length">  length Length of a section of the symbol array.</param>
 /// <param name="symbols"> symbols Symbol array.</param>
 public AccessorBase
     (IIndexer indexer, int length, ISymbolArray symbols)
 {
     Indexer = indexer;
     Length = length;
     this.symbols = symbols;
 }
Example #6
0
        private void DotDensity(IFeatureLayer pFeatLyr, string sFieldName, int intRendererDensity)
        {
            IGeoFeatureLayer    pGeoFeatureLayer    = pFeatLyr as IGeoFeatureLayer;
            IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass();
            IRendererFields     pRendererFields     = pDotDensityRenderer as IRendererFields;

            //设置渲染字段
            pRendererFields.AddField(sFieldName);
            //设置填充背景色
            IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass();

            pDotDensityFillSymbol.DotSize         = 3;
            pDotDensityFillSymbol.BackgroundColor = GetRgbColor(0, 255, 0);
            //设置渲染符号
            ISymbolArray        pSymbolArray        = pDotDensityFillSymbol as ISymbolArray;
            ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass();

            pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSimpleMarkerSymbol.Color = GetRgbColor(0, 0, 255);
            pSymbolArray.AddSymbol(pSimpleMarkerSymbol as ISymbol);
            pDotDensityRenderer.DotDensitySymbol = pDotDensityFillSymbol;
            //设置渲染密度,即每个点符号所代表的数值大小
            pDotDensityRenderer.DotValue = intRendererDensity;
            //创建图例
            pDotDensityRenderer.CreateLegend();
            pGeoFeatureLayer.Renderer = pDotDensityRenderer as IFeatureRenderer;
            axMapControl1.Refresh();
            axMapControl1.Update();
            Close();
        }
Example #7
0
        /// <summary>
        /// Dot Density Render
        /// </summary>
        /// <param name="currentLayer"></param>
        /// <param name="breakCount"></param>
        /// <author>Shen Yongyuan</author>
        /// <date>20091114</date>
        public static void DotDensityRender(ILayer currentLayer, string fieldName)
        {
            IGeoFeatureLayer pGeoFeatureL = currentLayer as IGeoFeatureLayer;

            pGeoFeatureL.ScaleSymbols = true;

            //Dot Density Render
            IDotDensityRenderer pDotDensityRenderer = new DotDensityRendererClass();
            IRendererFields     pRendererFields     = (IRendererFields)pDotDensityRenderer;

            pRendererFields.AddField(fieldName, "生态");

            //Dot Style
            IDotDensityFillSymbol pDotDensityFillS = new DotDensityFillSymbolClass();

            pDotDensityFillS.DotSize         = 4;
            pDotDensityFillS.Color           = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(0, 0, 0));
            pDotDensityFillS.BackgroundColor = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(239, 228, 190));

            //Symbol Array
            ISymbolArray        pSymbolArray   = (ISymbolArray)pDotDensityFillS;
            ISimpleMarkerSymbol pSimpleMarkerS = new SimpleMarkerSymbolClass();

            pSimpleMarkerS.Style = esriSimpleMarkerStyle.esriSMSCircle;
            pSimpleMarkerS.Size  = 4;
            pSimpleMarkerS.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(128, 128, 255));
            pSymbolArray.AddSymbol((ISymbol)pSimpleMarkerS);

            pDotDensityRenderer.DotDensitySymbol = pDotDensityFillS;
            pDotDensityRenderer.DotValue         = 0.05;
            pDotDensityRenderer.CreateLegend();
            pGeoFeatureL.Renderer = (IFeatureRenderer)pDotDensityRenderer;
        }
Example #8
0
        private void btnMoveDown_Click(object sender, EventArgs e)
        {
            int            index = this.SelectFieldslistView.SelectedIndices[0];
            ListViewItemEx ex    = this.SelectFieldslistView.Items[index] as ListViewItemEx;

            this.SelectFieldslistView.Items.RemoveAt(index);
            if ((index + 1) == this.SelectFieldslistView.Items.Count)
            {
                this.SelectFieldslistView.Items.Add(ex);
            }
            else
            {
                this.SelectFieldslistView.Items.Insert(index + 1, ex);
            }
            ISymbolArray dotDensitySymbol = this.idotDensityRenderer_0.DotDensitySymbol as ISymbolArray;

            dotDensitySymbol.MoveSymbol(dotDensitySymbol.get_Symbol(index), index + 1);
            IRendererFields fields = this.idotDensityRenderer_0 as IRendererFields;

            fields.ClearFields();
            for (int i = 0; i < this.SelectFieldslistView.Items.Count; i++)
            {
                ex = this.SelectFieldslistView.Items[i] as ListViewItemEx;
                FieldWrap tag = ex.Tag as FieldWrap;
                fields.AddField(tag.Name, tag.ToString());
            }
        }
Example #9
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;
        }
Example #10
0
        public ChartRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, string pFieldName)
        {
            IGeoFeatureLayer pGeoFeaturelayer = pFtLayer as IGeoFeatureLayer;

            IChartRenderer pChart = new ChartRendererClass();



            IDataStatistics pDataStat = new DataStatisticsClass();

            IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);

            pDataStat.Cursor = pFtCursor as ICursor;

            pDataStat.Field = pFieldName;

            double pMax = pDataStat.Statistics.Maximum;



            IRendererFields pRenderFields = pChart as IRendererFields;

            pRenderFields.AddField(pFieldName, pFieldName);

            IBarChartSymbol pBarChart = new BarChartSymbolClass();

            pBarChart.Width = 5;


            IMarkerSymbol pMarkerSymbol = pBarChart as IMarkerSymbol;


            pMarkerSymbol.Size = 12;


            IChartSymbol pChartSym = pBarChart as IChartSymbol;

            pChartSym.MaxValue = pMax;


            ISymbolArray pSymbolArr = pBarChart as ISymbolArray;


            IFillSymbol pFillSy = new SimpleFillSymbolClass();

            pFillSy.Color = GetRgb(220, 0, 0);

            pSymbolArr.AddSymbol(pFillSy as ISymbol);

            pGeoFeaturelayer.Renderer = pChart as IFeatureRenderer;


            pMapcontrol.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Example #11
0
        private void mnuDotDensity_Click(object sender, EventArgs e)
        {
            ILayer           pLayer           = MainMap.get_Layer(0);
            ITable           pTable           = pLayer as ITable;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

            IDotDensityRenderer pDotDensityRender = new DotDensityRendererClass();
            IRendererFields     pRendererFields   = pDotDensityRender as IRendererFields;

            pRendererFields.AddField("AREA");

            // 建立一个用于填充的点符号
            IDotDensityFillSymbol pDotDensityFillSymbol = new DotDensityFillSymbolClass();

            pDotDensityFillSymbol.DotSize = 3;

            IRgbColor pRgbColor = new RgbColorClass();

            pRgbColor.Red   = 0;
            pRgbColor.Green = 0;
            pRgbColor.Blue  = 0;

            IColor pColor = pRgbColor as IColor;

            pDotDensityFillSymbol.Color = pColor;

            pRgbColor       = new RgbColorClass();
            pRgbColor.Red   = 239;
            pRgbColor.Green = 228;
            pRgbColor.Blue  = 190;
            pColor          = pRgbColor as IColor;
            pDotDensityFillSymbol.BackgroundColor = pColor;

            ISymbolArray        pSymbolArray  = pDotDensityFillSymbol as ISymbolArray;
            ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass();

            pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSSquare;

            pRgbColor           = new RgbColorClass();
            pRgbColor.Red       = 0;
            pRgbColor.Green     = 0;
            pRgbColor.Blue      = 0;
            pColor              = pRgbColor as IColor;
            pMarkerSymbol.Color = pColor;
            pSymbolArray.AddSymbol(pMarkerSymbol as ISymbol);

            // 开始着色
            pDotDensityRender.DotDensitySymbol = pDotDensityFillSymbol;
            pDotDensityRender.DotValue         = 2;
            pGeoFeatureLayer.Renderer          = pDotDensityRender as IFeatureRenderer;
            MainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
        }
Example #12
0
        private void btnUnSelectAll_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < this.SelectFieldslistView.Items.Count; i++)
            {
                ListViewItemEx ex = this.SelectFieldslistView.Items[i] as ListViewItemEx;
                this.FieldsListBoxCtrl.Items.Add(ex.Tag);
            }
            this.SelectFieldslistView.Items.Clear();
            ISymbolArray dotDensitySymbol = this.idotDensityRenderer_0.DotDensitySymbol as ISymbolArray;

            (this.idotDensityRenderer_0 as IRendererFields).ClearFields();
            dotDensitySymbol.ClearSymbols();
        }
Example #13
0
        /// <summary>
        /// 点状密度法渲染器(DotDensityRenderer)——在多边形特征中绘制不同密度的点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 点状密度法渲染ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //声明IGeoFeatureLayer变量, 提供一个要素图层对成员控制地理特征的入口
            IGeoFeatureLayer geoFeatureLayer;
            //定义点密度填充符号变量, 控制点符号的属性
            IDotDensityFillSymbol dotDensityFillSymbol;
            //定义点密度渲染对象
            IDotDensityRenderer dotDensityRenderer;

            //获取渲染图层
            geoFeatureLayer = getGeoLayer("北部湾");
            //实例化点密度渲染对象
            dotDensityRenderer = new DotDensityRendererClass();
            //强转点密度渲染对象并强转成渲染字段对象
            IRendererFields rendererFields = dotDensityRenderer as IRendererFields;
            //设置渲染字段
            string field1 = "年";

            //向渲染器添加字段(字段名、别名)
            rendererFields.AddField(field1, field1);
            //实例化点密度填充符号
            dotDensityFillSymbol         = new DotDensityFillSymbolClass();
            dotDensityFillSymbol.DotSize = 4;                 //设置点的大小
            dotDensityFillSymbol.Color   = getRGB(0, 255, 0); //设置点的颜色

            //将点密度填充符号强转为符号数组成员
            ISymbolArray symbolArray = dotDensityFillSymbol as ISymbolArray;
            //实例化简单标记符号
            ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass();

            //设置点的符号为圆圈
            simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;
            simpleMarkerSymbol.Size  = 4;                 //设置大小
            simpleMarkerSymbol.Color = getRGB(0, 255, 0); //设置颜色
            //点符号的外边不填充颜色
            simpleMarkerSymbol.OutlineColor = getNoRGB();
            //将简单标记符号样式增加到符号数组成员中
            symbolArray.AddSymbol(simpleMarkerSymbol as ISymbol);
            //赋值点密度渲染(dotDensityRenderer)的点密度符号(DotDensitySymbol)属性
            dotDensityRenderer.DotDensitySymbol = dotDensityFillSymbol;
            //设置渲染密度
            dotDensityRenderer.DotValue = 0.003;
            //设置点密度填充符号的背景色
            dotDensityFillSymbol.BackgroundColor = getRGB(255, 255, 255);
            //创建图例
            dotDensityRenderer.CreateLegend();
            //赋值目标图层的渲染器属性
            geoFeatureLayer.Renderer = dotDensityRenderer as IFeatureRenderer;
            axMapControl1.Refresh(); //刷新axMapControl1
            axTOCControl1.Update();  //更新axTOCControl1
        }
Example #14
0
        private void btnUnSelect_Click(object sender, EventArgs e)
        {
            int          index = this.SelectFieldslistView.SelectedIndices[0];
            ListViewItem item  = this.SelectFieldslistView.SelectedItems[0];

            this.FieldsListBoxCtrl.Items.Add(item.Tag);
            ISymbolArray dotDensitySymbol = this.idotDensityRenderer_0.DotDensitySymbol as ISymbolArray;

            dotDensitySymbol.DeleteSymbol(dotDensitySymbol.get_Symbol(index));
            (this.idotDensityRenderer_0 as IRendererFields).DeleteField(item.Text);
            this.SelectFieldslistView.Items.RemoveAt(index);
            if (this.SelectFieldslistView.Items.Count == 0)
            {
                this.btnUnSelectAll.Enabled = false;
            }
        }
Example #15
0
 private void colorRampComboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.bool_0)
     {
         IFields fields = this.igeoFeatureLayer_0.FeatureClass.Fields;
         this.ienumColors_0 = this.method_1(this.colorRampComboBox1.GetSelectColorRamp(), fields.FieldCount);
         this.ienumColors_0.Reset();
         this.ichartRenderer_0.ColorScheme = this.colorRampComboBox1.Text;
         ISymbolArray chartSymbol = this.ichartRenderer_0.ChartSymbol as ISymbolArray;
         for (int i = 0; i < chartSymbol.SymbolCount; i++)
         {
             IFillSymbol symbol = chartSymbol.get_Symbol(i) as IFillSymbol;
             symbol.Color = this.ienumColors_0.Next();
         }
         this.SelectFieldslistView.Invalidate();
     }
 }
        private IChartRenderer CreateRenderer(IFeatureClass featureClass)
        {
            if (chartSymbol == null)
            {
                return(null);
            }

            double dmaxValue = 0.0;

            dmaxValue            = FindMaxValueInRendererFields(featureClass);
            chartSymbol.MaxValue = dmaxValue;

            IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)chartSymbol;

            pMarkerSymbol.Size = symbolSize;
            //Now set up symbols for each bar
            ISymbolArray pSymbolArray = (ISymbolArray)chartSymbol;

            pSymbolArray.ClearSymbols();
            IChartRenderer  pChartRenderer  = new ChartRendererClass();
            IRendererFields pRendererFields = (IRendererFields)pChartRenderer;

            foreach (System.Collections.DictionaryEntry de in fieldSymbolHashTable)
            {
                string  strField = de.Key.ToString();;
                ISymbol symbol   = de.Value as ISymbol;
                pRendererFields.AddField(strField, strField);
                pSymbolArray.AddSymbol(symbol);
            }

            pChartRenderer.ChartSymbol   = chartSymbol;
            pChartRenderer.Label         = "统计符号化";
            pChartRenderer.UseOverposter = false;

            if (gBaseSymbol != nudDotSize)
            {
                pChartRenderer.BaseSymbol = gBaseSymbol;
            }
            pChartRenderer.CreateLegend();

            return(pChartRenderer);
        }
Example #17
0
        private void btnMoveUp_Click(object sender, EventArgs e)
        {
            int            index = this.SelectFieldslistView.SelectedIndices[0];
            ListViewItemEx item  = this.SelectFieldslistView.Items[index] as ListViewItemEx;

            this.SelectFieldslistView.Items.RemoveAt(index);
            this.SelectFieldslistView.Items.Insert(index - 1, item);
            ISymbolArray chartSymbol = this.ichartRenderer_0.ChartSymbol as ISymbolArray;

            chartSymbol.MoveSymbol(chartSymbol.get_Symbol(index), index - 1);
            IRendererFields fields = this.ichartRenderer_0 as IRendererFields;

            fields.ClearFields();
            for (int i = 0; i < this.SelectFieldslistView.Items.Count; i++)
            {
                item = this.SelectFieldslistView.Items[i] as ListViewItemEx;
                FieldWrap tag = item.Tag as FieldWrap;
                fields.AddField(tag.Name, tag.ToString());
            }
        }
Example #18
0
 private void btnUnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         int          index = this.SelectFieldslistView.SelectedIndices[0];
         ListViewItem item  = this.SelectFieldslistView.SelectedItems[0];
         this.FieldsListBoxCtrl.Items.Add(item.Tag);
         (this.ichartRenderer_0 as IRendererFields).DeleteField(item.SubItems[1].Text);
         ISymbolArray chartSymbol = this.ichartRenderer_0.ChartSymbol as ISymbolArray;
         chartSymbol.DeleteSymbol(chartSymbol.get_Symbol(index));
         this.SelectFieldslistView.Items.RemoveAt(index);
         if (this.SelectFieldslistView.Items.Count == 0)
         {
             this.btnUnSelectAll.Enabled = false;
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.ToString());
     }
 }
Example #19
0
        //Draw Symbols by features
        public void Draw(IFeatureCursor pFCursor, esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel trackCancel)
        {
            pFCursor = m_pFeatureClass.Search(m_pQueryFilter, true);
            clsSnippet pSnippet = new clsSnippet();

            IFeature pFeature = pFCursor.NextFeature();

            double dblValue    = 0;
            double dblUncern   = 0;
            double dblInterval = 0;

            IStackedChartSymbol barChartSymbol;
            IChartSymbol        chartSymbol;

            while (pFeature != null)
            {
                IFeatureDraw pFeatDraw = (IFeatureDraw)pFeature;

                dblValue  = Convert.ToDouble(pFeature.get_Value(intValueFldIdx));
                dblUncern = Convert.ToDouble(pFeature.get_Value(intUncerFldIdx));

                dblInterval = dblError * dblUncern;


                barChartSymbol = new StackedChartSymbolClass();

                barChartSymbol.Width = 10;

                if (bln3Dfeature)
                {
                    I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol;
                    p3DChartSymbol.Display3D = true;
                    p3DChartSymbol.Thickness = 3;
                }

                //IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
                //markerSymbol.Size = 50;
                chartSymbol          = barChartSymbol as IChartSymbol;
                chartSymbol.MaxValue = dblMaxValue;


                ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
                //Upper Error Symbol
                IFillSymbol fillSymbol = new SimpleFillSymbolClass();
                fillSymbol.Color         = pSnippet.getRGB(0, 0, 255);
                fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
                symbolArray.AddSymbol(fillSymbol as ISymbol);
                chartSymbol.set_Value(0, dblInterval);

                //Lower Error
                fillSymbol               = new SimpleFillSymbolClass();
                fillSymbol.Color         = pSnippet.getRGB(255, 0, 0);
                fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
                symbolArray.AddSymbol(fillSymbol as ISymbol);
                chartSymbol.set_Value(1, dblInterval);

                //Value -Error to represent mean value
                fillSymbol               = new SimpleFillSymbolClass();
                fillSymbol.Color         = pSnippet.getRGB(255, 255, 255);
                fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
                symbolArray.AddSymbol(fillSymbol as ISymbol);
                chartSymbol.set_Value(2, dblValue - dblInterval);
                Display = m_pDisplay;
                Display.SetSymbol((ISymbol)chartSymbol);
                DrawPhase = esriDrawPhase.esriDPGeography;
                pFeatDraw.Draw(DrawPhase, Display, (ISymbol)chartSymbol, true,
                               null, esriDrawStyle.esriDSNormal);
                pFeature = pFCursor.NextFeature();
            }
        }
Example #20
0
        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                string strLayerName = cboSourceLayer.Text;
                if (cboSourceLayer.Text == "" || cboValueField.Text == "" || cboUField.Text == "")
                {
                    MessageBox.Show("Assign proper layer and field");
                    return;
                }

                int    intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName);
                ILayer pLayer    = mForm.axMapControl1.get_Layer(intLIndex);

                IFeatureLayer pFLayer = pLayer as IFeatureLayer;
                IFeatureClass pFClass = pFLayer.FeatureClass;

                //Create Rendering of Mean Value at Target Layer
                int    intGCBreakeCount = Convert.ToInt32(nudGCNClasses.Value);
                string strGCRenderField = cboValueField.Text;

                IGeoFeatureLayer pGeofeatureLayer;
                if (chkNewLayer.Checked == true)
                {
                    IFeatureLayer pflOutput = new FeatureLayerClass();
                    pflOutput.FeatureClass = pFClass;
                    pflOutput.Name         = txtNewLayer.Text;
                    pflOutput.Visible      = true;

                    pGeofeatureLayer = (IGeoFeatureLayer)pflOutput;
                }
                else
                {
                    pGeofeatureLayer = (IGeoFeatureLayer)pFLayer;
                }

                ITable       pTable = (ITable)pFClass;
                IClassifyGEN pClassifyGEN;
                switch (cboGCClassify.Text)
                {
                case "Equal Interval":
                    pClassifyGEN = new EqualIntervalClass();
                    break;

                case "Geometrical Interval":
                    pClassifyGEN = new GeometricalInterval();
                    break;

                case "Natural Breaks":
                    pClassifyGEN = new NaturalBreaksClass();
                    break;

                case "Quantile":
                    pClassifyGEN = new QuantileClass();
                    break;

                case "StandardDeviation":
                    pClassifyGEN = new StandardDeviationClass();
                    break;

                default:
                    pClassifyGEN = new NaturalBreaksClass();
                    break;
                }

                //Need to be changed 1/29/15
                ITableHistogram pTableHistogram = new BasicTableHistogramClass();
                pTableHistogram.Field = strGCRenderField;
                pTableHistogram.Table = pTable;
                IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram;

                object xVals, frqs;
                pHistogram.GetHistogram(out xVals, out frqs);
                pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount);

                ClassBreaksRenderer pRender = new ClassBreaksRenderer();
                double[]            cb      = (double[])pClassifyGEN.ClassBreaks;
                pRender.Field        = strGCRenderField;
                pRender.BreakCount   = intGCBreakeCount;
                pRender.MinimumBreak = cb[0];

                //' create our color ramp
                IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass();
                pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                IRgbColor pColor1 = new RgbColor();
                IRgbColor pColor2 = new RgbColor();

                //Can Change the color in here!
                pColor1.Red   = picSymolfrom.BackColor.R;
                pColor1.Green = picSymolfrom.BackColor.G;
                pColor1.Blue  = picSymolfrom.BackColor.B;

                Boolean blnOK = true;
                pColor2.Red          = picSymbolTo.BackColor.R;
                pColor2.Green        = picSymbolTo.BackColor.G;
                pColor2.Blue         = picSymbolTo.BackColor.B;
                pColorRamp.FromColor = pColor1;
                pColorRamp.ToColor   = pColor2;
                pColorRamp.Size      = intGCBreakeCount;
                pColorRamp.CreateRamp(out blnOK);

                IEnumColors pEnumColors = pColorRamp.Colors;
                pEnumColors.Reset();

                IRgbColor pColorOutline = new RgbColor();
                //Can Change the color in here!
                pColorOutline.Red   = picGCLineColor.BackColor.R;
                pColorOutline.Green = picGCLineColor.BackColor.G;
                pColorOutline.Blue  = picGCLineColor.BackColor.B;
                double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value);

                ICartographicLineSymbol pOutLines = new CartographicLineSymbol();
                pOutLines.Width = dblGCOutlineSize;
                pOutLines.Color = (IColor)pColorOutline;

                //' use this interface to set dialog properties
                IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender;
                pUIProperties.ColorRamp = "Custom";

                ISimpleFillSymbol pSimpleFillSym;
                //' be careful, indices are different for the diff lists
                for (int j = 0; j < intGCBreakeCount; j++)
                {
                    pRender.Break[j]          = cb[j + 1];
                    pRender.Label[j]          = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                    pUIProperties.LowBreak[j] = cb[j];
                    pSimpleFillSym            = new SimpleFillSymbolClass();
                    pSimpleFillSym.Color      = pEnumColors.Next();
                    pSimpleFillSym.Outline    = pOutLines;
                    pRender.Symbol[j]         = (ISymbol)pSimpleFillSym;
                }
                pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender;
                if (chkNewLayer.Checked == true)
                {
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer);
                }



                ////* Uncertainty Part *////
                //Declare variables in if parts

                if (tcUncern.SelectedIndex == 0) //Graduated Color
                {
                    int    intUncernBreakCount = Convert.ToInt32(nudCoNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUIColProperties = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    pColorRamp           = new AlgorithmicColorRampClass();
                    pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm;
                    pColor1 = new RgbColor();
                    pColor2 = new RgbColor();

                    //Can Change the color in here!
                    pColor1 = pSnippet.getRGB(picCoColorFrom.BackColor.R, picCoColorFrom.BackColor.G, picCoColorFrom.BackColor.B);
                    pColor2 = pSnippet.getRGB(picCoColorTo.BackColor.R, picCoColorTo.BackColor.G, picCoColorTo.BackColor.B);
                    if (pColor1 == null || pColor2 == null)
                    {
                        return;
                    }

                    blnOK = true;
                    pColorRamp.FromColor = pColor1;
                    pColorRamp.ToColor   = pColor2;
                    pColorRamp.Size      = intUncernBreakCount;
                    pColorRamp.CreateRamp(out blnOK);

                    pEnumColors = pColorRamp.Colors;
                    pEnumColors.Reset();

                    pColorOutline = pSnippet.getRGB(picCoLineColor.BackColor.R, picCoLineColor.BackColor.G, picCoLineColor.BackColor.B);
                    if (pColorOutline == null)
                    {
                        return;
                    }

                    double dblCoOutlineSize = Convert.ToDouble(nudCoLinewidth.Value);

                    pOutLines       = new CartographicLineSymbol();
                    pOutLines.Width = dblCoOutlineSize;
                    pOutLines.Color = (IColor)pColorOutline;

                    //' use this interface to set dialog properties
                    pUIColProperties           = (IClassBreaksUIProperties)pRender;
                    pUIColProperties.ColorRamp = "Custom";

                    ISimpleMarkerSymbol pSimpleMarkerSym;
                    double dblCoSymSize = Convert.ToDouble(nudCoSymbolSize.Value);
                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]              = cb[j + 1];
                        pRender.Label[j]              = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString();
                        pUIColProperties.LowBreak[j]  = cb[j];
                        pSimpleMarkerSym              = new SimpleMarkerSymbolClass();
                        pSimpleMarkerSym.Size         = dblCoSymSize;
                        pSimpleMarkerSym.Color        = pEnumColors.Next();
                        pSimpleMarkerSym.Outline      = true;
                        pSimpleMarkerSym.OutlineColor = pColorOutline;
                        pSimpleMarkerSym.OutlineSize  = dblCoOutlineSize;
                        pRender.Symbol[j]             = (ISymbol)pSimpleMarkerSym;
                    }

                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 1) //Texture
                {
                    //Create Rendering of Uncertainty at Target Layer
                    int    intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value);
                    string strUncerFieldName   = cboUField.Text;

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    switch (cboTeClassify.Text)
                    {
                    case "Equal Interval":
                        pClassifyGEN = new EqualIntervalClass();
                        break;

                    case "Geometrical Interval":
                        pClassifyGEN = new GeometricalInterval();
                        break;

                    case "Natural Breaks":
                        pClassifyGEN = new NaturalBreaksClass();
                        break;

                    case "Quantile":
                        pClassifyGEN = new QuantileClass();
                        break;

                    case "StandardDeviation":
                        pClassifyGEN = new StandardDeviationClass();
                        break;

                    default:
                        pClassifyGEN = new NaturalBreaksClass();
                        break;
                    }
                    //Need to be changed 1/29/15
                    pTableHistogram       = new BasicTableHistogramClass();
                    pTableHistogram.Field = strUncerFieldName;
                    pTableHistogram.Table = pTable;
                    pHistogram            = (IBasicHistogram)pTableHistogram;

                    pHistogram.GetHistogram(out xVals, out frqs);
                    pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount);

                    pRender              = new ClassBreaksRenderer();
                    cb                   = (double[])pClassifyGEN.ClassBreaks;
                    pRender.Field        = strUncerFieldName;
                    pRender.BreakCount   = intUncernBreakCount;
                    pRender.MinimumBreak = cb[0];

                    IClassBreaksUIProperties pUITexProperties = (IClassBreaksUIProperties)pRender;
                    pUITexProperties.ColorRamp = "Custom";

                    ILineFillSymbol pLineFillSym    = new LineFillSymbolClass();
                    double          dblFromSep      = Convert.ToDouble(nudSeperationFrom.Value);
                    double          dblToSep        = Convert.ToDouble(nudSeperationTo.Value);
                    double          dblInstantSep   = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblFromAngle    = Convert.ToDouble(nudAngleFrom.Value);
                    double          dblToAngle      = Convert.ToDouble(nudAngleFrom.Value); // Remove the angle part (04/16)
                    double          dblInstantAngle = (dblToAngle - dblFromAngle) / Convert.ToDouble(intUncernBreakCount - 1);
                    double          dblLinewidth    = Convert.ToDouble(nudTeLinewidth.Value);
                    IRgbColor       pLineColor      = new RgbColor();
                    pLineColor.Red   = picTeLineColor.BackColor.R;
                    pLineColor.Green = picTeLineColor.BackColor.G;
                    pLineColor.Blue  = picTeLineColor.BackColor.B;

                    //' be careful, indices are different for the diff lists
                    for (int j = 0; j < intUncernBreakCount; j++)
                    {
                        pRender.Break[j]             = cb[j + 1];
                        pRender.Label[j]             = Math.Round(cb[j], 5).ToString() + " - " + Math.Round(cb[j + 1], 5).ToString();
                        pUITexProperties.LowBreak[j] = cb[j];
                        pLineFillSym                  = new LineFillSymbolClass();
                        pLineFillSym.Angle            = dblFromAngle + (dblInstantAngle * Convert.ToDouble(j));
                        pLineFillSym.Color            = pLineColor;
                        pLineFillSym.Separation       = dblFromSep - (dblInstantSep * Convert.ToDouble(j));
                        pLineFillSym.LineSymbol.Width = dblLinewidth;
                        pRender.Symbol[j]             = (ISymbol)pLineFillSym;
                    }
                    pGFLUncern.Renderer = (IFeatureRenderer)pRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 2) //For Proportional Symbols
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMinPtSize      = Convert.ToDouble(nudProSymbolSize.Value);
                    double dblLineWidth      = Convert.ToDouble(nudProLinewidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    //Find Fields
                    int intUncernIdx = pTable.FindField(strUncerFieldName);

                    //Find Min value
                    //Set to initial value for min
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMinValue  = pStatResults.Minimum;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IRgbColor pSymbolRgb = pSnippet.getRGB(picProSymbolColor.BackColor.R, picProSymbolColor.BackColor.G, picProSymbolColor.BackColor.B);
                    if (pSymbolRgb == null)
                    {
                        return;
                    }

                    IRgbColor pLineRgb = pSnippet.getRGB(picProiLineColor.BackColor.R, picProiLineColor.BackColor.G, picProiLineColor.BackColor.B);
                    if (pLineRgb == null)
                    {
                        return;
                    }

                    ISimpleMarkerSymbol pSMarkerSym = new SimpleMarkerSymbolClass();
                    pSMarkerSym.Style        = esriSimpleMarkerStyle.esriSMSCircle;
                    pSMarkerSym.Size         = dblMinPtSize;
                    pSMarkerSym.OutlineSize  = dblLineWidth;
                    pSMarkerSym.Outline      = true;
                    pSMarkerSym.OutlineColor = (IColor)pLineRgb;
                    pSMarkerSym.Color        = (IColor)pSymbolRgb;

                    IGeoFeatureLayer            pGFLUncern    = (IGeoFeatureLayer)pflUncern;
                    IProportionalSymbolRenderer pUncernRender = new ProportionalSymbolRendererClass();
                    pUncernRender.LegendSymbolCount = 2; //Need to be changed 0219
                    pUncernRender.Field             = strUncerFieldName;
                    pUncernRender.MaxDataValue      = dblMaxValue;
                    pUncernRender.MinDataValue      = dblMinValue;
                    pUncernRender.MinSymbol         = (ISymbol)pSMarkerSym;
                    pUncernRender.ValueUnit         = esriUnits.esriUnknownUnits;
                    pUncernRender.BackgroundSymbol  = null;
                    pUncernRender.CreateLegendSymbols();

                    pGFLUncern.Renderer = (IFeatureRenderer)pUncernRender;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                else if (tcUncern.SelectedIndex == 3) // Bar
                {
                    string strUncerFieldName = cboUField.Text;
                    double dblMaxLength      = Convert.ToDouble(nudMaxBarHeight.Value);
                    double dblBarWidth       = Convert.ToDouble(nudBarWidth.Value);

                    IFeatureLayer pflUncern = new FeatureLayerClass();
                    pflUncern.FeatureClass = pFClass;
                    pflUncern.Name         = cboSourceLayer.Text + " Uncertainty";
                    pflUncern.Visible      = true;

                    int             intUncernIdx = pTable.FindField(strUncerFieldName);
                    IField          pUncernField = pTable.Fields.get_Field(intUncernIdx);
                    ICursor         pCursor      = pTable.Search(null, false);
                    IDataStatistics pDataStat    = new DataStatisticsClass();
                    pDataStat.Field  = pUncernField.Name;
                    pDataStat.Cursor = pCursor;
                    IStatisticsResults pStatResults = pDataStat.Statistics;
                    double             dblMaxValue  = pStatResults.Maximum;
                    pCursor.Flush();


                    IChartRenderer  chartRenderer  = new ChartRendererClass();
                    IRendererFields rendererFields = chartRenderer as IRendererFields;
                    rendererFields.AddField(strUncerFieldName);

                    IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
                    barChartSymbol.Width = dblBarWidth;
                    IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol;
                    markerSymbol.Size = dblMaxLength;
                    IChartSymbol chartSymbol = barChartSymbol as IChartSymbol;
                    chartSymbol.MaxValue = dblMaxValue;
                    ISymbolArray symbolArray = barChartSymbol as ISymbolArray;
                    IFillSymbol  fillSymbol  = new SimpleFillSymbolClass();
                    fillSymbol.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    if (fillSymbol.Color == null)
                    {
                        return;
                    }
                    symbolArray.AddSymbol(fillSymbol as ISymbol);

                    if (chk3D.Checked)
                    {
                        I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol;
                        p3DChartSymbol.Display3D = true;
                        p3DChartSymbol.Thickness = 3;
                    }
                    chartRenderer.ChartSymbol = barChartSymbol as IChartSymbol;
                    SimpleFillSymbol pBaseFillSym = new SimpleFillSymbolClass();
                    //pBaseFillSym.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B);
                    //chartRenderer.BaseSymbol = pBaseFillSym as ISymbol;
                    chartRenderer.UseOverposter = false;
                    chartRenderer.CreateLegend();
                    IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern;
                    pGFLUncern.Renderer = (IFeatureRenderer)chartRenderer;
                    mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern);
                }
                #region illumination
                //This function is not applied in this version. 032317 HK
                //}
                //    else if (tcUncern.SelectedIndex == 4) //illumination
                //    {
                //        frmProgress pfrmProgress = new frmProgress();
                //        pfrmProgress.lblStatus.Text = "Processing:";
                //        pfrmProgress.pgbProgress.Style = ProgressBarStyle.Marquee;
                //        pfrmProgress.Show();

                //        string strUncerFieldName = cboUField.Text;

                //        IGeoDataset geoDataset_output = createRasterfromPolygon(pFClass, strUncerFieldName, pFLayer, 100);

                //        double altitude = Convert.ToDouble(nudAltitude.Value);
                //        double azimuth = Convert.ToDouble(nudAzimuth.Value);
                //        object zFactor = Convert.ToDouble(nudZFactor.Value);


                //        ISurfaceOp2 pSurfOP = new RasterSurfaceOpClass();
                //        IRaster pOutputDS = (IRaster)pSurfOP.HillShade(geoDataset_output, azimuth, altitude, true, ref zFactor);

                //        ((IDataset)geoDataset_output).Delete();
                //        // Create a raster for viewing
                //        ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = new ESRI.ArcGIS.Carto.RasterLayerClass();
                //        rasterLayer.CreateFromRaster(pOutputDS);

                //        //Calculate hillshade value at slope 0 to set as background value
                //        double dblRadian = (Math.PI / 180) * (90 - altitude);
                //        double dblBackValue = Math.Truncate(255 * Math.Cos(dblRadian));

                //        IRasterStretch pRasterStretch = new RasterStretchColorRampRendererClass();
                //        IColor pColor = new RgbColorClass();
                //        pColor.NullColor = true;
                //        pColor.Transparency = 0;
                //        pRasterStretch.Background = true;
                //        pRasterStretch.BackgroundColor = pColor;
                //        pRasterStretch.set_BackgroundValues(ref dblBackValue);

                //        rasterLayer.Name = "Uncertainty of " + strGCRenderField;
                //        rasterLayer.Renderer = pRasterStretch as IRasterRenderer;
                //        rasterLayer.Renderer.Update();

                //        //Apply Transparency
                //        ILayerEffects pLayerEffect = (ILayerEffects)rasterLayer;
                //        pLayerEffect.Transparency = Convert.ToInt16(nudTransparent.Value);

                //        pfrmProgress.Close();
                //        // Add the raster to the map
                //        pActiveView.FocusMap.AddLayer(rasterLayer);

                //    }

                //    mForm.axMapControl1.ActiveView.Refresh();
                //    mForm.axTOCControl1.Update();
                #endregion
            }
            catch (Exception ex)
            {
                frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog();
                return;
            }
        }
Example #21
0
        public void InitRendererObject(List <FieldInfo> pFields, IFeatureRenderer pRenderer, esriSymbologyStyleClass _SymbologyStyleClass)
        {
            listAddField.Items.Clear();
            flag = true;
            m_SymbologyStyleClass = _SymbologyStyleClass;

            if (!(pRenderer is IChartRenderer))//ÅжÏÊÇ·ñÊÇͼ±íäÖȾ
            {
                return;
            }
            IChartRenderer pChartRenderer = pRenderer as IChartRenderer;

            if (pChartRenderer.ColorScheme != "")//ÑÕÉ«·½°¸
            {
                cmbColorRamp.Text = pChartRenderer.ColorScheme;
            }

            if (pChartRenderer.BaseSymbol != null)//±³¾°
            {
                labelPreviewBack.Tag = pChartRenderer.BaseSymbol;
            }
            else
            {
                labelPreviewBack.Tag = ModuleCommon.CreateSymbol(m_SymbologyStyleClass);
            }
            labelPreviewBack.Image = ModuleCommon.Symbol2Picture(labelPreviewBack.Tag as ISymbol, ModuleCommon.ImageWidth, ModuleCommon.ImageHeight);
            if (pChartRenderer.UseOverposter)//·ÀÖ¹¸²¸Ç
            {
                chkIsUnOverlap.Checked = true;
            }
            else
            {
                chkIsUnOverlap.Checked = false;
            }
            //IChartSymbol pCS = pChartRenderer.ChartSymbol;
            //sizeInput.Value = pCS.MaxValue;//´óС
            IMarkerSymbol pMS = pChartRenderer.ChartSymbol as IMarkerSymbol;

            sizeInput.Value = pMS.Size;                                        //´óС
            IRendererFields pRenderFields = pChartRenderer as IRendererFields; //×Ö¶Î
            ISymbolArray    pSymbolArray  = pChartRenderer.ChartSymbol as ISymbolArray;

            listAddField.SmallImageList.Images.Clear();
            List <string> fdLst = new List <string>();//¼Ç¼äÖȾ¶ÔÏóÒÑÓÃ×Ö¶Î

            for (int i = 0; i < pRenderFields.FieldCount; i++)
            {
                listAddField.SmallImageList.Images.Add("Symbol" + i.ToString(), ModuleCommon.Symbol2Picture(pSymbolArray.get_Symbol(i), ModuleCommon.ImageWidth, ModuleCommon.ImageHeight));
                System.Windows.Forms.ListViewItem item = new System.Windows.Forms.ListViewItem();
                item.Name     = "Item" + i;
                item.Text     = "";
                item.ImageKey = "Symbol" + i.ToString();
                item.Tag      = pSymbolArray.get_Symbol(i);
                System.Windows.Forms.ListViewItem.ListViewSubItem subItem = new System.Windows.Forms.ListViewItem.ListViewSubItem();
                subItem.Text = pRenderFields.get_Field(i);
                item.SubItems.Add(subItem);
                listAddField.Items.Add(item);
                fdLst.Add(pRenderFields.get_Field(i));
            }
            if (listAddField.SmallImageList.Images.Count >= 0)
            {
                selnum   = pFields.Count;
                pSymbols = CreateSymbols(selnum);
                int ii = 0;
                foreach (FieldInfo fi in pFields)
                {
                    listAddField.SmallImageList.Images.Add("Symbol" + ii.ToString(), ModuleCommon.Symbol2Picture(pSymbols[ii], ModuleCommon.ImageWidth, ModuleCommon.ImageHeight));
                    ii++;
                }
            }
            foreach (FieldInfo fi in pFields)
            {
                if (fi.FieldName != "<NONE>" && !fdLst.Contains(fi.FieldName))
                {
                    listAllField.Items.Add(fi.FieldName);
                }
            }
            flag = false;
        }
        public PieRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, string pFieldName1, string pFieldName2)
        {
            IGeoFeatureLayer pGeoFeaLayer   = (IGeoFeatureLayer)pFtLayer;
            IChartRenderer   pChartRenderer = new ChartRendererClass();
            // Set up the field to draw charts
            IRendererFields pRenderFields = (IRendererFields)pChartRenderer;

            pRenderFields.AddField(pFieldName1, pFieldName1);
            pRenderFields.AddField(pFieldName2, pFieldName2);
            IPieChartRenderer pPieChartRender = (IPieChartRenderer)pChartRenderer;

            //计算最大值部分有待补充////////////////////////////////////
            //Calculate the max value of the data field to scale the chart

            //ICursor pCursor = new CursorClass();
            IQueryFilter pQueryFilter = new QueryFilterClass();
            //IRowBuffer pRow = new RowBufferClass();
            ITable pTable = (ITable)pGeoFeaLayer;

            pQueryFilter.AddField(pFieldName1);
            ICursor pCursor = pTable.Search(pQueryFilter, true);

            IDataStatistics pDataStat = new DataStatisticsClass();

            IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);

            pDataStat.Cursor = pFtCursor as ICursor;

            pDataStat.Field = pFieldName1;

            double pMax = pDataStat.Statistics.Maximum;



            IPieChartSymbol pPiechartSymbol = new PieChartSymbolClass();
            IFillSymbol     pFillSymbol     = new SimpleFillSymbolClass();
            IChartSymbol    pChartSymbol    = (IChartSymbol)pPiechartSymbol;

            pPiechartSymbol.Clockwise  = true;
            pPiechartSymbol.UseOutline = true;
            ILineSymbol pOutLine = new SimpleLineSymbolClass();

            pOutLine.Color          = GetRGBColor(255, 0, 255);
            pOutLine.Width          = 1;
            pPiechartSymbol.Outline = pOutLine;

            IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pPiechartSymbol;

            //finally
            pChartSymbol.MaxValue = pMax;
            pMarkerSymbol.Size    = 16;
            //像符号数组中添加 添加符号
            ISymbolArray pSymbolArray = (ISymbolArray)pPiechartSymbol;

            pFillSymbol.Color   = GetRGBColor(213, 212, 252);
            pFillSymbol.Outline = pOutLine;
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
            //////////////////////////
            pFillSymbol.Color   = GetRGBColor(183, 242, 122);
            pFillSymbol.Outline = pOutLine;
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
            //set up the background
            pFillSymbol.Color                    = GetRGBColor(239, 228, 190);
            pChartRenderer.BaseSymbol            = (ISymbol)pFillSymbol;
            pChartRenderer.UseOverposter         = false;
            pPieChartRender.MinSize              = 1;
            pPieChartRender.MinValue             = pDataStat.Statistics.Minimum;
            pPieChartRender.FlanneryCompensation = false;
            pPieChartRender.ProportionalBySum    = true;
            pChartRenderer.ChartSymbol           = (IChartSymbol)pPiechartSymbol;
            pChartRenderer.CreateLegend();
            pGeoFeaLayer.Renderer = (IFeatureRenderer)pChartRenderer;
            pMapcontrol.ActiveView.Refresh();
        }
Example #23
0
        //创建柱状专题图
        public void CreateBarRenderer(int layerID, string[] fields)
        {
            // 得到地图服务下的ArcObjects map对象
            ESRI.ArcGIS.Server.IServerContext pServerContext = GetServerContext();

            ESRI.ArcGIS.Carto.IMapServer         mapServer        = (ESRI.ArcGIS.Carto.IMapServer)pServerContext.ServerObject;
            ESRI.ArcGIS.Carto.IMapServerObjects2 mapServerObjects = (ESRI.ArcGIS.Carto.IMapServerObjects2)mapServer;
            string mapName = mapServer.DefaultMapName;

            ESRI.ArcGIS.Carto.IMap aoMap = mapServerObjects.get_Map(mapName);

            ESRI.ArcGIS.Carto.ILayer           pLayer    = aoMap.get_Layer(layerID);//得到图层
            ESRI.ArcGIS.Carto.IGeoFeatureLayer pGeoLayer = pLayer as IGeoFeatureLayer;
            //设置专题图元素的属性名称列表
            IChartRenderer  pChartRender  = pServerContext.CreateObject("esriCarto.ChartRenderer") as IChartRenderer;
            IRendererFields pRenderFields = pChartRender as IRendererFields;

            foreach (string var in fields)
            {
                pRenderFields.AddField(var, var);
            }

            //实例化图表对象并取得元素指定属性的最大值
            IBarChartSymbol pBarChartSymbol = pServerContext.CreateObject("esriDisplay.BarChartSymbol") as IBarChartSymbol;
            IChartSymbol    pChartSymbol    = pBarChartSymbol as IChartSymbol;

            pChartSymbol.MaxValue = GetStaMaxMin(fields, pGeoLayer)[0];
            pBarChartSymbol.Width = 8;
            IMarkerSymbol pMarkerSymbol = pBarChartSymbol as IMarkerSymbol;

            pMarkerSymbol.Size = 50;

            //设置柱状图每列填充效果
            ISymbolArray pSymbolArray = pBarChartSymbol as ISymbolArray;
            Random       ranColor     = new Random();

            for (int i = 0; i < fields.Length; i++)
            {
                IFillSymbol pFillSymbol = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as IFillSymbol;
                pFillSymbol.Color = GetRGB(ranColor.Next(255), ranColor.Next(255), ranColor.Next(255), pServerContext);
                pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
            }

            //设置地图图层背景
            ESRI.ArcGIS.Display.ISimpleFillSymbol pFSymbol = pServerContext.CreateObject("esriDisplay.SimpleFillSymbol") as ESRI.ArcGIS.Display.SimpleFillSymbol;
            pFSymbol.Color          = GetRGB(239, 228, 249, pServerContext);
            pChartRender.BaseSymbol = pFSymbol as ISymbol;

            //应用柱状专题到指定图层
            pChartRender.ChartSymbol   = pBarChartSymbol as IChartSymbol;
            pChartRender.Label         = "Test";
            pChartRender.UseOverposter = false;
            pChartRender.CreateLegend();
            pGeoLayer.Renderer = pChartRender as IFeatureRenderer;

            //刷新地图显示图表及图例
            mapServerObjects.RefreshServerObjects();
            Map1.RefreshResource("MapResourceItem0");
            Toc1.BuddyControl = "Map1";
            //Toc1.Refresh();
            Map1.Refresh();
            pServerContext.ReleaseContext();
        }
 /// <summary>
 ///  Creates an linear accessor.
 /// </summary>
 /// <param name="index">   Indexer used to index symbols in the symbol array. </param>
 /// <param name="length">  Length of a section of the symbol array.</param>
 /// <param name="symbols"> Symbol array.</param>
 public AccessorLinear
     (IIndexer index, int length, ISymbolArray symbols)
     : base (index, length, symbols)
 {
     this.defaultSymbol = symbols.Alphabet['-'];
 }
Example #25
0
        private static void AddSymbolNode(TreeNodeComLayer tnComLayer, object renderer)
        {
            int             index;
            LogicBaseTree   logicBT    = new LogicBaseTree();
            ImageCollection treeImages = logicBT.TreeList.StateImageList as ImageCollection;

            if (renderer is SimpleRenderer)
            {
                ISimpleRenderer simpleRenderer = (ISimpleRenderer)renderer;
                ISymbol         symbol         = simpleRenderer.Symbol;
                Image           img            = ConvertSymbolToImage.Convert(symbol, 16, 16);
                index = treeImages.Images.Add(img);
                //img.Save("d:\\" + index + ".JPG");

                string         label    = simpleRenderer.Label;
                TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                {
                    Name = label, CustomValue = symbol
                };
                tnSymbol.ImageIndex = index;
                tnComLayer.Add(tnSymbol);
            }
            else if (renderer is UniqueValueRenderer)
            {
                string renderLabel = "";
                IUniqueValueRenderer uniqueValueRenderer = renderer as IUniqueValueRenderer;
                for (int i = 0; i < uniqueValueRenderer.FieldCount - 1; i++)
                {
                    renderLabel += uniqueValueRenderer.get_Field(i) + " /";
                }
                renderLabel += uniqueValueRenderer.get_Field(uniqueValueRenderer.FieldCount - 1);//FieldCount为地物分类数
                //getImage(esriGeometryType.esriGeometryPolygon, Color.White).Save("D:\\111.jpg");
                index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White));

                TreeNodeSymbol tnChartNode = new TreeNodeSymbol()
                {
                    Name = renderLabel, CustomValue = uniqueValueRenderer
                };
                tnChartNode.ImageIndex = index;
                tnComLayer.Add(tnChartNode);

                for (int i = 0; i < uniqueValueRenderer.ValueCount; i++)//ValueCount为地物分类下的设施种类数
                {
                    ISymbol symbol = uniqueValueRenderer.get_Symbol(uniqueValueRenderer.get_Value(i));

                    Image img = ConvertSymbolToImage.Convert(symbol, 16, 16);
                    //img.Save("D:\\121121.jpg");


                    index = treeImages.Images.Add(img);

                    TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                    {
                        Name = uniqueValueRenderer.get_Label(uniqueValueRenderer.get_Value(i)), CustomValue = symbol
                    };
                    tnSymbol.ImageIndex = index;
                    tnComLayer.Add(tnSymbol);
                }
                if (uniqueValueRenderer.UseDefaultSymbol)
                {
                    ISymbol symbol = uniqueValueRenderer.DefaultSymbol;
                    Image   img    = ConvertSymbolToImage.Convert(symbol, 16, 16);
                    index = treeImages.Images.Add(img);

                    TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                    {
                        Name = uniqueValueRenderer.DefaultLabel, CustomValue = symbol
                    };
                    tnSymbol.ImageIndex = index;
                    tnComLayer.Add(tnSymbol);
                }
            }
            else if (renderer is IChartRenderer)
            {
                IChartRenderer  chartRenderer = renderer as IChartRenderer;
                IRendererFields pFields       = chartRenderer as IRendererFields;
                string          renderLabel   = "";
                for (int i = 0; i < pFields.FieldCount - 1; i++)
                {
                    renderLabel += pFields.get_FieldAlias(i) + " /";
                }
                renderLabel += pFields.get_FieldAlias(pFields.FieldCount - 1);

                index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White));

                TreeNodeSymbol tnChartNode = new TreeNodeSymbol()
                {
                    Name = renderLabel, CustomValue = chartRenderer
                };
                tnChartNode.ImageIndex = index;
                tnComLayer.Add(tnChartNode);


                ISymbolArray symArray = chartRenderer.ChartSymbol as ISymbolArray;
                for (int i = 0; i < symArray.SymbolCount; i++)
                {
                    ISymbol symbol = symArray.get_Symbol(i);

                    Image img = ConvertSymbolToImage.Convert(symbol, 16, 16);
                    index = treeImages.Images.Add(img);

                    TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                    {
                        Name = pFields.get_FieldAlias(i), CustomValue = symbol
                    };
                    tnSymbol.ImageIndex = index;
                    tnComLayer.Add(tnSymbol);
                }
            }
            else if (renderer is IClassBreaksRenderer)
            {
                IClassBreaksRenderer classRenderer = renderer as IClassBreaksRenderer;
                index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White));

                TreeNodeSymbol tnChartNode = new TreeNodeSymbol()
                {
                    Name = classRenderer.Field, CustomValue = classRenderer
                };
                tnChartNode.ImageIndex = index;
                tnComLayer.Add(tnChartNode);


                for (int i = 0; i < classRenderer.BreakCount; i++)
                {
                    ISymbol symbol = classRenderer.get_Symbol(i);

                    Image img = ConvertSymbolToImage.Convert(symbol, 16, 16);
                    index = treeImages.Images.Add(img);

                    TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                    {
                        Name = classRenderer.get_Label(i), CustomValue = symbol
                    };
                    tnSymbol.ImageIndex = index;
                    tnComLayer.Add(tnSymbol);
                }
            }
            else if (renderer is IRasterRenderer)
            {
                if (renderer is IRasterClassifyColorRampRenderer)
                {
                    //MessageBox.Show("IRasterClassifyColorRampRenderer");
                }
                else if (renderer is IRasterUniqueValueRenderer)
                {
                    //MessageBox.Show("IRasterUniqueValueRenderer");
                }
                else if (renderer is IRasterStretchColorRampRenderer)
                {
                    ////MessageBox.Show("IRasterStretchColorRampRenderer");
                    IRasterStretchColorRampRenderer pRSCRR = renderer as IRasterStretchColorRampRenderer;

                    index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White));
                    TreeNodeSymbol tnChartNode = new TreeNodeSymbol()
                    {
                        Name = "<Value>", CustomValue = pRSCRR
                    };
                    tnChartNode.ImageIndex = index;
                    tnComLayer.Add(tnChartNode);

                    if (pRSCRR.ColorRamp.Size >= 3)
                    {
                        IEnumColors colors = pRSCRR.ColorRamp.Colors;
                        colors.Reset();
                        IColor  c      = colors.Next();
                        Color[] cArray = new Color[3];
                        int     count  = 0;
                        while (c != null)
                        {
                            count++;
                            if (count == 1)
                            {
                                cArray[0] = Color.FromArgb(c.RGB);
                            }
                            else if (count == pRSCRR.ColorRamp.Size / 2)
                            {
                                cArray[1] = Color.FromArgb(c.RGB);
                            }
                            else if (count == pRSCRR.ColorRamp.Size)
                            {
                                cArray[2] = Color.FromArgb(c.RGB);
                            }
                            c = colors.Next();
                        }
                        for (int i = 0; i < 3; i++)
                        {
                            Image img = getImage(esriGeometryType.esriGeometryPolygon, cArray[i]);
                            index = treeImages.Images.Add(img);

                            string label = "";
                            if (i == 0)
                            {
                                label = pRSCRR.LabelLow;
                            }
                            else if (i == 1)
                            {
                                label = pRSCRR.LabelMedium;
                            }
                            else if (i == 2)
                            {
                                label = pRSCRR.LabelHigh;
                            }

                            TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                            {
                                Name = label, CustomValue = cArray[i]
                            };
                            tnSymbol.ImageIndex = index;
                            tnComLayer.Add(tnSymbol);
                        }
                    }
                }

                else if (renderer is IRasterRGBRenderer)
                {
                    //MessageBox.Show("IRasterRGBRenderer");
                }
                else if (renderer is IRasterColormap)
                {
                    //MessageBox.Show("IRasterColormap");
                }
                else
                {
                    //MessageBox.Show("未处理的IRasterRenderer类型:  " + renderer.GetType().FullName);
                }
            }
            else if (renderer is ITinRenderer)
            {
                if (renderer is ITinColorRampRenderer)
                {
                    ////MessageBox.Show("ITinColorRampRenderer");
                    ITinColorRampRenderer pTCRR = renderer as ITinColorRampRenderer;

                    index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White));
                    TreeNodeSymbol tnChartNode = new TreeNodeSymbol()
                    {
                        Name = "Elevation", CustomValue = pTCRR
                    };
                    tnChartNode.ImageIndex = index;
                    tnComLayer.Add(tnChartNode);



                    for (int i = 0; i < pTCRR.BreakCount; i++)
                    {
                        ISymbol symbol = pTCRR.get_Symbol(i);
                        Image   img    = ConvertSymbolToImage.Convert(symbol, 16, 16);
                        index = treeImages.Images.Add(img);
                        TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                        {
                            Name = pTCRR.get_Label(i), CustomValue = symbol
                        };
                        tnSymbol.ImageIndex = index;
                        tnComLayer.Add(tnSymbol);
                    }
                }
                else if (renderer is ITinUniqueValueRenderer)
                {
                    ////MessageBox.Show("ITinUniqueValueRenderer");
                    ITinUniqueValueRenderer pTUVR = renderer as ITinUniqueValueRenderer;

                    index = treeImages.Images.Add(getImage(esriGeometryType.esriGeometryPolygon, Color.White));

                    TreeNodeSymbol tnChartNode = new TreeNodeSymbol()
                    {
                        Name = "Elevation", CustomValue = pTUVR
                    };
                    tnChartNode.ImageIndex = index;
                    tnComLayer.Add(tnChartNode);


                    for (int i = 0; i < pTUVR.ValueCount; i++)
                    {
                        string  val    = pTUVR.get_Value(i);
                        ISymbol symbol = pTUVR.get_Symbol(val);
                        Image   img    = ConvertSymbolToImage.Convert(symbol, 16, 16);
                        index = treeImages.Images.Add(img);

                        TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                        {
                            Name = pTUVR.get_Label(val), CustomValue = symbol
                        };
                        tnSymbol.ImageIndex = index;
                        tnComLayer.Add(tnSymbol);
                    }
                    if (pTUVR.UseDefaultSymbol)
                    {
                        ISymbol symbol = pTUVR.DefaultSymbol;
                        Image   img    = ConvertSymbolToImage.Convert(symbol, 16, 16);
                        index = treeImages.Images.Add(img);

                        TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                        {
                            Name = pTUVR.DefaultLabel, CustomValue = symbol
                        };
                        tnSymbol.ImageIndex = index;
                        tnComLayer.Add(tnSymbol);
                    }
                }
                else if (renderer is ITinSingleSymbolRenderer)
                {
                    ////MessageBox.Show("ITinSingleSymbolRenderer");
                    ITinSingleSymbolRenderer pTSSR = renderer as ITinSingleSymbolRenderer;
                    ISymbol symbol = pTSSR.Symbol;
                    Image   img    = ConvertSymbolToImage.Convert(symbol, 16, 16);
                    index = treeImages.Images.Add(img);

                    TreeNodeSymbol tnSymbol = new TreeNodeSymbol()
                    {
                        Name = pTSSR.Label, CustomValue = symbol
                    };
                    tnSymbol.ImageIndex = index;
                    tnComLayer.Add(tnSymbol);
                }
                else
                {
                    //MessageBox.Show("未处理的ITinRenderer类型:  " + renderer.GetType().FullName);
                }
            }
            else
            {
                //MessageBox.Show("未处理的Renderer类型:  " + renderer.GetType().FullName);
            }
        }
 /// <summary>
 ///  Creates an accessor which returns complements of symbols.
 /// </summary>
 /// <param name="symbols">An array of symbols that implements ISymbolArray</param>
 public AccessorComplement(ISymbolArray symbols)
     : base(null, 0, symbols)
 { /* No implementation required */ }
Example #27
0
        public void ApplyBarChartValue(IGeoFeatureLayer geoLayer, string aFieldName)
        {
            //IChartRender is engaged with feature data
            IChartRenderer  chartRender  = new ChartRenderer();
            IRendererFields renderFields = chartRender as IRendererFields;

            renderFields.AddField(aFieldName);
            //Search Max
            IQueryFilter queryFilter = new QueryFilter();

            //Content in Cursor
            queryFilter.AddField(aFieldName);
            //Search all features without WhereClause
            IFeatureCursor fCursor = geoLayer.FeatureClass.Search(queryFilter, true);
            //the index of Field
            int           indexField = fCursor.FindField(aFieldName);
            List <double> valueList  = new List <double>();
            IFeature      aFeature   = fCursor.NextFeature();

            while (aFeature != null)
            {
                valueList.Add(Convert.ToDouble(aFeature.get_Value(indexField)));
                aFeature = fCursor.NextFeature();
            }
            //BarChartSymbol
            IBarChartSymbol barSymbol = new BarChartSymbol() as IBarChartSymbol;

            barSymbol.Width = 12;
            IChartSymbol chartSym = barSymbol as IChartSymbol;

            //
            chartSym.MaxValue = valueList.Max();
            IMarkerSymbol markerSymbol = (IMarkerSymbol)chartSym;

            markerSymbol.Size = 50;
            //Set Symbol
            ISymbolArray pSymbolArray = (ISymbolArray)barSymbol;
            IRgbColor    aColor       = new RgbColor();

            aColor.Red   = Convert.ToInt32(255);
            aColor.Green = Convert.ToInt32(255);
            aColor.Blue  = Convert.ToInt32(0);
            ISimpleFillSymbol pFillSymbol = new SimpleFillSymbol();

            pFillSymbol.Color = aColor;
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

            //Render Attribute
            chartRender.ChartSymbol   = (IChartSymbol)barSymbol;
            chartRender.Label         = "指标";
            chartRender.UseOverposter = false;
            chartRender.CreateLegend();

            //Back Ground
            ISimpleFillSymbol bgSym   = new SimpleFillSymbol();
            IRgbColor         bgColor = new RgbColor();

            bgColor.Red   = Convert.ToInt32(239);
            bgColor.Green = Convert.ToInt32(228);
            bgColor.Blue  = Convert.ToInt32(190);
            bgSym.Color   = bgColor;
            //bgSym.Color = Convert.ToInt32(System.Drawing.Color.FromArgb(239, 228, 190));
            chartRender.BaseSymbol = (ISymbol)bgSym;

            //Render Label
            geoLayer.ScaleSymbols = true;
            //Scale Symbol
            geoLayer.Renderer = chartRender as IFeatureRenderer;
            axMapControl1.ActiveView.Refresh();
            axTOCControl1.Update();
        }
 /// <summary>
 ///  Creates a symbol array accessor on base of the provided symbol array.
 /// </summary>
 /// <param name="index">  Indexer used to index symbols in the symbol array. </param>
 /// <param name="length"> Length of a section of the symbol array. </param>
 /// <param name="symbols">Symbol array. </param>
 public AccessorTransparent
     (IIndexer index, int length, ISymbolArray symbols)
     : base(index, length, symbols)
 { /* NO IMPLEMENTATION*/ }
Example #29
0
        private void method_0()
        {
            IFields fields2;
            int     num;

            this.FieldsListBoxCtrl.Items.Clear();
            this.SelectFieldslistView.Items.Clear();
            IRendererFields fields = this.idotDensityRenderer_0 as IRendererFields;

            if (this.igeoFeatureLayer_0 is IDisplayTable)
            {
                fields2 = (this.igeoFeatureLayer_0 as IDisplayTable).DisplayTable.Fields;
            }
            else
            {
                fields2 = this.igeoFeatureLayer_0.FeatureClass.Fields;
            }
            this.colorRampComboBox1.Text = this.idotDensityRenderer_0.ColorScheme;
            if (this.colorRampComboBox1.Items.Count == 0)
            {
                this.ienumColors_0 = this.method_1(null, fields2.FieldCount);
            }
            else
            {
                this.ienumColors_0 = this.method_1(this.colorRampComboBox1.GetSelectColorRamp(), fields2.FieldCount);
            }
            bool flag = false;

            for (num = 0; num < fields2.FieldCount; num++)
            {
                IField        field = fields2.get_Field(num);
                esriFieldType type  = field.Type;
                if ((((type != esriFieldType.esriFieldTypeDouble) && (type != esriFieldType.esriFieldTypeInteger)) &&
                     (type != esriFieldType.esriFieldTypeSingle)) && (type != esriFieldType.esriFieldTypeSmallInteger))
                {
                    continue;
                }
                flag = true;
                string str = field.Name.ToUpper();
                for (int i = 0; i < fields.FieldCount; i++)
                {
                    if (str == fields.get_Field(i).ToUpper())
                    {
                        goto Label_0145;
                    }
                }
                goto Label_0147;
Label_0145:
                flag = false;
Label_0147:
                if (flag)
                {
                    this.FieldsListBoxCtrl.Items.Add(new FieldWrap(field));
                }
            }
            double[]     numArray         = new double[fields.FieldCount];
            double[]     numArray2        = new double[fields.FieldCount];
            double[]     numArray3        = new double[fields.FieldCount];
            string[]     strArray         = new string[2];
            ISymbolArray dotDensitySymbol = this.idotDensityRenderer_0.DotDensitySymbol as ISymbolArray;

            for (num = 0; num < fields.FieldCount; num++)
            {
                double num3;
                double num4;
                double num5;
                strArray[0] = "";
                strArray[1] = fields.get_FieldAlias(num);
                ListViewItemEx ex = new ListViewItemEx(strArray)
                {
                    Style = dotDensitySymbol.get_Symbol(num),
                    Tag   = new FieldWrap(fields2.get_Field(fields2.FindField(fields.get_Field(num))))
                };
                this.SelectFieldslistView.Add(ex);
                this.GetStaticsValue(fields.get_Field(num), out num3, out num4, out num5);
                numArray[num]  = num3;
                numArray3[num] = num4;
                numArray2[num] = num5;
            }
            if (fields.FieldCount > 0)
            {
                this.btnUnSelectAll.Enabled = true;
            }
            this.txtSize.Text       = this.idotDensityRenderer_0.DotDensitySymbol.DotSize.ToString();
            this.txtPointValue.Text = this.idotDensityRenderer_0.DotValue.ToString();
            double num7 = double.Parse(this.txtPointValue.Text);
            IDotDensityFillSymbol symbol =
                (this.idotDensityRenderer_0.DotDensitySymbol as IClone).Clone() as IDotDensityFillSymbol;
            IDotDensityFillSymbol symbol2 =
                (this.idotDensityRenderer_0.DotDensitySymbol as IClone).Clone() as IDotDensityFillSymbol;
            IDotDensityFillSymbol symbol3 =
                (this.idotDensityRenderer_0.DotDensitySymbol as IClone).Clone() as IDotDensityFillSymbol;

            this.MinsymbolItem.Symbol  = symbol;
            this.MeansymbolItem.Symbol = symbol2;
            this.MaxsymbolItem.Symbol  = symbol3;
            for (num = 0; num < (symbol as ISymbolArray).SymbolCount; num++)
            {
                symbol.set_DotCount(num, (int)(numArray[num] / num7));
                symbol2.set_DotCount(num, (int)(numArray3[num] / num7));
                symbol3.set_DotCount(num, (int)(numArray2[num] / num7));
            }
            this.MinsymbolItem.Invalidate();
            this.MeansymbolItem.Invalidate();
            this.MaxsymbolItem.Invalidate();
        }
Example #30
0
        /// <summary>
        /// Bar Chart Render for Enviroment
        /// </summary>
        /// <param name="currentLayer"></param>
        /// <param name="breakCount"></param>
        /// <author>Shen Yongyuan</author>
        /// <date>20091114</date>
        public static void BarChartRenderSingle(ILayer currentLayer)
        {
            //Scale Symbol
            IGeoFeatureLayer pGeoFeatureL = currentLayer as IGeoFeatureLayer;

            pGeoFeatureL.ScaleSymbols = true;

            //Chart Render
            IChartRenderer  pChartRenderer  = new ChartRendererClass();
            IRendererFields pRendererFields = (IRendererFields)pChartRenderer;

            pRendererFields.AddField(Town.Constant.Constant.TmpTableIndex + "." + Town.Constant.Constant.TmpFieldName, "指标");

            //Search Max
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.AddField(Town.Constant.Constant.TmpTableIndex + "." + Town.Constant.Constant.TmpFieldName);
            IFeatureCursor pCursor = pGeoFeatureL.DisplayFeatureClass.Search(pQueryFilter, true);

            int fldFiledEcology = pCursor.Fields.FindField(Town.Constant.Constant.TmpTableIndex + "." + Town.Constant.Constant.TmpFieldName);

            List <double> valueList = new List <double>();

            IFeature pFeature = pCursor.NextFeature();

            while (pFeature != null)
            {
                valueList.Add(Convert.ToDouble(pFeature.get_Value(fldFiledEcology)));
                pFeature = pCursor.NextFeature();
            }

            //Bar Chart
            IBarChartSymbol pBarChartSymbol = new BarChartSymbolClass();
            IChartSymbol    pChartSymbol    = (IChartSymbol)pBarChartSymbol;

            pBarChartSymbol.Width = 12;
            IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pBarChartSymbol;

            pChartSymbol.MaxValue = valueList.Max();
            pMarkerSymbol.Size    = 50;

            //Set Symbol
            ISymbolArray      pSymbolArray = (ISymbolArray)pBarChartSymbol;
            ISimpleFillSymbol pFillSymbol  = new SimpleFillSymbolClass();

            pFillSymbol.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.Green);
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

            //Render Attribute
            pChartRenderer.ChartSymbol   = (IChartSymbol)pBarChartSymbol;
            pChartRenderer.Label         = "指标";
            pChartRenderer.UseOverposter = false;
            pChartRenderer.CreateLegend();

            //Back Ground
            pFillSymbol               = new SimpleFillSymbolClass();
            pFillSymbol.Color         = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(239, 228, 190));
            pChartRenderer.BaseSymbol = (ISymbol)pFillSymbol;

            //Render Label
            pGeoFeatureL.Renderer = pChartRenderer as IFeatureRenderer;
        }
Example #31
0
        /// <summary>
        /// Pie Chart Render
        /// </summary>
        /// <param name="currentLayer"></param>
        /// <param name="breakCount"></param>
        /// <author>Shen Yongyuan</author>
        /// <date>20091114</date>
        public static void PieChartRender(ILayer currentLayer)
        {
            //Scale Symbol
            IGeoFeatureLayer pGeoFeatureL = currentLayer as IGeoFeatureLayer;

            pGeoFeatureL.ScaleSymbols = true;

            //Chart Render
            IChartRenderer  pChartRenderer  = new ChartRendererClass();
            IRendererFields pRendererFields = (IRendererFields)pChartRenderer;

            pRendererFields.AddField(Town.Constant.Constant.TmpTableIndex + "." + "Ecology", "生态");
            pRendererFields.AddField(Town.Constant.Constant.TmpTableIndex + "." + "Social", "社会");
            pRendererFields.AddField(Town.Constant.Constant.TmpTableIndex + "." + "Economic", "经济");

            //Search Max
            IQueryFilter pQueryFilter = new QueryFilterClass();

            pQueryFilter.AddField(Town.Constant.Constant.TmpTableIndex + "." + "Ecology");
            pQueryFilter.AddField(Town.Constant.Constant.TmpTableIndex + "." + "Social");
            pQueryFilter.AddField(Town.Constant.Constant.TmpTableIndex + "." + "Economic");
            IFeatureCursor pCursor = pGeoFeatureL.DisplayFeatureClass.Search(pQueryFilter, true);

            int fldFiledEcology  = pCursor.Fields.FindField(Town.Constant.Constant.TmpTableIndex + "." + "Ecology");
            int fldFiledSocial   = pCursor.Fields.FindField(Town.Constant.Constant.TmpTableIndex + "." + "Social");
            int fldFiledEconomic = pCursor.Fields.FindField(Town.Constant.Constant.TmpTableIndex + "." + "Economic");

            List <double> valueList = new List <double>();

            IFeature pFeature = pCursor.NextFeature();

            while (pFeature != null)
            {
                valueList.Add(Convert.ToDouble(pFeature.get_Value(fldFiledEcology)));
                valueList.Add(Convert.ToDouble(pFeature.get_Value(fldFiledSocial)));
                valueList.Add(Convert.ToDouble(pFeature.get_Value(fldFiledEconomic)));
                pFeature = pCursor.NextFeature();
            }

            //Pie Chart
            IPieChartSymbol pPieChartSymbol;

            pPieChartSymbol = new PieChartSymbolClass();
            IChartSymbol pChartSymbol = (IChartSymbol)pPieChartSymbol;

            //Pie Chart Attribute
            pPieChartSymbol.Clockwise  = true;
            pPieChartSymbol.UseOutline = true;
            ILineSymbol pOutline;

            pOutline                = new SimpleLineSymbolClass();
            pOutline.Color          = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(100, 205, 30));
            pOutline.Width          = 1;
            pPieChartSymbol.Outline = pOutline;
            IMarkerSymbol pMarkerSymbol = (IMarkerSymbol)pPieChartSymbol;

            pChartSymbol.MaxValue = valueList.Max();
            pMarkerSymbol.Size    = 60;

            //Symbol Array
            ISymbolArray      pSymbolArray = (ISymbolArray)pPieChartSymbol;
            ISimpleFillSymbol pFillSymbol  = new SimpleFillSymbolClass();

            pFillSymbol.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.Green);
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
            pFillSymbol       = new SimpleFillSymbolClass();
            pFillSymbol.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.Red);
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);
            pFillSymbol       = new SimpleFillSymbolClass();
            pFillSymbol.Color = ArcGIS.Color.ToEsriColor(System.Drawing.Color.Blue);
            pSymbolArray.AddSymbol((ISymbol)pFillSymbol);

            pChartRenderer.ChartSymbol = (IChartSymbol)pPieChartSymbol;
            pChartRenderer.Label       = "指标";

            //Back Ground
            pFillSymbol               = new SimpleFillSymbolClass();
            pFillSymbol.Color         = ArcGIS.Color.ToEsriColor(System.Drawing.Color.FromArgb(239, 228, 190));
            pChartRenderer.BaseSymbol = (ISymbol)pFillSymbol;

            //Render Label
            pGeoFeatureL.Renderer = pChartRenderer as IFeatureRenderer;
        }
Example #32
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         int          num3;
         double       num              = 0.0;
         double       num2             = double.Parse(this.txtSize.Text);
         ISymbolArray dotDensitySymbol = this.idotDensityRenderer_0.DotDensitySymbol as ISymbolArray;
         string[]     strArray         = new string[2];
         for (num3 = this.FieldsListBoxCtrl.SelectedIndices.Count - 1; num3 >= 0; num3--)
         {
             int index = this.FieldsListBoxCtrl.SelectedIndices[num3];
             (this.idotDensityRenderer_0 as IRendererFields).AddField(
                 (this.FieldsListBoxCtrl.Items[index] as FieldWrap).Name,
                 this.FieldsListBoxCtrl.Items[index].ToString());
             IColor color = this.ienumColors_0.Next();
             if (color == null)
             {
                 this.ienumColors_0.Reset();
                 color = this.ienumColors_0.Next();
             }
             ISymbol symbol =
                 this.CreateMarkerSymbol(color, esriSimpleMarkerStyle.esriSMSCircle, num2) as ISymbol;
             strArray[0] = "";
             strArray[1] = this.FieldsListBoxCtrl.Items[index].ToString();
             ListViewItemEx ex = new ListViewItemEx(strArray)
             {
                 Style = symbol,
                 Tag   = this.FieldsListBoxCtrl.Items[index]
             };
             this.SelectFieldslistView.Add(ex);
             dotDensitySymbol.AddSymbol(symbol);
             this.FieldsListBoxCtrl.Items.RemoveAt(index);
         }
         IDotDensityFillSymbol symbol2 = (dotDensitySymbol as IClone).Clone() as IDotDensityFillSymbol;
         IDotDensityFillSymbol symbol3 = (dotDensitySymbol as IClone).Clone() as IDotDensityFillSymbol;
         IDotDensityFillSymbol symbol4 = (dotDensitySymbol as IClone).Clone() as IDotDensityFillSymbol;
         this.MinsymbolItem.Symbol  = symbol2;
         this.MeansymbolItem.Symbol = symbol3;
         this.MaxsymbolItem.Symbol  = symbol4;
         double[] numArray  = new double[dotDensitySymbol.SymbolCount];
         double[] numArray2 = new double[dotDensitySymbol.SymbolCount];
         double[] numArray3 = new double[dotDensitySymbol.SymbolCount];
         for (num3 = 0; num3 < dotDensitySymbol.SymbolCount; num3++)
         {
             double num5;
             double num6;
             double num7;
             this.GetStaticsValue((this.idotDensityRenderer_0 as IRendererFields).get_Field(num3), out num5,
                                  out num6, out num7);
             numArray[num3]  = num5;
             numArray3[num3] = num6;
             numArray2[num3] = num7;
             if (num5 > 0.0)
             {
                 if (num == 0.0)
                 {
                     num = num5;
                 }
                 else
                 {
                     num = (num < num5) ? num : num5;
                 }
             }
             num = (num > this.idotDensityRenderer_0.DotValue) ? this.idotDensityRenderer_0.DotValue : num;
             if (num == 0.0)
             {
                 num = 500.0;
             }
             this.txtPointValue.Text             = num.ToString();
             this.idotDensityRenderer_0.DotValue = num;
         }
         for (num3 = 0; num3 < numArray.Length; num3++)
         {
             symbol2.set_DotCount(num3, (int)(numArray[num3] / num));
             symbol3.set_DotCount(num3, (int)(numArray3[num3] / num));
             symbol4.set_DotCount(num3, (int)(numArray2[num3] / num));
         }
         this.MinsymbolItem.Invalidate();
         this.MeansymbolItem.Invalidate();
         this.MaxsymbolItem.Invalidate();
     }
     catch
     {
     }
     this.btnUnSelectAll.Enabled = true;
 }
        public BarRender(AxMapControl pMapcontrol, IFeatureLayer pFtLayer, String pFieldName1, string pFieldName2)
        {
            //IGeoFeatureLayer pGeoFeatureLayer = pFtLayer as IGeoFeatureLayer;


            //IFeatureClass pFeatureClass = pFtLayer.FeatureClass;

            ////定义柱状图渲染组建对象
            //IChartRenderer pChartRenderer = new ChartRendererClass();
            ////定义渲染字段对象并给字段对象实例化为pChartRenderer
            //IRendererFields pRendererFields;
            //pRendererFields = (IRendererFields)pChartRenderer;
            ////向渲染字段对象中添加字段--- 待补充自定义添加
            //pRendererFields.AddField(pFieldName1, pFieldName1);
            //pRendererFields.AddField(pFieldName2, pFieldName2);


            //ITable pTable;
            //pTable = pGeoFeatureLayer as ITable;


            //int[] pFieldIndecies = new int[2];


            //pFieldIndecies[0] = pTable.FindField(pFieldName1);
            //pFieldIndecies[1] = pTable.FindField(pFieldName2);



            //IDataStatistics pDataStat = new DataStatisticsClass();

            //IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search(null, false);

            //pDataStat.Cursor = pFtCursor as ICursor;

            //pDataStat.Field = pFieldName2;

            //double pMax = pDataStat.Statistics.Maximum;

            //// 定义并设置渲染时用的chart marker symbol
            //IBarChartSymbol pBarChartSymbol = new BarChartSymbolClass();
            //pBarChartSymbol.Width = 6;

            //IChartSymbol pChartSymbol;
            //pChartSymbol = pBarChartSymbol as IChartSymbol;

            //IMarkerSymbol pMarkerSymbol;
            //pMarkerSymbol = (IMarkerSymbol)pBarChartSymbol;



            //IFillSymbol pFillSymbol;
            ////设置pChartSymbol的最大值
            //pChartSymbol.MaxValue = pMax;
            //// 设置bars的最大高度
            //pMarkerSymbol.Size = 80;
            ////下面给每一个bar设置符号

            ////定义符号数组
            //ISymbolArray pSymbolArray = (ISymbolArray)pBarChartSymbol;



            ////添加第一个符号
            //pFillSymbol = new SimpleFillSymbolClass();
            //pFillSymbol.Color = GetRGBColor(193, 252, 179) as IColor;
            //pSymbolArray.AddSymbol(pFillSymbol as ISymbol);
            ////添加第二个符号
            //pFillSymbol = new SimpleFillSymbolClass();
            // pFillSymbol.Color = GetRGBColor(145, 55, 251) as IColor;
            //pSymbolArray.AddSymbol(pFillSymbol as ISymbol);



            //pChartRenderer.ChartSymbol = pChartSymbol as IChartSymbol;
            ////pChartRenderer.Label = "AREA";
            //pChartRenderer.CreateLegend();

            //pChartRenderer.UseOverposter = false;
            ////将柱状图渲染对象与渲染图层挂钩
            //pGeoFeatureLayer.Renderer = (IFeatureRenderer)pChartRenderer;


            ////刷新地图和TOOCotrol
            //IActiveView pActiveView = pMapcontrol .ActiveView as IActiveView;
            //pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);



            //获取当前图层 ,并把它设置成IGeoFeatureLayer的实例
            IMap             pMap             = pMapcontrol.Map;
            ILayer           pLayer           = pMap.get_Layer(0) as IFeatureLayer;
            IFeatureLayer    pFeatureLayer    = pLayer as IFeatureLayer;
            IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer;

            //获取图层上的feature
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            //定义柱状图渲染组建对象
            IChartRenderer pChartRenderer = new ChartRendererClass();
            //定义渲染字段对象并给字段对象实例化为pChartRenderer
            IRendererFields pRendererFields;

            pRendererFields = (IRendererFields)pChartRenderer;
            //向渲染字段对象中添加字段--- 待补充自定义添加
            pRendererFields.AddField(pFieldName1, pFieldName1);
            pRendererFields.AddField(pFieldName2, pFieldName2);

            // 通过查找features的所用字段的值,计算出数据字段的最大值,作为设置柱状图的比例大小的依据
            ITable pTable;
            int    fieldNumber;

            pTable = pGeoFeatureLayer as ITable;
            // 查找出geoFeatureLayer的属性表中的字段个数
            fieldNumber = pTable.FindField(pFieldName1);
            if (fieldNumber == -1)
            {
                MessageBox.Show("Can't find field called ", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            const int numFields = 2;// 设置bars的个数

            int[] fieldIndecies = new int[2];
            //long fieldIndex;
            double maxValue;
            bool   firstValue;
            //double[] fieldValue=new double[5];
            double fieldValue;

            fieldIndecies[0] = pTable.FindField(pFieldName1);
            fieldIndecies[1] = pTable.FindField(pFieldName2);
            firstValue       = true;
            maxValue         = 0;
            int n = pFeatureClass.FeatureCount(null);

            for (int i = 0; i < numFields; i++)
            {
                IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false);
                for (int j = 0; j < n; j++)
                {
                    IFeature pFeature = pFeatureCursor.NextFeature();
                    fieldValue = Convert.ToDouble(pFeature.get_Value(fieldIndecies[i]));

                    if (firstValue)
                    {
                        //给maxValue赋初值
                        maxValue   = fieldValue;
                        firstValue = false;
                    }
                    else if (fieldValue > maxValue)
                    {
                        maxValue = fieldValue;
                    }
                }
            }

            if (maxValue <= 0)
            {
                MessageBox.Show("Failed to calculate the maximum value or maxvalue is 0.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            // 定义并设置渲染时用的chart marker symbol
            IBarChartSymbol pBarChartSymbol = new BarChartSymbolClass();

            pBarChartSymbol.Width = 6;

            IChartSymbol pChartSymbol;

            pChartSymbol = pBarChartSymbol as IChartSymbol;

            IMarkerSymbol pMarkerSymbol;

            pMarkerSymbol = (IMarkerSymbol)pBarChartSymbol;



            IFillSymbol pFillSymbol;

            //设置pChartSymbol的最大值
            pChartSymbol.MaxValue = maxValue;
            // 设置bars的最大高度
            pMarkerSymbol.Size = 16;
            //下面给每一个bar设置符号

            //定义符号数组
            ISymbolArray pSymbolArray = (ISymbolArray)pBarChartSymbol;

            //克隆pFillSymbol用于符号操作
            //IClone pSourceClone = pFillSymbol as IClone;
            //ISimpleFillSymbol pSimpleFillSymbol = pSourceClone.Clone() as ISimpleFillSymbol;

            // 向符号数组中添加设置后的符号
            //pSimpleFillSymbol.Color = GetRGBColor(193, 252, 179);
            //pSymbolArray.AddSymbol(pSimpleFillSymbol as ISymbol);

            //pSimpleFillSymbol.Color = GetRGBColor(145, 55, 200);
            //pSymbolArray.AddSymbol(pSimpleFillSymbol as ISymbol);

            //添加第一个符号
            pFillSymbol       = new SimpleFillSymbolClass();
            pFillSymbol.Color = GetRGBColor(193, 252, 179) as IColor;
            pSymbolArray.AddSymbol(pFillSymbol as ISymbol);
            //添加第二个符号
            pFillSymbol       = new SimpleFillSymbolClass();
            pFillSymbol.Color = GetRGBColor(145, 55, 251) as IColor;
            pSymbolArray.AddSymbol(pFillSymbol as ISymbol);



            // 设置背景符号
            //pSimpleFillSymbol.Color = GetRGBColor(239, 150, 190);
            //pChartRenderer.BaseSymbol = pSimpleFillSymbol as ISymbol;

            // Disable overpoaster 让符号处于图形中央
            pChartRenderer.UseOverposter = false;


            //pChartRenderer.ChartSymbol = pSymbolArray as IChartSymbol;
            pChartRenderer.ChartSymbol = pChartSymbol as IChartSymbol;
            //pChartRenderer.Label = "AREA";
            pChartRenderer.CreateLegend();

            //将柱状图渲染对象与渲染图层挂钩
            pGeoFeatureLayer.Renderer     = (IFeatureRenderer)pChartRenderer;
            pGeoFeatureLayer.DisplayField = pFieldName1;
            //刷新地图和TOOCotrol
            IActiveView pActiveView = pMapcontrol.Map as IActiveView;

            pActiveView.Refresh();
        }
        /// <summary>
        ///  Creates an accessor with its {Indexer}.
        /// <para></para>
        /// <see cref="QUT.Bio.BioPatML.Symbols.Accessor.AccessorCircular">AccessorCircular</see>
        /// <para></para>
        /// <see cref="QUT.Bio.BioPatML.Symbols.Accessor.AccessorLinear">AccessorLinear</see>
        /// <para></para>
        /// <see cref="QUT.Bio.BioPatML.Symbols.Accessor.AccessorComplement">AccessorComplement</see>
        /// 
        /// </summary>
        /// <param name="type"> Type of the accessor. See constants.</param>
        /// <param name="ioff"> Offset for the indexer.</param>
        /// <param name="ilen"> Length for the indexer.</param>
        /// <param name="length"> Length of the accessor section.</param>
        /// <param name="symbols"> Symbol array the accessor works on.</param>
        /// <returns> Returns an accessor. </returns>
        public static AccessorBase Instance
            (int type, int ioff, int ilen, int length, ISymbolArray symbols)
        {
            AccessorBase accessor   = null;
            Indexer.Indexer indexor = null;


            //Create the chosen Indexer
            if ((type & REVERSE) > 0)
                indexor = new IndexerReverse(ioff, ilen);

            else
                indexor = new IndexerDirect(ioff);


            //create the chosen accessor
            if ((type & CIRCULAR) > 0)
                accessor = new AccessorCircular(indexor, length, symbols);

            else
                if ((type & TRANSPARENT) > 0)
                    accessor = new AccessorTransparent(indexor, length, symbols);

            else
                accessor = new AccessorLinear(indexor, length, symbols);


            if ((type & COMPLEMENT) > 0)
                accessor = new AccessorComplement(accessor);


            return accessor;
        }
Example #35
0
        //Create Legend
        public void CreateLegend()
        {
            clsSnippet pSnippet = new clsSnippet();

            //Create Legend Group
            m_pLegendGroup          = new LegendGroup();
            m_pLegendGroup.Heading  = m_strOriRenderField;
            m_pLegendGroup.Editable = true;
            m_pLegendGroup.Visible  = true;

            ILegendClass legendClass = new LegendClass();

            legendClass.Label = Math.Round(dblMaxValue, 0).ToString();

            IStackedChartSymbol stackedChartSymbol = new StackedChartSymbolClass();

            //IBarChartSymbol barChartSymbol = new BarChartSymbolClass();
            stackedChartSymbol.Width = 10;
            if (bln3Dfeature)
            {
                I3DChartSymbol p3DChartSymbol = stackedChartSymbol as I3DChartSymbol;
                p3DChartSymbol.Display3D = true;
                p3DChartSymbol.Thickness = 3;
            }
            //IMarkerSymbol markerSymbol = stackedChartSymbol as IMarkerSymbol;
            //markerSymbol.Size = 50;
            IChartSymbol chartSymbol = stackedChartSymbol as IChartSymbol;

            chartSymbol.MaxValue = dblMaxValue;

            ISymbolArray symbolArray = stackedChartSymbol as ISymbolArray;
            //Stacked Symbol
            IFillSymbol fillSymbol = new SimpleFillSymbolClass();

            fillSymbol.Color         = pSnippet.getRGB(255, 0, 0);
            fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            chartSymbol.set_Value(0, dblMaxUncern);

            //fillSymbol = new SimpleFillSymbolClass();
            //fillSymbol.Color = pSnippet.getRGB(255, 0, 0);
            //fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
            //symbolArray.AddSymbol(fillSymbol as ISymbol);
            //chartSymbol.set_Value(1, dblMaxUncern);

            fillSymbol               = new SimpleFillSymbolClass();
            fillSymbol.Color         = pSnippet.getRGB(255, 255, 255);
            fillSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);
            symbolArray.AddSymbol(fillSymbol as ISymbol);
            chartSymbol.set_Value(1, dblMaxEstimate - dblMaxUncern);

            legendClass.Symbol = (ISymbol)chartSymbol;
            m_pLegendGroup.AddClass(legendClass);

            //Bounds
            legendClass       = new LegendClass();
            legendClass.Label = "Upper Bound";
            ISimpleFillSymbol pLegendUncerSymbol = new SimpleFillSymbol();

            pLegendUncerSymbol.Color         = pSnippet.getRGB(0, 0, 255);
            pLegendUncerSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);

            legendClass.Symbol = (ISymbol)pLegendUncerSymbol;
            m_pLegendGroup.AddClass(legendClass);

            legendClass                      = new LegendClass();
            legendClass.Label                = "Lower Bound";
            pLegendUncerSymbol               = new SimpleFillSymbol();
            pLegendUncerSymbol.Color         = pSnippet.getRGB(255, 0, 0);
            pLegendUncerSymbol.Outline.Color = pSnippet.getRGB(0, 0, 0);

            legendClass.Symbol = (ISymbol)pLegendUncerSymbol;
            m_pLegendGroup.AddClass(legendClass);
        }
 /// <summary>
 ///  Creates a symbol array accessor on base of the provided symbol array.
 /// </summary>
 /// <param name="indexer"> Indexer used to index symbols in the symbol array. </param>
 /// <param name="length">  Length of a section of the symbol array.</param>
 /// <param name="symbols"> Symbol array.</param>
 public AccessorCircular
     (IIndexer indexer, int length, ISymbolArray symbols)
     : base(indexer, length, symbols)
 { /* No implementation needed */ }