private void pictureBox1_Paint object sender PaintEventArgs if touchPo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
if (touchPoint != -1 && touch)
{
e.Graphics.DrawEllipse(penPoints, list[touchPoint].X - 5, list[touchPoint].Y - 5, 10, 10);
}
}
private void pictureBox_mouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
for (int i = 0; i < list.Count; i++)
{
if ((e.X - list[i].X) * (e.X - list[i].X) + (e.Y - list[i].Y) * (e.Y - list[i].Y) <= 400f)
{
touchPoint = i;
touch = true;
break;
}
}
if (!touch)
{
list.Add(new Point(e.X, e.Y));
}
}
pictureBox1.Invalidate();
}
private void pictureBox_mouseMove(object sendre, MouseEventArgs e)
{
if (touch)
{
list[touchPoint] = new Point(e.X, e.Y);
pictureBox1.Invalidate();
}
}
private void pictureBox_mouseUp(object sender, MouseEventArgs e)
{
if (touch)
{
list[touchPoint] = new Point(e.X, e.Y);
touch = false;
}
}