add:新设置

This commit is contained in:
2026-01-02 13:38:04 +08:00
parent 9d14f16fe2
commit acafdcc991
7 changed files with 354 additions and 127 deletions
@@ -483,12 +483,18 @@ namespace Ink_Canvas.Windows.SettingsViews
if (isRegistered) if (isRegistered)
{ {
FileAssociationStatusText.Text = "✓ .icstk文件关联已注册"; FileAssociationStatusText.Text = "✓ .icstk文件关联已注册";
FileAssociationStatusText.Foreground = new SolidColorBrush(Colors.LightGreen); // 使用主题适配的绿色
FileAssociationStatusText.Foreground = ThemeHelper.IsDarkTheme
? new SolidColorBrush(Color.FromRgb(76, 175, 80)) // 深色主题下的绿色
: new SolidColorBrush(Color.FromRgb(46, 125, 50)); // 浅色主题下的绿色
} }
else else
{ {
FileAssociationStatusText.Text = "✗ .icstk文件关联未注册"; FileAssociationStatusText.Text = "✗ .icstk文件关联未注册";
FileAssociationStatusText.Foreground = new SolidColorBrush(Colors.LightCoral); // 使用主题适配的红色
FileAssociationStatusText.Foreground = ThemeHelper.IsDarkTheme
? new SolidColorBrush(Color.FromRgb(244, 67, 54)) // 深色主题下的红色
: new SolidColorBrush(Color.FromRgb(198, 40, 40)); // 浅色主题下的红色
} }
} }
} }
@@ -498,7 +504,10 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
FileAssociationStatusText.Visibility = Visibility.Visible; FileAssociationStatusText.Visibility = Visibility.Visible;
FileAssociationStatusText.Text = $"✗ 检查文件关联状态时出错: {ex.Message}"; FileAssociationStatusText.Text = $"✗ 检查文件关联状态时出错: {ex.Message}";
FileAssociationStatusText.Foreground = new SolidColorBrush(Colors.LightCoral); // 使用主题适配的红色
FileAssociationStatusText.Foreground = ThemeHelper.IsDarkTheme
? new SolidColorBrush(Color.FromRgb(244, 67, 54)) // 深色主题下的红色
: new SolidColorBrush(Color.FromRgb(198, 40, 40)); // 浅色主题下的红色
} }
} }
} }
@@ -512,6 +521,26 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
SetOptionButtonState("AutoBackupInterval", MainWindow.Settings.Advanced.AutoBackupIntervalDays); SetOptionButtonState("AutoBackupInterval", MainWindow.Settings.Advanced.AutoBackupIntervalDays);
} }
// 如果文件关联状态文本已显示,更新其颜色以适配主题
if (FileAssociationStatusText != null && FileAssociationStatusText.Visibility == Visibility.Visible)
{
var currentText = FileAssociationStatusText.Text;
if (currentText.Contains("✓") || currentText.Contains("已注册"))
{
// 成功状态 - 绿色
FileAssociationStatusText.Foreground = ThemeHelper.IsDarkTheme
? new SolidColorBrush(Color.FromRgb(76, 175, 80))
: new SolidColorBrush(Color.FromRgb(46, 125, 50));
}
else if (currentText.Contains("✗") || currentText.Contains("未注册") || currentText.Contains("出错"))
{
// 错误状态 - 红色
FileAssociationStatusText.Foreground = ThemeHelper.IsDarkTheme
? new SolidColorBrush(Color.FromRgb(244, 67, 54))
: new SolidColorBrush(Color.FromRgb(198, 40, 40));
}
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -4,6 +4,7 @@ using System;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using Application = System.Windows.Application; using Application = System.Windows.Application;
@@ -413,7 +414,7 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
private void AutoSaveIntervalButton_Click(object sender, RoutedEventArgs e) private void AutoSaveIntervalButton_Click(object sender, MouseButtonEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -123,7 +123,7 @@
</StackPanel> </StackPanel>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0"> <WrapPanel Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,15,0">
<Border x:Name="UpdateChannelReleaseBorder" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateChannel_Release" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click"> <Border x:Name="UpdateChannelReleaseBorder" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateChannel_Release" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
<TextBlock Foreground="#2e3436" FontSize="14" FontWeight="Bold" Text="稳定版"/> <TextBlock Foreground="#2e3436" FontSize="14" Text="稳定版"/>
</Border> </Border>
<Border x:Name="UpdateChannelBetaBorder" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateChannel_Beta" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click"> <Border x:Name="UpdateChannelBetaBorder" Padding="13,7" CornerRadius="8" Cursor="Hand" Tag="UpdateChannel_Beta" Margin="0,0,8,8" MouseLeftButtonDown="OptionButton_Click">
<TextBlock Foreground="#2e3436" FontSize="14" Text="测试版"/> <TextBlock Foreground="#2e3436" FontSize="14" Text="测试版"/>
@@ -1,4 +1,4 @@
using Ink_Canvas; using Ink_Canvas;
using iNKORE.UI.WPF.Helpers; using iNKORE.UI.WPF.Helpers;
using System; using System;
using System.Linq; using System.Linq;
@@ -8,6 +8,9 @@ using System.Windows.Media;
namespace Ink_Canvas.Windows.SettingsViews namespace Ink_Canvas.Windows.SettingsViews
{ {
/// <summary>
/// StartupPanel.xaml 的交互逻辑
/// </summary>
public partial class StartupPanel : UserControl public partial class StartupPanel : UserControl
{ {
private bool _isLoaded = false; private bool _isLoaded = false;
@@ -21,14 +24,21 @@ namespace Ink_Canvas.Windows.SettingsViews
private void StartupPanel_Loaded(object sender, RoutedEventArgs e) private void StartupPanel_Loaded(object sender, RoutedEventArgs e)
{ {
LoadSettings(); LoadSettings();
// 添加触摸支持
EnableTouchSupport(); EnableTouchSupport();
// 应用主题
ApplyTheme(); ApplyTheme();
_isLoaded = true; _isLoaded = true;
} }
/// <summary>
/// 为面板中的所有交互控件启用触摸支持
/// </summary>
private void EnableTouchSupport() private void EnableTouchSupport()
{ {
try try
{ {
// 延迟执行,确保所有控件都已加载
Dispatcher.BeginInvoke(new Action(() => Dispatcher.BeginInvoke(new Action(() =>
{ {
EnableTouchSupportForControls(this); EnableTouchSupportForControls(this);
@@ -36,11 +46,16 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"StartupPanel 启用触摸支持时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"StartupPanel 启用触摸支持时出错: {ex.Message}");
} }
} }
/// <summary>
/// 为控件树中的所有交互控件启用触摸支持
/// </summary>
private void EnableTouchSupportForControls(System.Windows.DependencyObject parent) private void EnableTouchSupportForControls(System.Windows.DependencyObject parent)
{ {
// 使用 MainWindowSettingsHelper 的通用方法
MainWindowSettingsHelper.EnableTouchSupportForControls(parent); MainWindowSettingsHelper.EnableTouchSupportForControls(parent);
} }
@@ -59,6 +74,10 @@ namespace Ink_Canvas.Windows.SettingsViews
IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs()); IsTopBarNeedNoShadowEffect?.Invoke(this, new RoutedEventArgs());
} }
} }
/// <summary>
/// 加载设置到UI
/// </summary>
public void LoadSettings() public void LoadSettings()
{ {
if (MainWindow.Settings == null) return; if (MainWindow.Settings == null) return;
@@ -67,12 +86,15 @@ namespace Ink_Canvas.Windows.SettingsViews
try try
{ {
// 自动更新设置
var toggleSwitchIsAutoUpdate = FindToggleSwitch("ToggleSwitchIsAutoUpdate"); var toggleSwitchIsAutoUpdate = FindToggleSwitch("ToggleSwitchIsAutoUpdate");
if (toggleSwitchIsAutoUpdate != null) if (toggleSwitchIsAutoUpdate != null)
{ {
bool isAutoUpdate = MainWindow.Settings.Startup.IsAutoUpdate; bool isAutoUpdate = MainWindow.Settings.Startup.IsAutoUpdate;
SetToggleSwitchState(toggleSwitchIsAutoUpdate, isAutoUpdate); SetToggleSwitchState(toggleSwitchIsAutoUpdate, isAutoUpdate);
} }
// 静默更新设置
var toggleSwitchIsAutoUpdateWithSilence = FindToggleSwitch("ToggleSwitchIsAutoUpdateWithSilence"); var toggleSwitchIsAutoUpdateWithSilence = FindToggleSwitch("ToggleSwitchIsAutoUpdateWithSilence");
if (toggleSwitchIsAutoUpdateWithSilence != null) if (toggleSwitchIsAutoUpdateWithSilence != null)
{ {
@@ -80,11 +102,17 @@ namespace Ink_Canvas.Windows.SettingsViews
SetToggleSwitchState(toggleSwitchIsAutoUpdateWithSilence, isAutoUpdateWithSilence); SetToggleSwitchState(toggleSwitchIsAutoUpdateWithSilence, isAutoUpdateWithSilence);
toggleSwitchIsAutoUpdateWithSilence.Visibility = MainWindow.Settings.Startup.IsAutoUpdate ? Visibility.Visible : Visibility.Collapsed; toggleSwitchIsAutoUpdateWithSilence.Visibility = MainWindow.Settings.Startup.IsAutoUpdate ? Visibility.Visible : Visibility.Collapsed;
} }
// 静默更新时间段
if (AutoUpdateTimePeriodBlock != null)
{ {
AutoUpdateTimePeriodBlock.Visibility = AutoUpdateTimePeriodBlock.Visibility =
(MainWindow.Settings.Startup.IsAutoUpdateWithSilence && MainWindow.Settings.Startup.IsAutoUpdate) ? (MainWindow.Settings.Startup.IsAutoUpdateWithSilence && MainWindow.Settings.Startup.IsAutoUpdate) ?
Visibility.Visible : Visibility.Collapsed; Visibility.Visible : Visibility.Collapsed;
} }
// 设置时间选择器
if (AutoUpdateWithSilenceStartTimeComboBox != null)
{ {
var startTime = MainWindow.Settings.Startup.AutoUpdateWithSilenceStartTime ?? "06:00"; var startTime = MainWindow.Settings.Startup.AutoUpdateWithSilenceStartTime ?? "06:00";
var startItem = AutoUpdateWithSilenceStartTimeComboBox.Items.Cast<ComboBoxItem>() var startItem = AutoUpdateWithSilenceStartTimeComboBox.Items.Cast<ComboBoxItem>()
@@ -105,38 +133,53 @@ namespace Ink_Canvas.Windows.SettingsViews
AutoUpdateWithSilenceEndTimeComboBox.SelectedItem = endItem; AutoUpdateWithSilenceEndTimeComboBox.SelectedItem = endItem;
} }
} }
// 开机时运行
var toggleSwitchRunAtStartup = FindToggleSwitch("ToggleSwitchRunAtStartup"); var toggleSwitchRunAtStartup = FindToggleSwitch("ToggleSwitchRunAtStartup");
if (toggleSwitchRunAtStartup != null) if (toggleSwitchRunAtStartup != null)
{ {
// 检查启动项是否存在
bool runAtStartup = System.IO.File.Exists( bool runAtStartup = System.IO.File.Exists(
Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\Ink Canvas Annotation.lnk"); Environment.GetFolderPath(Environment.SpecialFolder.Startup) + "\\Ink Canvas Annotation.lnk");
SetToggleSwitchState(toggleSwitchRunAtStartup, runAtStartup); SetToggleSwitchState(toggleSwitchRunAtStartup, runAtStartup);
} }
// 启动时折叠
var toggleSwitchFoldAtStartup = FindToggleSwitch("ToggleSwitchFoldAtStartup"); var toggleSwitchFoldAtStartup = FindToggleSwitch("ToggleSwitchFoldAtStartup");
if (toggleSwitchFoldAtStartup != null) if (toggleSwitchFoldAtStartup != null)
{ {
SetToggleSwitchState(toggleSwitchFoldAtStartup, MainWindow.Settings.Startup.IsFoldAtStartup); SetToggleSwitchState(toggleSwitchFoldAtStartup, MainWindow.Settings.Startup.IsFoldAtStartup);
} }
// 窗口无焦点模式
var toggleSwitchNoFocusMode = FindToggleSwitch("ToggleSwitchNoFocusMode"); var toggleSwitchNoFocusMode = FindToggleSwitch("ToggleSwitchNoFocusMode");
if (toggleSwitchNoFocusMode != null && MainWindow.Settings.Advanced != null) if (toggleSwitchNoFocusMode != null && MainWindow.Settings.Advanced != null)
{ {
SetToggleSwitchState(toggleSwitchNoFocusMode, MainWindow.Settings.Advanced.IsNoFocusMode); SetToggleSwitchState(toggleSwitchNoFocusMode, MainWindow.Settings.Advanced.IsNoFocusMode);
} }
// 窗口无边框模式
var toggleSwitchWindowMode = FindToggleSwitch("ToggleSwitchWindowMode"); var toggleSwitchWindowMode = FindToggleSwitch("ToggleSwitchWindowMode");
if (toggleSwitchWindowMode != null && MainWindow.Settings.Advanced != null) if (toggleSwitchWindowMode != null && MainWindow.Settings.Advanced != null)
{ {
SetToggleSwitchState(toggleSwitchWindowMode, MainWindow.Settings.Advanced.WindowMode); SetToggleSwitchState(toggleSwitchWindowMode, MainWindow.Settings.Advanced.WindowMode);
} }
// 窗口置顶
var toggleSwitchAlwaysOnTop = FindToggleSwitch("ToggleSwitchAlwaysOnTop"); var toggleSwitchAlwaysOnTop = FindToggleSwitch("ToggleSwitchAlwaysOnTop");
if (toggleSwitchAlwaysOnTop != null && MainWindow.Settings.Advanced != null) if (toggleSwitchAlwaysOnTop != null && MainWindow.Settings.Advanced != null)
{ {
SetToggleSwitchState(toggleSwitchAlwaysOnTop, MainWindow.Settings.Advanced.IsAlwaysOnTop); SetToggleSwitchState(toggleSwitchAlwaysOnTop, MainWindow.Settings.Advanced.IsAlwaysOnTop);
} }
// UIA置顶
var toggleSwitchUIAccessTopMost = FindToggleSwitch("ToggleSwitchUIAccessTopMost"); var toggleSwitchUIAccessTopMost = FindToggleSwitch("ToggleSwitchUIAccessTopMost");
if (toggleSwitchUIAccessTopMost != null && MainWindow.Settings.Advanced != null) if (toggleSwitchUIAccessTopMost != null && MainWindow.Settings.Advanced != null)
{ {
SetToggleSwitchState(toggleSwitchUIAccessTopMost, MainWindow.Settings.Advanced.EnableUIAccessTopMost); SetToggleSwitchState(toggleSwitchUIAccessTopMost, MainWindow.Settings.Advanced.EnableUIAccessTopMost);
} }
// 更新通道
if (MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Release) if (MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Release)
{ {
UpdateUpdateChannelButtons(true); UpdateUpdateChannelButtons(true);
@@ -145,6 +188,8 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
UpdateUpdateChannelButtons(false); UpdateUpdateChannelButtons(false);
} }
// 仅PPT模式
var toggleSwitchMode = FindToggleSwitch("ToggleSwitchMode"); var toggleSwitchMode = FindToggleSwitch("ToggleSwitchMode");
if (toggleSwitchMode != null && MainWindow.Settings.ModeSettings != null) if (toggleSwitchMode != null && MainWindow.Settings.ModeSettings != null)
{ {
@@ -153,27 +198,37 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"加载启动设置时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"加载启动设置时出错: {ex.Message}");
} }
_isLoaded = true; _isLoaded = true;
} }
/// <summary>
/// 查找ToggleSwitch控件
/// </summary>
private Border FindToggleSwitch(string name) private Border FindToggleSwitch(string name)
{ {
return this.FindDescendantByName(name) as Border; return this.FindDescendantByName(name) as Border;
} }
/// <summary>
/// 设置ToggleSwitch状态
/// </summary>
private void SetToggleSwitchState(Border toggleSwitch, bool isOn) private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
{ {
if (toggleSwitch == null) return; if (toggleSwitch == null) return;
toggleSwitch.Background = isOn toggleSwitch.Background = isOn ? new SolidColorBrush(Color.FromRgb(53, 132, 228)) : new SolidColorBrush(Color.FromRgb(225, 225, 225));
? ThemeHelper.GetToggleSwitchOnBackgroundBrush()
: ThemeHelper.GetToggleSwitchOffBackgroundBrush();
var innerBorder = toggleSwitch.Child as Border; var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null) if (innerBorder != null)
{ {
innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left; innerBorder.HorizontalAlignment = isOn ? HorizontalAlignment.Right : HorizontalAlignment.Left;
} }
} }
/// <summary>
/// ToggleSwitch点击事件处理
/// </summary>
private void ToggleSwitch_Click(object sender, RoutedEventArgs e) private void ToggleSwitch_Click(object sender, RoutedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -181,7 +236,7 @@ namespace Ink_Canvas.Windows.SettingsViews
var border = sender as Border; var border = sender as Border;
if (border == null) return; if (border == null) return;
bool isOn = ThemeHelper.IsToggleSwitchOn(border.Background); bool isOn = border.Background.ToString() == "#FF3584E4";
bool newState = !isOn; bool newState = !isOn;
SetToggleSwitchState(border, newState); SetToggleSwitchState(border, newState);
@@ -191,7 +246,9 @@ namespace Ink_Canvas.Windows.SettingsViews
switch (tag) switch (tag)
{ {
case "IsAutoUpdate": case "IsAutoUpdate":
// 直接调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsAutoUpdate", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsAutoUpdate", newState);
// 更新UI状态
var toggleSwitchIsAutoUpdateWithSilence = FindToggleSwitch("ToggleSwitchIsAutoUpdateWithSilence"); var toggleSwitchIsAutoUpdateWithSilence = FindToggleSwitch("ToggleSwitchIsAutoUpdateWithSilence");
if (toggleSwitchIsAutoUpdateWithSilence != null) if (toggleSwitchIsAutoUpdateWithSilence != null)
{ {
@@ -206,32 +263,45 @@ namespace Ink_Canvas.Windows.SettingsViews
break; break;
case "IsAutoUpdateWithSilence": case "IsAutoUpdateWithSilence":
// 直接调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsAutoUpdateWithSilence", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchIsAutoUpdateWithSilence", newState);
// 更新UI状态
if (AutoUpdateTimePeriodBlock != null)
{ {
AutoUpdateTimePeriodBlock.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; AutoUpdateTimePeriodBlock.Visibility = newState ? Visibility.Visible : Visibility.Collapsed;
} }
break; break;
case "RunAtStartup": case "RunAtStartup":
// 直接调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchRunAtStartup", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchRunAtStartup", newState);
break; break;
case "FoldAtStartup": case "FoldAtStartup":
// 直接调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFoldAtStartup", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchFoldAtStartup", newState);
break; break;
case "NoFocusMode": case "NoFocusMode":
if (MainWindow.Settings.Advanced != null) // 窗口无焦点模式
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
MainWindow.Settings.Advanced.IsNoFocusMode = newState; if (MainWindow.Settings.Advanced != null)
} {
MainWindow.Settings.Advanced.IsNoFocusMode = newState;
}
}, "ToggleSwitchNoFocusMode");
// 调用 ApplyNoFocusMode 方法
MainWindowSettingsHelper.InvokeMainWindowMethod("ApplyNoFocusMode"); MainWindowSettingsHelper.InvokeMainWindowMethod("ApplyNoFocusMode");
break; break;
case "WindowMode": case "WindowMode":
// 窗口无边框模式
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchWindowMode", newState);
break; break;
case "AlwaysOnTop": case "AlwaysOnTop":
// 窗口置顶
MainWindowSettingsHelper.UpdateSettingDirectly(() => MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
if (MainWindow.Settings.Advanced != null) if (MainWindow.Settings.Advanced != null)
@@ -239,10 +309,12 @@ namespace Ink_Canvas.Windows.SettingsViews
MainWindow.Settings.Advanced.IsAlwaysOnTop = newState; MainWindow.Settings.Advanced.IsAlwaysOnTop = newState;
} }
}, "ToggleSwitchAlwaysOnTop"); }, "ToggleSwitchAlwaysOnTop");
// 调用 SetAlwaysOnTop 方法(如果存在)
MainWindowSettingsHelper.InvokeMainWindowMethod("SetAlwaysOnTop", newState); MainWindowSettingsHelper.InvokeMainWindowMethod("SetAlwaysOnTop", newState);
break; break;
case "UIAccessTopMost": case "UIAccessTopMost":
// UIA置顶
MainWindowSettingsHelper.UpdateSettingDirectly(() => MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
if (MainWindow.Settings.Advanced != null) if (MainWindow.Settings.Advanced != null)
@@ -253,10 +325,15 @@ namespace Ink_Canvas.Windows.SettingsViews
break; break;
case "Mode": case "Mode":
// 仅PPT模式
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchMode", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchMode", newState);
break; break;
} }
} }
/// <summary>
/// 选项按钮点击事件处理
/// </summary>
private void OptionButton_Click(object sender, RoutedEventArgs e) private void OptionButton_Click(object sender, RoutedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -270,80 +347,107 @@ namespace Ink_Canvas.Windows.SettingsViews
switch (tag) switch (tag)
{ {
case "UpdateChannel_Release": case "UpdateChannel_Release":
// 选择稳定版
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
MainWindow.Settings.Startup.UpdateChannel = UpdateChannel.Release; MainWindow.Settings.Startup.UpdateChannel = UpdateChannel.Release;
MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked", }, "UpdateChannelSelector");
new System.Windows.Controls.RadioButton { Tag = "Release" }, e); // 调用 MainWindow 中的方法
UpdateUpdateChannelButtons(true); MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked",
} new System.Windows.Controls.RadioButton { Tag = "Release" }, e);
// 更新UI状态
UpdateUpdateChannelButtons(true);
break; break;
case "UpdateChannel_Beta": case "UpdateChannel_Beta":
// 选择测试版
MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
MainWindow.Settings.Startup.UpdateChannel = UpdateChannel.Beta; MainWindow.Settings.Startup.UpdateChannel = UpdateChannel.Beta;
MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked", }, "UpdateChannelSelector");
new System.Windows.Controls.RadioButton { Tag = "Beta" }, e); // 调用 MainWindow 中的方法
UpdateUpdateChannelButtons(false); MainWindowSettingsHelper.InvokeMainWindowMethod("UpdateChannelSelector_Checked",
} new System.Windows.Controls.RadioButton { Tag = "Beta" }, e);
// 更新UI状态
UpdateUpdateChannelButtons(false);
break; break;
} }
} }
/// <summary>
/// 更新更新通道按钮状态
/// </summary>
private void UpdateUpdateChannelButtons(bool isReleaseSelected) private void UpdateUpdateChannelButtons(bool isReleaseSelected)
{ {
try try
{ {
if (UpdateChannelReleaseBorder != null) // 使用 ThemeHelper 的统一方法设置按钮状态,与其他选项按钮保持一致
{ ThemeHelper.SetOptionButtonSelectedState(UpdateChannelReleaseBorder, isReleaseSelected);
ThemeHelper.SetOptionButtonSelectedState(UpdateChannelReleaseBorder, isReleaseSelected); ThemeHelper.SetOptionButtonSelectedState(UpdateChannelBetaBorder, !isReleaseSelected);
}
if (UpdateChannelBetaBorder != null)
{
ThemeHelper.SetOptionButtonSelectedState(UpdateChannelBetaBorder, !isReleaseSelected);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"更新更新通道按钮状态时出错: {ex.Message}"); System.Diagnostics.Debug.WriteLine($"更新更新通道按钮状态时出错: {ex.Message}");
} }
} }
/// <summary>
/// 手动更新按钮点击事件
/// </summary>
private async void ManualUpdateButton_Click(object sender, RoutedEventArgs e) private async void ManualUpdateButton_Click(object sender, RoutedEventArgs e)
{ {
MainWindowSettingsHelper.InvokeMainWindowMethod("ManualUpdateButton_Click", sender, e); MainWindowSettingsHelper.InvokeMainWindowMethod("ManualUpdateButton_Click", sender, e);
} }
/// <summary>
/// 版本修复按钮点击事件
/// </summary>
private async void FixVersionButton_Click(object sender, RoutedEventArgs e) private async void FixVersionButton_Click(object sender, RoutedEventArgs e)
{ {
MainWindowSettingsHelper.InvokeMainWindowMethod("FixVersionButton_Click", sender, e); MainWindowSettingsHelper.InvokeMainWindowMethod("FixVersionButton_Click", sender, e);
} }
/// <summary>
/// 历史版本回滚按钮点击事件
/// </summary>
private void HistoryRollbackButton_Click(object sender, RoutedEventArgs e) private void HistoryRollbackButton_Click(object sender, RoutedEventArgs e)
{ {
// 查找 MainWindow 中的历史版本回滚方法
MainWindowSettingsHelper.InvokeMainWindowMethod("HistoryRollbackButton_Click", sender, e); MainWindowSettingsHelper.InvokeMainWindowMethod("HistoryRollbackButton_Click", sender, e);
} }
/// <summary>
/// ComboBox选择变化事件处理
/// </summary>
private void AutoUpdateWithSilenceStartTimeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void AutoUpdateWithSilenceStartTimeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
// 直接调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("AutoUpdateWithSilenceStartTimeComboBox", AutoUpdateWithSilenceStartTimeComboBox?.SelectedItem); MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("AutoUpdateWithSilenceStartTimeComboBox", AutoUpdateWithSilenceStartTimeComboBox?.SelectedItem);
} }
private void AutoUpdateWithSilenceEndTimeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) private void AutoUpdateWithSilenceEndTimeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
// 直接调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("AutoUpdateWithSilenceEndTimeComboBox", AutoUpdateWithSilenceEndTimeComboBox?.SelectedItem); MainWindowSettingsHelper.InvokeComboBoxSelectionChanged("AutoUpdateWithSilenceEndTimeComboBox", AutoUpdateWithSilenceEndTimeComboBox?.SelectedItem);
} }
/// <summary>
/// 应用主题
/// </summary>
public void ApplyTheme() public void ApplyTheme()
{ {
try try
{ {
bool isDarkTheme = ThemeHelper.IsDarkTheme; // 更新更新通道按钮 - 使用统一的方法保持与其他选项按钮一致
// 更新更新通道按钮状态 if (MainWindow.Settings?.Startup != null)
if (MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Release)
{ {
UpdateUpdateChannelButtons(true); bool isReleaseSelected = MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Release;
} UpdateUpdateChannelButtons(isReleaseSelected);
else
{
UpdateUpdateChannelButtons(false);
} }
// 更新按钮
if (ManualUpdateButton != null) if (ManualUpdateButton != null)
{ {
ManualUpdateButton.Background = ThemeHelper.GetButtonBackgroundBrush(); ManualUpdateButton.Background = ThemeHelper.GetButtonBackgroundBrush();
@@ -359,29 +463,19 @@ namespace Ink_Canvas.Windows.SettingsViews
HistoryRollbackButton.Background = ThemeHelper.GetButtonBackgroundBrush(); HistoryRollbackButton.Background = ThemeHelper.GetButtonBackgroundBrush();
HistoryRollbackButton.Foreground = ThemeHelper.GetTextPrimaryBrush(); HistoryRollbackButton.Foreground = ThemeHelper.GetTextPrimaryBrush();
} }
// 使用 ThemeHelper 递归更新其他元素
ThemeHelper.ApplyThemeToControl(this); ThemeHelper.ApplyThemeToControl(this);
UpdateComboBoxDropdownTheme(AutoUpdateWithSilenceStartTimeComboBox);
UpdateComboBoxDropdownTheme(AutoUpdateWithSilenceEndTimeComboBox); if (MainWindow.Settings?.Startup != null)
{
bool isReleaseSelected = MainWindow.Settings.Startup.UpdateChannel == UpdateChannel.Release;
UpdateUpdateChannelButtons(isReleaseSelected);
}
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"StartupPanel 应用主题时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"StartupPanel 应用主题时出错: {ex.Message}");
}
}
private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox)
{
if (comboBox == null) return;
comboBox.DropDownOpened -= ComboBox_DropDownOpened;
comboBox.DropDownOpened += ComboBox_DropDownOpened;
}
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
if (sender is System.Windows.Controls.ComboBox comboBox)
{
Dispatcher.BeginInvoke(new Action(() =>
{
ThemeHelper.UpdateComboBoxDropdownColors(comboBox);
}), System.Windows.Threading.DispatcherPriority.Loaded);
} }
} }
} }
@@ -1,4 +1,4 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
@@ -48,7 +48,7 @@ namespace Ink_Canvas.Windows.SettingsViews
public static Color ButtonHoverBackground => IsDarkTheme ? Color.FromRgb(55, 55, 55) : Color.FromRgb(210, 210, 210); public static Color ButtonHoverBackground => IsDarkTheme ? Color.FromRgb(55, 55, 55) : Color.FromRgb(210, 210, 210);
public static Color ToggleSwitchOnBackground => IsDarkTheme ? Color.FromRgb(0, 122, 204) : Color.FromRgb(53, 132, 228); public static Color ToggleSwitchOnBackground => IsDarkTheme ? Color.FromRgb(0, 122, 204) : Color.FromRgb(53, 132, 228);
public static Color ToggleSwitchOffBackground => IsDarkTheme ? ButtonBackground : Color.FromRgb(225, 225, 225); public static Color ToggleSwitchOffBackground => IsDarkTheme ? ButtonBackground : Color.FromRgb(225, 225, 225);
public static Color OptionButtonSelectedBackground => IsDarkTheme ? Color.FromRgb(62, 62, 62) : Color.FromRgb(235, 235, 235); public static Color OptionButtonSelectedBackground => SelectedBackground;
public static Color OptionButtonUnselectedBackground => Colors.Transparent; public static Color OptionButtonUnselectedBackground => Colors.Transparent;
public static Color OptionButtonSelectedBorder => IsDarkTheme ? Color.FromRgb(100, 100, 100) : Color.FromRgb(160, 160, 160); public static Color OptionButtonSelectedBorder => IsDarkTheme ? Color.FromRgb(100, 100, 100) : Color.FromRgb(160, 160, 160);
public static Color OptionButtonUnselectedBorder => IsDarkTheme ? Color.FromRgb(50, 50, 50) : Color.FromRgb(220, 220, 220); public static Color OptionButtonUnselectedBorder => IsDarkTheme ? Color.FromRgb(50, 50, 50) : Color.FromRgb(220, 220, 220);
@@ -1,4 +1,4 @@
using Ink_Canvas; using Ink_Canvas;
using iNKORE.UI.WPF.Helpers; using iNKORE.UI.WPF.Helpers;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -11,6 +11,9 @@ using Hardcodet.Wpf.TaskbarNotification;
namespace Ink_Canvas.Windows.SettingsViews namespace Ink_Canvas.Windows.SettingsViews
{ {
/// <summary>
/// ThemePanel.xaml 的交互逻辑
/// </summary>
public partial class ThemePanel : UserControl public partial class ThemePanel : UserControl
{ {
private bool _isLoaded = false; private bool _isLoaded = false;
@@ -24,15 +27,21 @@ namespace Ink_Canvas.Windows.SettingsViews
private void ThemePanel_Loaded(object sender, RoutedEventArgs e) private void ThemePanel_Loaded(object sender, RoutedEventArgs e)
{ {
LoadSettings(); LoadSettings();
// 添加触摸支持
EnableTouchSupport(); EnableTouchSupport();
// 应用主题
ApplyTheme(); ApplyTheme();
_isLoaded = true; _isLoaded = true;
} }
/// <summary>
/// 为面板中的所有交互控件启用触摸支持
/// </summary>
private void EnableTouchSupport() private void EnableTouchSupport()
{ {
try try
{ {
// 延迟执行,确保所有控件都已加载
Dispatcher.BeginInvoke(new Action(() => Dispatcher.BeginInvoke(new Action(() =>
{ {
MainWindowSettingsHelper.EnableTouchSupportForControls(this); MainWindowSettingsHelper.EnableTouchSupportForControls(this);
@@ -40,7 +49,7 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"ThemePanel 启用触摸支持时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"ThemePanel 启用触摸支持时出错: {ex.Message}");
} }
} }
@@ -61,6 +70,9 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
/// <summary>
/// 加载设置到UI
/// </summary>
public void LoadSettings() public void LoadSettings()
{ {
if (MainWindow.Settings == null || MainWindow.Settings.Appearance == null) return; if (MainWindow.Settings == null || MainWindow.Settings.Appearance == null) return;
@@ -71,25 +83,33 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
var appearance = MainWindow.Settings.Appearance; var appearance = MainWindow.Settings.Appearance;
// 主题设置
SetOptionButtonState("Theme", appearance.Theme); SetOptionButtonState("Theme", appearance.Theme);
// 启用启动动画
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableSplashScreen"), appearance.EnableSplashScreen); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableSplashScreen"), appearance.EnableSplashScreen);
if (SplashScreenStylePanel != null) if (SplashScreenStylePanel != null)
{ {
SplashScreenStylePanel.Visibility = appearance.EnableSplashScreen ? Visibility.Visible : Visibility.Collapsed; SplashScreenStylePanel.Visibility = appearance.EnableSplashScreen ? Visibility.Visible : Visibility.Collapsed;
} }
// 启动动画样式
if (ComboBoxSplashScreenStyle != null) if (ComboBoxSplashScreenStyle != null)
{ {
ComboBoxSplashScreenStyle.SelectedIndex = Math.Min(appearance.SplashScreenStyle, ComboBoxSplashScreenStyle.Items.Count - 1); ComboBoxSplashScreenStyle.SelectedIndex = Math.Min(appearance.SplashScreenStyle, ComboBoxSplashScreenStyle.Items.Count - 1);
} }
// 浮动工具栏图标
if (ComboBoxFloatingBarImg != null) if (ComboBoxFloatingBarImg != null)
{ {
// 更新自定义图标列表(如果需要)
// UpdateCustomIconsInComboBox();
int selectedIndex = Math.Min(appearance.FloatingBarImg, ComboBoxFloatingBarImg.Items.Count - 1); int selectedIndex = Math.Min(appearance.FloatingBarImg, ComboBoxFloatingBarImg.Items.Count - 1);
ComboBoxFloatingBarImg.SelectedIndex = selectedIndex; ComboBoxFloatingBarImg.SelectedIndex = selectedIndex;
} }
// 浮动工具栏缩放
if (ViewboxFloatingBarScaleTransformValueSlider != null) if (ViewboxFloatingBarScaleTransformValueSlider != null)
{ {
double val = appearance.ViewboxFloatingBarScaleTransformValue; double val = appearance.ViewboxFloatingBarScaleTransformValue;
@@ -101,6 +121,7 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
// 浮动工具栏透明度
if (ViewboxFloatingBarOpacityValueSlider != null) if (ViewboxFloatingBarOpacityValueSlider != null)
{ {
ViewboxFloatingBarOpacityValueSlider.Value = appearance.ViewboxFloatingBarOpacityValue; ViewboxFloatingBarOpacityValueSlider.Value = appearance.ViewboxFloatingBarOpacityValue;
@@ -110,6 +131,7 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
// 浮栏在PPT下透明度
if (ViewboxFloatingBarOpacityInPPTValueSlider != null) if (ViewboxFloatingBarOpacityInPPTValueSlider != null)
{ {
ViewboxFloatingBarOpacityInPPTValueSlider.Value = appearance.ViewboxFloatingBarOpacityInPPTValue; ViewboxFloatingBarOpacityInPPTValueSlider.Value = appearance.ViewboxFloatingBarOpacityInPPTValue;
@@ -119,13 +141,16 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
// 在调色盘窗口中显示笔尖模式按钮
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableDisPlayNibModeToggle"), appearance.IsEnableDisPlayNibModeToggler); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableDisPlayNibModeToggle"), appearance.IsEnableDisPlayNibModeToggler);
// 使用老版浮动栏按钮UI
if (CheckBoxUseLegacyFloatingBarUI != null) if (CheckBoxUseLegacyFloatingBarUI != null)
{ {
CheckBoxUseLegacyFloatingBarUI.IsChecked = appearance.UseLegacyFloatingBarUI; CheckBoxUseLegacyFloatingBarUI.IsChecked = appearance.UseLegacyFloatingBarUI;
} }
// 浮动栏按钮显示控制
if (CheckBoxShowShapeButton != null) CheckBoxShowShapeButton.IsChecked = appearance.IsShowShapeButton; if (CheckBoxShowShapeButton != null) CheckBoxShowShapeButton.IsChecked = appearance.IsShowShapeButton;
if (CheckBoxShowUndoButton != null) CheckBoxShowUndoButton.IsChecked = appearance.IsShowUndoButton; if (CheckBoxShowUndoButton != null) CheckBoxShowUndoButton.IsChecked = appearance.IsShowUndoButton;
if (CheckBoxShowRedoButton != null) CheckBoxShowRedoButton.IsChecked = appearance.IsShowRedoButton; if (CheckBoxShowRedoButton != null) CheckBoxShowRedoButton.IsChecked = appearance.IsShowRedoButton;
@@ -136,58 +161,76 @@ namespace Ink_Canvas.Windows.SettingsViews
if (CheckBoxShowLassoSelectButton != null) CheckBoxShowLassoSelectButton.IsChecked = appearance.IsShowLassoSelectButton; if (CheckBoxShowLassoSelectButton != null) CheckBoxShowLassoSelectButton.IsChecked = appearance.IsShowLassoSelectButton;
if (CheckBoxShowClearAndMouseButton != null) CheckBoxShowClearAndMouseButton.IsChecked = appearance.IsShowClearAndMouseButton; if (CheckBoxShowClearAndMouseButton != null) CheckBoxShowClearAndMouseButton.IsChecked = appearance.IsShowClearAndMouseButton;
// 启用系统托盘图标
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableTrayIcon"), appearance.EnableTrayIcon); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableTrayIcon"), appearance.EnableTrayIcon);
// 画板UI缩放
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableViewboxBlackBoardScaleTransform"), appearance.EnableViewboxBlackBoardScaleTransform); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableViewboxBlackBoardScaleTransform"), appearance.EnableViewboxBlackBoardScaleTransform);
// 白板模式时间显示
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableTimeDisplayInWhiteboardMode"), appearance.EnableTimeDisplayInWhiteboardMode); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableTimeDisplayInWhiteboardMode"), appearance.EnableTimeDisplayInWhiteboardMode);
// 白板模式鸡汤文
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableChickenSoupInWhiteboardMode"), appearance.EnableChickenSoupInWhiteboardMode); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableChickenSoupInWhiteboardMode"), appearance.EnableChickenSoupInWhiteboardMode);
// 启用快捷面板
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableQuickPanel"), appearance.IsShowQuickPanel); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableQuickPanel"), appearance.IsShowQuickPanel);
// 退出折叠模式后自动进入批注模式
if (MainWindow.Settings.Automation != null) if (MainWindow.Settings.Automation != null)
{ {
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode"), MainWindow.Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode"), MainWindow.Settings.Automation.IsAutoEnterAnnotationModeWhenExitFoldMode);
} }
// PPT放映结束后自动折叠
if (MainWindow.Settings.Automation != null) if (MainWindow.Settings.Automation != null)
{ {
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldAfterPPTSlideShow"), MainWindow.Settings.Automation.IsAutoFoldAfterPPTSlideShow); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldAfterPPTSlideShow"), MainWindow.Settings.Automation.IsAutoFoldAfterPPTSlideShow);
} }
// 退出白板模式后自动折叠
if (MainWindow.Settings.Automation != null) if (MainWindow.Settings.Automation != null)
{ {
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldWhenExitWhiteboard"), MainWindow.Settings.Automation.IsAutoFoldWhenExitWhiteboard); SetToggleSwitchState(FindToggleSwitch("ToggleSwitchAutoFoldWhenExitWhiteboard"), MainWindow.Settings.Automation.IsAutoFoldWhenExitWhiteboard);
} }
// 信仰の源出自Where
SetOptionButtonState("ChickenSoupSource", appearance.ChickenSoupSource); SetOptionButtonState("ChickenSoupSource", appearance.ChickenSoupSource);
// 取消收纳按钮图标
SetOptionButtonState("UnFoldBtnImg", appearance.UnFoldButtonImageType); SetOptionButtonState("UnFoldBtnImg", appearance.UnFoldButtonImageType);
// 快捷调色盘显示模式
SetOptionButtonState("QuickColorPaletteDisplayMode", appearance.QuickColorPaletteDisplayMode); SetOptionButtonState("QuickColorPaletteDisplayMode", appearance.QuickColorPaletteDisplayMode);
// 橡皮按钮显示
SetOptionButtonState("EraserDisplayOption", appearance.EraserDisplayOption); SetOptionButtonState("EraserDisplayOption", appearance.EraserDisplayOption);
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"加载个性化设置时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"加载个性化设置时出错: {ex.Message}");
} }
_isLoaded = true; _isLoaded = true;
} }
/// <summary>
/// 查找ToggleSwitch控件
/// </summary>
private Border FindToggleSwitch(string name) private Border FindToggleSwitch(string name)
{ {
return this.FindDescendantByName(name) as Border; return this.FindDescendantByName(name) as Border;
} }
/// <summary>
/// 设置ToggleSwitch状态
/// </summary>
private void SetToggleSwitchState(Border toggleSwitch, bool isOn) private void SetToggleSwitchState(Border toggleSwitch, bool isOn)
{ {
if (toggleSwitch == null) return; if (toggleSwitch == null) return;
toggleSwitch.Background = isOn toggleSwitch.Background = isOn
? ThemeHelper.GetToggleSwitchOnBackgroundBrush() ? new SolidColorBrush(Color.FromRgb(53, 132, 228))
: ThemeHelper.GetToggleSwitchOffBackgroundBrush(); : new SolidColorBrush(Color.FromRgb(225, 225, 225));
var innerBorder = toggleSwitch.Child as Border; var innerBorder = toggleSwitch.Child as Border;
if (innerBorder != null) if (innerBorder != null)
{ {
@@ -195,6 +238,9 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
/// <summary>
/// ToggleSwitch点击事件处理
/// </summary>
private void ToggleSwitch_Click(object sender, RoutedEventArgs e) private void ToggleSwitch_Click(object sender, RoutedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -202,7 +248,7 @@ namespace Ink_Canvas.Windows.SettingsViews
var border = sender as Border; var border = sender as Border;
if (border == null) return; if (border == null) return;
bool isOn = ThemeHelper.IsToggleSwitchOn(border.Background); bool isOn = border.Background.ToString() == "#FF3584E4";
bool newState = !isOn; bool newState = !isOn;
SetToggleSwitchState(border, newState); SetToggleSwitchState(border, newState);
@@ -215,7 +261,9 @@ namespace Ink_Canvas.Windows.SettingsViews
switch (tag) switch (tag)
{ {
case "EnableSplashScreen": case "EnableSplashScreen":
// 调用 MainWindow 中的方法(带主题检查)
MainWindowSettingsHelper.InvokeToggleSwitchToggledWithThemeCheck("ToggleSwitchEnableSplashScreen", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggledWithThemeCheck("ToggleSwitchEnableSplashScreen", newState);
// 更新UI状态
if (SplashScreenStylePanel != null) if (SplashScreenStylePanel != null)
{ {
SplashScreenStylePanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed; SplashScreenStylePanel.Visibility = newState ? Visibility.Visible : Visibility.Collapsed;
@@ -223,11 +271,14 @@ namespace Ink_Canvas.Windows.SettingsViews
break; break;
case "EnableDisPlayNibModeToggle": case "EnableDisPlayNibModeToggle":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableDisPlayNibModeToggle", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableDisPlayNibModeToggle", newState);
break; break;
case "EnableTrayIcon": case "EnableTrayIcon":
// 调用 MainWindow 中的方法(带主题检查)
MainWindowSettingsHelper.InvokeToggleSwitchToggledWithThemeCheck("ToggleSwitchEnableTrayIcon", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggledWithThemeCheck("ToggleSwitchEnableTrayIcon", newState);
// 更新系统托盘图标可见性
var taskbar = Application.Current.Resources["TaskbarTrayIcon"] as TaskbarIcon; var taskbar = Application.Current.Resources["TaskbarTrayIcon"] as TaskbarIcon;
if (taskbar != null) if (taskbar != null)
{ {
@@ -236,40 +287,51 @@ namespace Ink_Canvas.Windows.SettingsViews
break; break;
case "EnableViewboxBlackBoardScaleTransform": case "EnableViewboxBlackBoardScaleTransform":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableViewboxBlackBoardScaleTransform", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableViewboxBlackBoardScaleTransform", newState);
break; break;
case "EnableTimeDisplayInWhiteboardMode": case "EnableTimeDisplayInWhiteboardMode":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableTimeDisplayInWhiteboardMode", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableTimeDisplayInWhiteboardMode", newState);
break; break;
case "EnableChickenSoupInWhiteboardMode": case "EnableChickenSoupInWhiteboardMode":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableChickenSoupInWhiteboardMode", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableChickenSoupInWhiteboardMode", newState);
break; break;
case "EnableQuickPanel": case "EnableQuickPanel":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableQuickPanel", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchEnableQuickPanel", newState);
break; break;
case "AutoEnterAnnotationModeWhenExitFoldMode": case "AutoEnterAnnotationModeWhenExitFoldMode":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoEnterAnnotationModeWhenExitFoldMode", newState);
break; break;
case "AutoFoldAfterPPTSlideShow": case "AutoFoldAfterPPTSlideShow":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoFoldAfterPPTSlideShow", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoFoldAfterPPTSlideShow", newState);
break; break;
case "AutoFoldWhenExitWhiteboard": case "AutoFoldWhenExitWhiteboard":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoFoldWhenExitWhiteboard", newState); MainWindowSettingsHelper.InvokeToggleSwitchToggled("ToggleSwitchAutoFoldWhenExitWhiteboard", newState);
break; break;
} }
} }
/// <summary>
/// ComboBox选择变化事件处理
/// </summary>
private void ComboBoxSplashScreenStyle_SelectionChanged(object sender, SelectionChangedEventArgs e) private void ComboBoxSplashScreenStyle_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
if (ComboBoxSplashScreenStyle?.SelectedIndex >= 0) if (ComboBoxSplashScreenStyle?.SelectedIndex >= 0)
{ {
// 调用 MainWindow 中的方法(带主题检查)
MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxSplashScreenStyle", ComboBoxSplashScreenStyle.SelectedItem); MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxSplashScreenStyle", ComboBoxSplashScreenStyle.SelectedItem);
} }
} }
@@ -279,10 +341,14 @@ namespace Ink_Canvas.Windows.SettingsViews
if (!_isLoaded) return; if (!_isLoaded) return;
if (ComboBoxFloatingBarImg?.SelectedIndex >= 0) if (ComboBoxFloatingBarImg?.SelectedIndex >= 0)
{ {
// 调用 MainWindow 中的方法(带主题检查)
MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxFloatingBarImg", ComboBoxFloatingBarImg.SelectedItem); MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxFloatingBarImg", ComboBoxFloatingBarImg.SelectedItem);
} }
} }
/// <summary>
/// Slider值变化事件处理
/// </summary>
private void ViewboxFloatingBarScaleTransformValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) private void ViewboxFloatingBarScaleTransformValueSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -290,6 +356,7 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
double val = ViewboxFloatingBarScaleTransformValueSlider.Value; double val = ViewboxFloatingBarScaleTransformValueSlider.Value;
ViewboxFloatingBarScaleTransformValueText.Text = val.ToString("F2"); ViewboxFloatingBarScaleTransformValueText.Text = val.ToString("F2");
// 调用 MainWindow 中的方法(会自动检查主题更新)
MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarScaleTransformValueSlider", val); MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarScaleTransformValueSlider", val);
} }
} }
@@ -301,6 +368,7 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
double val = ViewboxFloatingBarOpacityValueSlider.Value; double val = ViewboxFloatingBarOpacityValueSlider.Value;
ViewboxFloatingBarOpacityValueText.Text = val.ToString("F2"); ViewboxFloatingBarOpacityValueText.Text = val.ToString("F2");
// 调用 MainWindow 中的方法(会自动检查主题更新)
MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityValueSlider", val); MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityValueSlider", val);
} }
} }
@@ -312,10 +380,14 @@ namespace Ink_Canvas.Windows.SettingsViews
{ {
double val = ViewboxFloatingBarOpacityInPPTValueSlider.Value; double val = ViewboxFloatingBarOpacityInPPTValueSlider.Value;
ViewboxFloatingBarOpacityInPPTValueText.Text = val.ToString("F2"); ViewboxFloatingBarOpacityInPPTValueText.Text = val.ToString("F2");
// 调用 MainWindow 中的方法(会自动检查主题更新)
MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityInPPTValueSlider", val); MainWindowSettingsHelper.InvokeSliderValueChanged("ViewboxFloatingBarOpacityInPPTValueSlider", val);
} }
} }
/// <summary>
/// CheckBox变化事件处理
/// </summary>
private void CheckBox_CheckedChanged(object sender, RoutedEventArgs e) private void CheckBox_CheckedChanged(object sender, RoutedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -330,47 +402,60 @@ namespace Ink_Canvas.Windows.SettingsViews
switch (name) switch (name)
{ {
case "CheckBoxUseLegacyFloatingBarUI": case "CheckBoxUseLegacyFloatingBarUI":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxUseLegacyFloatingBarUI", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxUseLegacyFloatingBarUI", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowShapeButton": case "CheckBoxShowShapeButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowShapeButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowShapeButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowUndoButton": case "CheckBoxShowUndoButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowUndoButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowUndoButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowRedoButton": case "CheckBoxShowRedoButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowRedoButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowRedoButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowClearButton": case "CheckBoxShowClearButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowClearButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowClearButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowWhiteboardButton": case "CheckBoxShowWhiteboardButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowWhiteboardButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowWhiteboardButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowHideButton": case "CheckBoxShowHideButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowHideButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowHideButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowQuickColorPalette": case "CheckBoxShowQuickColorPalette":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowQuickColorPalette", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowQuickColorPalette", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowLassoSelectButton": case "CheckBoxShowLassoSelectButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowLassoSelectButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowLassoSelectButton", checkBox.IsChecked ?? false);
break; break;
case "CheckBoxShowClearAndMouseButton": case "CheckBoxShowClearAndMouseButton":
// 调用 MainWindow 中的方法
MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowClearAndMouseButton", checkBox.IsChecked ?? false); MainWindowSettingsHelper.InvokeCheckBoxCheckedChanged("CheckBoxShowClearAndMouseButton", checkBox.IsChecked ?? false);
break; break;
} }
} }
/// <summary>
/// 设置选项按钮状态
/// </summary>
private void SetOptionButtonState(string group, int selectedIndex) private void SetOptionButtonState(string group, int selectedIndex)
{ {
var buttons = new Dictionary<string, string[]> var buttons = new Dictionary<string, string[]>
@@ -391,11 +476,31 @@ namespace Ink_Canvas.Windows.SettingsViews
var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border; var button = this.FindDescendantByName($"{group}{buttonNames[i]}Border") as Border;
if (button != null) if (button != null)
{ {
ThemeHelper.SetOptionButtonSelectedState(button, i == selectedIndex); if (i == selectedIndex)
{
button.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var textBlock = button.Child as TextBlock;
if (textBlock != null)
{
textBlock.FontWeight = FontWeights.Bold;
}
}
else
{
button.Background = new SolidColorBrush(Colors.Transparent);
var textBlock = button.Child as TextBlock;
if (textBlock != null)
{
textBlock.FontWeight = FontWeights.Normal;
}
}
} }
} }
} }
/// <summary>
/// 选项按钮点击事件处理
/// </summary>
private void OptionButton_Click(object sender, RoutedEventArgs e) private void OptionButton_Click(object sender, RoutedEventArgs e)
{ {
if (!_isLoaded) return; if (!_isLoaded) return;
@@ -412,6 +517,7 @@ namespace Ink_Canvas.Windows.SettingsViews
string group = parts[0]; string group = parts[0];
string value = parts[1]; string value = parts[1];
// 清除同组其他按钮的选中状态
var parent = border.Parent as Panel; var parent = border.Parent as Panel;
if (parent != null) if (parent != null)
{ {
@@ -422,13 +528,24 @@ namespace Ink_Canvas.Windows.SettingsViews
string childTag = childBorder.Tag?.ToString(); string childTag = childBorder.Tag?.ToString();
if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_")) if (!string.IsNullOrEmpty(childTag) && childTag.StartsWith(group + "_"))
{ {
ThemeHelper.SetOptionButtonSelectedState(childBorder, false); childBorder.Background = new SolidColorBrush(Colors.Transparent);
var textBlock = childBorder.Child as TextBlock;
if (textBlock != null)
{
textBlock.FontWeight = FontWeights.Normal;
}
} }
} }
} }
} }
ThemeHelper.SetOptionButtonSelectedState(border, true); // 设置当前按钮为选中状态
border.Background = new SolidColorBrush(Color.FromRgb(225, 225, 225));
var currentTextBlock = border.Child as TextBlock;
if (currentTextBlock != null)
{
currentTextBlock.FontWeight = FontWeights.Bold;
}
var appearance = MainWindow.Settings.Appearance; var appearance = MainWindow.Settings.Appearance;
if (appearance == null) return; if (appearance == null) return;
@@ -436,6 +553,7 @@ namespace Ink_Canvas.Windows.SettingsViews
switch (group) switch (group)
{ {
case "Theme": case "Theme":
// 通过 MainWindowSettingsHelper 调用 ComboBoxTheme 的 SelectionChanged 事件处理器
try try
{ {
var mainWindow = Application.Current.MainWindow as MainWindow; var mainWindow = Application.Current.MainWindow as MainWindow;
@@ -444,22 +562,23 @@ namespace Ink_Canvas.Windows.SettingsViews
var comboBox = mainWindow.FindName("ComboBoxTheme") as System.Windows.Controls.ComboBox; var comboBox = mainWindow.FindName("ComboBoxTheme") as System.Windows.Controls.ComboBox;
if (comboBox != null) if (comboBox != null)
{ {
int themeIndex; // 根据 value 找到对应的 ComboBoxItem
switch (value) int themeIndex;
{ switch (value)
case "Light": {
themeIndex = 0; case "Light":
break; themeIndex = 0;
case "Dark": break;
themeIndex = 1; case "Dark":
break; themeIndex = 1;
case "System": break;
themeIndex = 2; case "System":
break; themeIndex = 2;
default: break;
themeIndex = 2; default:
break; themeIndex = 2;
} break;
}
if (comboBox.Items.Count > themeIndex) if (comboBox.Items.Count > themeIndex)
{ {
@@ -467,18 +586,21 @@ namespace Ink_Canvas.Windows.SettingsViews
MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxTheme", selectedItem); MainWindowSettingsHelper.InvokeComboBoxSelectionChangedWithThemeCheck("ComboBoxTheme", selectedItem);
} }
else else
{ {
// 如果找不到控件,直接更新设置并通知主题更新
MainWindowSettingsHelper.UpdateSettingSafely(() => MainWindowSettingsHelper.UpdateSettingSafely(() =>
{ {
appearance.Theme = themeIndex; appearance.Theme = themeIndex;
}, "ComboBoxTheme_SelectionChanged", "ComboBoxTheme"); }, "ComboBoxTheme_SelectionChanged", "ComboBoxTheme");
MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxTheme"); MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxTheme");
// 触发主题变化事件,通知设置窗口更新主题
ThemeChanged?.Invoke(this, new RoutedEventArgs()); ThemeChanged?.Invoke(this, new RoutedEventArgs());
} }
} }
else else
{ {
// 如果找不到控件,直接更新设置并通知主题更新
int themeIndex; int themeIndex;
switch (value) switch (value)
{ {
@@ -500,14 +622,15 @@ namespace Ink_Canvas.Windows.SettingsViews
appearance.Theme = themeIndex; appearance.Theme = themeIndex;
}, "ComboBoxTheme_SelectionChanged", "ComboBoxTheme"); }, "ComboBoxTheme_SelectionChanged", "ComboBoxTheme");
MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxTheme"); MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxTheme");
ThemeChanged?.Invoke(this, new RoutedEventArgs()); // 触发主题变化事件,通知设置窗口更新主题
ThemeChanged?.Invoke(this, new RoutedEventArgs());
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"切换主题时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"切换主题时出错: {ex.Message}");
} }
break; break;
@@ -531,6 +654,7 @@ namespace Ink_Canvas.Windows.SettingsViews
sourceIndex = 3; sourceIndex = 3;
break; break;
} }
// 调用 MainWindow 中的方法
var mainWindow6 = Application.Current.MainWindow as MainWindow; var mainWindow6 = Application.Current.MainWindow as MainWindow;
if (mainWindow6 != null) if (mainWindow6 != null)
{ {
@@ -542,9 +666,10 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
else else
{ {
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() => MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
appearance.ChickenSoupSource = sourceIndex; appearance.ChickenSoupSource = sourceIndex;
}, "ComboBoxChickenSoupSource"); }, "ComboBoxChickenSoupSource");
} }
} }
@@ -564,6 +689,7 @@ namespace Ink_Canvas.Windows.SettingsViews
imgType = 0; imgType = 0;
break; break;
} }
// 调用 MainWindow 中的方法(带主题检查)
var mainWindow3 = Application.Current.MainWindow as MainWindow; var mainWindow3 = Application.Current.MainWindow as MainWindow;
if (mainWindow3 != null) if (mainWindow3 != null)
{ {
@@ -575,9 +701,10 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
else else
{ {
// 如果找不到控件,直接更新设置并通知主题更新
MainWindowSettingsHelper.UpdateSettingSafely(() => MainWindowSettingsHelper.UpdateSettingSafely(() =>
{ {
appearance.UnFoldButtonImageType = imgType; appearance.UnFoldButtonImageType = imgType;
}, "ComboBoxUnFoldBtnImg_SelectionChanged", "ComboBoxUnFoldBtnImg"); }, "ComboBoxUnFoldBtnImg_SelectionChanged", "ComboBoxUnFoldBtnImg");
MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxUnFoldBtnImg"); MainWindowSettingsHelper.NotifyThemeUpdateIfNeeded("ComboBoxUnFoldBtnImg");
} }
@@ -598,6 +725,7 @@ namespace Ink_Canvas.Windows.SettingsViews
displayMode = 1; displayMode = 1;
break; break;
} }
// 调用 MainWindow 中的方法
var mainWindow4 = Application.Current.MainWindow as MainWindow; var mainWindow4 = Application.Current.MainWindow as MainWindow;
if (mainWindow4 != null) if (mainWindow4 != null)
{ {
@@ -609,9 +737,10 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
else else
{ {
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() => MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
appearance.QuickColorPaletteDisplayMode = displayMode; appearance.QuickColorPaletteDisplayMode = displayMode;
}, "ComboBoxQuickColorPaletteDisplayMode"); }, "ComboBoxQuickColorPaletteDisplayMode");
} }
} }
@@ -637,6 +766,7 @@ namespace Ink_Canvas.Windows.SettingsViews
eraserOption = 0; eraserOption = 0;
break; break;
} }
// 调用 MainWindow 中的方法
var mainWindow5 = Application.Current.MainWindow as MainWindow; var mainWindow5 = Application.Current.MainWindow as MainWindow;
if (mainWindow5 != null) if (mainWindow5 != null)
{ {
@@ -648,9 +778,10 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
else else
{ {
// 如果找不到控件,直接更新设置
MainWindowSettingsHelper.UpdateSettingDirectly(() => MainWindowSettingsHelper.UpdateSettingDirectly(() =>
{ {
appearance.EraserDisplayOption = eraserOption; appearance.EraserDisplayOption = eraserOption;
}, "ComboBoxEraserDisplayOption"); }, "ComboBoxEraserDisplayOption");
} }
} }
@@ -658,46 +789,18 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
} }
/// <summary>
/// 应用主题
/// </summary>
public void ApplyTheme() public void ApplyTheme()
{ {
try try
{ {
ThemeHelper.ApplyThemeToControl(this); ThemeHelper.ApplyThemeToControl(this);
if (MainWindow.Settings?.Appearance != null)
{
var appearance = MainWindow.Settings.Appearance;
SetOptionButtonState("Theme", appearance.Theme);
SetOptionButtonState("ChickenSoupSource", appearance.ChickenSoupSource);
SetOptionButtonState("UnFoldBtnImg", appearance.UnFoldButtonImageType);
SetOptionButtonState("QuickColorPaletteDisplayMode", appearance.QuickColorPaletteDisplayMode);
SetOptionButtonState("EraserDisplayOption", appearance.EraserDisplayOption);
}
UpdateComboBoxDropdownTheme(ComboBoxSplashScreenStyle);
UpdateComboBoxDropdownTheme(ComboBoxFloatingBarImg);
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"ThemePanel 应用主题时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"ThemePanel 应用主题时出错: {ex.Message}");
}
}
private void UpdateComboBoxDropdownTheme(System.Windows.Controls.ComboBox comboBox)
{
if (comboBox == null) return;
comboBox.DropDownOpened -= ComboBox_DropDownOpened;
comboBox.DropDownOpened += ComboBox_DropDownOpened;
}
private void ComboBox_DropDownOpened(object sender, EventArgs e)
{
if (sender is System.Windows.Controls.ComboBox comboBox)
{
Dispatcher.BeginInvoke(new Action(() =>
{
ThemeHelper.UpdateComboBoxDropdownColors(comboBox);
}), System.Windows.Threading.DispatcherPriority.Loaded);
} }
} }
} }
@@ -92,7 +92,7 @@ namespace Ink_Canvas.Windows.SettingsViews
} }
catch (Exception ex) catch (Exception ex)
{ {
System.Diagnostics.Debug.WriteLine($"TimerPanel 应用主题时出? {ex.Message}"); System.Diagnostics.Debug.WriteLine($"TimerPanel 应用主题时出错: {ex.Message}");
} }
} }
private void TimerVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) private void TimerVolumeSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)