Ejemplo n.º 1
0
        private void SetClassView()
        {
            listView1.Items.Clear();
            IColorRamp pColorRamp  = (IColorRamp)EnumStyleItem[comboBoxColor.SelectedIndex];
            int        ClassCount  = comboBoxClassValue.SelectedIndex + 1;
            int        ColorNumber = pColorRamp.Size;
            int        Count       = Math.Min(ClassCount, ColorNumber);

            if ((comboBoxClassValue.SelectedIndex + 1) > Count)
            {
                comboBoxClassValue.SelectedIndex = Count - 1;
            }

            for (int i = 0; i < Count; i++)
            {
                ListViewItem lv     = new ListViewItem();
                int          nclass = i + 1;
                lv.SubItems.Add("");
                int n1 = 255 / Count * i; int n2 = 255 / Count * (i + 1);
                lv.SubItems.Add(n1.ToString() + "---" + n2.ToString());
                lv.UseItemStyleForSubItems = false;
                lv.SubItems[0].BackColor   = PageLayoutInsert.IColorToColor(pColorRamp.get_Color(i));
                lv.SubItems[1].BackColor   = PageLayoutInsert.IColorToColor(pColorRamp.get_Color(i));
                listView1.Items.Add(lv);
            }
        }
Ejemplo n.º 2
0
        private void StretchRender()
        {
            if (comboBoxBand.SelectedItem == null)
            {
                MessageBox.Show("波段不能为空!");
                return;
            }
            IColorRamp   pColorRamp  = (IColorRamp)EnumStyleItem[comboBoxColor.SelectedIndex];
            IRasterLayer pRasterLayr = m_layer as IRasterLayer;
            IRasterStretchColorRampRenderer pStretchRenderer = new RasterStretchColorRampRendererClass();
            IRasterRenderer pRasterRenderer = (IRasterRenderer)pStretchRenderer;
            IRaster         pRaster         = pRasterLayr.Raster;

            pRasterRenderer.Raster = pRaster;
            pRasterRenderer.Update();
            pStretchRenderer.BandIndex = comboBoxBand.SelectedIndex;
            pStretchRenderer.ColorRamp = pColorRamp;
            IRasterStretch pStretchType = (IRasterStretch)pRasterRenderer;

            pStretchType.StretchType             = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations;
            pStretchType.StandardDeviationsParam = Convert.ToDouble(textBoxStandardValue.Text);

            pRasterLayr.Renderer = pRasterRenderer;

            m_mapControl3.Refresh();
        }
Ejemplo n.º 3
0
        private void DrawColorRamp()
        {
            string               sInstall            = ESRI.ArcGIS.RuntimeManager.ActiveRuntime.Path;
            string               styleFilePath       = sInstall + "\\Styles\\ESRI.ServerStyle";
            IStyleGallery        styleGallery        = new ServerStyleGalleryClass();
            IStyleGalleryItem    styleGalleryItem    = null;
            IStyleGalleryStorage styleGalleryStorage = styleGallery as IStyleGalleryStorage;

            styleGalleryStorage.AddFile(styleFilePath);

            IEnumStyleGalleryItem enumStyleGalleryItem = styleGallery.get_Items("Color Ramps", styleFilePath, "");

            enumStyleGalleryItem.Reset();

            styleGalleryItem = enumStyleGalleryItem.Next();

            while (styleGalleryItem != null)
            {
                m_ColorRamp = (IColorRamp)styleGalleryItem.Item;
                EnumStyleItem.Add(m_ColorRamp);
                m_FillSymbol = new GradientFillSymbol();
                m_FillSymbol.GradientAngle = 0;
                m_FillSymbol.ColorRamp     = m_ColorRamp;
                pictureBox1.Image          = SymbolToBitmap(m_FillSymbol, 0, pictureBox1.Width, pictureBox1.Height);
                imageList1.Images.Add(pictureBox1.Image);
                comboBoxColor.Items.Add(pictureBox1.Image);
                styleGalleryItem = enumStyleGalleryItem.Next();
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(enumStyleGalleryItem);
        }
Ejemplo n.º 4
0
 private void cboColorRamp_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.bool_0)
     {
         bool flag;
         this.icolorRamp_0 = this.cboColorRamp.GetSelectStyleGalleryItem().Item as IColorRamp;
         (this.irasterStretchColorRampRenderer_0 as IRasterRendererColorRamp).ColorScheme =
             this.cboColorRamp.Text;
         IRasterStretchColorRampRenderer renderer = this.irasterStretchColorRampRenderer_0;
         IRasterRenderer renderer2 = (IRasterRenderer)renderer;
         if (this.icolorRamp_0 == null)
         {
             IAlgorithmicColorRamp ramp = new AlgorithmicColorRampClass();
             IColor color = new RgbColorClass();
             (color as IRgbColor).Red   = 255;
             (color as IRgbColor).Red   = 0;
             (color as IRgbColor).Green = 0;
             (color as IRgbColor).Blue  = 0;
             IColor color2 = new RgbColorClass();
             (color2 as IRgbColor).Red   = 255;
             (color2 as IRgbColor).Green = 255;
             (color2 as IRgbColor).Blue  = 255;
             ramp.FromColor    = color;
             ramp.ToColor      = color2;
             this.icolorRamp_0 = ramp;
         }
         this.icolorRamp_0.Size = 255;
         this.icolorRamp_0.CreateRamp(out flag);
         renderer.ColorRamp = this.icolorRamp_0;
         renderer2.Update();
     }
 }
Ejemplo n.º 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     ColorRampForm colorRampForm = new ColorRampForm();
     colorRampForm.ShowDialog();
     colorRamp = colorRampForm.m_styleGalleryItem.Item as IColorRamp;
     colorRampForm.Dispose();
 }
Ejemplo n.º 6
0
        private ISymbol[] CreateSymbols()
        {
            IColorRamp pColorRamp = (cmbColorRamp.SelectedItem as DevComponents.Editors.ComboItem).Tag as IColorRamp;
            bool       bCreateRamp;

            pColorRamp.Size = levelInput.Value <= 1 ? 2 : levelInput.Value;
            pColorRamp.CreateRamp(out bCreateRamp);
            IEnumColors enumColors = pColorRamp.Colors;

            enumColors.Reset();

            ISymbol[] symbols = new ISymbol[levelInput.Value];
            ESRI.ArcGIS.esriSystem.IObjectCopy copy = new ESRI.ArcGIS.esriSystem.ObjectCopyClass();
            for (int i = 0; i < levelInput.Value; i++)
            {
                symbols[i] = copy.Copy(labelPreviewFore.Tag) as ISymbol;
                IColor pColor = enumColors.Next();
                if (pColor == null)
                {
                    enumColors.Reset();
                    enumColors.Next();
                }
                ModuleCommon.ChangeSymbolColor(symbols[i], pColor);
            }
            return(symbols);
        }
