Files
omni-scheduler/OmniScheduler/SettingsWindow.xaml.cs
home-PC 2a669bdfe7 feat(app): 初始化 OmniScheduler WPF 调度器
基于 PRD 搭建 .NET 8 WPF 桌面应用,包含主控制台、任务编辑、全局设置、系统托盘和应用图标集成。

实现本地任务模型、触发器规则、JSON 状态持久化、OmniNotify HTTP 推送、执行日志记录、动态变量替换以及基础 Cron 预览能力。

补充 .gitignore,排除构建产物和本地 IDE 文件。

BREAKING CHANGE: 首次提交,建立项目初始结构
2026-05-20 00:12:17 +08:00

57 lines
1.7 KiB
C#

using System.Windows;
namespace OmniScheduler;
public partial class SettingsWindow : Window
{
private readonly AppSettings _settings;
private SettingsWindow(Window owner, AppSettings settings)
{
InitializeComponent();
Owner = owner;
_settings = settings;
StartWithWindowsBox.IsChecked = settings.StartWithWindows;
UrlBox.Text = settings.OmniNotifyUrl;
RetentionDaysBox.Text = settings.LogRetentionDays.ToString();
MaxRecordsBox.Text = settings.MaxLogRecords.ToString();
}
public static bool Edit(Window owner, AppSettings settings)
{
var dialog = new SettingsWindow(owner, settings);
return dialog.ShowDialog() == true;
}
private void Save_Click(object sender, RoutedEventArgs e)
{
ValidationText.Text = "";
if (!Uri.TryCreate(UrlBox.Text.Trim(), UriKind.Absolute, out _))
{
ValidationText.Text = "API 地址格式不正确";
return;
}
if (!int.TryParse(RetentionDaysBox.Text, out var days) || days < 1)
{
ValidationText.Text = "日志保留天数至少为 1";
return;
}
if (!int.TryParse(MaxRecordsBox.Text, out var max) || max < 100)
{
ValidationText.Text = "最大日志条数至少为 100";
return;
}
_settings.StartWithWindows = StartWithWindowsBox.IsChecked == true;
_settings.OmniNotifyUrl = UrlBox.Text.Trim();
_settings.LogRetentionDays = days;
_settings.MaxLogRecords = max;
DialogResult = true;
}
private void Cancel_Click(object sender, RoutedEventArgs e)
=> DialogResult = false;
}