Hi,
This may be a simple issue, but im gettin nowhere trying to fix it.
I have a form with a picturebox, the picturebox shows a map of our greenhouses. I want to be able to create clickable areas on the image.
I have created a class to store each area, and can create them fine.
The issue comes in trying to draw the areas onto the picture.
Heres what i have:
Bay _bay = new Bay();
_bay.Points = newBay;
_bay.Color = Color.Red;
_bay.Highlight = false;
Bays.Add(_bay);
pictureBox1.Invalidate();
each clickable area will be a bay in the greenhouse. I create an instance of the Bay class, instantiate it with a set of 4 PointF values (newBay) which denote the area.
next:
void pictureBox1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
foreach (Bay b in Bays)
{
b.Draw(e.Graphics);
}
}
each Bay's draw method is called...
public void Draw(Graphics g)
{
SolidBrush b = new SolidBrush(this.Color);
g.FillPolygon(b, _points);
b.Dispose();
if (Highlight)
{
Pen p = new Pen(Color.Red, 3);
p.DashStyle = DashStyle.DashDot;
g.DrawPolygon(p, _points);
p.Dispose();
}
}
My problem is that only the LAST polygon is showing up : / i think the Graphics object may be overwritten by each call...but i cant figure out why or how to stop it...someone help..please! :)