回读图像功能优化

This commit is contained in:
“hsc”
2026-07-30 16:33:32 +08:00
parent f350058f53
commit 850156bfa2
10 changed files with 672 additions and 11 deletions

View File

@@ -61,6 +61,37 @@ namespace UIShare.GlobalVariable
}
}
/// <summary>
/// 保存全局配置
/// </summary>
public static void SaveGlobalConfig(GlobalConfig config)
{
if (config == null) return;
lock (_fileLock)
{
try
{
if (!Directory.Exists(config.SystemPath))
Directory.CreateDirectory(config.SystemPath);
string configPath = Path.Combine(config.SystemPath, "GlobalConfig.json");
string json = JsonConvert.SerializeObject(config, Formatting.Indented, new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.All
});
File.WriteAllText(configPath, json);
}
catch (Exception ex)
{
}
}
}
/// <summary>
/// 确保配置中至少包含一个 CAN 设备(对应 SystemConfig.CANFD
/// 旧配置或空配置会自动升级,使用户在设置界面能看到 CAN 设备。

View File

@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UIShare.GlobalVariable
{
public class GlobalConfig
{
[JsonIgnore]
public string SystemPath { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ACP");
public string DefaultCSVFilePath { get; set; } = "";
}
}