private void btn_saveNodes_Click(object sender, EventArgs e) { string fileName = ""; using (textInputDialogue updateJarakDialogue = new textInputDialogue("Nama File", "Nama File", null)) { if (updateJarakDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileName = updateJarakDialogue.inputText; } } string path = Directory.GetCurrentDirectory(); path = string.Format("{0}\\SavedGraphs", path); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (fileName == "" || fileName == null) { fileName = "default"; } path = string.Format("{0}\\{1}.json", path, fileName); JsonSerialization.WriteToJsonFile(path, nodeCollection.serialize()); }
private void listview_nodeNeighbors_DoubleClick(object sender, EventArgs e) { if (listview_nodeNeighbors.SelectedItems.Count > 0) { var selectedNode = nodeCollection.getNodeByName(treeView1.SelectedNode.Text); var selectedNeighbor = selectedNode.getNeighborByName(listview_nodeNeighbors.SelectedItems[0].Text); using (textInputDialogue updateJarakDialogue = new textInputDialogue("Update Jarak", "", selectedNeighbor.jarak.ToString())) { updateJarakDialogue.checkBox.Text = "Dua arah"; updateJarakDialogue.checkBox.Visible = true; if (updateJarakDialogue.ShowDialog() == System.Windows.Forms.DialogResult.OK) { selectedNeighbor.jarak = double.Parse(updateJarakDialogue.inputText); if (updateJarakDialogue.checkBox.Checked == true) { if (nodeCollection.getNodeByName(selectedNeighbor.node.name).getNeighborByName(nodeCollection.selectedNode.name) == null) { nodeCollection.getNodeByName(selectedNeighbor.node.name).addNeighbor(nodeCollection.selectedNode.name); } selectedNeighbor.node.getNeighborByName(selectedNode.name).jarak = selectedNeighbor.jarak; } } } populateSelectedNodeDataToList(); } }