bool DeleteGraphJSON(ExtendProgressBar pb_graph) { lock (lockObj) { var path = Properties.Settings.Default.WorkingFolderPath; if (!Directory.Exists(path)) { return(true); } string[] filePaths = Directory.GetFiles(path); try { foreach (string filePath in filePaths) { var graph = Properties.Settings.Default.RawGraphFile; var graph_flag = Properties.Settings.Default.RawGraphFlag; if (filePath.Contains(graph) || filePath.Contains(graph_flag)) { File.SetAttributes(filePath, FileAttributes.Normal); File.Delete(filePath); } } pb_graph.Refresh("delete json graph."); return(true); } catch (Exception) { pb_graph.Refresh("fail to delete json graph"); return(false); } } }
protected bool DeleteLayout(ExtendProgressBar pb_layout) { var path = Properties.Settings.Default.WorkingFolderPath; if (!Directory.Exists(path)) { return(true); } string[] filePaths = Directory.GetFiles(path); try { foreach (string filePath in filePaths) { var layout = Properties.Settings.Default.LayoutFile; var layout_flag = Properties.Settings.Default.LayoutFlag; if (filePath.Contains(layout) || filePath.Contains(layout_flag)) { File.SetAttributes(filePath, FileAttributes.Normal); File.Delete(filePath); } } pb_layout.Refresh("delete json graph."); return(true); } catch (Exception) { pb_layout.Refresh("fail to delete json graph"); return(false); } }
protected bool DeleteTmpGraphJSON(ExtendProgressBar pb_layout) { var path = Properties.Settings.Default.WorkingFolderPath; if (!Directory.Exists(path)) { return(true); } string[] filePaths = Directory.GetFiles(path); try { foreach (string filePath in filePaths) { var graph = Properties.Settings.Default.TmpGraphFile; if (filePath.Contains(graph)) { File.SetAttributes(filePath, FileAttributes.Normal); File.Delete(filePath); } } pb_layout.Refresh("delete tmp json"); return(true); } catch (Exception) { pb_layout.Refresh("fail to delete tmp json"); return(false); } }
public RawGraph Generate(int graph_seed, ExtendProgressBar pb_graph) { var working_folder_path = Properties.Settings.Default.WorkingFolderPath; var state = 0; switch (state) { case 0: //Console.WriteLine("-----"); //Console.WriteLine("ok Start Graph Generation"); var delete_success = this.DeleteGraphJSON(pb_graph); //グラフjson削除 if (!delete_success) { goto default; } var python_success = this.PythonGraphGenerate(graph_seed, this.SeedEnable); //グラフjson生成 if (!python_success) { goto default; } var raw_graph = this.ReadJSON(); //生成したグラフjson読み込み var graph_enum = this.MyGraphEnum; //graphGeneratorのインスタンス化時に設定済み raw_graph.MyGraphEnum = graph_enum; if (raw_graph.Links == null || raw_graph.Nodes.Count == 0 || graph_enum == GraphEnum.Void) { goto default; } pb_graph.Refresh($"{graph_enum.ToString()} size:{raw_graph.Nodes.Count} edge:{raw_graph.Links.Count} seed:{graph_seed}"); //Console.Write("Node: " + raw_graph.Nodes.Count); //Console.Write(" Edge: " + raw_graph.Links.Count); //Console.Write(" GraphEnum: " + graph_enum.ToString()); //Console.WriteLine(" Graph Seed: " + graph_seed); return(raw_graph); default: //Console.WriteLine("no Failure Graph Generation"); pb_graph.Refresh($"failure graph generate"); return(null); } }
public virtual Layout Generate(ExtendProgressBar pb_layout) { var state = 0; switch (state) { case 0: var delete_success = this.DeleteLayout(pb_layout); if (!delete_success) { goto default; } delete_success = this.DeleteTmpGraphJSON(pb_layout); if (!delete_success) { goto default; } var python_success = this.PythonLayoutGenerate(this.MyGraph); if (!python_success) { goto default; } var layout = this.ReadLayout(); if (layout == null) { goto default; } pb_layout.Refresh("success layout generate"); return(layout); default: pb_layout.Refresh($"failure graph generate"); return(null); } }