private void onGraphDelete(object sender, EventArgs e) { if (graphCounter <= 0) { return; } //We want to delete the graph that is on the current tab GraphPanel gp = graphTabControl.TabPages[graphTabControl.SelectedIndex].Controls[0] as GraphPanel; Graph victim = gp.Graph; app.DeleteGraph(victim); int deleteIndex = graphTabControl.SelectedIndex; graphTabControl.TabPages.Remove(graphTabControl.TabPages[deleteIndex]); graphCounter--; Console.WriteLine("Deleted " + victim.Name); if (graphCounter <= 0) { selectedItemPropertyGrid.SelectedObject = 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 AddVertex(GraphApp app, GraphAppGUI appGUI, Point p) { Vertex v = app.AddVertex(); GraphPanel gp = appGUI.CurrentGraphPanel; gp.AddVertex(v, p); }
public void EndSelect(GraphApp app, GraphAppGUI appGUI, Point p, bool shiftHeld) { Console.WriteLine("Selection end: " + p.ToString()); Started = false; endPoint = p; Rectangle selectionRect = getSelectionRectangle(startPoint, endPoint); GraphPanel gp = appGUI.CurrentGraphPanel; if (!shiftHeld) { gp.Deselect(); } List <ISelectable> selectables = gp.Selectables; int selectTotal = 0; foreach (ISelectable s in selectables) { if (s.Intersects(selectionRect)) { bool filterPass = false; foreach (SelectionFilter filter in filters) { if (filter.PassesFilter(s.GetItem())) { filterPass = true; } } if (!filterPass) { continue; } gp.Select(s); s.Select(); selectTotal++; Console.WriteLine("Selected " + s.ToString()); } } if (selectTotal == 0) { Console.WriteLine("Selected nothing"); gp.Deselect(); } gp.Refresh(); }
private void onTabChange(object sender, EventArgs e) { int tabIndex = graphTabControl.SelectedIndex; if (tabIndex < 0) { return; } GraphPanel gp = graphTabControl.TabPages[graphTabControl.SelectedIndex].Controls[0] as GraphPanel; Graph currentGraph = gp.Graph; app.SetCurrentGraph(currentGraph); selectedItemPropertyGrid.SelectedObject = currentGraph; gp.CurrentTool = currentTool; Console.WriteLine("Changed to " + currentGraph.Name); }
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; } }
private void makeNewGraphPanel(Graph newGraph) { graphTabControl.TabPages.Add(newGraph.Name); GraphPanel gp = new GraphPanel(); gp.CurrentTool = currentTool; gp.Graph = newGraph; gp.MouseClick += new MouseEventHandler(gp_MouseClick); gp.MouseDown += new MouseEventHandler(gp_MouseDown); gp.MouseUp += new MouseEventHandler(gp_MouseUp); gp.MouseMove += new MouseEventHandler(gp_MouseMove); gp.Dock = DockStyle.Fill; graphTabControl.TabPages[graphCounter].Controls.Add(gp); graphTabControl.TabPages[graphCounter].ContextMenuStrip = graphRightClickMenu; graphTabControl.SelectTab(graphTabControl.TabCount - 1); graphCounter++; selectedItemPropertyGrid.SelectedObject = newGraph; }