Hi Everyone
I am creating a level bulider using windows forms and the background for the level is stored in a picture box control. All i want to do is draw a number of lines over the image to create a grid allowing better placement on the builder.
here is my code so far. It draws a single line but if i place a control over it, it is drawn over.
any help would be greatly appreciated.
Martin.
I am creating a level bulider using windows forms and the background for the level is stored in a picture box control. All i want to do is draw a number of lines over the image to create a grid allowing better placement on the builder.
here is my code so far. It draws a single line but if i place a control over it, it is drawn over.
Code:
namespace GraphicsTest
{
public partial class Form1 : Form
{
private Bitmap m_myLine;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
m_myLine = new Bitmap(this.ClientRectangle.Width,
this.ClientRectangle.Height,
System.Drawing.Imaging.PixelFormat.Format24bppRgb);
InitializeImage();
}
private void InitializeImage()
{
Graphics objGraphics;
objGraphics = Graphics.FromImage(m_myLine);
objGraphics.Clear(SystemColors.Control);
objGraphics.DrawLine(Pens.Orange, 10, 0, 10, 50);
objGraphics.Dispose();
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(m_myLine, 0, 0, m_myLine.Width,
m_myLine.Height);
e.Graphics.Dispose();
this.Invalidate();
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
m_myLine.Dispose();
}
}
}
Martin.
Comment