准备做控件序列化工作
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Ramitta;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -122,6 +124,11 @@ namespace template
|
||||
|
||||
private void 改(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string outputPath = @"C:\Users\Xeroly\Desktop\sieghail.json";
|
||||
|
||||
// 方法1:使用File.ReadAllText(推荐)
|
||||
string jsonContent = File.ReadAllText(outputPath);
|
||||
TreeList.JsonParse(jsonContent);
|
||||
|
||||
}
|
||||
|
||||
@@ -132,15 +139,24 @@ namespace template
|
||||
|
||||
private void 查(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var sukablayt = TreeList.FindArgvNode(null, ["GroupF"]);
|
||||
|
||||
foreach (var arg in sukablayt.Children) {
|
||||
var suka = arg as CheckboxTreeNode;
|
||||
Debug.WriteLine($"{arg.Text}:{suka.IsChecked}");
|
||||
string outputPath = @"C:\Users\Xeroly\Desktop\sieghail.json"; // 修改为你想要保存的路径
|
||||
|
||||
// 获取要输出的文本
|
||||
string outputText = TreeList.JsonPrint().ToString();
|
||||
|
||||
// 使用StreamWriter将文本写入文件
|
||||
try
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(outputPath, false)) // 'true'表示以追加模式写入文件
|
||||
{
|
||||
writer.WriteLine(outputText); // 写入文本
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("错误: " + ex.Message); // 如果写入过程中出现异常,弹出错误信息
|
||||
}
|
||||
|
||||
if (sukablayt == null)DebugBar(Debugtag, $"没找到", 通知蓝色);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user