Ejemplo n.º 7
0
        //分级渲染函数
        private void RasterClassifyRender(IRasterLayer pRasterLayer)
        {
            try
            {
                IColorRamp pColorRamp = (IColorRamp)EnumStyleItem[comboBoxColor.SelectedIndex];

                IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRenderer() as IRasterClassifyColorRampRenderer;
                IRasterRenderer pRRend = pRClassRend as IRasterRenderer;

                IRaster pRaster = pRasterLayer.Raster;
                IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection;
                IRasterBand           pRBand    = pRBandCol.Item(0);
                if (pRBand.Histogram == null)
                {
                    pRBand.ComputeStatsAndHist();
                }
                pRRend.Raster = pRaster;

                pRRend.Update();

                IRgbColor pFromColor = new RgbColor() as IRgbColor;
                pFromColor.Red   = 255;
                pFromColor.Green = 0;
                pFromColor.Blue  = 0;
                IRgbColor pToColor = new RgbColor() as IRgbColor;
                pToColor.Red   = 0;
                pToColor.Green = 0;
                pToColor.Blue  = 255;

                IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRamp() as IAlgorithmicColorRamp;

                //colorRamp = pColorRamp as IAlgorithmicColorRamp;///////
                colorRamp.Size = comboBoxClassValue.SelectedIndex + 1;

                //colorRamp.FromColor = pFromColor;
                //colorRamp.ToColor = pToColor;
                int nClass = comboBoxClassValue.SelectedIndex + 1;
                colorRamp.FromColor = pColorRamp.get_Color(0);
                colorRamp.ToColor   = pColorRamp.get_Color(nClass - 1);
                bool createColorRamp;


                colorRamp.CreateRamp(out createColorRamp);

                IFillSymbol fillSymbol = new SimpleFillSymbol() as IFillSymbol;

                for (int i = 0; i < nClass; i++)
                {
                    fillSymbol.Color = colorRamp.get_Color(i);
                    pRClassRend.set_Symbol(i, fillSymbol as ISymbol);
                    pRClassRend.set_Label(i, pRClassRend.get_Break(i).ToString("0.00"));
                }
                pRasterLayer.Renderer = pRRend;
                m_mapControl.Refresh();
            }
            catch (Exception e)
            {
                MessageBox.Show("创建失败!");
            }
        }
Ejemplo n.º 8
0
 private void cboColorRamp_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.bool_0)
     {
         this.iuniqueValueRenderer_0.ColorScheme = this.cboColorRamp.Text;
         this.icolorRamp_0 = this.cboColorRamp.GetSelectStyleGalleryItem().Item as IColorRamp;
         if (this.icolorRamp_0 != null)
         {
             bool flag;
             this.icolorRamp_0.Size = this.int_0;
             this.icolorRamp_0.CreateRamp(out flag);
             this.ienumColors_0 = this.icolorRamp_0.Colors;
             this.ienumColors_0.Reset();
             IColor color = null;
             for (int i = 0; i < this.iuniqueValueRenderer_0.ValueCount; i++)
             {
                 ISymbol symbol = this.iuniqueValueRenderer_0.get_Symbol(this.iuniqueValueRenderer_0.get_Value(i));
                 color = this.ienumColors_0.Next();
                 if (color == null)
                 {
                     this.ienumColors_0.Reset();
                     color = this.ienumColors_0.Next();
                 }
                 this.method_5(symbol, color);
                 this.iuniqueValueRenderer_0.set_Symbol(this.iuniqueValueRenderer_0.get_Value(i), symbol);
                 this.listView1.Items[i].Tag = symbol;
             }
             this.listView1.Invalidate();
         }
     }
 }
Ejemplo n.º 9
0
        private void cmbColorRamp_SelectedIndexChanged(object sender, EventArgs e)
        {
            int symbolindex = cmbColorRamp.SelectedIndex;//获取选择的序号
            IStyleGalleryItem mpStyleGalleryItem = pSymbolClass.GetItem(symbolindex);

            PColorramp = (IColorRamp)mpStyleGalleryItem.Item;//获取选择的符号
        }
Ejemplo n.º 10
0
        internal static void UsingRasterClassifyRendered1(IRasterLayer irasterLayer_0, int int_0, string string_0)
        {
            bool    flag;
            IRaster raster = irasterLayer_0.Raster;
            IRasterClassifyColorRampRenderer o = new RasterClassifyColorRampRenderer();
            IRasterRenderer renderer2          = o as IRasterRenderer;

            renderer2.Raster = raster;
            o.ClassField     = string_0;
            o.ClassCount     = int_0;
            IClassify classify = new EqualInterval() as IClassify;
            UID       classID  = classify.ClassID;
            IRasterClassifyUIProperties properties = o as IRasterClassifyUIProperties;

            properties.ClassificationMethod = classID;
            renderer2.Update();
            IColorRamp ramp = ColorManage.CreateColorRamp();

            ramp.Size = int_0;
            ramp.CreateRamp(out flag);
            IFillSymbol symbol = new SimpleFillSymbol();

            for (int i = 0; i < o.ClassCount; i++)
            {
                symbol.Color = ramp.get_Color(i);
                o.set_Symbol(i, symbol as ISymbol);
            }
            renderer2.Update();
            irasterLayer_0.Renderer = o as IRasterRenderer;
            Marshal.ReleaseComObject(o);
            o = null;
        }
Ejemplo n.º 11
0
        //yjl20110826 add
        private ISymbol[] CreateSymbols(int count)
        {
            IColorRamp pColorRamp = (cmbColorRamp.SelectedItem as DevComponents.Editors.ComboItem).Tag as IColorRamp;
            bool       bCreateRamp;

            pColorRamp.Size = count <= 1 ? 2 : count;
            pColorRamp.CreateRamp(out bCreateRamp);
            IEnumColors enumColors = pColorRamp.Colors;

            enumColors.Reset();
            ESRI.ArcGIS.esriSystem.IObjectCopy copy = new ESRI.ArcGIS.esriSystem.ObjectCopyClass();
            ISymbol[] symbols   = new ISymbol[count];
            ISymbol   tmpSymbol = ModuleCommon.CreateSymbol(m_SymbologyStyleClass);

            for (int i = 0; i < count; i++)
            {
                symbols[i] = copy.Copy(tmpSymbol) as ISymbol;
                IColor pColor = enumColors.Next();
                if (pColor == null)
                {
                    enumColors.Reset();
                    enumColors.Next();
                }
                ModuleCommon.ChangeSymbolColor(symbols[i], pColor);
            }
            return(symbols);
        }
