feat(设置): 新增高级设置和随机点名设置页面
refactor: 将高级和随机点名设置从主窗口迁移到独立页面 style: 优化墨迹识别页面的高精度直线拉直开关样式 fix: 修复URI处理中未刷新配置列表的问题
This commit is contained in:
@@ -3550,7 +3550,7 @@ namespace Ink_Canvas
|
||||
SyncPdfPageSidebarWithCanvas();
|
||||
}
|
||||
|
||||
internal int BoundsWidth = 5;
|
||||
public int BoundsWidth = 5;
|
||||
|
||||
private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
@@ -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<double> 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<double> 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<double> 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<Settings>(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<double> e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.RandSettings.MLAvoidanceHistoryCount = (int)MLAvoidanceHistorySlider.Value;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void MLAvoidanceWeightSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> 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;
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user