void UpdateStat(GraphController <int, int> t) // updates bottom pannel information { int iteratorpointer = -1; try { label10.Text = test.LastVertex.ToString(); if (test.IsValid()) { panel3.BackColor = Color.LightGreen; } else { panel3.BackColor = Color.Red; } try { iteratorpointer = test.Current(); } catch (Exception e) { iteratorpointer = -2; panel3.BackColor = Color.Red; } label6.Text = "Info: Vertices: " + t.VertexCount + " Edges: " + t.EdgeCount + " Type: "; if (!test.IslistBased()) { label6.Text += "MatrixBased"; } else { label6.Text += "ListBased"; } label6.Text += " K: " + test.Getk; if (t.EdgeExists(sel1, sel2)) { panel2.BackgroundImage = GetImageFromPath("layout\\edgeexist.png"); } else { panel2.BackgroundImage = GetImageFromPath("layout\\edgenotexist.png"); } textBox4.Text = test.GetEdgeWeight(sel1, sel2).ToString(); } catch (Exception eeee) { textBox4.Text = "N/a"; return; } }
void RenderLinks(GraphController <int, int> g, System.Drawing.Graphics gdi, Control[] ctrls)// renders links between vertices and directon markers { Bitmap buffer = new Bitmap((int)gdi.VisibleClipBounds.Width, (int)gdi.VisibleClipBounds.Height); Graphics localg = Graphics.FromImage(buffer); localg.SmoothingMode = gdi.SmoothingMode; List <Rectangle> points = new List <Rectangle>(); Pen pen = new Pen(Brushes.Black, 2); Brush br = Brushes.Gray; for (int i = 0; i < g.VertexCount; i++) { for (int j = 0; j < g.VertexCount; j++) { if (!g.EdgeExists(i, j)) { continue; } Control c1 = GetControlbyName(i.ToString(), ctrls); Control c2 = GetControlbyName(j.ToString(), ctrls); Point p1 = c1.Location + new Size(c1.Size.Width / 2, c1.Size.Height / 2); Point p2 = c2.Location + new Size(c2.Size.Width / 2, c2.Size.Height / 2); //gdi.DrawLine(pen, p1, p2); localg.DrawLine(pen, p1, p2); points.Add(new Rectangle(p2 - new Size((int)(0.199 * (p2.X - p1.X)) + 5, (int)(0.199 * (p2.Y - p1.Y)) + 5), new Size(10, 10))); } } if (g.IsDirected) { foreach (Rectangle r in points) { //gdi.FillEllipse(br, r); localg.FillEllipse(br, r); } } gdi.Clear(Color.White); gdi.DrawImageUnscaled(buffer, 0, 0); }
void RenderVertices(GraphController <int, int> g, int formation, int sel1, int sel2, int edgesize, Control[] ctrls, Image normal, Image iterator, Image selected)// render vertices, formation: 0 - round { for (int i = 0; i < ctrls.Length; i++) { Control curr = ctrls[i]; if (i == sel1 || i == sel2) { curr.BackgroundImage = selected; } else { curr.BackgroundImage = normal; } try { if (g.Current() == i) { curr.BackgroundImage = iterator; } } catch (Exception e) { } curr.Size = new System.Drawing.Size(edgesize, edgesize); curr.Controls[0].Size = new Size(edgesize, edgesize); } }
public void Set(GraphController <int, int> gin, int basevertex) { g = gin; this.basevertex = basevertex; }
public void Set(GraphController <int, int> gin) { g = gin; }
public void DrawFastMove(GraphController <int, int> g, int dx, int dy, Panel p, Graphics gdi, Control[] ctrls) { MoveEdges(dx, dy, p); RenderLinks(g, gdi, ctrls); }
public void DrawIncrementalFast(GraphController <int, int> g, int sel1, int sel2, int edgesize, Graphics gdi, Control[] ctrls, Image normal, Image iterator, Image selected) { RenderVertices(g, 0, sel1, sel2, edgesize, ctrls, normal, iterator, selected); RenderLinks(g, gdi, ctrls); }