コード例 #1
0
        public ColorPicker(MapWinGIS.GridColorBreak colorBreak)
        {
            InitializeComponent();

            btnStartColor.BackColor = ColorScheme.UIntToColor(colorBreak.LowColor);
            btnEndColor.BackColor   = ColorScheme.UIntToColor(colorBreak.HighColor);

            m_SFBreak  = null;
            m_GrdBreak = colorBreak;
        }
コード例 #2
0
        public ColorPicker(System.Drawing.Color startc, System.Drawing.Color endc)
        {
            InitializeComponent();

            m_GrdBreak = null;
            m_SFBreak  = null;

            btnStartColor.BackColor = startc;
            btnEndColor.BackColor   = endc;

            UpdatePreview();
        }
コード例 #3
0
        private void btnQuant_Click(object sender, EventArgs e)
        {
            //Create a new instance for MapWinGIS.Table
            MapWinGIS.Table myTable = new MapWinGIS.Table();
            //Define the data source of Table instance
            myTable.Open(@"D:\GISSampleData2\arabcntry.dbf", null);
            //Define the index of the field will used in symbology
            int myFieldIndex = 1;
            //Get the number of rows in the table
            int numberOfRows = myTable.NumRows;

            //Create an array to store the cell values of the field
            double[] myCellsValues = new double[numberOfRows];
            //Populate the array with cell values restored from the Table instance
            for (int i = 0; i < numberOfRows - 1; i++)
            {
                myCellsValues[i] =
                    System.Convert.ToDouble(myTable.get_CellValue(1, i));
            }
            //Get the minimum and maximum values
            double minValue = myCellsValues.Min();
            double maxValue = myCellsValues.Max();

            //Create a new instance for MapWinGIS.ShapefileColorScheme
            MapWinGIS.ShapefileColorScheme myScheme = new MapWinGIS.ShapefileColorScheme();
            //Set the layer handler to the MapWinGIS.ShapefileColorScheme instance
            myScheme.LayerHandle = intHandler;
            //Set the field index to use in symbology
            myScheme.FieldIndex = myFieldIndex;
            //Create a new instance for MapWinGIS.ShapefileColorBreak
            MapWinGIS.ShapefileColorBreak myBreak = new MapWinGIS.ShapefileColorBreak();
            //Set the minimum value in the field as a start value
            myBreak.StartValue = minValue;
            //Set the start color of the scheme
            myBreak.StartColor =
                (UInt32)(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Aqua));
            //Set the maximum value in the field as an end value
            myBreak.EndValue = maxValue;
            //Set the end color of the sceme
            myBreak.EndColor =
                (UInt32)(System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.DarkBlue));
            //Add the break to the color scheme
            myScheme.Add(myBreak);
            //Upgrade display using the scheme
            axMap1.ApplyLegendColors(myScheme);
        }
コード例 #4
0
        private static bool ImportScheme(MapWinGIS.ShapefileColorScheme sch, MapWinGIS.Shapefile sf, XmlElement e)
        {
            string FldName;
            int    i;

            MapWinGIS.ShapefileColorBreak brk;
            XmlNode n;
            bool    foundField = false;

            if (e == null)
            {
                return(false);
            }

            FldName = e.Attributes["FieldName"].InnerText;
            for (i = 0; i < sf.NumFields; i++)
            {
                if (sf.Field[i].Name.ToLower() == FldName.ToLower())
                {
                    sch.FieldIndex = i;
                    foundField     = true;
                    break;
                }
            }
            if (!foundField)
            {
                MapWinGIS.Utility.Logger.Message("无法找到 field \'" + FldName + "\'  无法导入coloring scheme.");
                return(false);
            }
            sch.Key = e.Attributes["Key"].InnerText;

            for (i = 0; i < e.ChildNodes.Count; i++)
            {
                n              = e.ChildNodes[i];
                brk            = new MapWinGIS.ShapefileColorBreak();
                brk.Caption    = n.Attributes["Caption"].InnerText;
                brk.StartColor = ColorScheme.ColorToUInt(Color.FromArgb(System.Convert.ToInt32(n.Attributes["StartColor"].InnerText)));
                brk.EndColor   = ColorScheme.ColorToUInt(Color.FromArgb(System.Convert.ToInt32(n.Attributes["EndColor"].InnerText)));
                brk.StartValue = n.Attributes["StartValue"].InnerText;
                brk.EndValue   = n.Attributes["EndValue"].InnerText;
                sch.Add(brk);
            }
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// 从mwsr中取得每个shape的颜色设置,并应用到图层中
        /// </summary>
        private void LoadShpFileColoringScheme(XmlElement legend, int handle)
        {
            MapWinGIS.ShapefileColorScheme shpscheme = new MapWinGIS.ShapefileColorScheme();
            int numOfBreaks;

            MapWinGIS.ShapefileColorBreak _break;
            int i;

            try
            {
                //设置ShapefileColorScheme
                shpscheme.FieldIndex  = int.Parse(legend.Attributes["FieldIndex"].InnerText);
                shpscheme.LayerHandle = handle;
                shpscheme.Key         = legend.Attributes["Key"].InnerText;

                try
                {
                    Program.frmMain.Legend.Layers.ItemByHandle(handle).ColorSchemeFieldCaption = legend.Attributes["SchemeCaption"].InnerText;
                }
                catch
                {
                }

                //设置所有的breaks
                numOfBreaks = legend["ColorBreaks"].ChildNodes.Count;
                for (i = 0; i < numOfBreaks; i++)
                {
                    object with_1 = legend["ColorBreaks"].ChildNodes[i];
                    _break            = new MapWinGIS.ShapefileColorBreak();
                    _break.Caption    = legend["ColorBreaks"].ChildNodes[i].Attributes["Caption"].InnerText;
                    _break.StartColor = System.Convert.ToUInt32(legend["ColorBreaks"].ChildNodes[i].Attributes["StartColor"].InnerText);
                    _break.EndColor   = System.Convert.ToUInt32(legend["ColorBreaks"].ChildNodes[i].Attributes["EndColor"].InnerText);
                    if (legend["ColorBreaks"].ChildNodes[i].Attributes["StartValue"].InnerText == "(null)")
                    {
                        _break.StartValue = null;
                    }
                    else
                    {
                        _break.StartValue = legend["ColorBreaks"].ChildNodes[i].Attributes["StartValue"].InnerText;
                    }

                    if (legend["ColorBreaks"].ChildNodes[i].Attributes["EndValue"].InnerText == "(null)")
                    {
                        _break.EndValue = null;
                    }
                    else
                    {
                        _break.EndValue = legend["ColorBreaks"].ChildNodes[i].Attributes["EndValue"].InnerText;
                    }

                    if (legend["ColorBreaks"].ChildNodes[i].Attributes["Visible"] != null && legend["ColorBreaks"].ChildNodes[i].Attributes["Visible"].InnerText != "")
                    {
                        _break.Visible = bool.Parse(legend["ColorBreaks"].ChildNodes[i].Attributes["Visible"].InnerText);
                    }

                    shpscheme.Add(_break);
                }

                if (numOfBreaks > 0)
                {
                    //set that layers scheme and redraw the legend
                    //设置Layer的颜色设置,并重回legend
                    Program.frmMain.Layers[handle].ColoringScheme = shpscheme;
                    Program.frmMain.Legend.Refresh();
                }
            }
            catch (System.Exception e)
            {
                m_ErrorMsg    += "在LoadShpFileColoringScheme()方法中出错:" + e.Message + "\r\n";
                m_ErrorOccured = true;
            }
        }