private void OnClickButtonOpenJsonFile(object sender, RoutedEventArgs e) { if (JsonInfo.current == null) { return; } JsonInfo.current.Clear(); OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = root_path; if (JsonInfo.current.Path != null) { string dir_path = JsonInfo.current.Path.Substring(0, JsonInfo.current.Path.LastIndexOf('\\') + 1); DirectoryInfo d = new DirectoryInfo(dir_path); if (d.Exists) { ofd.InitialDirectory = dir_path; } } // 파일 열기 ofd.Filter = "JSon Files (.json)|*.json"; if (ofd.ShowDialog(this) == true) { Console.WriteLine(ofd.FileName); string json = FileContoller.read(ofd.FileName); refreshJsonTree(JsonController.parseJson(json)); JsonInfo.current.Path = ofd.FileName; } }
public void refreshJsonItem(string jsonString) { cur_jsonfile.jroot = JsonController.parseJson(jsonString); var children = new List <JToken>(); if (cur_jsonfile.jroot != null) { children.Add(cur_jsonfile.jroot); } treeView1.ItemsSource = null; treeView1.Items.Clear(); treeView1.ItemsSource = children; }
private void OnClickButtonCancelJsonFile(object sender, RoutedEventArgs e) { if (JsonInfo.current == null || JsonInfo.current.Path == null) { return; } string dir_path = JsonInfo.current.Path.Substring(0, JsonInfo.current.Path.LastIndexOf('\\') + 1); DirectoryInfo d = new DirectoryInfo(dir_path); if (!d.Exists) { return; } string json = FileContoller.read(JsonInfo.current.path); refreshJsonTree(JsonController.parseJson(json)); }
public void refreshJsonItem(string json, string filenama) { // 삭제 treeView_json.Items.Clear(); // 추가 List <string> key_stack = new List <string>(); TreeViewItem trvItem = new TreeViewItem(); trvItem.Header = filenama; //trvItem.Tag = "0000"; addButtonAddjson(trvItem, key_stack); treeView_json.Items.Add(trvItem); if (json != null) { cur_jsonfile.jtoken = JsonController.parseJson(json); addJsonItem(trvItem, cur_jsonfile.jtoken as JObject, key_stack); } }
private void OnClickButtonViewJsonFile(object sender, RoutedEventArgs e) { if (JsonInfo.current == null || JsonInfo.current.Path == null) { return; } JsonTreeViewItem root = json_tree_view.Items[0] as JsonTreeViewItem; if (root == null) { return; } Window_ViewFile w = new Window_ViewFile(JsonTreeViewItem.convertToJToken(root).ToString(), JsonInfo.current.Path); //Window_ViewFile w = new Window_ViewFile(FileContoller.read(JsonInfo.current.Path), JsonInfo.current.Path); if (w.ShowDialog() == true) { refreshJsonTree(JsonController.parseJson(w.tb_file.Text)); } }