Ejemplo n.º 12
0
        private void textBox1_Leave(object sender, System.EventArgs e)
        {
            IColorRamp colorRamp = (IColorRamp)m_styleGalleryItem.Item;

            //Ensure is numeric
            if (IsInteger(textBox1.Text) == false)
            {
                System.Windows.Forms.MessageBox.Show("Must be a numeric!");
                textBox1.Text = "10";
                return;
            }
            else if (Convert.ToInt32(textBox1.Text) <= 0)
            {
                //Ensure is not zero
                System.Windows.Forms.MessageBox.Show("Must be greater than 0!");
                textBox1.Text = "10";
                return;
            }
            else if (Convert.ToInt32(textBox1.Text) > colorRamp.Size)
            {
                //Ensure does not exceed number of colors in color ramp
                System.Windows.Forms.MessageBox.Show("Must be less than " + colorRamp.Size + "!");
                textBox1.Text = "10";
                return;
            }
        }
Ejemplo n.º 13
0
        public static IEnumColors CreateColors(IColorRamp icolorRamp_0, int int_0)
        {
            IEnumColors colors;

            if (icolorRamp_0 != null)
            {
                icolorRamp_0.Size = int_0;
                bool flag = false;
                try
                {
                    icolorRamp_0.CreateRamp(out flag);
                    if (flag)
                    {
                        colors = icolorRamp_0.Colors;
                        return(colors);
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.ToString());
                }
            }
            colors = null;
            return(colors);
        }
Ejemplo n.º 14
0
        private static IStyleGalleryItem GetESRIStyleColorRamp(out IColorRamp pColorRamp, string sColorRampName)
        {
            IStyleGallery        pStyleGallery = new ESRI.ArcGIS.Framework.StyleGalleryClass();
            IStyleGalleryStorage pStyleStorage;

            pStyleStorage = pStyleGallery as IStyleGalleryStorage;
            string pStylePath = pStyleStorage.DefaultStylePath + "ESRI.style";

            pStyleStorage.AddFile(pStylePath);
            ESRI.ArcGIS.esriSystem.IEnumBSTR eESRIRampCategories = pStyleGallery.Categories["Color Ramps"];
            string            sESRIRampCategoryName = eESRIRampCategories.Next();
            IStyleGalleryItem pStyleItem;

            while (!string.IsNullOrEmpty(sESRIRampCategoryName))
            {
                IEnumStyleGalleryItem eESRIColorRamps = pStyleGallery.Items["Color Ramps", pStylePath, sESRIRampCategoryName];
                pStyleItem = eESRIColorRamps.Next();
                while (pStyleItem != null)
                {
                    if (string.Compare(pStyleItem.Name, sColorRampName) == 0)
                    {
                        pColorRamp = (IColorRamp)pStyleItem.Item;
                        return(pStyleItem);
                    }

                    pStyleItem = eESRIColorRamps.Next();
                }

                sESRIRampCategoryName = eESRIRampCategories.Next();
            }

            throw new Exception(string.Format("Cannot find the color ramp with the name '{0}'", sColorRampName));
        }
Ejemplo n.º 15
0
 private void cboBand_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.bool_0 && (this.cboBand.SelectedIndex != -1))
     {
         bool flag;
         IRasterStretchColorRampRenderer renderer = this.irasterStretchColorRampRenderer_0;
         IRasterRenderer renderer2 = (IRasterRenderer)renderer;
         renderer.BandIndex = this.cboBand.SelectedIndex;
         if (this.icolorRamp_0 == null)
         {
             IAlgorithmicColorRamp ramp = new AlgorithmicColorRampClass();
             IColor color = new RgbColorClass();
             (color as IRgbColor).Red   = 255;
             (color as IRgbColor).Red   = 0;
             (color as IRgbColor).Green = 0;
             (color as IRgbColor).Blue  = 0;
             IColor color2 = new RgbColorClass();
             (color2 as IRgbColor).Red   = 255;
             (color2 as IRgbColor).Green = 255;
             (color2 as IRgbColor).Blue  = 255;
             ramp.FromColor    = color;
             ramp.ToColor      = color2;
             this.icolorRamp_0 = ramp;
         }
         this.icolorRamp_0.Size = 255;
         this.icolorRamp_0.CreateRamp(out flag);
         renderer.ColorRamp = this.icolorRamp_0;
         renderer2.Update();
     }
 }
Ejemplo n.º 16
0
        private void RefreshColorRamp()
        {//刷新符号颜色
            if (flag)
            {
                return;
            }
            IColorRamp pColorRamp = (cmbColorRamp.SelectedItem as DevComponents.Editors.ComboItem).Tag as IColorRamp;
            bool       bCreateRamp;

            pColorRamp.Size = levelInput.Value <= 1 ? 2 : levelInput.Value;
            pColorRamp.CreateRamp(out bCreateRamp);
            IEnumColors enumColors = pColorRamp.Colors;

            enumColors.Reset();
            listValueItem.SmallImageList.Images.Clear();
            for (int i = 0; i < listValueItem.Items.Count; i++)
            {
                IColor pColor = enumColors.Next();
                if (pColor == null)
                {
                    enumColors.Reset();
                    enumColors.Next();
                }

                System.Windows.Forms.ListViewItem item = listValueItem.Items[i];
                ModuleCommon.ChangeSymbolColor(item.Tag as ISymbol, pColor);
                listValueItem.SmallImageList.Images.Add(item.Name.Replace("Item", "Symbol"),
                                                        ModuleCommon.Symbol2Picture(item.Tag as ISymbol, ModuleCommon.ImageWidth, ModuleCommon.ImageHeight));
                listValueItem.Items[i].ImageKey = item.Name.Replace("Item", "Symbol");
            }
        }
