v1.2.0: 重构为插件+独立Manager架构,横版UI,精确保留文本框边距的文档转换
This commit is contained in:
44
Manager/Services/InkSettings.cs
Normal file
44
Manager/Services/InkSettings.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace BetterSeewo.Manager.Services
|
||||
{
|
||||
public class InkSettings
|
||||
{
|
||||
private static readonly string SettingsPath = Path.Combine(
|
||||
System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData),
|
||||
"BetterEN5", "ink-settings.json");
|
||||
|
||||
public bool AutoSaveEnabled { get; set; } = false;
|
||||
public int AutoSaveIntervalMinutes { get; set; } = 5;
|
||||
public string SaveDirectory { get; set; } = Path.Combine(
|
||||
System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments),
|
||||
"Better-Seewo", "Ink");
|
||||
|
||||
public static InkSettings Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(SettingsPath))
|
||||
{
|
||||
var json = File.ReadAllText(SettingsPath);
|
||||
return JsonSerializer.Deserialize<InkSettings>(json) ?? new InkSettings();
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
return new InkSettings();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dir = Path.GetDirectoryName(SettingsPath);
|
||||
if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
File.WriteAllText(SettingsPath, JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true }));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user