namespace proj { public patrial class Form1 : Form { class Figure { public PointF p1; public PointF p2; public Figure(PointF p1, PointF p2) { this.p1 = p1; this.p2 = p2; } } private int mousestillclick = 0; public float max; public PointF p1; public PointF p2; private Figure[] figures = new Figure[1000]; private int countFigures = 0; public string maxrest; private PointF[] points = new PointF[1000]; public float maxr = 0; public float minr; private int k = 0; public float ras; public float sq11; public float sq22; private PointF start; public float mood; private PointF mousea; Pen pen; public Form1() { InitializeComponent(); } private void Form1_MouseClick(object sender, MouseEventArgs e) { if (k < points.Length) { points[k] = new PointF(e.X, e.Y); k++; } } private void Form1_MouseDown(object sender, MouseEventArgs e) { start = new PointF(e.X, e.Y); mousestillclick = 1; } private void Form1_MouseMove(object sender, MouseEventArgs e) { mousea = new PointF(e.X, e.Y); if (mousestillclick == 1) Refresh(); } private void Form1_MouseUp(object sender, MouseEventArgs e) { if (countFigures < figures.Length) { figures[countFigures] = new Figure(start, new PointF(e.X, e.Y)); countFigures++; Refresh(); } mousestillclick = 0; } private void Form1_Paint_1(object sender, PaintEventArgs e) { pen = new Pen(Color.Red); Font font = new Font("Times New Roman", 14); Brush brush = new SolidBrush(Color.Black); for (int n = 0; n < countFigures; n++) for (int i = n + 1; i < countFigures; i++) { float sq1 = (figures[n].p2.X - figures[n].p1.X) * (figures[n].p2.X - figures[n].p1.X) + (figures[n].p2.Y - figures[n].p1.Y) * (figures[n].p2.Y - figures[n].p1.Y); sq11 = (float)Math.Sqrt(sq1); e.Graphics.DrawEllipse(pen, figures[n].p1.X - (float)Math.Sqrt(sq1), figures[n].p1.Y - (float)Math.Sqrt(sq1), 2 * (float)Math.Sqrt(sq1), 2 * (float)Math.Sqrt(sq1)); float sq2 = (figures[i].p2.X - figures[i].p1.X) * (figures[i].p2.X - figures[i].p1.X) + (figures[i].p2.Y - figures[i].p1.Y) * (figures[i].p2.Y - figures[i].p1.Y); sq22 = (float)Math.Sqrt(sq2); e.Graphics.DrawEllipse(pen, figures[i].p1.X - (float)Math.Sqrt(sq2), figures[i].p1.Y - (float)Math.Sqrt(sq2), 2 * (float)Math.Sqrt(sq2), 2 * (float)Math.Sqrt(sq2)); if (sq11 >= sq22) { maxr = sq11; } else { maxr = sq22; } float de = (figures[i].p1.X - figures[n].p1.X) * (figures[i].p1.X - figures[n].p1.X) + (figures[i].p1.Y - figures[n].p1.Y) * (figures[i].p1.Y - figures[n].p1.Y); float des = (float)Math.Sqrt(de); if (des >= (sq11 + sq22)) { max = 0; } if (des <= (Math.Abs(sq11 - sq22))) { max = 0; } if ((Math.Abs(sq11 - sq22)) < des && des < (sq11 + sq22)) { max = 2 * (float)Math.Sqrt((4 * sq22 * sq22 * des * des) - (sq22 * sq22 - sq11 * sq11 + des * des) * (sq22 * sq22 - sq11 * sq11 + des * des)) / (2 * des); } if ((des < maxr) && des > (Math.Abs(sq11 - sq22))) { max = 2 * (float)Math.Sqrt((4 * sq22 * sq22 * des * des) - (sq22 * sq22 - sq11 * sq11 - des * des) * (sq22 * sq22 - sq11 * sq11 - des * des)) / (2 * des); } string maxrest = "Max = " + max; e.Graphics.DrawString(maxrest, font, brush, 600, 70); } if (mood == 1) { } if (mousestillclick == 1) { float sq1 = (mousea.X - start.X) * (mousea.X - start.X) + (mousea.Y - start.Y) * (mousea.Y - start.Y); e.Graphics.DrawEllipse(pen, start.X - (float)Math.Sqrt(sq1), start.Y - (float)Math.Sqrt(sq1), 2 * (float)Math.Sqrt(sq1), 2 * (float)Math.Sqrt(sq1)); float sq2 = (mousea.X - start.X) * (mousea.X - start.X) + (mousea.Y - start.Y) * (mousea.Y - start.Y); e.Graphics.DrawEllipse(pen, start.X - (float)Math.Sqrt(sq2), start.Y - (float)Math.Sqrt(sq2), 2 * (float)Math.Sqrt(sq2), 2 * (float)Math.Sqrt(sq2)); } } private void removeToolStripMenuItem_Click(object sender, EventArgs e) { mood = 1; } } }