63 lines
1.9 KiB
C#
63 lines
1.9 KiB
C#
namespace WorkCameraExport.Models
|
|
{
|
|
/// <summary>
|
|
/// 应用配置 - 用户可配置项
|
|
/// </summary>
|
|
public class AppConfig
|
|
{
|
|
/// <summary>
|
|
/// 默认保存路径
|
|
/// </summary>
|
|
public string DefaultSavePath { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// 图片下载并发数 (1-10)
|
|
/// </summary>
|
|
public int ImageDownloadConcurrency { get; set; } = 5;
|
|
|
|
/// <summary>
|
|
/// 图片压缩质量 (30-100)
|
|
/// </summary>
|
|
public int ImageCompressQuality { get; set; } = 50;
|
|
|
|
/// <summary>
|
|
/// 自动清理临时文件
|
|
/// </summary>
|
|
public bool AutoCleanTempFiles { get; set; } = true;
|
|
|
|
/// <summary>
|
|
/// 验证并修正配置值
|
|
/// </summary>
|
|
public void Validate()
|
|
{
|
|
// 并发数限制在 1-10
|
|
if (ImageDownloadConcurrency < 1) ImageDownloadConcurrency = 1;
|
|
if (ImageDownloadConcurrency > 10) ImageDownloadConcurrency = 10;
|
|
|
|
// 压缩质量限制在 30-100
|
|
if (ImageCompressQuality < 30) ImageCompressQuality = 30;
|
|
if (ImageCompressQuality > 100) ImageCompressQuality = 100;
|
|
|
|
// 默认保存路径为空时使用桌面
|
|
if (string.IsNullOrWhiteSpace(DefaultSavePath))
|
|
{
|
|
DefaultSavePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建默认配置
|
|
/// </summary>
|
|
public static AppConfig CreateDefault()
|
|
{
|
|
return new AppConfig
|
|
{
|
|
DefaultSavePath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
|
|
ImageDownloadConcurrency = 5,
|
|
ImageCompressQuality = 50,
|
|
AutoCleanTempFiles = true
|
|
};
|
|
}
|
|
}
|
|
}
|