private void SetupCustomRenderSettings(string fieldName, int layerIndex, TooltipHeaderFieldNamePair[] tooltipFields)
        {
            //get the required layer
            EGIS.ShapeFileLib.RenderSettings renderSettings = SFMap1.GetLayer(layerIndex).RenderSettings;
            int numRecords = SFMap1.GetLayer(layerIndex).RecordCount;

            EGIS.ShapeFileLib.DbfReader dbfReader = renderSettings.DbfReader;
            int fieldIndex = dbfReader.IndexOfFieldName(fieldName);

            double[] samples = new double[numRecords];
            //find the range of population values and obtain the quintile quantiles
            for (int n = 0; n < numRecords; n++)
            {
                if (String.IsNullOrEmpty(dbfReader.GetField(n, fieldIndex)) == false)
                {
                    string tmp = dbfReader.GetField(n, fieldIndex);
                    int    value;
                    if (int.TryParse(tmp, out value))
                    {
                        double d = double.Parse(dbfReader.GetField(n, fieldIndex), System.Globalization.CultureInfo.InvariantCulture);
                        samples[n] = d;
                    }
                }
            }
            double[] ranges = GetQuintiles(samples);

            //create the quintile colors - there will be 1 more color than the number of elements in quantiles
            Color[] cols = new Color[] {
                Color.FromArgb(96, 169, 5),
                Color.FromArgb(201, 200, 123),
                Color.FromArgb(157, 135, 151),
                Color.FromArgb(112, 155, 235),
                Color.FromArgb(255, 0, 0)
            };

            //setup the list of tooltip fields
            System.Collections.Generic.List <TooltipHeaderFieldNamePair> tooltipPairList = null;
            if (tooltipFields != null)
            {
                tooltipPairList = new System.Collections.Generic.List <TooltipHeaderFieldNamePair>();
                tooltipPairList.AddRange(tooltipFields);
            }

            //create a new QuantileCustomRenderSettings and add it to the SFMap
            QuantileCustomRenderSettings rcrs = new QuantileCustomRenderSettings(renderSettings, cols, ranges, fieldName, tooltipPairList);

            SFMap1.SetCustomRenderSettings(layerIndex, rcrs);
        }
Esempio n. 2
0
 public _cl_map_hydro(string ShpPath, string DbfPath, Encoding code)
 {
     sf      = new EGIS.ShapeFileLib.ShapeFile(ShpPath);
     dbr     = new EGIS.ShapeFileLib.DbfReader(DbfPath);
     endcode = code;
 }