Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
0
        private void method_2()
        {
            IFields fields2;
            int     num;

            this.FieldsListBoxCtrl.Items.Clear();
            this.SelectFieldslistView.Items.Clear();
            IRendererFields fields = this.ichartRenderer_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.ichartRenderer_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));
                }
            }
            string[]     strArray    = new string[2];
            ISymbolArray chartSymbol = this.ichartRenderer_0.ChartSymbol as ISymbolArray;

            for (num = 0; num < fields.FieldCount; num++)
            {
                strArray[0] = "";
                strArray[1] = fields.get_FieldAlias(num);
                ListViewItemEx ex = new ListViewItemEx(strArray)
                {
                    Style = chartSymbol.get_Symbol(num),
                    Tag   = new FieldWrap(fields2.get_Field(fields2.FindField(fields.get_Field(num))))
                };
                this.SelectFieldslistView.Add(ex);
            }
            if ((this.igeoFeatureLayer_0.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) ||
                (this.igeoFeatureLayer_0.FeatureClass.ShapeType == esriGeometryType.esriGeometryMultipoint))
            {
                this.lblBackground.Visible = false;
                this.btnStyle.Visible      = false;
            }
            else
            {
                this.lblBackground.Visible = true;
                this.btnStyle.Visible      = true;
            }
            if (this.ichartRenderer_0.BaseSymbol == null)
            {
                this.ichartRenderer_0.BaseSymbol = this.method_8(this.igeoFeatureLayer_0.FeatureClass.ShapeType);
            }
            this.btnStyle.Style        = this.ichartRenderer_0.BaseSymbol;
            this.chkOverposter.Checked = this.ichartRenderer_0.UseOverposter;
        }