I have many images and their coordinates with width and height. The image is placed in the image box, and I send the coordinates to draw a rectangle on it. The panel has a lot of images.
I send my paths to the class PicturePaneland with some coordinates and width / height properties to draw a rectangle. However, my problem is that she draws it and immediately removes it. If I do not put a message after each image, I do not see the rectangles. Here is the code:
if (IsRun())
{
MessageBox.Show("rontool true");
Rectangle ee = drawARectangle(xCoor, yCoor, MainScreen.tempR.wid / ratioOfx, MainScreen.tempR.heig / ratioOfy); // I wrote this, it only creates and returns the rectangle.
//MessageBox.Show("x : " + xCoor + " y: " + yCoor + " width : " + (MainScreen.tempR.wid / ratioOfx) + " height: " + (MainScreen.tempR.heig / ratioOfy));
using (Pen pen = new Pen(Color.Red, 2))
{
pictureBox.CreateGraphics().DrawRectangle(pen, ee);
// e.Graphics.DrawRectangle(pen, ee);
}
}
It is in
private void PictureBox_Paint(object sender, PaintEventArgs e).
A for the loop is in another class, creates a graphic box and initializes it x, y, etc. However, he draws and immediately removes it. or sometimes doesn’t even draw.
, . ?