How can I draw these specific figures on the panels?
I have two panels to which I want to draw these two figures:
A figure in each one, could put the image as such in the background property
BackgroundImage
of the panel, but at certain times I should change the color of the figure, therefore if I use it as a background image I would have to Create an image of each color you want to use or create a method to change the color to an image that sounds complicated.
For example in this way:
private readonly List<Image> imageList;
private int currentImageIndex = 1;
private List<Image> CreateImages()
{
var lista = new List<Image>();
int width = 250;
int height = 50;
using (SolidBrush brush = new SolidBrush(Color.SteelBlue))
using (SolidBrush whiteBrush = new SolidBrush(Color.White))
{
for (int i = 0; i <= width; i += 10)
{
var bmp = new Bitmap(width, height);
using (Graphics gfx = Graphics.FromImage(bmp))
{
gfx.FillRectangle(whiteBrush, 0, 0, width, height);
gfx.FillRectangle(brush, width / 2 - i / 2, 0, i, height);
}
lista.Add(bmp);
}
}
return lista;
}
Its use would be the following:
panel1.BackgroundImage = imageList[currentImageIndex]; //Indice 0
panel2.BackgroundImage = imageList[currentImageIndex]; //Indice 1
Or converting the figure to BitMap (But how would you use this?):
var bmp1 = new Bitmap(Properties.Resources.Figura1);
var bmp2 = new Bitmap(Properties.Resources.Figura2);
Environment: Visual Studio 2010 - C # & .NET Framework 4