I am trying get get specific pieces of this layer to be colored with different colors.is there a better way than using a counter and a bunch of if statements?
private Collection<
ValueItem
> colorSelect(Collection<
Feature
> allFeatures, string layercode,Collection<
ValueItem
> valueItems)
{
List<
string
> values = new List<
string
>();
foreach (Feature f in allFeatures)
{
if (f.ColumnValues.ContainsKey(layercode))
{
if (!values.Contains(f.ColumnValues[layercode].ToString()))
{
values.Add(f.ColumnValues[layercode].ToString());
}
}
}
string json = JsonConvert.SerializeObject(values);
if (values.Count > 0)
{
int count = 0;
foreach (string esnCode in values)
{
//int count = 0;
if (count == 0)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Green, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 1)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Pink, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 2)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Blue, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 3)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Yellow, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 4)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Violet, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 5)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Red, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 6)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Aqua, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 7)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Black, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 8)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Brown, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 9)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Coral, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
if (count == 10)
{
ValueItem item = new ValueItem(esnCode, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.DarkKhaki, GeoColor.StandardColors.Black, 3));
valueItems.Add(item);
}
count++;
}
}
return (valueItems);
}