private void drawing_panel_MouseUp(object sender, MouseEventArgs e) { if (moving) { moving = false; currently_changed_vertex = null; } drawing_panel.Invalidate(); }
private void drawing_panel_MouseDown(object sender, MouseEventArgs e) { VertexPoint tmp = FindIfOnVertex(e.Location); if (!(tmp is null)) { currently_changed_vertex = tmp; moving = true; } }
public Edge(VertexPoint a_, VertexPoint b_) { if (a_.Get().Y < b_.Get().Y) { a = a_; b = b_; } else { a = b_; b = a_; } SetXmin(); CalculateOneDivM(); }
private void CreateNet(int xcount, int ycount) { triangles_net = new List <Polygon>(); vertices = new VertexPoint[xcount, ycount]; Point start = new Point((int)Math.Round(drawing_panel.Width * 0.1), (int)Math.Round(drawing_panel.Height * 0.1)); int diffX = (int)Math.Round((drawing_panel.Width * 0.8) / xcount); int diffY = (int)Math.Round((drawing_panel.Height * 0.8) / ycount); int currentX = start.X; int currentY = start.Y; for (int i = 0; i < xcount; i++) { for (int j = 0; j < ycount; j++) { vertices[i, j] = new VertexPoint(currentX, currentY); currentY += diffY; } currentX += diffX; currentY = start.Y; } for (int i = 0; i < xcount - 1; i++) { for (int j = 0; j < ycount - 1; j++) { triangles_net.Add(new Polygon()); triangles_net.Last().AddVertex(vertices[i, j]); triangles_net.Last().AddVertex(vertices[i, j + 1]); triangles_net.Last().AddVertex(vertices[i + 1, j]); triangles_net.Add(new Polygon()); triangles_net.Last().AddVertex(vertices[i + 1, j]); triangles_net.Last().AddVertex(vertices[i + 1, j + 1]); triangles_net.Last().AddVertex(vertices[i, j + 1]); } } }
public void AddVertex(VertexPoint point) { vertices.Add(point); MakeEdges(); }