public void DrawLines(List <Triangule> triangules, Graphics g) { foreach (Triangule t in triangules) { g.DrawLine(Pens.Blue, t.a.x, t.a.y, t.b.x, t.b.y); g.DrawLine(Pens.Blue, t.b.x, t.b.y, t.c.x, t.c.y); g.DrawLine(Pens.Blue, t.c.x, t.c.y, t.a.x, t.a.y); if (selectedTriangule == t) { Circle c = delaunay.GetCircumcicles(new List <Triangule>() { selectedTriangule })[t]; float x = c.center.x - c.radius; float y = c.center.y - c.radius; g.DrawEllipse(Pens.GreenYellow, x, y, 2 * c.radius, 2 * c.radius); } if (selectedTriangule != null) { continue; } if (checkBox1.Checked) { if (triangulatedWithCircles.ContainsKey(t)) { Circle c = triangulatedWithCircles[t]; float x = c.center.x - c.radius; float y = c.center.y - c.radius; g.DrawEllipse(Pens.GreenYellow, x, y, 2 * c.radius, 2 * c.radius); } } } }
private void button2_Click(object sender, EventArgs e)//triangular { if (points.Count > 2) { selectedTriangule = null; delaunay = new DelaunayTriangulation(points); triangulated = delaunay.Triangulate(); if (checkBox1.Checked) { triangulatedWithCircles = delaunay.GetCircumcicles(triangulated); } Refresh(); } }
private void Form1_KeyUp(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.Z) { if (points.Count > 0) { points.RemoveAt(points.Count - 1); delaunay = new DelaunayTriangulation(points); triangulated = delaunay.Triangulate(); if (checkBox1.Checked) { triangulatedWithCircles = delaunay.GetCircumcicles(triangulated); } Refresh(); } } }