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;
}
}