Ejemplo n.º 17
0
        private void DrawColorRamp()
        {
            string               strDefaultStyleFileName = string.Format("{0}\\CNUStyles\\ESRI.ServerStyle", Application.StartupPath);
            IStyleGallery        styleGallery            = new ServerStyleGalleryClass();
            IStyleGalleryItem    styleGalleryItem        = new ServerStyleGalleryItemClass();
            IStyleGalleryStorage styleGalleryStorage     = styleGallery as IStyleGalleryStorage;

            styleGalleryStorage.AddFile(strDefaultStyleFileName);
            IEnumStyleGalleryItem enumStyleGalleryItem = styleGallery.get_Items("Color Ramps", strDefaultStyleFileName, "");

            enumStyleGalleryItem.Reset();
            styleGalleryItem = enumStyleGalleryItem.Next();
            while (styleGalleryItem != null)
            {
                m_ColorRamp = (IColorRamp)styleGalleryItem.Item;
                EnumStyleItem.Add(m_ColorRamp);
                //新建m_FillSymbol和m_colorRamp
                m_FillSymbol = new GradientFillSymbol();
                m_FillSymbol.GradientPercentage = 1;
                m_FillSymbol.IntervalCount      = 255;
                m_FillSymbol.GradientAngle      = 0;
                m_FillSymbol.ColorRamp          = m_ColorRamp;
                pictureBox1.Image = SymbolToBitmap(m_FillSymbol, 0, pictureBox1.Width, pictureBox1.Height);
                pictureBox2.Image = SymbolToBitmap(m_FillSymbol, 0, pictureBox1.Width, pictureBox1.Height);
                imageList1.Images.Add(m_ColorRamp.Name, pictureBox1.Image);
                imageList2.Images.Add(m_ColorRamp.Name, pictureBox1.Image);
                colorComboBox.Items.Add(pictureBox1.Image);
                colorComboBox1.Items.Add(pictureBox2.Image);
                styleGalleryItem = enumStyleGalleryItem.Next();
            }
        }
Ejemplo n.º 18
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (tabControl1.SelectedIndex == 0)
     {
         try
         {
             ChangeRender2RasterStretchColorRampRender(rasterlayer);
             axmapcontrol.Refresh();
             axtoccontrol.Update();
             axmapcontrol.Extent = rasterlayer.AreaOfInterest;
         }
         catch (Exception ec)
         {
             MessageBox.Show(ec.Message);
         }
     }
     else
     {
         try
         {
             IColorRamp pColorRamp = (IColorRamp)EnumStyleItem[colorComboBox1.SelectedIndex];
             RasterClassify(rasterlayer, cmbClassifyMethod.Text, Convert.ToInt32(nudClassCount.Text), pColorRamp);
             //ChangeRender2ClassifyColorRampRenderer(rasterlayer, Convert.ToInt32(nudClassCount.Text), pColorRamp);
             axmapcontrol.Refresh();
             axtoccontrol.Update();
             axmapcontrol.Extent = rasterlayer.AreaOfInterest;
         }
         catch (Exception ec)
         {
             MessageBox.Show(ec.Message);
         }
     }
 }
Ejemplo n.º 19
0
        private void button2_Click(object sender, EventArgs e)
        {
            ColorRampForm colorRampForm = new ColorRampForm();

            colorRampForm.ShowDialog();
            colorRamp = colorRampForm.m_styleGalleryItem.Item as IColorRamp;
            colorRampForm.Dispose();
        }
Ejemplo n.º 20
0
 private IEnumColors method_1(IColorRamp icolorRamp_1, int int_1)
 {
     if (icolorRamp_1 == null)
     {
         icolorRamp_1 = this.MakeNewRamp();
     }
     return(ColorManage.CreateColors(icolorRamp_1, int_1));
 }
Ejemplo n.º 21
0
 private void StatisticsSymbols_Load(object sender, EventArgs e)
 {
     CbxLayersAddItems();
     colorRamp   = GetColorRamp(10);
     gEnumColors = colorRamp.Colors;
     gEnumColors.Reset();
     lvRendererFields.View = View.List;
 }
Ejemplo n.º 22
0
 public ClassifyRender(IFeatureLayer Layer, string FiledName, IColorRamp ramp, int count, string classname)
 {
     this.Layer     = Layer;
     this.FiledName = FiledName;
     this.ramp      = ramp;
     this.count     = count;
     this.classname = classname;
 }
        //.................................................
        //.................................................
        //.................................................
        private void AssignColorRamp(string fieldname, List <RiskRankingRange> pRiskRankingRanges)
        {
            // Get Statistics Values for the Selected Field
            GetRankingStatistics(fieldname);
            if (_minriskvalue >= _maxriskvalue)
            {
                return;
            }
            if (pRiskRankingRanges.Count == 0)
            {
                return;
            }
            if (m_styleGalleryItem == null)
            {
                return;
            }
            if (m_featureLayer == null)
            {
                return;
            }
            m_classBreaksRenderer.Field        = fieldname;
            m_classBreaksRenderer.BreakCount   = pRiskRankingRanges.Count;
            m_classBreaksRenderer.MinimumBreak = 0;

            //Calculate the class interval by a simple mean value
            double interval = (_maxriskvalue - _minriskvalue) / pRiskRankingRanges.Count;

            //Get the color ramp
            IColorRamp colorRamp = (IColorRamp)m_styleGalleryItem.Item;

            //Set the size of the color ramp and recreate it
            colorRamp.Size = Convert.ToInt32(pRiskRankingRanges.Count);
            bool createRamp;

            colorRamp.CreateRamp(out createRamp);

            //Get the enumeration of colors from the color ramp
            IEnumColors enumColors = colorRamp.Colors;

            enumColors.Reset();
            double currentBreak = m_classBreaksRenderer.MinimumBreak;

            ISimpleLineSymbol simpleLineSymbol;

            //Loop through each class break
            for (int i = 0; i <= pRiskRankingRanges.Count - 1; i++)
            {
                //Set class break
                m_classBreaksRenderer.set_Break(i, currentBreak);
                //Create simple fill symbol and set color
                simpleLineSymbol       = new SimpleLineSymbolClass();
                simpleLineSymbol.Color = enumColors.Next();
                //Add symbol to renderer
                m_classBreaksRenderer.set_Symbol(i, (ISymbol)simpleLineSymbol);
                currentBreak += interval;
            }
        }
Ejemplo n.º 24
0
        private void RasterClassifiedRenderPage_Load(object sender, EventArgs e)
        {
            int num = -1;

            if (this.irasterClassifyColorRampRenderer_0 != null)
            {
                string colorRamp = (this.irasterClassifyColorRampRenderer_0 as IRasterClassifyUIProperties).ColorRamp;
                if (this.istyleGallery_0 != null)
                {
                    IEnumStyleGalleryItem item = this.istyleGallery_0.get_Items("Color Ramps", "", "");
                    item.Reset();
                    for (IStyleGalleryItem item2 = item.Next(); item2 != null; item2 = item.Next())
                    {
                        this.cboColorRamp.Add(item2);
                        if (item2.Name == colorRamp)
                        {
                            num = this.cboColorRamp.Items.Count - 1;
                        }
                    }
                    item = null;
                    GC.Collect();
                }
                if (this.cboColorRamp.Items.Count == 0)
                {
                    this.cboColorRamp.Enabled = false;
                    IRandomColorRamp ramp = new RandomColorRampClass
                    {
                        StartHue      = 40,
                        EndHue        = 120,
                        MinValue      = 65,
                        MaxValue      = 90,
                        MinSaturation = 25,
                        MaxSaturation = 45,
                        Size          = 5,
                        Seed          = 23
                    };
                    this.icolorRamp_0 = ramp;
                }
                else
                {
                    this.cboColorRamp.SelectedIndex = num;
                    if (this.cboColorRamp.SelectedIndex == -1)
                    {
                        this.cboColorRamp.SelectedIndex = 0;
                    }
                    this.icolorRamp_0 = this.cboColorRamp.GetSelectStyleGalleryItem().Item as IColorRamp;
                    (this.irasterClassifyColorRampRenderer_0 as IRasterClassifyUIProperties).ColorRamp =
                        this.cboColorRamp.Text;
                }
                if (this.irasterLayer_0 != null)
                {
                    this.method_1();
                }
                this.bool_0 = true;
            }
        }
