示例#1
0
        void ChangeColor(Color color)
        {
            this.mainColor = color;
            DrawMap();

            this.datagrid_infected.HeaderForeColor = mainColor;
            if (mainColor == Color.Transparent)
            {
                this.datagrid_infected.HeaderForeColor = HelperFunctions.GetRandomColor();
            }
            lbl_colorMap.ForeColor = mainColor;
            if (mainColor == Color.Transparent)
            {
                lbl_colorMap.ForeColor = HelperFunctions.GetRandomColor();
            }
        }
示例#2
0
        void DrawMap()
        {
            if (pbox_map.Width == 0)
            {
                return;
            }
            var saved         = new Dictionary <string, Country>();
            int maximInfected = 0;

            foreach (var country in countries.Values)
            {
                if (country.infected.Count > 1)
                {
                    maximInfected = Math.Max(maximInfected, country.infected.Last());
                }
            }
            bmp = new Bitmap(this.pbox_map.Width * 2, this.pbox_map.Height * 2);
            Graphics g = Graphics.FromImage(bmp);

            countries.Values.ToList().ForEach((country) => {
                country.polygons.ForEach((poly) => {
                    Brush brsh;
                    var imagePoly = HelperFunctions.PolygonToImagePoly(poly, bmp.Size).ToArray();
                    brsh          = new SolidBrush(Color.FromArgb(255, 255, 255));
                    try
                    {
                        g.FillPolygon(brsh, imagePoly);
                    }
                    catch { }
                    if (country.infected.Count > 0 && country.infected[slider_timeline.Value] > 0)
                    {
                        var clr = Color.FromArgb(Math.Max(20, Math.Min(255, (int)(255 * (((double)country.infected[slider_timeline.Value] * 5) / ((double)maximInfected))))), mainColor);
                        if (mainColor == Color.Transparent)
                        {
                            clr = Color.FromArgb(Math.Max(20, Math.Min(255, (int)(255 * (((double)country.infected[slider_timeline.Value] * 5) / ((double)maximInfected))))), HelperFunctions.GetRandomColor());
                        }
                        brsh = new SolidBrush(clr);
                        try
                        {
                            g.FillPolygon(brsh, imagePoly);
                        }
                        catch { }
                    }
                });
            });
            countries.Values.ToList().ForEach((country) => {
                country.polygons.ForEach((poly) => {
                    Pen pn = new Pen(mainColor, 3);
                    if (mainColor == Color.Transparent)
                    {
                        pn.Color = HelperFunctions.GetRandomColor();
                    }
                    try
                    {
                        g.DrawPolygon(pn, HelperFunctions.PolygonToImagePoly(poly, bmp.Size).ToArray());
                    }
                    catch { }
                });
            });
            this.pbox_map.Image = bmp;
        }