1
I have a pictureBox where the user with each mouse click inserts a text on top of an image in a pictureBox. It inserts several texts at various points in the image, the inserted text is taken from checkboxes.
Using this code
private void pictureBox2_MouseClick(object sender, MouseEventArgs e)
{
var g = Graphics.FromImage(pictureBox2.Image);
var mouseEventArgs = e as MouseEventArgs;
if (mouseEventArgs != null) textBox1.Text = "X= " + mouseEventArgs.X + " Y= " + mouseEventArgs.Y;
g.DrawString(texto, new Font("Verdana", 30F, FontStyle.Regular), Brushes.Red, new PointF(e.X * pictureBox2.Image.Width / pictureBox2.Width -30,
e.Y * pictureBox2.Image.Height / pictureBox2.Height -90));
pictureBox2.Refresh();
g.Dispose();
}
What I’m not getting is to delete the texts. I wish he could delete anyone he inserted in any order. I thought of a kind of CTRL+Z but that would delete one by one, if he already inserted 5, and want to delete only the first, Ctrl+z would no longer serve.
I thought of a kind of eraser, that it was moving the mouse over the text that he inserted and was erasing, without erasing the background image. Or by the checkbox itself that he clicked to choose which text to write, if you click on the checkbox again the Drawstring that corresponds to that checkbox text delete.
Is it possible to delete these Drawstring? The easiest way possible, I’m beginner.
As in the other question, I have this form that I made a long time ago, see if it helps: https://pastebin.com/qCs9RF6v Obs. You have the designer file code and then the form code itself
– Rovann Linhalis