private void OnClickButtonSaveJsonFile(object sender, RoutedEventArgs e) { if (JsonInfo.current == null) { return; } if (JsonInfo.current.Path == null) { OnClickButtonOtherSaveJsonFile(sender, e); return; } FileInfo f = new FileInfo(JsonInfo.current.Path); if (!f.Exists) { OnClickButtonOtherSaveJsonFile(sender, e); return; } // root JsonTreeViewItem = TreeView.Items[0] JsonTreeViewItem root = json_tree_view.Items[0] as JsonTreeViewItem; if (root == null) { return; } JToken Jtok_root = JsonTreeViewItem.convertToJToken(root); FileContoller.write(JsonInfo.current.Path, Jtok_root.ToString()); }
private void SaveFile(string path) { if (!CheckJson()) { return; } JToken Jtok_root = JsonTreeViewItem.convertToJToken(json_tree_view.Items[0] as JsonTreeViewItem); if (FileContoller.write(path, Jtok_root.ToString())) { MessageBox.Show(path + " 파일이 저장되었습니다.", "save"); } else { string caption = "save error"; string message = path + " 파일을 저장하는데 문제가 생겼습니다."; MessageBox.Show(message, caption); Console.WriteLine("[" + caption + "] " + message); } }
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)); } }
private void OnClickButtonOtherSaveJsonFile(object sender, RoutedEventArgs e) { if (JsonInfo.current == null) { return; } SaveFileDialog sfd = new SaveFileDialog(); sfd.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) { sfd.InitialDirectory = dir_path; } } sfd.Filter = "JSon Files (.json)|*.json"; if (sfd.ShowDialog(this) == true) { // root JsonTreeViewItem = TreeView.Items[0] JsonTreeViewItem root = json_tree_view.Items[0] as JsonTreeViewItem; if (root == null) { return; } JToken Jtok_root = JsonTreeViewItem.convertToJToken(root); FileContoller.write(sfd.FileName, Jtok_root.ToString()); JsonInfo.current.Path = sfd.FileName; } }