public void resetGraph() // Mengembalikan graf ke wujud awal saat dibentuk { for (int i = 1; i < map.getHouses(); i++) { for (int j = 0; j < map.getPath(i).Count(); j++) { string str1 = i.ToString(); string str2 = map.getPath(i)[j].ToString(); graph.FindNode(str1).Attr.FillColor = Microsoft.Msagl.Drawing.Color.White; graph.FindNode(str2).Attr.FillColor = Microsoft.Msagl.Drawing.Color.White; } } }
private void Load_Graph_Click(object sender, RoutedEventArgs e) // Membuat graf satu arah dari file peta yang sudah diload sebelumnya { try { map = new Graf(dirGraph); Enter_Query.IsEnabled = true; Open_Query.IsEnabled = true; Next.IsEnabled = false; this.gViewer.Graph = null; graph = new Msagl.Graph("graph"); for (int i = map.getHouses() - 1; i > 0; i--) { for (int j = map.getPath(i).Count() - 1; j >= 0; j--) { string str1 = i.ToString(); string str2 = map.getPath(i)[j].ToString(); graph.AddEdge(str1, str2).Attr.ArrowheadAtTarget = Msagl.ArrowStyle.None; Microsoft.Msagl.Drawing.Node from = graph.FindNode(str1); Microsoft.Msagl.Drawing.Node to = graph.FindNode(str2); from.Attr.FillColor = Microsoft.Msagl.Drawing.Color.White; from.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Circle; to.Attr.FillColor = Microsoft.Msagl.Drawing.Color.White; to.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Circle; } } this.gViewer.Graph = graph; } catch { MessageBox.Show(" Error Code 0x05021999\n File Input Error", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }