private void tracer_UpdateVertex(object sender, ShapeVertexEventArgs args) { // shape is TextShape if (this.vertexColors == null || !this.vertexColors.Contains(args.Vertex)) { return; } PropertyGridShape shape = (PropertyGridShape)args.Shape; switch (this.vertexColors[args.Vertex]) { case GraphColor.White: shape.TitleBackColor = Color.White; break; case GraphColor.Gray: shape.TitleBackColor = Color.LightGray; break; case GraphColor.Black: shape.TitleBackColor = Color.Red; break; } }
private void walker_WeightedTreeEdge(object sender, EdgeEventArgs e) { this.vertexCounts[e.Edge.Target]++; this.edgeCounts[e.Edge]++; this.edgeWeights[e.Edge] *= 0.9; PropertyGridShape shape = (PropertyGridShape)this.netronPanel.Populator.VertexShapes[e.Edge.Source]; shape.TitleBackColor = Color.White; shape = (PropertyGridShape)this.netronPanel.Populator.VertexShapes[e.Edge.Target]; shape.TitleBackColor = Color.LightGreen; shape.Title = this.vertexCounts[e.Edge.Target].ToString(); this.netronPanel.Invalidate(); }
private void netronPanel_SelectEvent(object sender, Netron.StatusEventArgs e) { if (e.Entity is PropertyGridShape) { PropertyGridShape shape = (PropertyGridShape)e.Entity; switch (e.Status) { case EnumStatusType.Selected: shape.CollapseRows = false; this.netronPanel.MoveToFront(shape); break; case EnumStatusType.Deselected: shape.CollapseRows = true; break; } } }
private void menuItem4_Click(object sender, System.EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Multiselect = false; dlg.DefaultExt = ".xml"; dlg.Title = "Load GraphML file"; if (dlg.ShowDialog() != DialogResult.OK) { return; } this.netronPanel.Clear(); // create serialize GraphMLGraphSerializer ser = new GraphMLGraphSerializer("."); ser.GraphType = typeof(BidirectionalGraph); ser.VertexProviderType = typeof(SerializableVertexProvider); ser.EdgeProviderType = typeof(SerializableEdgeProvider); try { XmlReader reader = new XmlTextReader(dlg.FileName); // validate GraphMLGraphSerializer.Validate(reader); reader = new XmlTextReader(dlg.FileName); this.netronPanel.Graph = (BidirectionalGraph)ser.Deserialize(reader); } catch (Exception ex) { Debug.Write(ex.ToString()); Debug.Flush(); throw; } this.netronPanel.Populator.PopulatePanel(this.netronPanel.Graphics); foreach (SerializableVertex v in this.netronPanel.Graph.Vertices) { PropertyGridShape shape = (PropertyGridShape)this.netronPanel.Populator.VertexShapes[v]; if (v.Entries.ContainsKey("name")) { shape.Title = v.Entries["name"]; } else { shape.Title = v.ID.ToString(); } if (v.Entries.ContainsKey("icon")) { try { shape.Icon = new Icon(v.Entries["icon"]); } catch (Exception) {} } // add some properties foreach (DictionaryEntry de in v.Entries) { if (de.Key.ToString() == "name" || de.Key.ToString() == "icon") { continue; } shape.Rows.Add(new PropertyEntry(de.Key.ToString(), de.Value.ToString())); } } foreach (SerializableEdge edge in this.netronPanel.Graph.Edges) { if (edge.Entries.ContainsKey("name")) { SplineConnection conn = (SplineConnection)this.netronPanel.Populator.EdgeConnections[edge]; conn.Label = edge.Entries["name"]; } } this.netronPanel.Populator.PopulatePanel(this.netronPanel.Graphics); }