private void AddNewPoint(ImageEditor imgEd, MouseEventArgs e, Polygon polyg) { int pos = Math.Max(imgEd.CurPoints[0], imgEd.CurPoints[1]); if (pos == polyg.VertexCount-1) pos++; Point E = imgEd.ShiftPointIfNotEmpty(new Point(e.X, e.Y)); Graphics g = imgEd.GetGraphics(); polyg.Paint(g, new Pen(Brushes.White, 2)); polyg.AddVertexAt(pos, E); imgEd.ReDraw(); g = imgEd.GetGraphics(); polyg.Paint(g); imgEd.ReDraw(); imgEd.CurPoints.Clear(); }
private void открытьToolStripMenuItem_Click(object sender, EventArgs e) { if (ImgEditor.Polygs.Count == 2) { MessageBox.Show("Вначале объедините существующие полигоны"); return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Выберите файл"; openFileDialog.Filter = "Текстовые файлы|*.txt"; if (openFileDialog.ShowDialog() != DialogResult.OK) return; string[] lines = ToFileFromFile.ReadFromFile(openFileDialog.FileName); Polygon poly = new Polygon(lines); Graphics g = ImgEditor.GetGraphics(); poly.Paint(g); ImgEditor.ReDraw(); ImgEditor.Polygs.Add(poly); ImgEditor.CurPolygon = poly; }