From f3ef2f7aecf8c2ab941c01e049a99d960d40a5df Mon Sep 17 00:00:00 2001
From: PrefacedCorg <1876568293@qq.com>
Date: Sat, 25 Apr 2026 20:26:56 +0800
Subject: [PATCH] =?UTF-8?q?feat(=E8=AE=BE=E7=BD=AE):=20=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=E9=AB=98=E7=BA=A7=E8=AE=BE=E7=BD=AE=E5=92=8C=E9=9A=8F=E6=9C=BA?=
=?UTF-8?q?=E7=82=B9=E5=90=8D=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
refactor: 将高级和随机点名设置从主窗口迁移到独立页面
style: 优化墨迹识别页面的高精度直线拉直开关样式
fix: 修复URI处理中未刷新配置列表的问题
---
Ink Canvas/MainWindow.xaml | 305 +-------
Ink Canvas/MainWindow.xaml.cs | 55 +-
.../MainWindow_cs/MW_FloatingBarIcons.cs | 2 +-
Ink Canvas/MainWindow_cs/MW_Settings.cs | 671 ------------------
Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs | 95 +--
Ink Canvas/MainWindow_cs/MW_UriHandler.cs | 1 -
.../SettingsViews/Pages/AdvancedPage.xaml | 226 ++++++
.../SettingsViews/Pages/AdvancedPage.xaml.cs | 467 ++++++++++++
.../Windows/SettingsViews/Pages/HomePage.xaml | 14 +
.../Pages/InkRecognitionPage.xaml | 16 +-
.../Pages/InkRecognitionPage.xaml.cs | 6 +-
.../SettingsViews/Pages/RandomDrawPage.xaml | 207 ++++++
.../Pages/RandomDrawPage.xaml.cs | 346 +++++++++
.../Windows/SettingsViews/SettingsWindow.xaml | 22 +
.../SettingsViews/SettingsWindow.xaml.cs | 2 +
15 files changed, 1339 insertions(+), 1096 deletions(-)
create mode 100644 Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml
create mode 100644 Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml.cs
create mode 100644 Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml
create mode 100644 Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml.cs
diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml
index 3c3b8c40..8da7981c 100644
--- a/Ink Canvas/MainWindow.xaml
+++ b/Ink Canvas/MainWindow.xaml
@@ -26,7 +26,7 @@
Closing="Window_Closing"
Closed="Window_Closed"
PreviewKeyDown="Main_Grid_PreviewKeyDown"
- Height="11080" Width="1440"
+ Height="6000" Width="1440"
FontFamily="Microsoft YaHei UI"
MouseWheel="Window_MouseWheel"
Foreground="{DynamicResource FloatBarForeground}"
@@ -1478,138 +1478,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- s
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs
index a7034425..26fc6532 100644
--- a/Ink Canvas/MainWindow.xaml.cs
+++ b/Ink Canvas/MainWindow.xaml.cs
@@ -1166,6 +1166,21 @@ namespace Ink_Canvas
public static Settings Settings { get => SettingsManager.Settings; set => SettingsManager.Settings = value; }
public static string settingsFileName => SettingsManager.SettingsFileName;
+
+ public void UpdateInkSmoothingConfig()
+ {
+ _inkSmoothingManager?.UpdateConfig();
+ }
+
+ public void UpdatePickNameBackgroundsInComboBox()
+ {
+ }
+
+ public void UpdatePickNameBackgroundDisplay()
+ {
+ }
+
+ public string _lastAppliedProfileName;
private bool isLoaded;
private bool _suppressChickenSoupSourceSelectionChanged;
private bool forcePointEraser;
@@ -2413,14 +2428,24 @@ namespace Ink_Canvas
targetGroupBox = GroupBoxPPT;
break;
case "advanced":
- targetGroupBox = GroupBoxAdvanced;
- break;
+ {
+ var sw = new Windows.SettingsViews.SettingsWindow();
+ sw.Owner = this;
+ sw.NavigateToPage("AdvancedPage");
+ sw.ShowDialog();
+ return;
+ }
case "automation":
targetGroupBox = GroupBoxAutomation;
break;
case "randomwindow":
- targetGroupBox = GroupBoxRandWindow;
- break;
+ {
+ var sw = new Windows.SettingsViews.SettingsWindow();
+ sw.Owner = this;
+ sw.NavigateToPage("RandomDrawPage");
+ sw.ShowDialog();
+ return;
+ }
case "theme":
{
var sw = new Windows.SettingsViews.SettingsWindow();
@@ -2563,8 +2588,13 @@ namespace Ink_Canvas
SetNavButtonTag("ppt");
break;
case "advanced":
- SetNavButtonTag("advanced");
- break;
+ {
+ var sw = new Windows.SettingsViews.SettingsWindow();
+ sw.Owner = this;
+ sw.NavigateToPage("AdvancedPage");
+ sw.ShowDialog();
+ return;
+ }
case "automation":
SetNavButtonTag("automation");
break;
@@ -3470,22 +3500,13 @@ namespace Ink_Canvas
PPTRSButtonOpacityValueSlider,
PPTLBButtonOpacityValueSlider,
PPTRBButtonOpacityValueSlider,
- TouchMultiplierSlider,
- NibModeBoundsWidthSlider,
- FingerModeBoundsWidthSlider,
SideControlMinimumAutomationSlider,
- RandWindowOnceCloseLatencySlider,
- RandWindowOnceMaxStudentsSlider,
- TimerVolumeSlider,
- ProgressiveReminderVolumeSlider,
BoardInkWidthSlider,
BoardInkAlphaSlider,
BoardHighlighterWidthSlider,
InkWidthSlider,
InkAlphaSlider,
- HighlighterWidthSlider,
- MLAvoidanceHistorySlider,
- MLAvoidanceWeightSlider
+ HighlighterWidthSlider
};
foreach (var slider in sliders)
@@ -3906,7 +3927,7 @@ namespace Ink_Canvas
///
/// 显示快抽悬浮按钮
///
- private void ShowQuickDrawFloatingButton()
+ public void ShowQuickDrawFloatingButton()
{
try
{
diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
index 0adc744c..c4422e94 100644
--- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
+++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
@@ -3550,7 +3550,7 @@ namespace Ink_Canvas
SyncPdfPageSidebarWithCanvas();
}
- internal int BoundsWidth = 5;
+ public int BoundsWidth = 5;
private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e)
{
diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs
index dba3a0c0..837e6072 100644
--- a/Ink Canvas/MainWindow_cs/MW_Settings.cs
+++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs
@@ -1887,22 +1887,6 @@ namespace Ink_Canvas
- private void ToggleSwitchDisableHardwareAcceleration_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- var isOnObj = sender?.GetType().GetProperty("IsOn")?.GetValue(sender);
- if (isOnObj is bool isOn)
- {
- Settings.Canvas.UseHardwareAcceleration = !isOn;
- }
- else
- {
- return;
- }
-
- _inkSmoothingManager?.UpdateConfig();
- SaveSettingsToFile();
- }
private void ToggleSwitchAutoSaveStrokesInPowerPoint_Toggled(object sender, RoutedEventArgs e)
{
@@ -2460,599 +2444,6 @@ namespace Ink_Canvas
#endregion
- #region Advanced
-
- private void ToggleSwitchIsSpecialScreen_OnToggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsSpecialScreen = ToggleSwitchIsSpecialScreen.IsOn;
- TouchMultiplierSlider.Visibility =
- ToggleSwitchIsSpecialScreen.IsOn ? Visibility.Visible : Visibility.Collapsed;
- SaveSettingsToFile();
- }
-
- private void TouchMultiplierSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.TouchMultiplier = e.NewValue;
- SaveSettingsToFile();
- }
-
- private void BorderCalculateMultiplier_TouchDown(object sender, TouchEventArgs e)
- {
- var args = e.GetTouchPoint(null).Bounds;
- double value;
- if (!Settings.Advanced.IsQuadIR) value = args.Width;
- else value = Math.Sqrt(args.Width * args.Height); //四边红外
-
- TextBlockShowCalculatedMultiplier.Text = (5 / (value * 1.1)).ToString();
- }
-
- private void ToggleSwitchEraserBindTouchMultiplier_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.EraserBindTouchMultiplier = ToggleSwitchEraserBindTouchMultiplier.IsOn;
- SaveSettingsToFile();
- }
-
- private void NibModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.NibModeBoundsWidth = (int)e.NewValue;
-
- if (Settings.Startup.IsEnableNibMode)
- BoundsWidth = Settings.Advanced.NibModeBoundsWidth;
- else
- BoundsWidth = Settings.Advanced.FingerModeBoundsWidth;
-
- SaveSettingsToFile();
- }
-
- private void FingerModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.FingerModeBoundsWidth = (int)e.NewValue;
-
- if (Settings.Startup.IsEnableNibMode)
- BoundsWidth = Settings.Advanced.NibModeBoundsWidth;
- else
- BoundsWidth = Settings.Advanced.FingerModeBoundsWidth;
-
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchIsQuadIR_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsQuadIR = ToggleSwitchIsQuadIR.IsOn;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchIsLogEnabled_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsLogEnabled = ToggleSwitchIsLogEnabled.IsOn;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchIsSaveLogByDate_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsSaveLogByDate = ToggleSwitchIsSaveLogByDate.IsOn;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchIsSecondConfimeWhenShutdownApp_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsSecondConfirmWhenShutdownApp = ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchIsAutoBackupBeforeUpdate_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsAutoBackupBeforeUpdate = ToggleSwitchIsAutoBackupBeforeUpdate.IsOn;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchIsAutoBackupEnabled_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.Advanced.IsAutoBackupEnabled = ToggleSwitchIsAutoBackupEnabled.IsOn;
- SaveSettingsToFile();
- }
-
- private void ComboBoxAutoBackupInterval_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!isLoaded) return;
- if (ComboBoxAutoBackupInterval.SelectedItem is ComboBoxItem selectedItem && selectedItem.Tag != null)
- {
- if (int.TryParse(selectedItem.Tag.ToString(), out int interval))
- {
- Settings.Advanced.AutoBackupIntervalDays = interval;
- SaveSettingsToFile();
- }
- }
- }
-
- private void BtnManualBackup_Click(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
-
- try
- {
- // 确保Backups目录存在
- string backupDir = Path.Combine(App.RootPath, "Backups");
- if (!Directory.Exists(backupDir))
- {
- Directory.CreateDirectory(backupDir);
- LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
- }
-
- // 创建备份文件名(使用当前日期时间)
- string backupFileName = $"Settings_Backup_{DateTime.Now:yyyyMMdd_HHmmss}.json";
- string backupPath = Path.Combine(backupDir, backupFileName);
-
- // 序列化当前设置并保存到备份文件
- string settingsJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
- File.WriteAllText(backupPath, settingsJson);
-
- LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}");
- MessageBox.Show($"设置已成功备份到:\n{backupPath}", "备份成功", MessageBoxButton.OK, MessageBoxImage.Information);
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"创建设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
- MessageBox.Show($"创建备份失败: {ex.Message}", "备份失败", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- private void BtnRestoreBackup_Click(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
-
- try
- {
- // 确保Backups目录存在
- string backupDir = Path.Combine(App.RootPath, "Backups");
- if (!Directory.Exists(backupDir))
- {
- Directory.CreateDirectory(backupDir);
- LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
- MessageBox.Show("没有找到备份文件,请先创建备份", "还原失败", MessageBoxButton.OK, MessageBoxImage.Warning);
- return;
- }
-
- // 打开文件选择对话框
- OpenFileDialog dlg = new OpenFileDialog();
- dlg.InitialDirectory = backupDir;
- dlg.Filter = "设置备份文件|Settings_Backup_*.json|所有JSON文件|*.json";
- dlg.Title = "选择要还原的备份文件";
-
- if (dlg.ShowDialog() == true)
- {
- // 读取备份文件
- string backupJson = File.ReadAllText(dlg.FileName);
-
- // 反序列化备份数据
- Settings backupSettings = JsonConvert.DeserializeObject(backupJson);
-
- if (backupSettings != null)
- {
- // 确认是否要还原
- if (MessageBox.Show("确定要还原选择的备份文件吗?当前设置将被覆盖。", "确认还原",
- MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
- {
-
- // 备份当前设置,以防出错
- string currentSettingsJson = JsonConvert.SerializeObject(Settings, Formatting.Indented);
- string tempBackupPath = Path.Combine(backupDir, $"Settings_Before_Restore_{DateTime.Now:yyyyMMdd_HHmmss}.json");
- File.WriteAllText(tempBackupPath, currentSettingsJson);
-
- // 还原设置
- Settings = backupSettings;
-
- // 保存还原后的设置到文件
- SaveSettingsToFile();
-
- // 重新加载设置到UI
- LoadSettings();
-
- LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}");
- MessageBox.Show("设置已成功还原,部分设置可能需要重启软件后生效。", "还原成功", MessageBoxButton.OK, MessageBoxImage.Information);
- }
- }
- else
- {
- MessageBox.Show("无法解析备份文件,文件可能已损坏", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"还原设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
- MessageBox.Show($"还原备份失败: {ex.Message}", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- private bool _isRefreshingConfigProfileList;
- private string _lastAppliedProfileName;
-
- private void RefreshConfigProfileList()
- {
- try
- {
- if (ComboBoxConfigProfile == null) return;
- _isRefreshingConfigProfileList = true;
- try
- {
- var names = ConfigProfileManager.ListProfileNames();
- ComboBoxConfigProfile.ItemsSource = names;
- if (names.Count == 0)
- {
- ComboBoxConfigProfile.SelectedItem = null;
- }
- else if (_lastAppliedProfileName != null && names.Contains(_lastAppliedProfileName))
- {
- ComboBoxConfigProfile.SelectedItem = _lastAppliedProfileName;
- }
- else
- {
- var selected = ComboBoxConfigProfile.SelectedItem as string;
- if (selected != null && names.Contains(selected))
- ComboBoxConfigProfile.SelectedItem = selected;
- else
- ComboBoxConfigProfile.SelectedIndex = 0;
- }
- if (BtnDeleteConfigProfile != null)
- BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile.SelectedItem != null;
- }
- finally
- {
- _isRefreshingConfigProfileList = false;
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"刷新配置方案列表失败: {ex.Message}", LogHelper.LogType.Error);
- }
- }
-
- private void ComboBoxConfigProfile_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (BtnDeleteConfigProfile != null)
- BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile?.SelectedItem != null;
- if (!isLoaded || _isRefreshingConfigProfileList) return;
- var name = ComboBoxConfigProfile?.SelectedItem as string;
- if (string.IsNullOrEmpty(name)) return;
- try
- {
- if (ConfigProfileManager.ApplyProfile(name))
- {
- _lastAppliedProfileName = name;
- ReloadSettingsFromFile();
- ShowNotification($"已切换至方案「{name}」");
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"切换配置方案失败: {ex.Message}", LogHelper.LogType.Error);
- }
- }
-
- private async void BtnSaveAsConfigProfile_Click(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- var input = new System.Windows.Controls.TextBox
- {
- MinWidth = 260,
- Padding = new Thickness(8, 6, 8, 6),
- Margin = new Thickness(0, 0, 0, 12)
- };
- var label = new System.Windows.Controls.TextBlock
- {
- Text = "方案名称",
- Margin = new Thickness(0, 0, 0, 8)
- };
- var content = new iNKORE.UI.WPF.Controls.SimpleStackPanel { Spacing = 6 };
- content.Children.Add(label);
- content.Children.Add(input);
- var dialog = new iNKORE.UI.WPF.Modern.Controls.ContentDialog
- {
- Title = "另存为方案",
- Content = content,
- PrimaryButtonText = "保存",
- SecondaryButtonText = "取消",
- Owner = this
- };
- var result = await dialog.ShowAsync();
- if (result != iNKORE.UI.WPF.Modern.Controls.ContentDialogResult.Primary) return;
- var name = input.Text?.Trim();
- if (string.IsNullOrEmpty(name))
- {
- MessageBox.Show("请输入方案名称。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Information);
- return;
- }
- try
- {
- var json = JsonConvert.SerializeObject(Settings, Formatting.Indented);
- if (ConfigProfileManager.SaveAsProfile(name, json))
- {
- _lastAppliedProfileName = name;
- RefreshConfigProfileList();
- ShowNotification($"已另存为方案:{name}");
- }
- else
- MessageBox.Show("保存失败,请查看日志。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"另存为方案失败: {ex.Message}", LogHelper.LogType.Error);
- MessageBox.Show($"保存失败: {ex.Message}", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- private void BtnDeleteConfigProfile_Click(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- var name = ComboBoxConfigProfile?.SelectedItem as string;
- if (string.IsNullOrEmpty(name))
- {
- MessageBox.Show("请先选择要删除的配置文件。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Information);
- return;
- }
- try
- {
- if (MessageBox.Show($"确定要删除配置文件「{name}」吗?", "确认删除", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
- return;
- if (ConfigProfileManager.DeleteProfile(name))
- {
- RefreshConfigProfileList();
- var nextName = ComboBoxConfigProfile?.SelectedItem as string;
- if (!string.IsNullOrEmpty(nextName) && ConfigProfileManager.ApplyProfile(nextName))
- {
- _lastAppliedProfileName = nextName;
- ReloadSettingsFromFile();
- ShowNotification($"已删除方案「{name}」,已切换至「{nextName}」");
- }
- else
- ShowNotification($"已删除方案:{name}");
- }
- else
- MessageBox.Show("删除配置文件失败,请查看日志。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Warning);
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"删除配置文件失败: {ex.Message}", LogHelper.LogType.Error);
- MessageBox.Show($"删除配置文件失败: {ex.Message}", "配置文件", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
-
- #endregion
-
- #region RandSettings
-
- private void ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.DisplayRandWindowNamesInputBtn = ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn;
- SaveSettingsToFile();
- }
-
- private void RandWindowOnceCloseLatencySlider_ValueChanged(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.RandWindowOnceCloseLatency = RandWindowOnceCloseLatencySlider.Value;
- SaveSettingsToFile();
- }
-
- private void RandWindowOnceMaxStudentsSlider_ValueChanged(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.RandWindowOnceMaxStudents = (int)RandWindowOnceMaxStudentsSlider.Value;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchUseLegacyTimerUI_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
- if (ToggleSwitchUseLegacyTimerUI.IsOn)
- {
- ToggleSwitchUseNewStyleUI.IsOn = false;
- Settings.RandSettings.UseNewStyleUI = false;
- }
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchUseNewStyleUI_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.UseNewStyleUI = ToggleSwitchUseNewStyleUI.IsOn;
- if (ToggleSwitchUseNewStyleUI.IsOn)
- {
- ToggleSwitchUseLegacyTimerUI.IsOn = false;
- Settings.RandSettings.UseLegacyTimerUI = false;
- }
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchEnableOvertimeCountUp_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.EnableOvertimeCountUp = ToggleSwitchEnableOvertimeCountUp.IsOn;
-
- if (!ToggleSwitchEnableOvertimeCountUp.IsOn)
- {
- ToggleSwitchEnableOvertimeRedText.IsOn = false;
- Settings.RandSettings.EnableOvertimeRedText = false;
- }
-
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchEnableOvertimeRedText_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
-
- if (ToggleSwitchEnableOvertimeRedText.IsOn && !ToggleSwitchEnableOvertimeCountUp.IsOn)
- {
- ToggleSwitchEnableOvertimeCountUp.IsOn = true;
- Settings.RandSettings.EnableOvertimeCountUp = true;
- }
-
- Settings.RandSettings.EnableOvertimeRedText = ToggleSwitchEnableOvertimeRedText.IsOn;
- SaveSettingsToFile();
- }
-
- private void TimerVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.TimerVolume = TimerVolumeSlider.Value;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchEnableProgressiveReminder_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.EnableProgressiveReminder = ToggleSwitchEnableProgressiveReminder.IsOn;
- SaveSettingsToFile();
- }
-
- // 新点名UI设置事件处理
- private void ToggleSwitchUseNewRollCallUI_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.UseNewRollCallUI = ToggleSwitchUseNewRollCallUI.IsOn;
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchEnableMLAvoidance_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.EnableMLAvoidance = ToggleSwitchEnableMLAvoidance.IsOn;
- SaveSettingsToFile();
- }
-
- private void MLAvoidanceHistorySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.MLAvoidanceHistoryCount = (int)MLAvoidanceHistorySlider.Value;
- SaveSettingsToFile();
- }
-
- private void MLAvoidanceWeightSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.MLAvoidanceWeight = MLAvoidanceWeightSlider.Value;
- SaveSettingsToFile();
- }
-
- private void ProgressiveReminderVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
- Settings.RandSettings.ProgressiveReminderVolume = ProgressiveReminderVolumeSlider.Value;
- SaveSettingsToFile();
- }
-
- private void ButtonSelectCustomProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
- {
- Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
- {
- Title = "选择渐进提醒音频文件",
- Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
- DefaultExt = "wav"
- };
-
- if (openFileDialog.ShowDialog() == true)
- {
- Settings.RandSettings.ProgressiveReminderSoundPath = openFileDialog.FileName;
- SaveSettingsToFile();
- }
- }
-
- private void ButtonResetProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
- {
- Settings.RandSettings.ProgressiveReminderSoundPath = "";
- SaveSettingsToFile();
- }
-
- private void ButtonSelectCustomTimerSound_Click(object sender, RoutedEventArgs e)
- {
- Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
- {
- Title = "选择计时器提醒铃声",
- Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
- DefaultExt = "wav"
- };
-
- if (openFileDialog.ShowDialog() == true)
- {
- Settings.RandSettings.CustomTimerSoundPath = openFileDialog.FileName;
- SaveSettingsToFile();
- MessageBox.Show("自定义铃声设置成功!", "设置成功", MessageBoxButton.OK, MessageBoxImage.Information);
- }
- }
-
- private void ButtonResetTimerSound_Click(object sender, RoutedEventArgs e)
- {
- Settings.RandSettings.CustomTimerSoundPath = "";
- SaveSettingsToFile();
- MessageBox.Show("已重置为默认铃声!", "重置成功", MessageBoxButton.OK, MessageBoxImage.Information);
- }
-
- private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
-
- // 获取开关状态并保存到设置中
- bool isToggled = ToggleSwitchShowRandomAndSingleDraw.IsOn;
- Settings.RandSettings.ShowRandomAndSingleDraw = isToggled;
-
- // 更新UI显示
- BoardRandomDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
- BoardSingleDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
-
- // 保存设置到文件
- SaveSettingsToFile();
- }
-
- private void ToggleSwitchEnableQuickDraw_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
-
- // 获取开关状态并保存到设置中
- Settings.RandSettings.EnableQuickDraw = ToggleSwitchEnableQuickDraw.IsOn;
-
- // 保存设置到文件
- SaveSettingsToFile();
-
- // 根据设置状态显示或隐藏快抽悬浮按钮
- ShowQuickDrawFloatingButton();
- }
-
- private void ToggleSwitchExternalCaller_Toggled(object sender, RoutedEventArgs e)
- {
- if (!isLoaded) return;
-
- // 获取开关状态并保存到设置中
- Settings.RandSettings.DirectCallCiRand = ToggleSwitchExternalCaller.IsOn;
-
- // 保存设置到文件
- SaveSettingsToFile();
- }
-
- private void ComboBoxExternalCallerType_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!isLoaded) return;
-
- // 获取下拉框选择并保存到设置中
- Settings.RandSettings.ExternalCallerType = ComboBoxExternalCallerType.SelectedIndex;
-
- // 保存设置到文件
- SaveSettingsToFile();
- }
public void UpdateFloatingBarIcons()
{
@@ -3159,8 +2550,6 @@ namespace Ink_Canvas
return "";
}
- #endregion
-
#region 浮动栏按钮显示控制
@@ -3370,66 +2759,6 @@ namespace Ink_Canvas
- // 自定义点名背景相关方法
- public void UpdatePickNameBackgroundsInComboBox()
- {
- // 清除现有的自定义背景选项
- if (ComboBoxPickNameBackground != null)
- {
- // 保留第一个默认选项
- while (ComboBoxPickNameBackground.Items.Count > 1)
- {
- ComboBoxPickNameBackground.Items.RemoveAt(ComboBoxPickNameBackground.Items.Count - 1);
- }
-
- // 添加自定义背景选项
- foreach (var background in Settings.RandSettings.CustomPickNameBackgrounds)
- {
- ComboBoxItem item = new ComboBoxItem();
- item.Content = background.Name;
- item.FontFamily = new FontFamily("Microsoft YaHei UI");
- ComboBoxPickNameBackground.Items.Add(item);
- }
- }
- }
-
- public void UpdatePickNameBackgroundDisplay()
- {
- // 此方法主要用于在外部窗口更改背景后更新UI
- if (ComboBoxPickNameBackground != null)
- {
- ComboBoxPickNameBackground.SelectedIndex = Settings.RandSettings.SelectedBackgroundIndex;
- }
- }
-
- private void ComboBoxPickNameBackground_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (!isLoaded) return;
-
- Settings.RandSettings.SelectedBackgroundIndex = ComboBoxPickNameBackground.SelectedIndex;
- SaveSettingsToFile();
- }
-
- private void ButtonAddCustomBackground_Click(object sender, RoutedEventArgs e)
- {
- AddPickNameBackgroundWindow dialog = new AddPickNameBackgroundWindow(this);
- dialog.Owner = this;
- dialog.ShowDialog();
-
- if (dialog.IsSuccess)
- {
- // 自动选中新添加的背景
- ComboBoxPickNameBackground.SelectedIndex = ComboBoxPickNameBackground.Items.Count - 1;
- }
- }
-
- private void ButtonManageBackgrounds_Click(object sender, RoutedEventArgs e)
- {
- ManagePickNameBackgroundsWindow dialog = new ManagePickNameBackgroundsWindow(this);
- dialog.Owner = this;
- dialog.ShowDialog();
- }
-
private void ToggleSwitchEnableWppProcessKill_Toggled(object sender, RoutedEventArgs e)
{
if (!isLoaded) return;
diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs
index 9f06df49..1882ef24 100644
--- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs
+++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs
@@ -699,8 +699,6 @@ namespace Ink_Canvas
drawingAttributes.FitToCurve = false;
}
- ToggleSwitchDisableHardwareAcceleration.IsOn = !Settings.Canvas.UseHardwareAcceleration;
-
// 初始化直线自动拉直相关设置
// 直线拉直灵敏度也在这里初始化,即使它存储在InkToShape中
// 初始化高精度直线拉直设置
@@ -712,30 +710,9 @@ namespace Ink_Canvas
Settings.Canvas = new Canvas();
}
- // Advanced
+ // Advanced - UI initialization (settings loading moved to AdvancedPage)
if (Settings.Advanced != null)
{
- TouchMultiplierSlider.Value = Settings.Advanced.TouchMultiplier;
- FingerModeBoundsWidthSlider.Value = Settings.Advanced.FingerModeBoundsWidth;
- NibModeBoundsWidthSlider.Value = Settings.Advanced.NibModeBoundsWidth;
- ToggleSwitchIsLogEnabled.IsOn = Settings.Advanced.IsLogEnabled;
- ToggleSwitchIsSaveLogByDate.IsOn = Settings.Advanced.IsSaveLogByDate;
- ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn = Settings.Advanced.IsSecondConfirmWhenShutdownApp;
- ToggleSwitchIsSpecialScreen.IsOn = Settings.Advanced.IsSpecialScreen;
- ToggleSwitchIsQuadIR.IsOn = Settings.Advanced.IsQuadIR;
- ToggleSwitchEraserBindTouchMultiplier.IsOn = Settings.Advanced.EraserBindTouchMultiplier;
- ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = Settings.Advanced.IsAutoBackupBeforeUpdate;
- ToggleSwitchIsAutoBackupEnabled.IsOn = Settings.Advanced.IsAutoBackupEnabled;
-
- // 设置备份间隔下拉框
- foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
- {
- if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int interval) && interval == Settings.Advanced.AutoBackupIntervalDays)
- {
- ComboBoxAutoBackupInterval.SelectedItem = item;
- break;
- }
- }
if (Settings.Advanced.IsEnableFullScreenHelper)
{
FullScreenHelper.MarkFullscreenWindowTaskbarList(new WindowInteropHelper(this).Handle, true);
@@ -757,8 +734,6 @@ namespace Ink_Canvas
if (OSVersion.GetOperatingSystem() >= OperatingSystem.Windows10)
EdgeGestureUtil.DisableEdgeGestures(new WindowInteropHelper(this).Handle, true);
}
- TouchMultiplierSlider.Visibility =
- ToggleSwitchIsSpecialScreen.IsOn ? Visibility.Visible : Visibility.Collapsed;
}
else
{
@@ -776,78 +751,15 @@ namespace Ink_Canvas
Settings.InkToShape = new InkToShape();
}
- // RandSettings
+ // RandSettings - UI initialization (settings loading moved to RandomDrawPage)
if (Settings.RandSettings != null)
{
- ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
- RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
- RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
- ToggleSwitchShowRandomAndSingleDraw.IsOn = Settings.RandSettings.ShowRandomAndSingleDraw;
- ToggleSwitchEnableQuickDraw.IsOn = Settings.RandSettings.EnableQuickDraw;
- ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
- ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
BoardRandomDrawToolBtn.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
BoardSingleDrawToolBtn.Visibility = Settings.RandSettings.ShowRandomAndSingleDraw ? Visibility.Visible : Visibility.Collapsed;
-
- // 计时器设置
- ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
- ToggleSwitchUseNewStyleUI.IsOn = Settings.RandSettings.UseNewStyleUI;
- ToggleSwitchEnableOvertimeCountUp.IsOn = Settings.RandSettings.EnableOvertimeCountUp;
-
- // 新点名UI设置
- ToggleSwitchUseNewRollCallUI.IsOn = Settings.RandSettings.UseNewRollCallUI;
- ToggleSwitchEnableMLAvoidance.IsOn = Settings.RandSettings.EnableMLAvoidance;
- MLAvoidanceHistorySlider.Value = Settings.RandSettings.MLAvoidanceHistoryCount;
- MLAvoidanceWeightSlider.Value = Settings.RandSettings.MLAvoidanceWeight;
-
- bool canEnableRedText = Settings.RandSettings.EnableOvertimeCountUp && Settings.RandSettings.EnableOvertimeRedText;
- ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
- if (!canEnableRedText)
- {
- Settings.RandSettings.EnableOvertimeRedText = false;
- }
-
- TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
-
- // 渐进提醒设置
- ToggleSwitchEnableProgressiveReminder.IsOn = Settings.RandSettings.EnableProgressiveReminder;
- ProgressiveReminderVolumeSlider.Value = Settings.RandSettings.ProgressiveReminderVolume;
-
- // 加载自定义点名背景
- UpdatePickNameBackgroundsInComboBox();
-
- // 设置选择的背景索引
- if (Settings.RandSettings.SelectedBackgroundIndex >= ComboBoxPickNameBackground.Items.Count)
- {
- Settings.RandSettings.SelectedBackgroundIndex = 0;
- }
- ComboBoxPickNameBackground.SelectedIndex = Settings.RandSettings.SelectedBackgroundIndex;
}
else
{
Settings.RandSettings = new RandSettings();
- ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = Settings.RandSettings.DisplayRandWindowNamesInputBtn;
- RandWindowOnceCloseLatencySlider.Value = Settings.RandSettings.RandWindowOnceCloseLatency;
- RandWindowOnceMaxStudentsSlider.Value = Settings.RandSettings.RandWindowOnceMaxStudents;
- ToggleSwitchEnableQuickDraw.IsOn = Settings.RandSettings.EnableQuickDraw;
- ToggleSwitchExternalCaller.IsOn = Settings.RandSettings.DirectCallCiRand;
- ComboBoxExternalCallerType.SelectedIndex = Settings.RandSettings.ExternalCallerType;
- ToggleSwitchUseLegacyTimerUI.IsOn = Settings.RandSettings.UseLegacyTimerUI;
- ToggleSwitchUseNewStyleUI.IsOn = Settings.RandSettings.UseNewStyleUI;
- ToggleSwitchEnableOvertimeCountUp.IsOn = Settings.RandSettings.EnableOvertimeCountUp;
-
- bool canEnableRedText = Settings.RandSettings.EnableOvertimeCountUp && Settings.RandSettings.EnableOvertimeRedText;
- ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
- if (!canEnableRedText)
- {
- Settings.RandSettings.EnableOvertimeRedText = false;
- }
-
- TimerVolumeSlider.Value = Settings.RandSettings.TimerVolume;
-
- // 渐进提醒设置
- ToggleSwitchEnableProgressiveReminder.IsOn = Settings.RandSettings.EnableProgressiveReminder;
- ProgressiveReminderVolumeSlider.Value = Settings.RandSettings.ProgressiveReminderVolume;
}
// ModeSettings
@@ -1005,9 +917,6 @@ namespace Ink_Canvas
// 加载画笔自动恢复设置
LoadBrushAutoRestoreSettings();
-
- // 刷新配置文件列表
- try { RefreshConfigProfileList(); } catch (Exception ex) { LogHelper.WriteLogToFile($"刷新配置文件列表失败: {ex.Message}", LogHelper.LogType.Warning); }
}
///
diff --git a/Ink Canvas/MainWindow_cs/MW_UriHandler.cs b/Ink Canvas/MainWindow_cs/MW_UriHandler.cs
index cbf0059a..67fd999f 100644
--- a/Ink Canvas/MainWindow_cs/MW_UriHandler.cs
+++ b/Ink Canvas/MainWindow_cs/MW_UriHandler.cs
@@ -232,7 +232,6 @@ namespace Ink_Canvas
}
_lastAppliedProfileName = profileName.Trim();
ReloadSettingsFromFile();
- RefreshConfigProfileList();
File.WriteAllText(resultPath, "ok", System.Text.Encoding.UTF8);
ShowNotification($"已通过 URI 切换至方案「{profileName}」");
LogHelper.WriteLogToFile($"URI 已切换配置方案: {profileName}", LogHelper.LogType.Event);
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml b/Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml
new file mode 100644
index 00000000..77ac4c83
--- /dev/null
+++ b/Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml
@@ -0,0 +1,226 @@
+
+
+
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml.cs b/Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml.cs
new file mode 100644
index 00000000..4780a3df
--- /dev/null
+++ b/Ink Canvas/Windows/SettingsViews/Pages/AdvancedPage.xaml.cs
@@ -0,0 +1,467 @@
+using Ink_Canvas.Helpers;
+using Ink_Canvas.Windows.SettingsViews.Helpers;
+using iNKORE.UI.WPF.Modern.Controls;
+using System;
+using System.IO;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Threading;
+using ContentDialog = iNKORE.UI.WPF.Modern.Controls.ContentDialog;
+using MessageBox = System.Windows.MessageBox;
+using Page = iNKORE.UI.WPF.Modern.Controls.Page;
+
+namespace Ink_Canvas.Windows.SettingsViews.Pages
+{
+ public partial class AdvancedPage : Page
+ {
+ private bool _isLoaded = false;
+ private bool _isRefreshingConfigProfileList = false;
+ private string _lastAppliedProfileName;
+
+ public AdvancedPage()
+ {
+ InitializeComponent();
+ Loaded += Page_Loaded;
+ Unloaded += Page_Unloaded;
+ }
+
+ private void Page_Loaded(object sender, RoutedEventArgs e)
+ {
+ LoadSettings();
+ _isLoaded = true;
+ RefreshConfigProfileList();
+ }
+
+ private void Page_Unloaded(object sender, RoutedEventArgs e)
+ {
+ _isLoaded = false;
+ }
+
+ private MainWindow GetMainWindow() => Application.Current.MainWindow as MainWindow;
+
+ private void LoadSettings()
+ {
+ var settings = SettingsManager.Settings;
+ if (settings?.Advanced == null) return;
+
+ ToggleSwitchIsSpecialScreen.IsOn = settings.Advanced.IsSpecialScreen;
+ ToggleSwitchDisableHardwareAcceleration.IsOn = !settings.Canvas.UseHardwareAcceleration;
+ TouchMultiplierSlider.Value = settings.Advanced.TouchMultiplier;
+ ToggleSwitchEraserBindTouchMultiplier.IsOn = settings.Advanced.EraserBindTouchMultiplier;
+ NibModeBoundsWidthSlider.Value = settings.Advanced.NibModeBoundsWidth;
+ FingerModeBoundsWidthSlider.Value = settings.Advanced.FingerModeBoundsWidth;
+ ToggleSwitchIsQuadIR.IsOn = settings.Advanced.IsQuadIR;
+ ToggleSwitchIsLogEnabled.IsOn = settings.Advanced.IsLogEnabled;
+ ToggleSwitchIsSaveLogByDate.IsOn = settings.Advanced.IsSaveLogByDate;
+ ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn = settings.Advanced.IsSecondConfirmWhenShutdownApp;
+ ToggleSwitchIsAutoBackupBeforeUpdate.IsOn = settings.Advanced.IsAutoBackupBeforeUpdate;
+ ToggleSwitchIsAutoBackupEnabled.IsOn = settings.Advanced.IsAutoBackupEnabled;
+
+ foreach (ComboBoxItem item in ComboBoxAutoBackupInterval.Items)
+ {
+ if (item.Tag != null && int.TryParse(item.Tag.ToString(), out int interval) && interval == settings.Advanced.AutoBackupIntervalDays)
+ {
+ ComboBoxAutoBackupInterval.SelectedItem = item;
+ break;
+ }
+ }
+
+ CardTouchMultiplier.IsExpanded = settings.Advanced.IsSpecialScreen;
+ }
+
+ #region Special Screen & Touch Multiplier
+
+ private void ToggleSwitchIsSpecialScreen_OnToggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsSpecialScreen = ToggleSwitchIsSpecialScreen.IsOn;
+ CardTouchMultiplier.IsExpanded = ToggleSwitchIsSpecialScreen.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchDisableHardwareAcceleration_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Canvas.UseHardwareAcceleration = !ToggleSwitchDisableHardwareAcceleration.IsOn;
+ var mw = GetMainWindow();
+ if (mw != null) mw.UpdateInkSmoothingConfig();
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void TouchMultiplierSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.TouchMultiplier = e.NewValue;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void BorderCalculateMultiplier_TouchDown(object sender, TouchEventArgs e)
+ {
+ var args = e.GetTouchPoint(null).Bounds;
+ double value;
+ if (!SettingsManager.Settings.Advanced.IsQuadIR) value = args.Width;
+ else value = Math.Sqrt(args.Width * args.Height);
+
+ TextBlockShowCalculatedMultiplier.Text = (5 / (value * 1.1)).ToString();
+ }
+
+ #endregion
+
+ #region Eraser & Bounds Width
+
+ private void ToggleSwitchEraserBindTouchMultiplier_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.EraserBindTouchMultiplier = ToggleSwitchEraserBindTouchMultiplier.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void NibModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.NibModeBoundsWidth = (int)e.NewValue;
+ var mw = GetMainWindow();
+ if (mw != null)
+ {
+ if (SettingsManager.Settings.Startup.IsEnableNibMode)
+ mw.BoundsWidth = SettingsManager.Settings.Advanced.NibModeBoundsWidth;
+ else
+ mw.BoundsWidth = SettingsManager.Settings.Advanced.FingerModeBoundsWidth;
+ }
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void FingerModeBoundsWidthSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.FingerModeBoundsWidth = (int)e.NewValue;
+ var mw = GetMainWindow();
+ if (mw != null)
+ {
+ if (SettingsManager.Settings.Startup.IsEnableNibMode)
+ mw.BoundsWidth = SettingsManager.Settings.Advanced.NibModeBoundsWidth;
+ else
+ mw.BoundsWidth = SettingsManager.Settings.Advanced.FingerModeBoundsWidth;
+ }
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchIsQuadIR_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsQuadIR = ToggleSwitchIsQuadIR.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ #endregion
+
+ #region Logging & Exit
+
+ private void ToggleSwitchIsLogEnabled_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsLogEnabled = ToggleSwitchIsLogEnabled.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchIsSaveLogByDate_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsSaveLogByDate = ToggleSwitchIsSaveLogByDate.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchIsSecondConfimeWhenShutdownApp_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsSecondConfirmWhenShutdownApp = ToggleSwitchIsSecondConfimeWhenShutdownApp.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ #endregion
+
+ #region Backup
+
+ private void ToggleSwitchIsAutoBackupBeforeUpdate_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsAutoBackupBeforeUpdate = ToggleSwitchIsAutoBackupBeforeUpdate.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchIsAutoBackupEnabled_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.Advanced.IsAutoBackupEnabled = ToggleSwitchIsAutoBackupEnabled.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ComboBoxAutoBackupInterval_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ if (ComboBoxAutoBackupInterval.SelectedItem is ComboBoxItem selectedItem && selectedItem.Tag != null)
+ {
+ if (int.TryParse(selectedItem.Tag.ToString(), out int interval))
+ {
+ SettingsManager.Settings.Advanced.AutoBackupIntervalDays = interval;
+ SettingsManager.SaveSettingsToFile();
+ }
+ }
+ }
+
+ private void BtnManualBackup_Click(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+
+ try
+ {
+ string backupDir = Path.Combine(App.RootPath, "Backups");
+ if (!Directory.Exists(backupDir))
+ {
+ Directory.CreateDirectory(backupDir);
+ LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
+ }
+
+ string backupFileName = $"Settings_Backup_{DateTime.Now:yyyyMMdd_HHmmss}.json";
+ string backupPath = Path.Combine(backupDir, backupFileName);
+
+ string settingsJson = Newtonsoft.Json.JsonConvert.SerializeObject(SettingsManager.Settings, Newtonsoft.Json.Formatting.Indented);
+ File.WriteAllText(backupPath, settingsJson);
+
+ LogHelper.WriteLogToFile($"成功创建设置备份: {backupPath}");
+ MessageBox.Show($"设置已成功备份到:\n{backupPath}", "备份成功", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"创建设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
+ MessageBox.Show($"创建备份失败: {ex.Message}", "备份失败", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void BtnRestoreBackup_Click(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+
+ try
+ {
+ string backupDir = Path.Combine(App.RootPath, "Backups");
+ if (!Directory.Exists(backupDir))
+ {
+ Directory.CreateDirectory(backupDir);
+ LogHelper.WriteLogToFile($"创建备份目录: {backupDir}");
+ MessageBox.Show("没有找到备份文件,请先创建备份", "还原失败", MessageBoxButton.OK, MessageBoxImage.Warning);
+ return;
+ }
+
+ var dlg = new Microsoft.Win32.OpenFileDialog();
+ dlg.InitialDirectory = backupDir;
+ dlg.Filter = "设置备份文件|Settings_Backup_*.json|所有JSON文件|*.json";
+ dlg.Title = "选择要还原的备份文件";
+
+ if (dlg.ShowDialog() == true)
+ {
+ string backupJson = File.ReadAllText(dlg.FileName);
+ Settings backupSettings = Newtonsoft.Json.JsonConvert.DeserializeObject(backupJson);
+
+ if (backupSettings != null)
+ {
+ if (MessageBox.Show("确定要还原选择的备份文件吗?当前设置将被覆盖。", "确认还原",
+ MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
+ {
+ string currentSettingsJson = Newtonsoft.Json.JsonConvert.SerializeObject(SettingsManager.Settings, Newtonsoft.Json.Formatting.Indented);
+ string tempBackupPath = Path.Combine(backupDir, $"Settings_Before_Restore_{DateTime.Now:yyyyMMdd_HHmmss}.json");
+ File.WriteAllText(tempBackupPath, currentSettingsJson);
+
+ SettingsManager.Settings = backupSettings;
+ SettingsManager.SaveSettingsToFile();
+
+ var mw = GetMainWindow();
+ if (mw != null) mw.ReloadSettingsFromFile();
+
+ LogHelper.WriteLogToFile($"成功从备份还原设置: {dlg.FileName}");
+ MessageBox.Show("设置已成功还原,部分设置可能需要重启软件后生效。", "还原成功", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+ else
+ {
+ MessageBox.Show("无法解析备份文件,文件可能已损坏", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"还原设置备份时出错: {ex.Message}", LogHelper.LogType.Error);
+ MessageBox.Show($"还原备份失败: {ex.Message}", "还原失败", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ #endregion
+
+ #region Config Profiles
+
+ private void RefreshConfigProfileList()
+ {
+ try
+ {
+ if (ComboBoxConfigProfile == null) return;
+ _isRefreshingConfigProfileList = true;
+ try
+ {
+ var names = ConfigProfileManager.ListProfileNames();
+ ComboBoxConfigProfile.ItemsSource = names;
+ if (names.Count == 0)
+ {
+ ComboBoxConfigProfile.SelectedItem = null;
+ }
+ else if (_lastAppliedProfileName != null && names.Contains(_lastAppliedProfileName))
+ {
+ ComboBoxConfigProfile.SelectedItem = _lastAppliedProfileName;
+ }
+ else
+ {
+ var selected = ComboBoxConfigProfile.SelectedItem as string;
+ if (selected != null && names.Contains(selected))
+ ComboBoxConfigProfile.SelectedItem = selected;
+ else
+ ComboBoxConfigProfile.SelectedIndex = 0;
+ }
+ if (BtnDeleteConfigProfile != null)
+ BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile.SelectedItem != null;
+ }
+ finally
+ {
+ _isRefreshingConfigProfileList = false;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"刷新配置方案列表失败: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
+ private void ComboBoxConfigProfile_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (BtnDeleteConfigProfile != null)
+ BtnDeleteConfigProfile.IsEnabled = ComboBoxConfigProfile?.SelectedItem != null;
+ if (!_isLoaded || _isRefreshingConfigProfileList) return;
+ var name = ComboBoxConfigProfile?.SelectedItem as string;
+ if (string.IsNullOrEmpty(name)) return;
+ try
+ {
+ if (ConfigProfileManager.ApplyProfile(name))
+ {
+ _lastAppliedProfileName = name;
+ var mw = GetMainWindow();
+ if (mw != null)
+ {
+ mw.ReloadSettingsFromFile();
+ mw.ShowNotification($"已切换至方案「{name}」");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"切换配置方案失败: {ex.Message}", LogHelper.LogType.Error);
+ }
+ }
+
+ private async void BtnSaveAsConfigProfile_Click(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ var input = new System.Windows.Controls.TextBox
+ {
+ MinWidth = 260,
+ Padding = new Thickness(8, 6, 8, 6),
+ Margin = new Thickness(0, 0, 0, 12)
+ };
+ var label = new System.Windows.Controls.TextBlock
+ {
+ Text = "方案名称",
+ Margin = new Thickness(0, 0, 0, 8)
+ };
+ var content = new iNKORE.UI.WPF.Controls.SimpleStackPanel { Spacing = 6 };
+ content.Children.Add(label);
+ content.Children.Add(input);
+ var dialog = new ContentDialog
+ {
+ Title = "另存为方案",
+ Content = content,
+ PrimaryButtonText = "保存",
+ SecondaryButtonText = "取消",
+ Owner = GetMainWindow()
+ };
+ var result = await dialog.ShowAsync();
+ if (result != ContentDialogResult.Primary) return;
+ var name = input.Text?.Trim();
+ if (string.IsNullOrEmpty(name))
+ {
+ MessageBox.Show("请输入方案名称。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+ try
+ {
+ var json = Newtonsoft.Json.JsonConvert.SerializeObject(SettingsManager.Settings, Newtonsoft.Json.Formatting.Indented);
+ if (ConfigProfileManager.SaveAsProfile(name, json))
+ {
+ _lastAppliedProfileName = name;
+ RefreshConfigProfileList();
+ var mw = GetMainWindow();
+ if (mw != null) mw.ShowNotification($"已另存为方案:{name}");
+ }
+ else
+ MessageBox.Show("保存失败,请查看日志。", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"另存为方案失败: {ex.Message}", LogHelper.LogType.Error);
+ MessageBox.Show($"保存失败: {ex.Message}", "另存为方案", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ private void BtnDeleteConfigProfile_Click(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ var name = ComboBoxConfigProfile?.SelectedItem as string;
+ if (string.IsNullOrEmpty(name))
+ {
+ MessageBox.Show("请先选择要删除的配置文件。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Information);
+ return;
+ }
+ try
+ {
+ if (MessageBox.Show($"确定要删除配置文件「{name}」吗?", "确认删除", MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
+ return;
+ if (ConfigProfileManager.DeleteProfile(name))
+ {
+ RefreshConfigProfileList();
+ var nextName = ComboBoxConfigProfile?.SelectedItem as string;
+ var mw = GetMainWindow();
+ if (!string.IsNullOrEmpty(nextName) && ConfigProfileManager.ApplyProfile(nextName))
+ {
+ _lastAppliedProfileName = nextName;
+ if (mw != null)
+ {
+ mw.ReloadSettingsFromFile();
+ mw.ShowNotification($"已删除方案「{name}」,已切换至「{nextName}」");
+ }
+ }
+ else
+ {
+ if (mw != null) mw.ShowNotification($"已删除方案:{name}");
+ }
+ }
+ else
+ MessageBox.Show("删除配置文件失败,请查看日志。", "配置文件", MessageBoxButton.OK, MessageBoxImage.Warning);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"删除配置文件失败: {ex.Message}", LogHelper.LogType.Error);
+ MessageBox.Show($"删除配置文件失败: {ex.Message}", "配置文件", MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/HomePage.xaml b/Ink Canvas/Windows/SettingsViews/Pages/HomePage.xaml
index 6e561efa..38c7f57e 100644
--- a/Ink Canvas/Windows/SettingsViews/Pages/HomePage.xaml
+++ b/Ink Canvas/Windows/SettingsViews/Pages/HomePage.xaml
@@ -78,6 +78,13 @@
+
+
+
+
+
+
@@ -92,6 +99,13 @@
+
+
+
+
+
+
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml b/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml
index fff8335e..ba137b31 100644
--- a/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml
+++ b/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml
@@ -79,18 +79,21 @@
-
+
-
+
-
+
@@ -128,9 +131,10 @@
-
+
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml.cs b/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml.cs
index 409b6c95..e4e0f85b 100644
--- a/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml.cs
+++ b/Ink Canvas/Windows/SettingsViews/Pages/InkRecognitionPage.xaml.cs
@@ -50,7 +50,7 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
{
ToggleSwitchAutoStraightenLine.IsOn = settings.Canvas.AutoStraightenLine;
AutoStraightenLineThresholdSlider.Value = settings.Canvas.AutoStraightenLineThreshold;
- CheckboxHighPrecisionLineStraighten.IsChecked = settings.Canvas.HighPrecisionLineStraighten;
+ ToggleSwitchHighPrecisionLineStraighten.IsOn = settings.Canvas.HighPrecisionLineStraighten;
ToggleSwitchLineEndpointSnapping.IsOn = settings.Canvas.LineEndpointSnapping;
}
}
@@ -146,10 +146,10 @@ namespace Ink_Canvas.Windows.SettingsViews.Pages
SettingsManager.SaveSettingsToFile();
}
- private void CheckboxHighPrecisionLineStraighten_CheckedChanged(object sender, RoutedEventArgs e)
+ private void ToggleSwitchHighPrecisionLineStraighten_Toggled(object sender, RoutedEventArgs e)
{
if (!_isLoaded) return;
- SettingsManager.Settings.Canvas.HighPrecisionLineStraighten = (bool)CheckboxHighPrecisionLineStraighten.IsChecked;
+ SettingsManager.Settings.Canvas.HighPrecisionLineStraighten = ToggleSwitchHighPrecisionLineStraighten.IsOn;
SettingsManager.SaveSettingsToFile();
}
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml b/Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml
new file mode 100644
index 00000000..fcffe083
--- /dev/null
+++ b/Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml
@@ -0,0 +1,207 @@
+
+
+
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml.cs b/Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml.cs
new file mode 100644
index 00000000..835c8ad0
--- /dev/null
+++ b/Ink Canvas/Windows/SettingsViews/Pages/RandomDrawPage.xaml.cs
@@ -0,0 +1,346 @@
+using Ink_Canvas.Helpers;
+using Ink_Canvas.Windows.SettingsViews.Helpers;
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using Page = iNKORE.UI.WPF.Modern.Controls.Page;
+
+namespace Ink_Canvas.Windows.SettingsViews.Pages
+{
+ public partial class RandomDrawPage : Page
+ {
+ private bool _isLoaded = false;
+
+ public RandomDrawPage()
+ {
+ InitializeComponent();
+ Loaded += Page_Loaded;
+ Unloaded += Page_Unloaded;
+ }
+
+ private void Page_Loaded(object sender, RoutedEventArgs e)
+ {
+ LoadSettings();
+ _isLoaded = true;
+ }
+
+ private void Page_Unloaded(object sender, RoutedEventArgs e)
+ {
+ _isLoaded = false;
+ }
+
+ private MainWindow GetMainWindow() => Application.Current.MainWindow as MainWindow;
+
+ private void LoadSettings()
+ {
+ var settings = SettingsManager.Settings;
+ if (settings?.RandSettings == null) return;
+
+ ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn = settings.RandSettings.DisplayRandWindowNamesInputBtn;
+ RandWindowOnceCloseLatencySlider.Value = settings.RandSettings.RandWindowOnceCloseLatency;
+ RandWindowOnceMaxStudentsSlider.Value = settings.RandSettings.RandWindowOnceMaxStudents;
+ ToggleSwitchShowRandomAndSingleDraw.IsOn = settings.RandSettings.ShowRandomAndSingleDraw;
+ ToggleSwitchEnableQuickDraw.IsOn = settings.RandSettings.EnableQuickDraw;
+ ToggleSwitchExternalCaller.IsOn = settings.RandSettings.DirectCallCiRand;
+ ComboBoxExternalCallerType.SelectedIndex = settings.RandSettings.ExternalCallerType;
+
+ ToggleSwitchUseNewRollCallUI.IsOn = settings.RandSettings.UseNewRollCallUI;
+ ToggleSwitchEnableMLAvoidance.IsOn = settings.RandSettings.EnableMLAvoidance;
+ MLAvoidanceHistorySlider.Value = settings.RandSettings.MLAvoidanceHistoryCount;
+ MLAvoidanceWeightSlider.Value = settings.RandSettings.MLAvoidanceWeight;
+
+ ToggleSwitchUseLegacyTimerUI.IsOn = settings.RandSettings.UseLegacyTimerUI;
+ ToggleSwitchUseNewStyleUI.IsOn = settings.RandSettings.UseNewStyleUI;
+ ToggleSwitchEnableOvertimeCountUp.IsOn = settings.RandSettings.EnableOvertimeCountUp;
+
+ bool canEnableRedText = settings.RandSettings.EnableOvertimeCountUp && settings.RandSettings.EnableOvertimeRedText;
+ ToggleSwitchEnableOvertimeRedText.IsOn = canEnableRedText;
+
+ TimerVolumeSlider.Value = settings.RandSettings.TimerVolume;
+ ToggleSwitchEnableProgressiveReminder.IsOn = settings.RandSettings.EnableProgressiveReminder;
+ ProgressiveReminderVolumeSlider.Value = settings.RandSettings.ProgressiveReminderVolume;
+
+ UpdatePickNameBackgroundsInComboBox();
+ if (settings.RandSettings.SelectedBackgroundIndex >= ComboBoxPickNameBackground.Items.Count)
+ {
+ settings.RandSettings.SelectedBackgroundIndex = 0;
+ }
+ ComboBoxPickNameBackground.SelectedIndex = settings.RandSettings.SelectedBackgroundIndex;
+ }
+
+ #region Basic Settings
+
+ private void ToggleSwitchDisplayRandWindowNamesInputBtn_OnToggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.DisplayRandWindowNamesInputBtn = ToggleSwitchDisplayRandWindowNamesInputBtn.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void RandWindowOnceCloseLatencySlider_ValueChanged(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.RandWindowOnceCloseLatency = RandWindowOnceCloseLatencySlider.Value;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void RandWindowOnceMaxStudentsSlider_ValueChanged(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.RandWindowOnceMaxStudents = (int)RandWindowOnceMaxStudentsSlider.Value;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchShowRandomAndSingleDraw_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ bool isToggled = ToggleSwitchShowRandomAndSingleDraw.IsOn;
+ SettingsManager.Settings.RandSettings.ShowRandomAndSingleDraw = isToggled;
+
+ var mw = GetMainWindow();
+ if (mw != null)
+ {
+ mw.BoardRandomDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
+ mw.BoardSingleDrawToolBtn.Visibility = isToggled ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchEnableQuickDraw_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.EnableQuickDraw = ToggleSwitchEnableQuickDraw.IsOn;
+ SettingsManager.SaveSettingsToFile();
+
+ var mw = GetMainWindow();
+ if (mw != null) mw.ShowQuickDrawFloatingButton();
+ }
+
+ private void ToggleSwitchExternalCaller_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.DirectCallCiRand = ToggleSwitchExternalCaller.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ComboBoxExternalCallerType_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.ExternalCallerType = ComboBoxExternalCallerType.SelectedIndex;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ #endregion
+
+ #region Background
+
+ private void UpdatePickNameBackgroundsInComboBox()
+ {
+ if (ComboBoxPickNameBackground == null) return;
+
+ while (ComboBoxPickNameBackground.Items.Count > 1)
+ {
+ ComboBoxPickNameBackground.Items.RemoveAt(ComboBoxPickNameBackground.Items.Count - 1);
+ }
+
+ foreach (var background in SettingsManager.Settings.RandSettings.CustomPickNameBackgrounds)
+ {
+ ComboBoxItem item = new ComboBoxItem();
+ item.Content = background.Name;
+ item.FontFamily = new FontFamily("Microsoft YaHei UI");
+ ComboBoxPickNameBackground.Items.Add(item);
+ }
+ }
+
+ private void ComboBoxPickNameBackground_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.SelectedBackgroundIndex = ComboBoxPickNameBackground.SelectedIndex;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ButtonAddCustomBackground_Click(object sender, RoutedEventArgs e)
+ {
+ var mw = GetMainWindow();
+ if (mw == null) return;
+
+ AddPickNameBackgroundWindow dialog = new AddPickNameBackgroundWindow(mw);
+ dialog.Owner = mw;
+ dialog.ShowDialog();
+
+ if (dialog.IsSuccess)
+ {
+ ComboBoxPickNameBackground.SelectedIndex = ComboBoxPickNameBackground.Items.Count - 1;
+ }
+ }
+
+ private void ButtonManageBackgrounds_Click(object sender, RoutedEventArgs e)
+ {
+ var mw = GetMainWindow();
+ if (mw == null) return;
+
+ ManagePickNameBackgroundsWindow dialog = new ManagePickNameBackgroundsWindow(mw);
+ dialog.Owner = mw;
+ dialog.ShowDialog();
+ }
+
+ #endregion
+
+ #region New Roll Call UI
+
+ private void ToggleSwitchUseNewRollCallUI_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.UseNewRollCallUI = ToggleSwitchUseNewRollCallUI.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchEnableMLAvoidance_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.EnableMLAvoidance = ToggleSwitchEnableMLAvoidance.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void MLAvoidanceHistorySlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.MLAvoidanceHistoryCount = (int)MLAvoidanceHistorySlider.Value;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void MLAvoidanceWeightSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.MLAvoidanceWeight = MLAvoidanceWeightSlider.Value;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ #endregion
+
+ #region Timer
+
+ private void ToggleSwitchUseLegacyTimerUI_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.UseLegacyTimerUI = ToggleSwitchUseLegacyTimerUI.IsOn;
+ if (ToggleSwitchUseLegacyTimerUI.IsOn)
+ {
+ ToggleSwitchUseNewStyleUI.IsOn = false;
+ SettingsManager.Settings.RandSettings.UseNewStyleUI = false;
+ }
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchUseNewStyleUI_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.UseNewStyleUI = ToggleSwitchUseNewStyleUI.IsOn;
+ if (ToggleSwitchUseNewStyleUI.IsOn)
+ {
+ ToggleSwitchUseLegacyTimerUI.IsOn = false;
+ SettingsManager.Settings.RandSettings.UseLegacyTimerUI = false;
+ }
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchEnableOvertimeCountUp_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.EnableOvertimeCountUp = ToggleSwitchEnableOvertimeCountUp.IsOn;
+
+ if (!ToggleSwitchEnableOvertimeCountUp.IsOn)
+ {
+ ToggleSwitchEnableOvertimeRedText.IsOn = false;
+ SettingsManager.Settings.RandSettings.EnableOvertimeRedText = false;
+ }
+
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ToggleSwitchEnableOvertimeRedText_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+
+ if (ToggleSwitchEnableOvertimeRedText.IsOn && !ToggleSwitchEnableOvertimeCountUp.IsOn)
+ {
+ ToggleSwitchEnableOvertimeCountUp.IsOn = true;
+ SettingsManager.Settings.RandSettings.EnableOvertimeCountUp = true;
+ }
+
+ SettingsManager.Settings.RandSettings.EnableOvertimeRedText = ToggleSwitchEnableOvertimeRedText.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void TimerVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.TimerVolume = TimerVolumeSlider.Value;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ButtonSelectCustomTimerSound_Click(object sender, RoutedEventArgs e)
+ {
+ Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
+ {
+ Title = "选择计时器提醒铃声",
+ Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
+ DefaultExt = "wav"
+ };
+
+ if (openFileDialog.ShowDialog() == true)
+ {
+ SettingsManager.Settings.RandSettings.CustomTimerSoundPath = openFileDialog.FileName;
+ SettingsManager.SaveSettingsToFile();
+ MessageBox.Show("自定义铃声设置成功!", "设置成功", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+ }
+
+ private void ButtonResetTimerSound_Click(object sender, RoutedEventArgs e)
+ {
+ SettingsManager.Settings.RandSettings.CustomTimerSoundPath = "";
+ SettingsManager.SaveSettingsToFile();
+ MessageBox.Show("已重置为默认铃声!", "重置成功", MessageBoxButton.OK, MessageBoxImage.Information);
+ }
+
+ private void ToggleSwitchEnableProgressiveReminder_Toggled(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.EnableProgressiveReminder = ToggleSwitchEnableProgressiveReminder.IsOn;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ProgressiveReminderVolumeSlider_ValueChanged(object sender, RoutedEventArgs e)
+ {
+ if (!_isLoaded) return;
+ SettingsManager.Settings.RandSettings.ProgressiveReminderVolume = ProgressiveReminderVolumeSlider.Value;
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ private void ButtonSelectCustomProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
+ {
+ Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog
+ {
+ Title = "选择渐进提醒音频文件",
+ Filter = "音频文件 (*.wav)|*.wav|所有文件 (*.*)|*.*",
+ DefaultExt = "wav"
+ };
+
+ if (openFileDialog.ShowDialog() == true)
+ {
+ SettingsManager.Settings.RandSettings.ProgressiveReminderSoundPath = openFileDialog.FileName;
+ SettingsManager.SaveSettingsToFile();
+ }
+ }
+
+ private void ButtonResetProgressiveReminderSound_Click(object sender, RoutedEventArgs e)
+ {
+ SettingsManager.Settings.RandSettings.ProgressiveReminderSoundPath = "";
+ SettingsManager.SaveSettingsToFile();
+ }
+
+ #endregion
+ }
+}
diff --git a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml
index f41fae23..c2524bc3 100644
--- a/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml
+++ b/Ink Canvas/Windows/SettingsViews/SettingsWindow.xaml
@@ -208,6 +208,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+