From 145cadc6fc74a1803410e9cfd02dae698a83e290 Mon Sep 17 00:00:00 2001 From: XY Wang Date: Thu, 14 Mar 2024 16:18:26 +0800 Subject: [PATCH] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 8939eb1e2828058acc49f3f09339c3d02d6ecdd1 Author: XY Wang Date: Thu Mar 14 16:09:31 2024 +0800 Update MainWindow.xaml.cs commit b8b9e7afcd913b9a4ece8d405c31077f66d95140 Merge: f84a4f2 80c57dc Author: XY Wang Date: Thu Mar 14 16:06:29 2024 +0800 Merge branch 'master' into master commit f84a4f2e442abceef39089f8a2ab16f9e38032ce Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Dec 23 20:51:22 2023 +0800 解决 MainWindow.xaml 冲突 commit f0c44fe092cc90ccc92b18ac0f5c2b3ed915dba4 Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Dec 2 20:14:48 2023 +0800 修复当使用橡皮时隐藏再显示画板导致显示浅色画笔的问题,恢复对关闭确认的修改 commit 7668ad365eda071aa52113bac802b3f36960fd24 Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Nov 25 20:33:47 2023 +0800 将第一个关闭警告修改为普通的 MessageBox,以防止 Windows 关机时出现警告音 commit 525cc8e232b9995936753e0cee3c4e0284f4ccff Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sun Nov 19 12:27:31 2023 +0800 修正 屏幕批注下按两次 Alt+E 变成浅色画笔 的问题 commit 01aad1f2ca1343be6734243d97487597103a467b Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sun Nov 19 11:29:05 2023 +0800 将贡献者中的 STBBRD(我) 改为 ZongziTEK(我) commit 21d8a8426e81a7d641c9641908e6a8bcbcf10b31 Merge: 228b687 c054e85 Author: ZongziTEK <62409850+STBBRD@users.noreply.github.com> Date: Sun Nov 19 11:17:31 2023 +0800 Merge branch 'WXRIW:master' into master commit 228b687c3cd721893163be9b7104bcd0f40269df Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Nov 4 20:09:32 2023 +0800 做了读取画笔颜色配置文件时的错误处理 commit acc3a0c842ee46d69fdff9e686592827bfc7cf14 Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sun Oct 29 09:19:48 2023 +0800 完成深浅色切换、根据配置文件自定义颜色功能 - 修复了加载颜色的所有问题 - 新增对更改颜色请求是否从浮动工具栏发出的判断 commit 02fa77565dd0d3136476887a7de973518eb66f4b Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sun Oct 29 08:44:37 2023 +0800 修复昨天的问题 commit 51c6127f6e0a2c5b74f8b2b0985db59536718a9e Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Oct 28 22:53:04 2023 +0800 初步适配了浮动工具栏UI中 黑板 屏幕批注 的画笔颜色模式切换,但是仍有问题 问题:从黑板直接到屏幕批注时浅色画笔不会变成深色画笔 commit d7d3f020d4f51e5fa01808a5989c99eec3943463 Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Oct 28 22:42:06 2023 +0800 更正一个注释中的错别字 commit 5f06a0701cf3acc5156f8fa2a132b0b078a1c45e Author: STBBRD <62409850+STBBRD@users.noreply.github.com> Date: Sat Oct 28 22:40:54 2023 +0800 新增 加载两种画笔颜色模式的配置文件,并应用于 Old UI 深浅色切换 --- Ink Canvas/MainWindow.xaml.cs | 167 ++++++++++++++++++++++++++++------ 1 file changed, 137 insertions(+), 30 deletions(-) diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index c6622426..666b996f 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -47,7 +47,6 @@ public MainWindow() { InitializeComponent(); - BorderSettings.Visibility = Visibility.Collapsed; StackPanelToolButtons.Visibility = Visibility.Collapsed; BorderDrawShape.Visibility = Visibility.Collapsed; @@ -155,16 +154,15 @@ private void TimerKillProcess_Elapsed(object sender, ElapsedEventArgs e) #region Ink Canvas Functions - Color Ink_DefaultColor = Colors.Red; - DrawingAttributes drawingAttributes; private void loadPenCanvas() { + SetDarkColors(); try { //drawingAttributes = new DrawingAttributes(); drawingAttributes = inkCanvas.DefaultDrawingAttributes; - drawingAttributes.Color = Ink_DefaultColor; + drawingAttributes.Color = ((SolidColorBrush)BtnColorRed.Background).Color; drawingAttributes.Height = 2.5; drawingAttributes.Width = 2.5; @@ -309,7 +307,7 @@ private void KeyChangeToEraser(object sender, ExecutedRoutedEventArgs e) { if (ImageEraserMask.Visibility == Visibility.Visible) { - BtnColorRed_Click(sender, null); + BorderPenColorRed_MouseUp(null, null); } else { @@ -1252,17 +1250,26 @@ private void BtnSwitchTheme_Click(object sender, RoutedEventArgs e) BtnExit.Foreground = Brushes.White; GridBackgroundCover.Background = new SolidColorBrush(StringToColor("#FFF2F2F2")); ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark; + SetDarkColors(); //在浅色背景上使用深色墨迹 if (inkColor == 0) { inkCanvas.DefaultDrawingAttributes.Color = Colors.White; } + else if (inkColor == 1) + { + BtnColorRed_Click(null, null); + } else if (inkColor == 2) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FF1ED760"); + BtnColorGreen_Click(null, null); + } + else if (inkColor == 3) + { + BtnColorBlue_Click(null, null); } else if (inkColor == 4) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FFFFC000"); + BtnColorYellow_Click(null, null); } } else @@ -1275,17 +1282,26 @@ private void BtnSwitchTheme_Click(object sender, RoutedEventArgs e) BtnExit.Foreground = Brushes.Black; GridBackgroundCover.Background = new SolidColorBrush(StringToColor("#FF1A1A1A")); ThemeManager.Current.ApplicationTheme = ApplicationTheme.Light; + SetLightColors(); //在深色背景上使用浅色墨迹 if (inkColor == 0) { - inkCanvas.DefaultDrawingAttributes.Color = Colors.Black; + inkCanvas.DefaultDrawingAttributes.Color = Colors.White; + } + else if (inkColor == 1) + { + BtnColorRed_Click(null, null); } else if (inkColor == 2) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FF169141"); + BtnColorGreen_Click(null, null); + } + else if (inkColor == 3) + { + BtnColorBlue_Click(null, null); } else if (inkColor == 4) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FFF38B00"); + BtnColorYellow_Click(null, null); } } if (!Settings.Appearance.IsTransparentButtonBackground) @@ -1354,7 +1370,7 @@ private void BtnHideInkCanvas_Click(object sender, RoutedEventArgs e) // Auto-clear Strokes - // 很烦, 要重新来, 要等待截图完成再清理笔记 + // 很烦, 要重新来, 要等待截图完成再清理笔迹 if (BtnPPTSlideShowEnd.Visibility != Visibility.Visible) { if (isLoaded && Settings.Automation.IsAutoClearWhenExitingWritingMode) @@ -1562,17 +1578,22 @@ private void BtnColorRed_Click(object sender, RoutedEventArgs e) { inkColor = 1; forceEraser = false; - inkCanvas.DefaultDrawingAttributes.Color = Colors.Red; - if (BtnSwitchTheme.Content.ToString() == "浅色") + if (!isLastSwitchColorByFloatBar) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FFFF3333"); - BtnColorRed.Background = new SolidColorBrush(StringToColor("#FFFF3333")); + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } } else { - inkCanvas.DefaultDrawingAttributes.Color = Colors.Red; - BtnColorRed.Background = Brushes.Red; + isLastSwitchColorByFloatBar = false; } + inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorRed.Background).Color; ColorSwitchCheck(); } @@ -1581,16 +1602,22 @@ private void BtnColorGreen_Click(object sender, RoutedEventArgs e) { inkColor = 2; forceEraser = false; - if (BtnSwitchTheme.Content.ToString() == "浅色") + if (!isLastSwitchColorByFloatBar) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FF1ED760"); - BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF1ED760")); + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } } else { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FF169141"); - BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF169141")); + isLastSwitchColorByFloatBar = false; } + inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorGreen.Background).Color; ColorSwitchCheck(); } @@ -1599,7 +1626,22 @@ private void BtnColorBlue_Click(object sender, RoutedEventArgs e) { inkColor = 3; forceEraser = false; - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FF239AD6"); + if (!isLastSwitchColorByFloatBar) + { + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } + } + else + { + isLastSwitchColorByFloatBar = false; + } + inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorBlue.Background).Color; ColorSwitchCheck(); } @@ -1608,16 +1650,22 @@ private void BtnColorYellow_Click(object sender, RoutedEventArgs e) { inkColor = 4; forceEraser = false; - if (BtnSwitchTheme.Content.ToString() == "浅色") + if (!isLastSwitchColorByFloatBar) { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FFFFC000"); - BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFFFC000")); + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } } else { - inkCanvas.DefaultDrawingAttributes.Color = StringToColor("#FFF38B00"); - BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFF38B00")); + isLastSwitchColorByFloatBar = false; } + inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorYellow.Background).Color; ColorSwitchCheck(); } @@ -2919,8 +2967,8 @@ private void ComboBoxEraserSize_SelectionChanged(object sender, SelectionChanged Settings.Canvas.EraserSize = ComboBoxEraserSize.SelectedIndex; SaveSettingsToFile(); } - - + + private void ComboBoxEraserType_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!isLoaded) return; @@ -5948,6 +5996,52 @@ private void UpdateIndexInfoDisplay() } } + private void SetLightColors() + { + if (File.Exists(App.RootPath + "Colors\\Light.ini")) + { + try + { + string[] lightColors = File.ReadAllLines(App.RootPath + "Colors\\Light.ini"); + BtnColorRed.Background = new SolidColorBrush(StringToColor(lightColors[0])); + BtnColorGreen.Background = new SolidColorBrush(StringToColor(lightColors[1])); + BtnColorBlue.Background = new SolidColorBrush(StringToColor(lightColors[2])); + BtnColorYellow.Background = new SolidColorBrush(StringToColor(lightColors[3])); + } + catch (Exception) { ShowNotification("读取亮色画笔颜色配置文件时遇到问题"); } + } + else + { + BtnColorRed.Background = new SolidColorBrush(StringToColor("#FFFF3333")); + BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF1ED760")); + BtnColorBlue.Background = new SolidColorBrush(StringToColor("#FF239AD6")); + BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFFFC000")); + } + } + + private void SetDarkColors() + { + if (File.Exists(App.RootPath + "Colors\\Dark.ini")) + { + try + { + string[] darkColors = File.ReadAllLines(App.RootPath + "Colors\\Dark.ini"); + BtnColorRed.Background = new SolidColorBrush(StringToColor(darkColors[0])); + BtnColorGreen.Background = new SolidColorBrush(StringToColor(darkColors[1])); + BtnColorBlue.Background = new SolidColorBrush(StringToColor(darkColors[2])); + BtnColorYellow.Background = new SolidColorBrush(StringToColor(darkColors[3])); + } + catch (Exception) { ShowNotification("读取深色画笔颜色配置文件时遇到问题"); } + } + else + { + BtnColorRed.Background = new SolidColorBrush(Colors.Red); + BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF169141")); + BtnColorBlue.Background = new SolidColorBrush(StringToColor("#FF239AD6")); + BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFF38B00")); + } + } + #endregion Whiteboard Controls #region Simulate Pen Pressure & Ink To Shape @@ -6915,6 +7009,8 @@ private void HideSubPanels() BorderTools.Visibility = Visibility.Collapsed; } + bool isLastSwitchColorByFloatBar = false; + private void BorderPenColorBlack_MouseUp(object sender, MouseButtonEventArgs e) { BtnColorBlack_Click(BtnColorBlack, null); @@ -6923,24 +7019,28 @@ private void BorderPenColorBlack_MouseUp(object sender, MouseButtonEventArgs e) private void BorderPenColorRed_MouseUp(object sender, MouseButtonEventArgs e) { + isLastSwitchColorByFloatBar = true; BtnColorRed_Click(BtnColorRed, null); HideSubPanels(); } private void BorderPenColorGreen_MouseUp(object sender, MouseButtonEventArgs e) { + isLastSwitchColorByFloatBar = true; BtnColorGreen_Click(BtnColorGreen, null); HideSubPanels(); } private void BorderPenColorBlue_MouseUp(object sender, MouseButtonEventArgs e) { + isLastSwitchColorByFloatBar = true; BtnColorBlue_Click(BtnColorBlue, null); HideSubPanels(); } private void BorderPenColorYellow_MouseUp(object sender, MouseButtonEventArgs e) { + isLastSwitchColorByFloatBar = true; BtnColorYellow_Click(BtnColorYellow, null); HideSubPanels(); } @@ -6984,6 +7084,8 @@ private async void SymbolIconCursor_Click(object sender, RoutedEventArgs e) } } } + + SetDarkColors(); } private void SymbolIconDelete_MouseUp(object sender, MouseButtonEventArgs e) @@ -7074,6 +7176,9 @@ private void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e) { BorderPenColorWhite_MouseUp(BorderPenColorWhite, null); } + + if (Settings.Canvas.UsingWhiteboard) SetDarkColors(); //在白板上用深色墨迹 + else SetLightColors(); //在黑板上用浅色墨迹 } else { @@ -7100,6 +7205,8 @@ private void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e) })).Start(); } BorderPenColorRed_MouseUp(BorderPenColorRed, null); + + SetDarkColors(); } BtnSwitch_Click(BtnSwitch, null);