void RefreshDisplay() { foreach (cCellType item in Parent.ListCellTypes) { Microsoft.Msagl.Drawing.Node NewNode = new Microsoft.Msagl.Drawing.Node(item.Name); NewNode.Label.FontColor = new Microsoft.Msagl.Drawing.Color(item.TypeColor.R, item.TypeColor.G, item.TypeColor.B); NewNode.Attr.FillColor = Microsoft.Msagl.Drawing.Color.DimGray; NewNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Ellipse; graph.AddNode(NewNode); } foreach (cCellType item in Parent.ListCellTypes) { foreach (cTransitionValue Transitions in item.ListInitialTransitions) { if (Transitions.Value == 0) continue; Microsoft.Msagl.Drawing.Edge Currentedge = new Microsoft.Msagl.Drawing.Edge(item.Name, Transitions.Value.ToString(), Transitions.DestType.Name); //Currentedge.Label.FontSize = Transitions.Value; //Currentedge.LabelText = ; graph.Edges.Add(Currentedge); } } GraphView.Graph = graph; GraphView.Dock = System.Windows.Forms.DockStyle.Fill; this.panel.Controls.Add(GraphView); }
internal void TakeEdge(Microsoft.Msagl.Drawing.Edge edge) { if (edge != null) { EdgeDetailsPanel.DataContext = edge; } }
internal static void VisualizeGraph(Graph gr) { System.Windows.Forms.Form form = new System.Windows.Forms.Form(); Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer(); Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph"); foreach (Vertex v in gr.Vertices()) { foreach (Edge e in v.edges) { Microsoft.Msagl.Drawing.Edge msagle_edge = graph.AddEdge( string.Format("{0} - {1} ", v.key, v.UserDefinedObjects[0]) , string.Format("{0} - {1} ", e.dest.key, e.dest.UserDefinedObjects[0]) ); if (e.cost > 0) { msagle_edge.LabelText = e.cost.ToString(); } } } viewer.Graph = graph; form.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); form.ShowDialog(); }
public MsaglEdgeEventArgs(TEdge edge, Microsoft.Msagl.Drawing.Edge gedge) : base(edge) { Contract.Requires(gedge != null); this.gedge = gedge; }
private void gViewer_MouseUp(object sender, MouseEventArgs e) { if (InteractiveMode == InteractiveMode.NonInteractive) { return; } if (mouseDownPosition == e.Location) { if (gViewer.SelectedObject is Microsoft.Msagl.Drawing.Node) { if (InteractiveMode == InteractiveMode.OnlyEdges) { return; } Microsoft.Msagl.Drawing.Node node = gViewer.SelectedObject as Microsoft.Msagl.Drawing.Node; int vertexIndex = int.Parse(node.Id) - 1; VertexSelectedEvent?.Invoke(Graph.Vertices[vertexIndex]); } else if (gViewer.SelectedObject is Microsoft.Msagl.Drawing.Edge) { if (InteractiveMode == InteractiveMode.OnlyVertices) { return; } Microsoft.Msagl.Drawing.Edge edge = gViewer.SelectedObject as Microsoft.Msagl.Drawing.Edge; int sourceIndex = int.Parse(edge.Source) - 1; int targetIndex = int.Parse(edge.Target) - 1; EdgeSelectedEvent?.Invoke(Graph.GetEdge(sourceIndex, targetIndex)); } } mouseDownPosition = Point.Empty; }
internal static List <ObjectWithBox> TessellateCurve(DEdge dedge, double radiusForUnderlyingPolylineCorners) { DrawingEdge edge = dedge.DrawingEdge; ICurve bc = edge.EdgeCurve; double lineWidth = edge.Attr.LineWidth; var ret = new List <ObjectWithBox>(); int n = 1; bool done; do { double d = (bc.ParEnd - bc.ParStart) / n; done = true; if (n <= 64) //don't break a segment into more than 64 parts { for (int i = 0; i < n; i++) { if (!WithinEpsilon(bc, d * i, d * (i + 1))) { n *= 2; done = false; break; } } } } while (!done); double del = (bc.ParEnd - bc.ParStart) / n; for (int j = 0; j < n; j++) { var line = new Line(dedge, bc[del * j], bc[del * (j + 1)], lineWidth); ret.Add(line); } //if (dedge.Label != null) // ret.Add(new LabelGeometry(dedge.Label, edge.Label.Left, // edge.Label.Bottom, new P2(edge.Label.Size.Width, edge.Label.Size.Height))); if (edge.Attr.ArrowAtTarget) { ret.Add(new Line(dedge, edge.EdgeCurve.End, edge.ArrowAtTargetPosition, edge.Attr.LineWidth)); } if (edge.Attr.ArrowAtSource) { ret.Add(new Line(dedge, edge.EdgeCurve.Start, edge.ArrowAtSourcePosition, edge.Attr.LineWidth)); } if (radiusForUnderlyingPolylineCorners > 0) { AddUnderlyingPolylineTessellation(ret, dedge, radiusForUnderlyingPolylineCorners); } return(ret); }
private void ArchitectureGraphRefresh() { foreach (string nodeName in ArchitectureGraphAccessor.nodeList) { architectureGraph.RemoveNode(architectureGraph.FindNode(nodeName)); } //foreach (string key in simulator.LayerList.Keys) //{ // architectureGraph.AddEdge(simulator.LayerList[key].Name + "Bias", simulator.LayerList[key].Name); // Microsoft.Msagl.Drawing.Node biasNode = architectureGraph.FindNode(simulator.LayerList[key].Name + "Bias"); // biasNode.LabelText = ""; //} foreach (string key in simulator.BundleList.Keys) { architectureGraph.AddEdge(simulator.BundleList[key].SendLayer.Name, simulator.BundleList[key].ReceiveLayer.Name); ArchitectureGraphAccessor.nodeList.Add(simulator.BundleList[key].SendLayer.Name); ArchitectureGraphAccessor.nodeList.Add(simulator.BundleList[key].ReceiveLayer.Name); Microsoft.Msagl.Drawing.Node sendLayerNode = architectureGraph.FindNode(simulator.BundleList[key].SendLayer.Name); sendLayerNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; sendLayerNode.Attr.LabelMargin = 10; Microsoft.Msagl.Drawing.Node receiveLayerNode = architectureGraph.FindNode(simulator.BundleList[key].ReceiveLayer.Name); receiveLayerNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box; receiveLayerNode.Attr.LabelMargin = 10; } foreach (string key in simulator.LayerList.Keys) { if (simulator.LayerList[key].LayerType == LayerType.BPTTLayer) { BPTTLayer selectedBPTTLayer = (BPTTLayer)simulator.LayerList[key]; //Microsoft.Msagl.Drawing.Edge TickInEdge = architectureGraph.AddEdge(selectedBPTTLayer.Name, selectedBPTTLayer.Name + " 0 Tick"); for (int i = 0; i < selectedBPTTLayer.Tick; i++) { architectureGraph.AddEdge(selectedBPTTLayer.Name, selectedBPTTLayer.Name + " " + i.ToString() + " Tick").Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Dotted); architectureGraph.AddEdge(selectedBPTTLayer.Name + " " + i.ToString() + " Tick", selectedBPTTLayer.Name + " " + (i + 1).ToString() + " Tick"); ArchitectureGraphAccessor.nodeList.Add(selectedBPTTLayer.Name); ArchitectureGraphAccessor.nodeList.Add(selectedBPTTLayer.Name + " " + i.ToString() + " Tick"); ArchitectureGraphAccessor.nodeList.Add(selectedBPTTLayer.Name + " " + (i + 1).ToString() + " Tick"); } Microsoft.Msagl.Drawing.Edge TickOutEdge = architectureGraph.AddEdge(selectedBPTTLayer.Name + " " + selectedBPTTLayer.Tick.ToString() + " Tick", selectedBPTTLayer.Name); //TickInEdge.Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Dotted); TickOutEdge.Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Dotted); } } ArchitectureGraphAccessor.architectureGraphViewer.Graph = ArchitectureGraphAccessor.architectureGraph; }
private void Viewer_Click(object sender, EventArgs e) { Microsoft.Msagl.GraphViewerGdi.GViewer viewer = sender as Microsoft.Msagl.GraphViewerGdi.GViewer; if (viewer.SelectedObject is Microsoft.Msagl.Drawing.Node) { Microsoft.Msagl.Drawing.Node node = viewer.SelectedObject as Microsoft.Msagl.Drawing.Node; MessageBox.Show($"Это вершина {node.Attr.Id}"); } else if (viewer.SelectedObject is Microsoft.Msagl.Drawing.Edge) { Microsoft.Msagl.Drawing.Edge edge = viewer.SelectedObject as Microsoft.Msagl.Drawing.Edge; MessageBox.Show($"Это дуга {edge.Source}-{edge.Target}"); } }
public void ApplyLinkStyle( Microsoft.Msagl.Drawing.Edge e, BomLinkStyle ls) { // any if (e == null || ls == null) { return; } if (ls.Direction == BomLinkDirection.None) { e.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None; e.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None; } if (ls.Direction == BomLinkDirection.Forward) { e.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None; } if (ls.Direction == BomLinkDirection.Backward) { e.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None; } if (ls.Color.HasContent()) { e.Attr.Color = GetMsaglColor(ls.Color); } if (ls.Dashed) { e.Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Dashed); } if (ls.Dotted) { e.Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Dotted); } if (ls.Bold) { e.Attr.AddStyle(Microsoft.Msagl.Drawing.Style.Bold); } e.Attr.LineWidth = ls.Width; if (ls.Text.HasContent()) { e.LabelText = ls.Text; } }
internal static void CheckNode <T>(Node <T> NodeCurrent, Microsoft.Msagl.Drawing.Graph graph) { if (NodeCurrent.left != null) { Microsoft.Msagl.Drawing.Edge msagle_edge = graph.AddEdge(NodeCurrent.ToString(), NodeCurrent.left.ToString()); CheckNode(NodeCurrent.left, graph); } if (NodeCurrent.right != null) { Microsoft.Msagl.Drawing.Edge msagle_edge = graph.AddEdge(NodeCurrent.ToString(), NodeCurrent.right.ToString()); CheckNode(NodeCurrent.right, graph); } }
public VisualiseDataForm(ref ObservableCollection Collection) { InitializeComponent(); //create a form System.Windows.Forms.Form form = this; //create a viewer object Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer(); //create a graph object Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph"); //Add all the nodes foreach (ObservableObject o in Collection.Observables) { graph.AddNode(o.DisplayTitle); } //create the links foreach (ObservableRelationship r in Collection.Relationships) { Microsoft.Msagl.Drawing.Edge ed = graph.AddEdge(Collection.Observables.Find(x => x.ID == r.From).DisplayTitle, Enum.GetName(typeof(ObservableRelationshipType), r.RelationshipType), Collection.Observables.Find(x => x.ID == r.To).DisplayTitle); //Set the link text to grey Microsoft.Msagl.Drawing.Label l = ed.Label; l.FontColor = Microsoft.Msagl.Drawing.Color.DarkGray; } //Get rid of GUI controls we dont want the user to have access to viewer.LayoutAlgorithmSettingsButtonVisible = false; viewer.EdgeInsertButtonVisible = false; viewer.SaveAsMsaglEnabled = false; //This disables save and load of the actual graph data. //Give some extra space graph.LayoutAlgorithmSettings.NodeSeparation = 10; //bind the graph to the viewer viewer.Graph = graph; //associate the viewer with the form form.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); }
public void drawGraph() { //create a form System.Windows.Forms.Form form = new System.Windows.Forms.Form(); //create a viewer object Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer(); //create a graph object Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph"); //create the graph content for (int i = 1; i <= n_house; i++) { for (int j = 0; j < way[i].Count; j++) { if (way[i][j] > i) { Edge edge = (Edge) graph.AddEdge("" + i, "" + way[i][j]); edge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None; } if (visited[i]) { if (found) { graph.FindNode("" + i).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green; } else { graph.FindNode("" + i).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta; } } } } viewer.Graph = graph; //associate the viewer with the form form.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); //show the form form.ShowDialog(); //System.Threading.Thread.Sleep(3000); }
private void Form2_Load(object sender, EventArgs e) { String[] words = new String[320]; string[] stringSeparators = new string[] { "\r\n", " " }; String s = File.ReadAllText(Form1.FilePath); words = s.Split(stringSeparators, StringSplitOptions.None); //words = s.Split(' ', '\n'); Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer(); //create a graph object Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph"); int cnt = 2; int n = Int32.Parse(words[0]); int m = Int32.Parse(words[1]); string line; int count = 0; var mylist = new List <KeyValuePair <string, double> >(); using (StreamReader sr = new StreamReader("graph_files/centrality.txt")) { line = sr.ReadLine(); while (line != null) { mylist.Add(new KeyValuePair <string, double>(count.ToString(), double.Parse(line, System.Globalization.CultureInfo.InvariantCulture))); count++; line = sr.ReadLine(); } sr.Close(); } mylist.Sort((x, y) => (y.Value.CompareTo(x.Value))); byte green = 70; int div = n; for (int i = 0; i < n; i++) { if (i > 0) { if (mylist[i].Value < mylist[i - 1].Value) { green = (byte)(green + (180 / div)); } else { div--; } } line = mylist[i].Key; Microsoft.Msagl.Drawing.Node l = graph.AddNode(line); l.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Circle; l.Attr.FillColor = new Microsoft.Msagl.Drawing.Color(0, green, 0); /*if (i < n / 4) * l.Attr.FillColor = Microsoft.Msagl.Drawing.Color.FromArgb(0x479DEE); * else if (i < 2 * n / 4) * l.Attr.FillColor = Microsoft.Msagl.Drawing.Color.SeaGreen; * else if (i < 3 * n / 4) * l.Attr.FillColor = Microsoft.Msagl.Drawing.Color.PaleGreen; * else * l.Attr.FillColor = Microsoft.Msagl.Drawing.Color.MistyRose;*/ } //create the graph content for (int i = 0; i < m; i++) { Microsoft.Msagl.Drawing.Edge x = graph.AddEdge(words[cnt], words[cnt + 2], words[cnt + 1]); x.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None; cnt = cnt + 3; } //float range = 20; viewer.Graph = graph; //associate the viewer with the form this.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; this.Controls.Add(viewer); this.ResumeLayout(); }
private Microsoft.Msagl.Drawing.Graph ComputeAndDisplayGraph(string DotString) { int CurrentPos = 0; int NextReturnPos = CurrentPos; List<int> ListNodeId = new List<int>(); string TmpDotString = DotString; Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph"); while (NextReturnPos != -1) { int NextBracket = DotString.IndexOf("["); string StringToProcess = DotString.Remove(NextBracket - 1); string StringToProcess1 = StringToProcess.Remove(0, 1); if (StringToProcess1.Contains("N") == false) { int Id = Convert.ToInt32(StringToProcess1); Microsoft.Msagl.Drawing.Node Currentnode = new Microsoft.Msagl.Drawing.Node(Id.ToString()); Currentnode.Label.FontColor = Microsoft.Msagl.Drawing.Color.Red; int LabelPos = DotString.IndexOf("label=\""); string LabelString = DotString.Remove(0, LabelPos + 7); LabelPos = LabelString.IndexOf("\""); string FinalLabel = LabelString.Remove(LabelPos); Currentnode.LabelText = FinalLabel; graph.AddNode(Currentnode); } NextReturnPos = DotString.IndexOf("\n"); if (NextReturnPos != -1) { string TmpString = DotString.Remove(0, NextReturnPos + 1); DotString = TmpString; } } DotString = TmpDotString; NextReturnPos = 0; while (NextReturnPos != -1) { int NextBracket = DotString.IndexOf("["); string StringToProcess = DotString.Remove(NextBracket - 1); string StringToProcess1 = StringToProcess.Remove(0, 1); if (StringToProcess1.Contains("N")) { string stringNodeIdxStart = StringToProcess1.Remove(StringToProcess1.IndexOf("-")); int NodeIdxStart = Convert.ToInt32(stringNodeIdxStart); string stringNodeIdxEnd = StringToProcess1.Remove(0, StringToProcess1.IndexOf("N") + 1); int NodeIdxSEnd = Convert.ToInt32(stringNodeIdxEnd); int LabelPos = DotString.IndexOf("label="); LabelPos += 7; string CurrLabelString = DotString.Remove(0, LabelPos); Microsoft.Msagl.Drawing.Edge Currentedge = new Microsoft.Msagl.Drawing.Edge(stringNodeIdxStart, ""/*NodeIdx.ToString()*/, stringNodeIdxEnd); Currentedge.LabelText = CurrLabelString.Remove(CurrLabelString.IndexOf("]") - 1); graph.Edges.Add(Currentedge); } NextReturnPos = DotString.IndexOf("\n"); if (NextReturnPos != -1) { string TmpString = DotString.Remove(0, NextReturnPos + 1); DotString = TmpString; } } return graph; }
//public static List<Microsoft.Msagl.Drawing.Graph> listagraph = new List<Microsoft.Msagl.Drawing.Graph>(); public static string wyszukaj(string el1, string el2, string path) { listaOdw.Add(el1); Microsoft.Msagl.Drawing.Node node1 = graph2.FindNode(el1); Microsoft.Msagl.Drawing.Node node2 = graph2.FindNode(el2); IEnumerator it1 = node1.Edges.GetEnumerator(); while (it1.MoveNext()) { Microsoft.Msagl.Drawing.Edge edgec = (Microsoft.Msagl.Drawing.Edge)it1.Current; Microsoft.Msagl.Drawing.Node nodetar = edgec.TargetNode; Microsoft.Msagl.Drawing.Node nodesou = edgec.SourceNode; Microsoft.Msagl.Drawing.Node good; if (nodetar.Label.Text == el1) { good = nodesou; } else { good = nodetar; } if (!listaOdw.Contains(good.Label.Text)) { //listaOdw.Add(good.Label.Text); if (good.Label.Text == el2) { if (nodetar.Label.Text == el1) { Microsoft.Msagl.Drawing.Edge edge = graph22.AddEdge(nodesou.Label.Text, el1); edge.LabelText = edgec.Label.Text; } else { Microsoft.Msagl.Drawing.Edge edge = graph22.AddEdge(el1, nodetar.Label.Text); edge.LabelText = edgec.Label.Text; } graph22.LayoutAlgorithmSettings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings(); viewer2.Graph = graph22; //associate the viewer with the form form22.Size = new Size(1200, 700); form22.SuspendLayout(); viewer2.Dock = System.Windows.Forms.DockStyle.Fill; form22.Controls.Add(viewer2); form22.ResumeLayout(); //show the form form22.Show(); return(path + " " + edgec.Label.Text + " " + good.Label.Text); } else { if (nodetar.Label.Text == el1) { Microsoft.Msagl.Drawing.Edge edge = graph22.AddEdge(nodesou.Label.Text, el1); edge.LabelText = edgec.Label.Text; } else { Microsoft.Msagl.Drawing.Edge edge = graph22.AddEdge(el1, nodetar.Label.Text); edge.LabelText = edgec.Label.Text; } return(wyszukaj(good.Label.Text, el2, path + " " + edgec.Label.Text + " " + good.Label.Text)); } } } return("not"); }
private void drawGraph(Graph _graph, List <int> _path = null) { List <List <bool> > drawnEdges = new List <List <bool> >(); for (int i = 0; i < _graph.edges.Count; i++) { List <bool> temp = new List <bool>(); temp.Add(true); for (int j = 1; j < _graph.edges[i].Count; j++) { temp.Add(false); } drawnEdges.Add(temp); } graphForm = new Form(); graphForm.Icon = Icon; Microsoft.Msagl.GraphViewerGdi.GViewer graphViewer = new Microsoft.Msagl.GraphViewerGdi.GViewer(); Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph(); for (int i = 0; i < _graph.edges.Count(); i++) { for (int j = 1; j < _graph.edges[i].Count(); j++) { if (!drawnEdges[i][j]) { int nodeAsal = _graph.edges[i][0]; int nodeTujuan = _graph.edges[i][j]; Microsoft.Msagl.Drawing.Edge newEdge = graph.AddEdge(nodeAsal.ToString(), nodeTujuan.ToString()); newEdge.Attr.ArrowheadAtSource = Microsoft.Msagl.Drawing.ArrowStyle.None; newEdge.Attr.ArrowheadAtTarget = Microsoft.Msagl.Drawing.ArrowStyle.None; if (_path != null) { int pathIDNodeAsal = _path.FindIndex(el => el == nodeAsal); int pathIDNodeTujuan = _path.FindIndex(el => el == nodeTujuan); if (pathIDNodeAsal != -1 && pathIDNodeTujuan != -1 && Math.Abs(pathIDNodeAsal - pathIDNodeTujuan) == 1) { newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Red; } else { newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Black; } } drawnEdges[nodeAsal - 1][j] = true; drawnEdges[nodeTujuan - 1][_graph.edges[nodeTujuan - 1].FindIndex(n => n == nodeAsal)] = true; } } } graphViewer.Graph = graph; graphForm.Controls.Add(graphViewer); graphForm.Size = new Size(graphViewer.Size.Width, graphViewer.Size.Height + 30); if (graphForm != null) { graphForm.Show(); } }
public void test9(string file) { parser = new OwlXmlParser(); graph = parser.ParseOwl(file); System.Windows.Forms.Form form = new System.Windows.Forms.Form(); form.Size = new Size(1200, 700); //create a viewer object viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer(); //create a graph object graph2 = new Microsoft.Msagl.Drawing.Graph("graph2"); graph2.LayoutAlgorithmSettings = new Microsoft.Msagl.Layout.MDS.MdsLayoutSettings(); form2 = new System.Windows.Forms.Form(); lista.Size = new Size(200, 30); lista.Location = new Point(40, 30); lista2.Size = new Size(200, 30); lista2.Location = new Point(40, 80); System.Windows.Forms.Button button = new System.Windows.Forms.Button(); button.Size = new Size(200, 30); button.Location = new Point(40, 130); button.Text = "Wybierz"; button.Click += button_click; IDictionaryEnumerator nEnumerator = (IDictionaryEnumerator)graph.Nodes.GetEnumerator(); while (nEnumerator.MoveNext()) { // Get the node from the graph OwlNode node = (OwlNode)graph.Nodes[(nEnumerator.Key).ToString()]; // We will cast the node to a OwlIndividual because we are looking for individuals OwlIndividual indNode = node as OwlIndividual; // If indNode is different from null, then we are dealing with an OwlIndividual -> OK // If the indNode is not anonymous, means that we have an individual with a proper name -> OK if ((indNode != null) && (!indNode.IsAnonymous())) { // So, now we have a good owl-individual Console.WriteLine(indNode.ID.Replace("urn:absolute:sample#", "") + ":"); foreach (OwlEdge a in indNode.ChildEdges) { Console.WriteLine((a.ParentNode.ID + " " + a.ID + " " + a.ChildNode.ID)); if (a.ChildNode.ID != "http://www.w3.org/2002/07/owl#NamedIndividual") { Microsoft.Msagl.Drawing.Edge edge = graph2.AddEdge(a.ParentNode.ID, a.ChildNode.ID); edge.LabelText = a.ID; if (!lista.Items.Contains(a.ParentNode.ID)) { lista.Items.Add(a.ParentNode.ID); lista2.Items.Add(a.ParentNode.ID); } } } /* * foreach (OwlEdge a in indNode.ParentEdges) * { * Console.WriteLine((a.ParentNode.ID + " " + a.ID + " " + a.ChildNode.ID).Replace("urn:absolute:sample#", "").Replace("http://www.w3.org/1999/02/22-rdf-syntax-ns#", "").Replace("http://www.w3.org/2000/01/rdf-schema#", "")); * } */ Console.Write("\n \n"); } } //bind the graph to the viewer viewer.Graph = graph2; //associate the viewer with the form form.SuspendLayout(); viewer.Dock = System.Windows.Forms.DockStyle.Fill; form.Controls.Add(viewer); form.ResumeLayout(); //show the form form.Show(); form2.Controls.Add(lista); form2.Controls.Add(lista2); form2.Controls.Add(button); //show the form form2.ShowDialog(); //Console.WriteLine(graph.Edges.Count); Console.ReadLine(); }
Microsoft.Msagl.Drawing.Graph ComputeAndDisplayGraph(string DotString, bool IsCellular) { int CurrentPos = 0; int NextReturnPos = CurrentPos; List<int> ListNodeId = new List<int>(); string TmpDotString = DotString; Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph"); while (NextReturnPos != -1) { int NextBracket = DotString.IndexOf("["); string StringToProcess = DotString.Remove(NextBracket - 1); string StringToProcess1 = StringToProcess.Remove(0, 1); if (StringToProcess1.Contains("N") == false) { int Id = Convert.ToInt32(StringToProcess1); Microsoft.Msagl.Drawing.Node Currentnode = new Microsoft.Msagl.Drawing.Node(Id.ToString()); Currentnode.Label.FontColor = Microsoft.Msagl.Drawing.Color.Red; int LabelPos = DotString.IndexOf("label=\""); string LabelString = DotString.Remove(0, LabelPos + 7); LabelPos = LabelString.IndexOf("\""); string FinalLabel = LabelString.Remove(LabelPos); Currentnode.LabelText = FinalLabel; if (IsCellular && (FinalLabel[FinalLabel.Length - 1] == ')') && (FinalLabel.Contains('('))) // that's a leaf { int LastBracket = FinalLabel.LastIndexOf('('); string LeafName = FinalLabel.Remove(LastBracket - 1); cCellularPhenotype CP = cGlobalInfo.ListCellularPhenotypes.FindFromName(LeafName); if (CP != null) { Currentnode.Attr.FillColor = new Microsoft.Msagl.Drawing.Color(CP.ColourForDisplay.R, CP.ColourForDisplay.G, CP.ColourForDisplay.B); } } graph.AddNode(Currentnode); } NextReturnPos = DotString.IndexOf("\n"); if (NextReturnPos != -1) { string TmpString = DotString.Remove(0, NextReturnPos + 1); DotString = TmpString; } } DotString = TmpDotString; NextReturnPos = 0; while (NextReturnPos != -1) { int NextBracket = DotString.IndexOf("["); string StringToProcess = DotString.Remove(NextBracket - 1); string StringToProcess1 = StringToProcess.Remove(0, 1); if (StringToProcess1.Contains("N")) { string stringNodeIdxStart = StringToProcess1.Remove(StringToProcess1.IndexOf("-")); int NodeIdxStart = Convert.ToInt32(stringNodeIdxStart); string stringNodeIdxEnd = StringToProcess1.Remove(0, StringToProcess1.IndexOf("N") + 1); int NodeIdxSEnd = Convert.ToInt32(stringNodeIdxEnd); int LabelPos = DotString.IndexOf("label="); LabelPos += 7; string CurrLabelString = DotString.Remove(0, LabelPos); Microsoft.Msagl.Drawing.Edge Currentedge = new Microsoft.Msagl.Drawing.Edge(stringNodeIdxStart, ""/*NodeIdx.ToString()*/, stringNodeIdxEnd); Currentedge.LabelText = CurrLabelString.Remove(CurrLabelString.IndexOf("]") - 1); graph.Edges.Add(Currentedge); } NextReturnPos = DotString.IndexOf("\n"); if (NextReturnPos != -1) { string TmpString = DotString.Remove(0, NextReturnPos + 1); DotString = TmpString; } } return graph; }
/// <summary> /// Displays the edge condition /// </summary> /// <param name="n1">id node 1</param> /// <param name="n2">id node 2</param> /// <param name="node1">node object 1</param> /// <param name="node2">node object 2</param> /// <param name="edge">edge object</param> /// <param name="useCase">use case object</param> private void DisplayEdgeCondition(int n1, int n2, Microsoft.Msagl.Drawing.Node node1, Microsoft.Msagl.Drawing.Node node2, Microsoft.Msagl.Drawing.Edge edge, UseCase useCase) { UseCaseCore.UcIntern.Condition condition = useCase.ConditionMatrix[n1, n2] ?? new UseCaseCore.UcIntern.Condition(); if (this.displayGraphConditions && condition.ConditionText != null) { edge.LabelText = condition.ConditionText + " is " + condition.ConditionState; edge.Label.FontSize = node1.Label.FontSize / 2; edge.Label.FontColor = node1.Attr.FillColor; } }
public MsaglEdgeEventArgs(TEdge edge, Microsoft.Msagl.Drawing.Edge gedge) : base(edge) { this.gedge = gedge; }
public EdgeEventArgs(DrawingEdge edge) { Edge = edge; }