public void Begin(GraphAppGUI appGUI, Point p) { if (HasBegun) { return; } isFlowNetwork = false; GraphPanel gp = appGUI.CurrentGraphPanel; isFlowNetwork = (gp.Graph as FlowNetwork) != null; List <GUIVertex> verts = gp.Vertices; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { startVert = v; Console.WriteLine("Edge tool selected vertex " + v.Vertex.Label); HasBegun = true; return; } } startVert = null; HasBegun = false; Console.WriteLine("Edge tool selected null"); }
public void Begin(GraphAppGUI appGUI, Point p) { if (HasBegun) { return; } isFlowNetwork = false; GraphPanel gp = appGUI.CurrentGraphPanel; isFlowNetwork = (gp.Graph as FlowNetwork) != null; List<GUIVertex> verts = gp.Vertices; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { startVert = v; Console.WriteLine("Edge tool selected vertex " + v.Vertex.Label); HasBegun = true; return; } } startVert = null; HasBegun = false; Console.WriteLine("Edge tool selected null"); }
public void DeleteSelection(GraphApp app) { List <GUIEdge> localEdges = new List <GUIEdge>(); foreach (ISelectable i in currentSelection) { GUIVertex gv = i as GUIVertex; if (gv != null) { RemoveVertex(gv, app); foreach (GUIEdge ge in gv.GetEdges()) { localEdges.Add(ge); } continue; } GUIEdge e = i as GUIEdge; if (e != null) { RemoveEdge(e, app); continue; } } foreach (GUIEdge connected in localEdges) { RemoveEdge(connected, app); } Refresh(); }
public GUIEdge(GUIVertex start, GUIVertex end, Edge e) { this.e = e; this.start = start; this.end = end; start.AddEdge(this); end.AddEdge(this); font = new Font(new FontFamily("Arial"), 12f, FontStyle.Regular); }
public void AddEdge(GUIVertex start, GUIVertex end, Edge e) { GUIEdge edge = new GUIEdge(start, end, e); edge.Brush = GUIEdge.DefaultBrush; edge.LineWidth = GUIEdge.DefaultLineWidth; edges.Add(edge); selectables.Add(edge); Refresh(); }
public void AddEdge(GUIVertex start, GUIVertex end, FlowEdge fe) { GUIFlowEdge edge = new GUIFlowEdge(start, end, fe); edge.Brush = GUIEdge.DefaultBrush; edge.LineWidth = GUIEdge.DefaultLineWidth; edges.Add(edge); selectables.Add(edge); Refresh(); }
public void AddVertex(Vertex v, Point pos) { GUIVertex gv = new GUIVertex(v, pos); gv.Brush = GUIVertex.DefaultBrush; gv.Radius = GUIVertex.DefaultRadius; gv.LineWidth = GUIVertex.DefaultLineWidth; verts.Add(gv); selectables.Add(gv); //Refresh to draw new vertices Refresh(); }
public void End(GraphApp app, GraphAppGUI appGUI, Point p) { if (!HasBegun) { return; } GraphPanel gp = appGUI.CurrentGraphPanel; List <GUIVertex> verts = gp.Vertices; bool foundVert = false; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { endVert = v; Console.WriteLine("Edge tool ended on vertex " + v.Vertex.Label); foundVert = true; //Add vertex if (isFlowNetwork) { FlowEdge fe = app.AddFlowEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, fe); } else { //Change to add two edges, for both directions Edge e = app.AddEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, e); } break; } } HasBegun = false; if (!foundVert) { startVert = null; endVert = null; return; } }
public override void Draw(Graphics g) { if (!hasBegun) { return; } if (selection != null) { foreach (ISelectable i in selection) { GUIVertex gv = i as GUIVertex; if (gv == null) { continue; } gv.Draw(g, delta); } } }
public void End(Point p) { delta = new Point(p.X - start.X, p.Y - start.Y); if (selection != null) { foreach (ISelectable i in selection) { GUIVertex gv = i as GUIVertex; if (gv == null) { continue; } gv.Pos = new Point(gv.Pos.X + delta.X, gv.Pos.Y + delta.Y); } } hasBegun = false; selection = null; }
public void End(GraphApp app, GraphAppGUI appGUI, Point p) { if (!HasBegun) { return; } GraphPanel gp = appGUI.CurrentGraphPanel; List<GUIVertex> verts = gp.Vertices; bool foundVert = false; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { endVert = v; Console.WriteLine("Edge tool ended on vertex " + v.Vertex.Label); foundVert = true; //Add vertex if (isFlowNetwork) { FlowEdge fe = app.AddFlowEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, fe); } else { //Change to add two edges, for both directions Edge e = app.AddEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, e); } break; } } HasBegun = false; if (!foundVert) { startVert = null; endVert = null; return; } }
public GUIFlowEdge(GUIVertex start, GUIVertex end, FlowEdge fe) : base(start, end, fe) { this.fe = fe; }
private void RemoveVertex(GUIVertex gv, GraphApp app) { app.RemoveVertex(gv.Vertex); verts.Remove(gv); selectables.Remove(gv); }