I use this code to fill counties that have a current advisory:
Code: Select all
using (MagickImage image = new MagickImage(@"mnmap.png"))
{
// Build Legend
List<string> legendAlerts = new List<string>();
foreach (AlertEntry alert in alerts)
{
//MessageBox.Show(alert.Event);
char[] seps = { ',', ';' };
string[] counties = alert.Counties.Split(seps);
// Add for legend
if(!Util.IsDup(alert.Event,legendAlerts))
legendAlerts.Add(alert.Event);
foreach(string county in counties)
{
string coords = GetCountyCoords(county.Trim().ToLower());
if(coords != "")
{
string x = coords.Split(',')[0];
string y = coords.Split(',')[1];
// Color Advisories via FloodFill
image.FloodFill(System.Drawing.ColorTranslator.FromHtml(GetColorCode(alert.Event)), int.Parse(x),int.Parse(y));
}
}
}
Code: Select all
// Legend
image.Extent(300, 400, Gravity.North);
int i = 325;
foreach(string alert in legendAlerts)
{
List<Drawable> drawables = new List<Drawable>();
drawables.Add(new DrawableFillColor(System.Drawing.ColorTranslator.FromHtml(GetColorCode(alert))));
drawables.Add(new DrawableFont("Segoe UI", FontStyleType.Any, FontWeight.Weight700, FontStretch.Normal));
drawables.Add(new DrawableText(30, i, alert));
image.Draw(drawables);
i = i + 12;
}
// Create final image file
image.Transparent(Color.White);
image.Write("newmap.png");
}
I'm not sure what would be causing the problem. Any help would be appreciated!