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);