/// <summary> /// Uses the settings on this scheme to create a random category. /// </summary> /// <returns>A new IFeatureCategory</returns> public override IFeatureCategory CreateRandomCategory(string filterExpression) { LineCategory result = new LineCategory(); Color fillColor = CreateRandomColor(); result.Symbolizer = new LineSymbolizer(fillColor, 2); result.FilterExpression = filterExpression; result.LegendText = filterExpression; return result; }
/// <summary> /// creates a new instance of the PointScheme, but assigns the specified symbolizer /// as the symbolizer to use on a single default category. /// </summary> /// <param name="extent">The geographic point size for the default will be 1/100th the specified extent</param> public LineScheme(IEnvelope extent) { Configure(); LineCategory def = new LineCategory(extent); Categories.Add(def); }
/// <summary> /// Calculates the unique colors as a scheme /// </summary> /// <param name="fs">The featureset with the data Table definition</param> /// <param name="uniqueField">The unique field</param> public Hashtable GenerateUniqueColors(IFeatureSet fs, string uniqueField) { Hashtable result = new Hashtable(); // a hashtable of colors DataTable dt = fs.DataTable; ArrayList vals = new ArrayList(); int i = 0; foreach (DataRow row in dt.Rows) { if (uniqueField != "FID") { if (vals.Contains(row[uniqueField]) == false) { vals.Add(row[uniqueField]); } } else { vals.Add(i); i++; } } Random rnd = new Random(); foreach (object item in vals) { Color c = rnd.NextColor(); while (result.ContainsKey(c)) { c = rnd.NextColor(); } LineCategory cat = new LineCategory(c, 1); string flt = "[" + uniqueField + "] = "; if(uniqueField == "FID") { flt += item; } else { if (dt.Columns[uniqueField].DataType == typeof(string)) { flt += "'" + item + "'"; } else { flt += item.ToString(); } } cat.FilterExpression = flt; Categories.Add(cat); result.Add(c, item); } return result; }