feat(设置): 新增个性化设置页面并重构主题相关功能
重构主题和语言设置功能,将相关代码从主窗口迁移至新增的个性化设置页面 优化浮动工具栏图标选择逻辑,移除冗余代码 统一设置页面中开关控件的样式和行为 修复设置页面导航项的选择状态问题
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using H.NotifyIcon;
|
||||
using H.NotifyIcon;
|
||||
using Ink_Canvas.Helpers;
|
||||
using Ink_Canvas.Windows.SettingsViews.Helpers;
|
||||
using Newtonsoft.Json;
|
||||
@@ -186,232 +186,9 @@ namespace Ink_Canvas
|
||||
|
||||
#region Appearance
|
||||
|
||||
/// <summary>
|
||||
/// 处理显示笔尖模式切换开关状态更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当显示笔尖模式切换开关状态更改时:
|
||||
/// 1. 保存显示笔尖模式切换设置
|
||||
/// 2. 根据设置显示或隐藏笔尖模式切换面板
|
||||
/// </remarks>
|
||||
private void ToggleSwitchEnableDisPlayNibModeToggle_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsEnableDisPlayNibModeToggler = ToggleSwitchEnableDisPlayNibModeToggle.IsOn;
|
||||
SaveSettingsToFile();
|
||||
if (!ToggleSwitchEnableDisPlayNibModeToggle.IsOn)
|
||||
{
|
||||
NibModeSimpleStackPanel.Visibility = Visibility.Collapsed;
|
||||
BoardNibModeSimpleStackPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
else
|
||||
{
|
||||
NibModeSimpleStackPanel.Visibility = Visibility.Visible;
|
||||
BoardNibModeSimpleStackPanel.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
//private void ToggleSwitchIsColorfulViewboxFloatingBar_Toggled(object sender, RoutedEventArgs e) {
|
||||
// if (!isLoaded) return;
|
||||
// Settings.Appearance.IsColorfulViewboxFloatingBar = ToggleSwitchColorfulViewboxFloatingBar.IsOn;
|
||||
// SaveSettingsToFile();
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 处理快速面板开关状态更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当快速面板开关状态更改时,保存设置到文件
|
||||
/// </remarks>
|
||||
private void ToggleSwitchEnableQuickPanel_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowQuickPanel = ToggleSwitchEnableQuickPanel.IsOn;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理启动屏幕开关状态更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当启动屏幕开关状态更改时,保存设置到文件
|
||||
/// </remarks>
|
||||
private void ToggleSwitchEnableSplashScreen_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.EnableSplashScreen = ToggleSwitchEnableSplashScreen.IsOn;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理启动屏幕样式选择更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当选择启动屏幕样式时,保存设置到文件
|
||||
/// </remarks>
|
||||
private void ComboBoxSplashScreenStyle_SelectionChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.SplashScreenStyle = ComboBoxSplashScreenStyle.SelectedIndex;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理浮动栏缩放值滑块值更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当浮动栏缩放值滑块值更改时:
|
||||
/// 1. 保存浮动栏缩放设置
|
||||
/// 2. 应用缩放值到浮动栏(限制在0.5-1.25范围内)
|
||||
/// 3. 等待UI更新后重新计算浮动栏位置,确保居中计算准确
|
||||
/// 4. 只在屏幕模式下重新计算浮动栏位置
|
||||
/// </remarks>
|
||||
private void ViewboxFloatingBarScaleTransformValueSlider_ValueChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.ViewboxFloatingBarScaleTransformValue =
|
||||
ViewboxFloatingBarScaleTransformValueSlider.Value;
|
||||
SaveSettingsToFile();
|
||||
var val = ViewboxFloatingBarScaleTransformValueSlider.Value;
|
||||
ViewboxFloatingBarScaleTransform.ScaleX =
|
||||
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
|
||||
ViewboxFloatingBarScaleTransform.ScaleY =
|
||||
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
|
||||
|
||||
// 等待UI更新后再重新计算浮动栏位置,确保居中计算准确
|
||||
Dispatcher.BeginInvoke(new Action(async () =>
|
||||
{
|
||||
// 强制更新布局以确保ActualWidth正确
|
||||
ViewboxFloatingBar.UpdateLayout();
|
||||
|
||||
// 等待一小段时间让布局完全更新
|
||||
await Task.Delay(100);
|
||||
|
||||
// 再次强制更新布局
|
||||
ViewboxFloatingBar.UpdateLayout();
|
||||
|
||||
// 强制重新测量和排列
|
||||
ViewboxFloatingBar.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
ViewboxFloatingBar.Arrange(new Rect(ViewboxFloatingBar.DesiredSize));
|
||||
|
||||
// auto align - 新增:只在屏幕模式下重新计算浮动栏位置
|
||||
if (currentMode == 0)
|
||||
{
|
||||
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
|
||||
ViewboxFloatingBarMarginAnimation(60);
|
||||
else
|
||||
ViewboxFloatingBarMarginAnimation(100, true);
|
||||
}
|
||||
}), DispatcherPriority.Render);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理浮动栏透明度值滑块值更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当浮动栏透明度值滑块值更改时:
|
||||
/// 1. 保存浮动栏透明度设置
|
||||
/// 2. 应用透明度值到浮动栏
|
||||
/// </remarks>
|
||||
private void ViewboxFloatingBarOpacityValueSlider_ValueChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.ViewboxFloatingBarOpacityValue = ViewboxFloatingBarOpacityValueSlider.Value;
|
||||
SaveSettingsToFile();
|
||||
ViewboxFloatingBar.Opacity = Settings.Appearance.ViewboxFloatingBarOpacityValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理PPT中浮动栏透明度值滑块值更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当PPT中浮动栏透明度值滑块值更改时,保存设置到文件
|
||||
/// </remarks>
|
||||
private void ViewboxFloatingBarOpacityInPPTValueSlider_ValueChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.ViewboxFloatingBarOpacityInPPTValue = ViewboxFloatingBarOpacityInPPTValueSlider.Value;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理托盘图标开关状态更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当托盘图标开关状态更改时:
|
||||
/// 1. 保存托盘图标设置
|
||||
/// 2. 根据设置显示或隐藏托盘图标示例图像
|
||||
/// 3. 根据设置显示或隐藏系统托盘图标
|
||||
/// </remarks>
|
||||
private void ToggleSwitchEnableTrayIcon_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.EnableTrayIcon = ToggleSwitchEnableTrayIcon.IsOn;
|
||||
ICCTrayIconExampleImage.Visibility = Settings.Appearance.EnableTrayIcon ? Visibility.Visible : Visibility.Collapsed;
|
||||
var _taskbar = (TaskbarIcon)Application.Current.Resources["TaskbarTrayIcon"];
|
||||
_taskbar.Visibility = ToggleSwitchEnableTrayIcon.IsOn ? Visibility.Visible : Visibility.Collapsed;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理展开按钮图像选择更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当选择展开按钮图像类型时:
|
||||
/// 1. 保存展开按钮图像类型设置
|
||||
/// 2. 根据选择的图像类型更新左右展开按钮的图标
|
||||
/// 3. 为不同的图像类型设置不同的大小和旋转角度
|
||||
/// </remarks>
|
||||
private void ComboBoxUnFoldBtnImg_SelectionChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.UnFoldButtonImageType = ComboBoxUnFoldBtnImg.SelectedIndex;
|
||||
SaveSettingsToFile();
|
||||
if (ComboBoxUnFoldBtnImg.SelectedIndex == 0)
|
||||
{
|
||||
RightUnFoldBtnImgChevron.Source =
|
||||
new BitmapImage(new Uri("pack://application:,,,/Resources/new-icons/unfold-chevron.png"));
|
||||
RightUnFoldBtnImgChevron.Width = 14;
|
||||
RightUnFoldBtnImgChevron.Height = 14;
|
||||
RightUnFoldBtnImgChevron.RenderTransform = new RotateTransform(180);
|
||||
LeftUnFoldBtnImgChevron.Source =
|
||||
new BitmapImage(new Uri("pack://application:,,,/Resources/new-icons/unfold-chevron.png"));
|
||||
LeftUnFoldBtnImgChevron.Width = 14;
|
||||
LeftUnFoldBtnImgChevron.Height = 14;
|
||||
LeftUnFoldBtnImgChevron.RenderTransform = null;
|
||||
}
|
||||
else if (ComboBoxUnFoldBtnImg.SelectedIndex == 1)
|
||||
{
|
||||
RightUnFoldBtnImgChevron.Source =
|
||||
new BitmapImage(new Uri("pack://application:,,,/Resources/new-icons/pen-white.png"));
|
||||
RightUnFoldBtnImgChevron.Width = 18;
|
||||
RightUnFoldBtnImgChevron.Height = 18;
|
||||
RightUnFoldBtnImgChevron.RenderTransform = null;
|
||||
LeftUnFoldBtnImgChevron.Source =
|
||||
new BitmapImage(new Uri("pack://application:,,,/Resources/new-icons/pen-white.png"));
|
||||
LeftUnFoldBtnImgChevron.Width = 18;
|
||||
LeftUnFoldBtnImgChevron.Height = 18;
|
||||
LeftUnFoldBtnImgChevron.RenderTransform = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly Lazy<object> HitokotoHttpClient = new Lazy<object>(CreateHitokotoClient, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);
|
||||
|
||||
@@ -462,7 +239,7 @@ namespace Ink_Canvas
|
||||
/// 当配置为内置来源时(0:OSUPlayer、1:名言警句、2:高考俗语)从对应数组中随机选择一条并设置为水印文本;
|
||||
/// 当配置为一言(3)时会异步请求 Hitokoto API 并在请求中显示占位提示,成功时将返回文本设为水印,失败时记录警告日志并设置可读的失败提示文本。此方法会修改 BlackBoardWaterMark.Text,并在发生异常时记录日志且设置合适的回退文本。
|
||||
/// </remarks>
|
||||
private async Task UpdateChickenSoupTextAsync()
|
||||
internal async Task UpdateChickenSoupTextAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -550,221 +327,8 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理名言来源选择更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当选择名言来源时:
|
||||
/// 1. 保存名言来源设置
|
||||
/// 2. 异步更新白板水印的名言文本
|
||||
/// </remarks>
|
||||
private async void ComboBoxChickenSoupSource_SelectionChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_suppressChickenSoupSourceSelectionChanged) return;
|
||||
if (!isLoaded) return;
|
||||
int idx = ComboBoxChickenSoupSource.SelectedIndex;
|
||||
if (idx < 0) return;
|
||||
if (Settings.Appearance.ChickenSoupSource == idx) return;
|
||||
|
||||
Settings.Appearance.ChickenSoupSource = idx;
|
||||
|
||||
if (BtnHitokotoCustomize != null)
|
||||
{
|
||||
BtnHitokotoCustomize.Visibility = ComboBoxChickenSoupSource.SelectedIndex == 3
|
||||
? Visibility.Visible
|
||||
: Visibility.Collapsed;
|
||||
}
|
||||
|
||||
SaveSettingsToFile();
|
||||
await UpdateChickenSoupTextAsync();
|
||||
}
|
||||
|
||||
private async void BtnHitokotoCustomize_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var categories = new Dictionary<string, string>
|
||||
{
|
||||
{ "a", "动画" },
|
||||
{ "b", "漫画" },
|
||||
{ "c", "游戏" },
|
||||
{ "d", "文学" },
|
||||
{ "e", "原创" },
|
||||
{ "f", "来自网络" },
|
||||
{ "g", "其他" },
|
||||
{ "h", "影视" },
|
||||
{ "i", "诗词" },
|
||||
{ "j", "网易云" },
|
||||
{ "k", "哲学" },
|
||||
{ "l", "抖机灵" }
|
||||
};
|
||||
|
||||
// 创建弹窗内容
|
||||
var contentPanel = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(20),
|
||||
Orientation = System.Windows.Controls.Orientation.Vertical
|
||||
};
|
||||
|
||||
// 全选复选框
|
||||
var selectAllCheckBox = new CheckBox
|
||||
{
|
||||
Content = "全选",
|
||||
FontSize = 14,
|
||||
FontFamily = new FontFamily("Microsoft YaHei UI"),
|
||||
Margin = new Thickness(0, 0, 0, 8)
|
||||
};
|
||||
|
||||
// 存储各个分类的复选框
|
||||
var categoryCheckBoxes = new Dictionary<string, CheckBox>();
|
||||
|
||||
var savedHitokoto = Settings.Appearance.HitokotoCategories;
|
||||
bool implicitAllCategories = savedHitokoto == null || savedHitokoto.Count == 0;
|
||||
|
||||
// 创建分类复选框
|
||||
foreach (var category in categories)
|
||||
{
|
||||
var checkBox = new CheckBox
|
||||
{
|
||||
Content = category.Value,
|
||||
Tag = category.Key,
|
||||
FontSize = 13,
|
||||
FontFamily = new FontFamily("Microsoft YaHei UI"),
|
||||
IsChecked = implicitAllCategories || savedHitokoto.Contains(category.Key),
|
||||
Margin = new Thickness(0, 0, 0, 8)
|
||||
};
|
||||
categoryCheckBoxes[category.Key] = checkBox;
|
||||
contentPanel.Children.Add(checkBox);
|
||||
}
|
||||
|
||||
// 全选复选框逻辑
|
||||
bool isUpdatingSelectAll = false;
|
||||
selectAllCheckBox.IsChecked = implicitAllCategories || savedHitokoto.Count == categories.Count;
|
||||
|
||||
selectAllCheckBox.Checked += (s, args) =>
|
||||
{
|
||||
if (isUpdatingSelectAll) return;
|
||||
isUpdatingSelectAll = true;
|
||||
foreach (var checkBox in categoryCheckBoxes.Values)
|
||||
{
|
||||
checkBox.IsChecked = true;
|
||||
}
|
||||
isUpdatingSelectAll = false;
|
||||
};
|
||||
|
||||
selectAllCheckBox.Unchecked += (s, args) =>
|
||||
{
|
||||
if (isUpdatingSelectAll) return;
|
||||
isUpdatingSelectAll = true;
|
||||
foreach (var checkBox in categoryCheckBoxes.Values)
|
||||
{
|
||||
checkBox.IsChecked = false;
|
||||
}
|
||||
isUpdatingSelectAll = false;
|
||||
};
|
||||
|
||||
// 监听各个复选框的变化,更新全选状态
|
||||
foreach (var checkBox in categoryCheckBoxes.Values)
|
||||
{
|
||||
checkBox.Checked += (s, args) =>
|
||||
{
|
||||
if (isUpdatingSelectAll) return;
|
||||
isUpdatingSelectAll = true;
|
||||
// 检查所有分类复选框是否都被勾选
|
||||
bool allChecked = categoryCheckBoxes.Values.All(cb => cb.IsChecked == true);
|
||||
selectAllCheckBox.IsChecked = allChecked;
|
||||
isUpdatingSelectAll = false;
|
||||
};
|
||||
checkBox.Unchecked += (s, args) =>
|
||||
{
|
||||
if (isUpdatingSelectAll) return;
|
||||
isUpdatingSelectAll = true;
|
||||
selectAllCheckBox.IsChecked = false;
|
||||
isUpdatingSelectAll = false;
|
||||
};
|
||||
}
|
||||
|
||||
// 将全选复选框添加到顶部
|
||||
var mainPanel = new StackPanel
|
||||
{
|
||||
Margin = new Thickness(0),
|
||||
Orientation = System.Windows.Controls.Orientation.Vertical
|
||||
};
|
||||
mainPanel.Children.Add(selectAllCheckBox);
|
||||
mainPanel.Children.Add(new Separator { Margin = new Thickness(0, 8, 0, 8) });
|
||||
mainPanel.Children.Add(contentPanel);
|
||||
|
||||
var scrollViewer = new ScrollViewer
|
||||
{
|
||||
Content = mainPanel,
|
||||
MaxHeight = 400,
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Auto
|
||||
};
|
||||
|
||||
// 创建ContentDialog显示自定义内容
|
||||
var contentDialog = new iNKORE.UI.WPF.Modern.Controls.ContentDialog
|
||||
{
|
||||
Title = "自定义一言分类",
|
||||
Content = scrollViewer,
|
||||
PrimaryButtonText = "确定",
|
||||
SecondaryButtonText = "取消",
|
||||
DefaultButton = iNKORE.UI.WPF.Modern.Controls.ContentDialogButton.Primary,
|
||||
Owner = this
|
||||
};
|
||||
|
||||
var dialogResult = await contentDialog.ShowAsync();
|
||||
|
||||
if (dialogResult == iNKORE.UI.WPF.Modern.Controls.ContentDialogResult.Primary)
|
||||
{
|
||||
// 保存选中的分类
|
||||
Settings.Appearance.HitokotoCategories = categoryCheckBoxes
|
||||
.Where(kvp => kvp.Value.IsChecked == true)
|
||||
.Select(kvp => kvp.Key)
|
||||
.ToList();
|
||||
|
||||
// 如果没有任何选中,默认全选
|
||||
if (Settings.Appearance.HitokotoCategories.Count == 0)
|
||||
{
|
||||
Settings.Appearance.HitokotoCategories = categories.Keys.ToList();
|
||||
}
|
||||
|
||||
SaveSettingsToFile();
|
||||
|
||||
// 如果当前正在使用API,更新名言
|
||||
if (Settings.Appearance.ChickenSoupSource == 3 && Settings.Appearance.EnableChickenSoupInWhiteboardMode)
|
||||
{
|
||||
_ = UpdateChickenSoupTextAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ToggleSwitchEnableViewboxBlackBoardScaleTransform_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.EnableViewboxBlackBoardScaleTransform =
|
||||
ToggleSwitchEnableViewboxBlackBoardScaleTransform.IsOn;
|
||||
SaveSettingsToFile();
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理浮动栏图标选择更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当选择浮动栏图标时:
|
||||
/// 1. 保存浮动栏图标设置
|
||||
/// 2. 更新浮动栏图标
|
||||
/// 3. 保存设置到文件
|
||||
/// </remarks>
|
||||
public void ComboBoxFloatingBarImg_SelectionChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.FloatingBarImg = ComboBoxFloatingBarImg.SelectedIndex;
|
||||
UpdateFloatingBarIcon();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据设置更新浮动栏图标
|
||||
@@ -903,125 +467,9 @@ namespace Ink_Canvas
|
||||
/// </remarks>
|
||||
public void UpdateCustomIconsInComboBox()
|
||||
{
|
||||
// 保留前12个内置图标选项
|
||||
while (ComboBoxFloatingBarImg.Items.Count > 12)
|
||||
{
|
||||
ComboBoxFloatingBarImg.Items.RemoveAt(ComboBoxFloatingBarImg.Items.Count - 1);
|
||||
}
|
||||
|
||||
// 添加自定义图标选项
|
||||
foreach (var customIcon in Settings.Appearance.CustomFloatingBarImgs)
|
||||
{
|
||||
ComboBoxItem item = new ComboBoxItem();
|
||||
item.Content = customIcon.Name;
|
||||
item.FontFamily = new FontFamily("Microsoft YaHei UI");
|
||||
ComboBoxFloatingBarImg.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理添加自定义图标按钮点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当点击添加自定义图标按钮时:
|
||||
/// 1. 显示添加自定义图标窗口
|
||||
/// 2. 如果添加成功,自动选中新添加的图标
|
||||
/// </remarks>
|
||||
private void ButtonAddCustomIcon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AddCustomIconWindow dialog = new AddCustomIconWindow(this);
|
||||
dialog.Owner = this;
|
||||
dialog.ShowDialog();
|
||||
|
||||
if (dialog.IsSuccess)
|
||||
{
|
||||
// 自动选中新添加的图标
|
||||
ComboBoxFloatingBarImg.SelectedIndex = ComboBoxFloatingBarImg.Items.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理管理自定义图标按钮点击事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当点击管理自定义图标按钮时,显示自定义图标管理窗口
|
||||
/// </remarks>
|
||||
private void ButtonManageCustomIcons_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CustomIconWindow dialog = new CustomIconWindow(this);
|
||||
dialog.Owner = this;
|
||||
dialog.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理白板模式下时间显示开关状态更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当白板模式下时间显示开关状态更改时:
|
||||
/// 1. 保存时间显示设置
|
||||
/// 2. 如果当前是白板模式,根据设置显示或隐藏时间和日期水印
|
||||
/// 3. 保存设置到文件
|
||||
/// 4. 重新加载设置以应用更改
|
||||
/// </remarks>
|
||||
private void ToggleSwitchEnableTimeDisplayInWhiteboardMode_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.EnableTimeDisplayInWhiteboardMode = ToggleSwitchEnableTimeDisplayInWhiteboardMode.IsOn;
|
||||
if (currentMode == 1)
|
||||
{
|
||||
if (ToggleSwitchEnableTimeDisplayInWhiteboardMode.IsOn)
|
||||
{
|
||||
WaterMarkTime.Visibility = Visibility.Visible;
|
||||
WaterMarkDate.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
WaterMarkTime.Visibility = Visibility.Collapsed;
|
||||
WaterMarkDate.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
SaveSettingsToFile();
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理白板模式下名言显示开关状态更改事件
|
||||
/// </summary>
|
||||
/// <param name="sender">事件发送者</param>
|
||||
/// <param name="e">路由事件参数</param>
|
||||
/// <remarks>
|
||||
/// 当白板模式下名言显示开关状态更改时:
|
||||
/// 1. 保存名言显示设置
|
||||
/// 2. 如果当前是白板模式,根据时间显示设置显示或隐藏名言水印
|
||||
/// 3. 保存设置到文件
|
||||
/// 4. 重新加载设置以应用更改
|
||||
/// </remarks>
|
||||
private void ToggleSwitchEnableChickenSoupInWhiteboardMode_Toggled(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.EnableChickenSoupInWhiteboardMode = ToggleSwitchEnableChickenSoupInWhiteboardMode.IsOn;
|
||||
if (currentMode == 1)
|
||||
{
|
||||
if (ToggleSwitchEnableTimeDisplayInWhiteboardMode.IsOn)
|
||||
{
|
||||
BlackBoardWaterMark.Visibility = Visibility.Visible;
|
||||
}
|
||||
else
|
||||
{
|
||||
BlackBoardWaterMark.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
SaveSettingsToFile();
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
//[Obsolete]
|
||||
//private void ToggleSwitchShowButtonPPTNavigation_OnToggled(object sender, RoutedEventArgs e) {
|
||||
@@ -3747,183 +3195,8 @@ namespace Ink_Canvas
|
||||
|
||||
#region 浮动栏按钮显示控制
|
||||
|
||||
private void CheckBoxUseLegacyFloatingBarUI_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.UseLegacyFloatingBarUI = CheckBoxUseLegacyFloatingBarUI.IsChecked ?? false;
|
||||
UpdateFloatingBarIcons();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxUseLegacyFloatingBarUI_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.UseLegacyFloatingBarUI = CheckBoxUseLegacyFloatingBarUI.IsChecked ?? false;
|
||||
UpdateFloatingBarIcons();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowShapeButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowShapeButton = CheckBoxShowShapeButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowShapeButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowShapeButton = CheckBoxShowShapeButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowUndoButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowUndoButton = CheckBoxShowUndoButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowUndoButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowUndoButton = CheckBoxShowUndoButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowRedoButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowRedoButton = CheckBoxShowRedoButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowRedoButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowRedoButton = CheckBoxShowRedoButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowClearButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowClearButton = CheckBoxShowClearButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowClearButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowClearButton = CheckBoxShowClearButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowWhiteboardButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowWhiteboardButton = CheckBoxShowWhiteboardButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowWhiteboardButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowWhiteboardButton = CheckBoxShowWhiteboardButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowLassoSelectButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowLassoSelectButton = CheckBoxShowLassoSelectButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowLassoSelectButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowLassoSelectButton = CheckBoxShowLassoSelectButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowClearAndMouseButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowClearAndMouseButton = CheckBoxShowClearAndMouseButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowClearAndMouseButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowClearAndMouseButton = CheckBoxShowClearAndMouseButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowHideButton_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowHideButton = CheckBoxShowHideButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowHideButton_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowHideButton = CheckBoxShowHideButton.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowQuickColorPalette_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowQuickColorPalette = CheckBoxShowQuickColorPalette.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void CheckBoxShowQuickColorPalette_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.IsShowQuickColorPalette = CheckBoxShowQuickColorPalette.IsChecked ?? false;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ComboBoxQuickColorPaletteDisplayMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.QuickColorPaletteDisplayMode = ComboBoxQuickColorPaletteDisplayMode.SelectedIndex;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void ComboBoxEraserDisplayOption_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (!isLoaded) return;
|
||||
Settings.Appearance.EraserDisplayOption = ComboBoxEraserDisplayOption.SelectedIndex;
|
||||
UpdateFloatingBarButtonsVisibility();
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
|
||||
private void UpdateFloatingBarButtonsVisibility()
|
||||
internal void UpdateFloatingBarButtonsVisibility()
|
||||
{
|
||||
// 根据设置更新浮动栏按钮的可见性
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user