Ejemplo n.º 25
0
        public static bool UniqueValueRenderer(IColorRamp colorRamp, IRasterLayer rasterLayer, string renderfiled = "Value")
        {
            try
            {
                IRasterUniqueValueRenderer uniqueValueRenderer = new RasterUniqueValueRendererClass();
                IRasterRenderer            pRasterRenderer     = uniqueValueRenderer as IRasterRenderer;
                pRasterRenderer.Raster = rasterLayer.Raster;
                pRasterRenderer.Update();
                IUniqueValues           uniqueValues     = new UniqueValuesClass();
                IRasterCalcUniqueValues calcUniqueValues = new RasterCalcUniqueValuesClass();
                calcUniqueValues.AddFromRaster(rasterLayer.Raster, 0, uniqueValues);//iBand=0
                IRasterRendererUniqueValues renderUniqueValues = uniqueValueRenderer as IRasterRendererUniqueValues;
                renderUniqueValues.UniqueValues = uniqueValues;
                uniqueValueRenderer.Field       = renderfiled;
                colorRamp.Size = uniqueValues.Count;

                uniqueValueRenderer.HeadingCount = 1;
                uniqueValueRenderer.set_Heading(0, "All Data Value");
                uniqueValueRenderer.set_ClassCount(0, uniqueValues.Count);
                bool pOk;
                colorRamp.CreateRamp(out pOk);
                IRasterRendererColorRamp pRasterRendererColorRamp = uniqueValueRenderer as IRasterRendererColorRamp;
                pRasterRendererColorRamp.ColorRamp = colorRamp;
                for (int i = 0; i < uniqueValues.Count; i++)
                {
                    uniqueValueRenderer.AddValue(0, i, uniqueValues.get_UniqueValue(i));
                    uniqueValueRenderer.set_Label(0, i, uniqueValues.get_UniqueValue(i).ToString());
                    IFillSymbol fs = new SimpleFillSymbol();
                    //fs.Color = colorRamp.get_Color(i);
                    IColor color = new RgbColorClass();
                    if ((Convert.ToByte(uniqueValues.get_UniqueValue(i)) == 255) || (Convert.ToByte(uniqueValues.get_UniqueValue(i)) == 0))
                    {
                        color.NullColor    = true;
                        color.Transparency = 0;
                        fs.Color           = color;
                    }
                    else
                    {
                        IRgbColor rgbColor = color as IRgbColor;
                        rgbColor.Red   = 0;
                        rgbColor.Green = 255;
                        rgbColor.Blue  = 0;
                        fs.Color       = rgbColor as IColor;
                    }
                    uniqueValueRenderer.set_Symbol(0, i, fs as ISymbol);
                }
                pRasterRenderer.Update();
                rasterLayer.Renderer = pRasterRenderer;
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 获取符号颜色数组
        /// </summary>
        /// <param name="ColorRamp"></param>
        /// <returns></returns>
        public static IList <string> GimmeArrayListForColorRamp(IColorRamp ColorRamp)
        {
            IEnumColors    EColors = ColorRamp.Colors;
            IList <string> AL      = new List <string>();

            for (int i = 0; i <= ColorRamp.Size - 1; i++)
            {
                AL.Add(GimmeStringForColor(EColors.Next()));
            }
            return(AL);
        }
Ejemplo n.º 27
0
 private void method_4(IColorRamp icolorRamp_1,
                       IRasterClassifyColorRampRenderer irasterClassifyColorRampRenderer_1, int int_0, ITable itable_0,
                       string string_0, string string_1)
 {
     try
     {
         bool flag;
         if (string_0.Length > 0)
         {
             irasterClassifyColorRampRenderer_1.ClassField = string_0;
         }
         if (string_1.Length > 0)
         {
             irasterClassifyColorRampRenderer_1.NormField = string_1;
         }
         IRasterRenderer renderer = (IRasterRenderer)irasterClassifyColorRampRenderer_1;
         renderer.Raster = this.irasterLayer_0.Raster;
         irasterClassifyColorRampRenderer_1.ClassCount = int_0;
         renderer.Update();
         this.bool_0 = false;
         this.cboClassifyNum.SelectedIndex = irasterClassifyColorRampRenderer_1.ClassCount - 1;
         this.bool_0       = true;
         icolorRamp_1.Size = irasterClassifyColorRampRenderer_1.ClassCount;
         icolorRamp_1.CreateRamp(out flag);
         IEnumColors colors = icolorRamp_1.Colors;
         ISymbol     symbol = null;
         for (int i = 0; i < irasterClassifyColorRampRenderer_1.ClassCount; i++)
         {
             string            str;
             IColor            color   = colors.Next();
             ISimpleFillSymbol symbol2 = new SimpleFillSymbolClass
             {
                 Color = color,
                 Style = esriSimpleFillStyle.esriSFSSolid
             };
             symbol = symbol2 as ISymbol;
             irasterClassifyColorRampRenderer_1.set_Symbol(i, symbol);
             if (i == (irasterClassifyColorRampRenderer_1.ClassCount - 1))
             {
                 str = irasterClassifyColorRampRenderer_1.get_Break(i).ToString("0.####");
             }
             else
             {
                 str = irasterClassifyColorRampRenderer_1.get_Break(i).ToString("0.####") + " - " +
                       irasterClassifyColorRampRenderer_1.get_Break(i + 1).ToString("0.####");
             }
             irasterClassifyColorRampRenderer_1.set_Label(i, str);
         }
     }
     catch (Exception exception)
     {
         Logger.Current.Error("", exception, "");
     }
 }
Ejemplo n.º 28
0
 private void btnClassBreaksColorRamp_Click(object sender, EventArgs e)
 {
     if (this.newColorRanmpSelectorFrm == null)
     {
         this.newColorRanmpSelectorFrm = new ColorRampSelectorFrm();
     }
     if (this.newColorRanmpSelectorFrm.ShowDialog() == DialogResult.OK)
     {
         this.pClassBreaksColorRamp = this.newColorRanmpSelectorFrm.pColorRamp;
         this.btnClassBreaksColorRamp.BackgroundImage = this.newColorRanmpSelectorFrm.pColorRampImage;
     }
 }
Ejemplo n.º 29
0
 private void btnClassBreaksColorRamp_Click(object sender, EventArgs e)
 {
     if (this.newColorRanmpSelectorFrm == null)
     {
         this.newColorRanmpSelectorFrm = new ColorRampSelectorFrm();
     }
     if (this.newColorRanmpSelectorFrm.ShowDialog() == DialogResult.OK)
     {
         this.pClassBreaksColorRamp = this.newColorRanmpSelectorFrm.pColorRamp;
         this.btnClassBreaksColorRamp.BackgroundImage = this.newColorRanmpSelectorFrm.pColorRampImage;
     }
 }
Ejemplo n.º 30
0
        private void ClassBreaksRendererCtrl_Load(object sender, EventArgs e)
        {
            this.method_1();
            int    num       = -1;
            string colorRamp = (this.iclassBreaksRenderer_0 as IClassBreaksUIProperties).ColorRamp;

            if (this.istyleGallery_0 != null)
            {
                IEnumStyleGalleryItem item = this.istyleGallery_0.get_Items("Color Ramps", "", "");
                item.Reset();
                for (IStyleGalleryItem item2 = item.Next(); item2 != null; item2 = item.Next())
                {
                    this.colorRampComboBox1.Add(item2);
                    if (item2.Name == colorRamp)
                    {
                        num = this.colorRampComboBox1.Items.Count - 1;
                    }
                }
                item = null;
                GC.Collect();
            }
            if (this.colorRampComboBox1.Items.Count == 0)
            {
                this.colorRampComboBox1.Enabled = false;
                IRandomColorRamp ramp = new RandomColorRampClass
                {
                    StartHue      = 40,
                    EndHue        = 120,
                    MinValue      = 65,
                    MaxValue      = 90,
                    MinSaturation = 25,
                    MaxSaturation = 45,
                    Size          = 5,
                    Seed          = 23
                };
                this.icolorRamp_0 = ramp;
            }
            else
            {
                this.colorRampComboBox1.SelectedIndex = num;
                if (this.colorRampComboBox1.SelectedIndex == -1)
                {
                    this.colorRampComboBox1.SelectedIndex = 0;
                }
                this.icolorRamp_0 = this.colorRampComboBox1.GetSelectColorRamp();
                (this.iclassBreaksRenderer_0 as IClassBreaksUIProperties).ColorRamp = this.colorRampComboBox1.Text;
            }
            if (this.igeoFeatureLayer_0 != null)
            {
                this.method_0();
            }
            this.bool_0 = true;
        }
        private void btnSelectColorRamp_Click(object sender, EventArgs e)
        {
            //GetSymbolByControl colorRampForm = new GetSymbolByControl(esriSymbologyStyleClass.esriStyleClassColorRamps);
            //colorRampForm.ShowDialog();   //08.04.09
            //if (colorRampForm.m_styleGalleryItem != null)
            //    colorRamp = colorRampForm.m_styleGalleryItem.Item as IColorRamp;

            //colorRampForm.Dispose();

            ColorRampForm colorRampform = new ColorRampForm();
            colorRampform.ShowDialog();
            colorRamp = colorRampform.m_styleGalleryItem.Item as IColorRamp;
            colorRampform.Dispose();
        }
Ejemplo n.º 32
0
        private void btnSelectColorRamp_Click(object sender, EventArgs e)
        {
            GetSymbol symbolForm = new GetSymbol(esriSymbologyStyleClass.esriStyleClassColorRamps);

            symbolForm.ShowDialog();
            IStyleGalleryItem styleGalleryItem = symbolForm.m_styleGalleryItem;

            if (styleGalleryItem == null)
            {
                return;
            }
            colorRamp = styleGalleryItem.Item as IColorRamp;
            symbolForm.Dispose();
        }
Ejemplo n.º 33
0
        public static IRasterRenderer CreateClassifyRenderer(GCDConsoleLib.Raster gRaster, int iClassCount, string sColorRampName, bool bInvert = false)
        {
            // Open file raster dataset and ensure that statistics and histograms are present (absence of histograms will cause Renderer.Update() to crash)
            IRasterDataset rasterDataset = ArcMapUtilities.GetRasterDataset(gRaster);

            ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection pRastBands     = (ESRI.ArcGIS.DataSourcesRaster.IRasterBandCollection)rasterDataset;
            ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand       enumRasterBand = (ESRI.ArcGIS.DataSourcesRaster.IEnumRasterBand)pRastBands.Bands;
            rasterDataset.PrecalculateStats(0);
            ESRI.ArcGIS.DataSourcesRaster.IRasterBand pRastBand = enumRasterBand.Next();
            pRastBand.ComputeStatsAndHist();

            gRaster.ComputeStatistics();
            decimal maxValue = gRaster.GetStatistics()["max"];

            IRasterClassifyColorRampRenderer classifyRenderer = new RasterClassifyColorRampRendererClass();
            IRasterRenderer rasterRenderer = (IRasterRenderer)classifyRenderer;
            IFillSymbol     fillSymbol     = new SimpleFillSymbol();
            IRaster         raster         = rasterDataset.CreateDefaultRaster();

            rasterRenderer.Raster = raster;
            IColorRamp        pColorRamp = null;
            IStyleGalleryItem pStyleItem = GetESRIStyleColorRamp(out pColorRamp, sColorRampName);

            classifyRenderer.ClassCount = iClassCount;
            rasterRenderer.Update();
            CreateClassBreaks((double)maxValue, iClassCount, classifyRenderer);
            pColorRamp.Size = iClassCount;
            bool bSucess = true;

            pColorRamp.CreateRamp(out bSucess);
            List <IColor> lColors = new List <IColor>();

            for (int i = 0; i < classifyRenderer.ClassCount; i++)
            {
                lColors.Add(pColorRamp.Color[i]);
            }

            if (bInvert)
            {
                lColors.Reverse();
            }

            for (int i = 0; i < classifyRenderer.ClassCount; i++)
            {
                fillSymbol.Color           = lColors[i];
                classifyRenderer.Symbol[i] = (ISymbol)fillSymbol;
            }

            return(rasterRenderer);
        }
Ejemplo n.º 34
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     this.pColorRamp = (IColorRamp)this.pStyleGalleryItem.Item;
     this.pColorRampImage = this.ptbPreview.Image;
 }
Ejemplo n.º 35
0
        public void RasterClassify(IRasterLayer rastlayer, string classMethod, int count, IColorRamp ramp)
        {
            IRasterBand band = GetBand(rastlayer);
            if (band.Histogram == null)
            {
                band.ComputeStatsAndHist();
            }
            IRasterClassifyColorRampRenderer rasClassifyRender = new RasterClassifyColorRampRendererClass();
            IRasterRenderer rasRender = rasClassifyRender as IRasterRenderer;
            rasRender.Raster = rastlayer.Raster;
            rasRender.Update();

            int numClasses = count;
            IRasterHistogram pRasterHistogram = band.Histogram;
            double[] dblValues = pRasterHistogram.Counts as double[];
            int intValueCount = dblValues.GetUpperBound(0) + 1;
            double[] vValues = new double[intValueCount];
            IRasterStatistics pRasterStatistic = band.Statistics;
            double dMaxValue = pRasterStatistic.Maximum;
            double dMinValue = pRasterStatistic.Minimum;
            if (dMinValue == 0)
            {
                pRasterStatistic.IgnoredValues = pRasterStatistic.Minimum;
                pRasterStatistic.Recalculate();
                dMinValue = pRasterStatistic.Minimum;
            }
            double BinInterval = Convert.ToDouble((dMaxValue - dMinValue) / intValueCount);
            for (int i = 0; i < intValueCount; i++)
            {
                vValues[i] = i * BinInterval + pRasterStatistic.Minimum;
            }
            long[] longvalues = new long[dblValues.Length];
            for (int i = 0; i <= dblValues.Length - 1; i++)
            {
                longvalues[i] = long.Parse(Convert.ToString(dblValues[i]));
            }
            //IClassifyGEN classify = null;
            IClassify classify = null;
            switch (classMethod)
            {
                case "等间距分级":
                    EqualInterval eqclassify = new EqualIntervalClass();
                    eqclassify.Classify(vValues, longvalues, ref numClasses);
                    classify = eqclassify as IClassify;
                    break;
                case "自然断点分级":
                    NaturalBreaks naclassify = new NaturalBreaksClass();
                    naclassify.Classify(vValues, longvalues, ref numClasses);
                    classify = naclassify as IClassify;
                    break;
            }
            //switch (classMethod)
            //{
            //    case "等间距分级":
            //        classify = new EqualIntervalClass();
            //        break;
            //    case "自然断点分级":
            //        classify = new NaturalBreaksClass();
            //        break;
            //}
            //classify.Classify(vValues, longvalues, ref numClasses);
            double[] Classes = classify.ClassBreaks as double[];
            UID pUid = classify.ClassID;
            IRasterClassifyUIProperties rasClassifyUI = rasClassifyRender as IRasterClassifyUIProperties;
            rasClassifyUI.ClassificationMethod = pUid;
            rasClassifyRender.ClassCount = count;
            IColor pColor;
            ISimpleFillSymbol pSym;
            for (int j = 0; j < count; j++)
            {
                IRasterProps rasterProps = (IRasterProps)rastlayer.Raster;
                rasterProps.NoDataValue = 0;
                pColor = ramp.get_Color(j * (ramp.Size / count));
                pSym = new SimpleFillSymbolClass();
                pSym.Color = pColor;
                rasClassifyRender.set_Symbol(j, (ISymbol)pSym);
                rasRender.Update();
                rasClassifyRender.set_Break(j,rasClassifyRender.get_Break(j));
                rasClassifyRender.set_Label(j, Classes[j].ToString("0.000") + "-" + Classes[j + 1].ToString("0.000"));
                rasRender.Update();
            }
            rastlayer.Renderer = rasClassifyRender as IRasterRenderer;
        }
Ejemplo n.º 36
0
        //public void RasterClassify(IRasterLayer rastlayer, string classMethod, int count, IColorRamp ramp,double minValue)
        //{
        //    IRasterBand band = GetBand(rastlayer);
        //    if (band.Histogram == null)
        //    {
        //        band.ComputeStatsAndHist();
        //    }
        //    IRasterClassifyColorRampRenderer rasClassifyRender = new RasterClassifyColorRampRendererClass();
        //    IRasterRenderer rasRender = rasClassifyRender as IRasterRenderer;
        //    rasRender.Raster = rastlayer.Raster;
        //    rasRender.Update();
        //    int numClasses = count;
        //    IRasterHistogram pRasterHistogram = band.Histogram;
        //    double[] dblValues = pRasterHistogram.Counts as double[];
        //    int intValueCount = dblValues.GetUpperBound(0) + 1;
        //    double[] vValues = new double[intValueCount];
        //    IRasterStatistics pRasterStatistic = band.Statistics;
        //    //double dMaxValue = pRasterStatistic.Maximum;
        //    double dMaxValue = minValue;
        //    double dMinValue = pRasterStatistic.Minimum;
        //    double BinInterval = Convert.ToDouble((dMaxValue - dMinValue) / intValueCount);
        //    for (int i = 0; i < intValueCount; i++)
        //    {
        //        vValues[i] = i * BinInterval + pRasterStatistic.Minimum;
        //    }
        //    long[] longvalues = new long[dblValues.Length];
        //    for (int i = 0; i <= dblValues.Length - 1; i++)
        //    {
        //        longvalues[i] = long.Parse(Convert.ToString(dblValues[i]));
        //    }
        //    //IClassifyGEN classify = null;
        //    IClassify classify = null;
        //    switch (classMethod)
        //    {
        //        case "等间距分级":
        //            EqualInterval eqclassify = new EqualIntervalClass();
        //            eqclassify.Classify(vValues, longvalues, ref numClasses);
        //            classify = eqclassify as IClassify;
        //            break;
        //        case "自然断点分级":
        //            NaturalBreaks naclassify = new NaturalBreaksClass();
        //            naclassify.Classify(vValues, longvalues, ref numClasses);
        //            classify = naclassify as IClassify;
        //            break;
        //    }
        //    //switch (classMethod)
        //    //{
        //    //    case "等间距分级":
        //    //        classify = new EqualIntervalClass();
        //    //        break;
        //    //    case "自然断点分级":
        //    //        classify = new NaturalBreaksClass();
        //    //        break;
        //    //}
        //    //classify.Classify(vValues, longvalues, ref numClasses);
        //    double[] Classes = classify.ClassBreaks as double[];
        //    UID pUid = classify.ClassID;
        //    IRasterClassifyUIProperties rasClassifyUI = rasClassifyRender as IRasterClassifyUIProperties;
        //    rasClassifyUI.ClassificationMethod = pUid;
        //    rasClassifyRender.ClassCount = count;
        //    IColor pColor;
        //    ISimpleFillSymbol pSym;
        //    for (int j = 0; j < count; j++)
        //    {
        //        pColor = ramp.get_Color(j * (ramp.Size / count));
        //        pSym = new SimpleFillSymbolClass();
        //        pSym.Color = pColor;
        //        rasClassifyRender.set_Symbol(j, (ISymbol)pSym);
        //        rasRender.Update();
        //        if (Classes[j] == 0)
        //        {
        //            rasClassifyRender.set_Label(j, Classes[j].ToString() + "-" + Classes[j + 1].ToString("0.000"));
        //            rasRender.Update();
        //        }
        //        else
        //        {
        //            rasClassifyRender.set_Label(j, Classes[j].ToString("0.000") + "-" + Classes[j + 1].ToString("0.000"));
        //            rasRender.Update();
        //        }
        //    }
        //    rastlayer.Renderer = rasClassifyRender as IRasterRenderer;
        public void RasterClassify(IRasterLayer rastlayer, string classMethod, int count, IColorRamp ramp)
        {
            try
            {  //进行唯一值判断
                IUniqueValues values = new UniqueValuesClass();
                IRasterCalcUniqueValues unique = new RasterCalcUniqueValuesClass();
                unique.AddFromRaster(rastlayer.Raster, 0, values);
                int uniquecount = values.get_UniqueCount(0);
                //计算统计图
                IRasterBand band = GetBand(rastlayer);
                if (band.Histogram == null)
                {
                    band.ComputeStatsAndHist();
                }
                IRasterClassifyColorRampRenderer rasClassifyRender = new RasterClassifyColorRampRendererClass();
                IRasterRenderer rasRender = rasClassifyRender as IRasterRenderer;
                rasRender.Raster = rastlayer.Raster;
                rasRender.Update();

                int numClasses = count;
                IRasterHistogram pRasterHistogram = band.Histogram;
                double[] dblValues = pRasterHistogram.Counts as double[];
                int intValueCount = dblValues.GetUpperBound(0) + 1;
                double[] vValues = new double[intValueCount];
                IRasterStatistics pRasterStatistic = band.Statistics;
                double dMaxValue = pRasterStatistic.Maximum;
                double dMinValue = pRasterStatistic.Minimum;
                if (dMinValue == 0)
                {
                    pRasterStatistic.IgnoredValues = pRasterStatistic.Minimum;
                    pRasterStatistic.Recalculate();
                    dMinValue = pRasterStatistic.Minimum;
                }
                double BinInterval = Convert.ToDouble((dMaxValue - dMinValue) / intValueCount);
                for (int i = 0; i < intValueCount; i++)
                {
                    vValues[i] = i * BinInterval + pRasterStatistic.Minimum;
                }
                long[] longvalues = new long[dblValues.Length];
                for (int i = 0; i <= dblValues.Length - 1; i++)
                {
                    longvalues[i] = long.Parse(Convert.ToString(dblValues[i]));
                }
                //IClassifyGEN classify = null;
                IClassify classify = null;
                switch (classMethod)
                {
                    case "等间距分级":
                        EqualInterval eqclassify = new EqualIntervalClass();
                        eqclassify.Classify(vValues, longvalues, ref numClasses);
                        classify = eqclassify as IClassify;
                        break;
                    case "自然断点分级":
                        NaturalBreaks naclassify = new NaturalBreaksClass();
                        naclassify.Classify(vValues, longvalues, ref numClasses);
                        classify = naclassify as IClassify;
                        break;
                }
                #region
                //switch (classMethod)
                //{
                //    case "等间距分级":
                //        classify = new EqualIntervalClass();
                //        break;
                //    case "自然断点分级":
                //        classify = new NaturalBreaksClass();
                //        break;
                //}
                //classify.Classify(vValues, longvalues, ref numClasses);
                #endregion
                double[] Classes = classify.ClassBreaks as double[];
                UID pUid = classify.ClassID;
                IRasterClassifyUIProperties rasClassifyUI = rasClassifyRender as IRasterClassifyUIProperties;
                rasClassifyUI.ClassificationMethod = pUid;
                rasClassifyRender.ClassCount = count;
                IColor pColor;
                ISimpleFillSymbol pSym;
                //排除数值
                double[] exdouble = new double[2] { 0, Classes[0] };
                IRasterDataExclusion ex = rasClassifyRender as IRasterDataExclusion;
                ex.ExcludeValues = exdouble;
                ex.ExcludeColor = GET(255, 255, 255);
                for (int j = 0; j < count; j++)
                {
                    pColor = ramp.get_Color(j * (ramp.Size / count));
                    pSym = new SimpleFillSymbolClass();
                    pSym.Color = pColor;
                    rasClassifyRender.set_Symbol(j, (ISymbol)pSym);
                    rasRender.Update();
                    rasClassifyRender.set_Break(j, rasClassifyRender.get_Break(j));
                    rasClassifyRender.set_Label(j, Classes[j].ToString("0.000") + "-" + Classes[j + 1].ToString("0.000"));
                    rasRender.Update();
                }

                //IRasterProps rasterProps = (IRasterProps)rastlayer.Raster;
                //rasterProps.NoDataValue = 0;
                //IRasterDisplayProps props = rasClassifyRender as IRasterDisplayProps;
                //props.NoDataColor = GET(255, 255, 255);
                //rasRender.Update();
                rastlayer.Renderer = rasClassifyRender as IRasterRenderer;
            }
            catch(Exception ex)
            {
                //MessageBox.Show(ex.ToString());
                if (ex.ToString().Contains("唯一值过多"))
                {
                    MessageBox.Show("唯一值数量已达到限制(65536)");
                }
                else
                {
                    MessageBox.Show("还未计算唯一值,进行唯一值计算!");
                }
            }

            //catch
            //{
            //    MessageBox.Show("数据需要先计算统计值,请点击确定进行计算!");
            //}
        }
Ejemplo n.º 37
0
 private void btnSelectColorRamp_Click(object sender, EventArgs e)
 {
     ColorRampForm colorRampForm = new ColorRampForm();
     colorRampForm.ShowDialog();
     colorRamp = colorRampForm.m_styleGalleryItem.Item as IColorRamp;
     colorRampForm.Dispose();
     if (colorRamp == null) return;
     gEnumColors = colorRamp.Colors;
     gEnumColors.Reset();
 }
Ejemplo n.º 38
0
 private void StatisticsSymbols_Load(object sender, EventArgs e)
 {
     CbxLayersAddItems();
     colorRamp = GetColorRamp(10);
     gEnumColors = colorRamp.Colors;
     gEnumColors.Reset();
     lvRendererFields.View = View.List;
 }