private void StartDraw object sender MouseEventArgs if editingMode if

 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
private void StartDraw(object sender, MouseEventArgs e)
{
if (!editingMode)
{
if (!MouseDown1)
{
First = new Point(e.Location.X, e.Location.Y);
MouseDown1 = true;
}
switch(curentShape)
{
case "Линия":
{
drawList.Add(new Line1(new Point(e.Location.X, e.Location.Y), new Pen(curentColor, WidthBar.Value)));
break;
}
case "Квадрат":
{
drawList.Add(new Rectangle1(new Point(e.Location.X, e.Location.Y), new Pen(curentColor, WidthBar.Value)));
break;
}
case "Круг":
{
drawList.Add(new circle(new Point(e.Location.X, e.Location.Y), new Pen(curentColor, WidthBar.Value)));
break;
}
}
}
else
{
clicked.Clear();
for (int i = 0; i < drawList.Count; i++)
{
if (isInArea(drawList[i], new Point(e.Location.X, e.Location.Y)))
{
clicked.Add(drawList[i]);
}
}
if (clicked.Count > 0)
{
int minwidth=999;
foreach(var a in clicked)
{
if (a.width < minwidth)
{
minwidth = a.width;
a1 = a;
}
}
curent = a1;
sqare.Location = new Point(curent.First.X + curent.width-10, curent.First.Y + curent.height-10);
sqare.Width = 10;
sqare.Height = 10;
MouseDown1 = true;
g.DrawRectangle(Pens.Red, sqare);
}
if (isInArea(sqare, e.Location))
{
MouseDown1 = true;
sqareClicked = true;
}
else sqareClicked = false;
}
}