diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index 5140e1bd..03341f98 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -46,7 +46,6 @@ public MainWindow() { InitializeComponent(); - BorderSettings.Visibility = Visibility.Collapsed; StackPanelToolButtons.Visibility = Visibility.Collapsed; BorderDrawShape.Visibility = Visibility.Collapsed; @@ -148,22 +147,21 @@ private void TimerKillProcess_Elapsed(object sender, ElapsedEventArgs e) } } catch { } - } + } #endregion Timer #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; @@ -1557,13 +1555,20 @@ private void BtnColorRed_Click(object sender, RoutedEventArgs e) { inkColor = 1; forceEraser = false; - if (BtnSwitchTheme.Content.ToString() == "浅色") + if (!isLastSwitchColorByFloatBar) { - SetDarkColors(); //在浅色背景上使用深色墨迹 + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } } else { - SetLightColors(); //在深色背景上使用浅色墨迹 + isLastSwitchColorByFloatBar = false; } inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorRed.Background).Color; @@ -1574,13 +1579,20 @@ private void BtnColorGreen_Click(object sender, RoutedEventArgs e) { inkColor = 2; forceEraser = false; - if (BtnSwitchTheme.Content.ToString() == "浅色") + if (!isLastSwitchColorByFloatBar) { - SetDarkColors(); //在浅色背景上使用深色墨迹 + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } } else { - SetLightColors(); //在深色背景上使用浅色墨迹 + isLastSwitchColorByFloatBar = false; } inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorGreen.Background).Color; @@ -1591,6 +1603,21 @@ private void BtnColorBlue_Click(object sender, RoutedEventArgs e) { inkColor = 3; forceEraser = false; + if (!isLastSwitchColorByFloatBar) + { + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } + } + else + { + isLastSwitchColorByFloatBar = false; + } inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorBlue.Background).Color; ColorSwitchCheck(); @@ -1600,13 +1627,20 @@ private void BtnColorYellow_Click(object sender, RoutedEventArgs e) { inkColor = 4; forceEraser = false; - if (BtnSwitchTheme.Content.ToString() == "浅色") + if (!isLastSwitchColorByFloatBar) { - SetDarkColors(); //在浅色背景上使用深色墨迹 + if (BtnSwitchTheme.Content.ToString() == "浅色") + { + SetDarkColors(); //在浅色背景上使用深色墨迹 + } + else + { + SetLightColors(); //在深色背景上使用浅色墨迹 + } } else { - SetLightColors(); //在深色背景上使用浅色墨迹 + isLastSwitchColorByFloatBar = false; } inkCanvas.DefaultDrawingAttributes.Color = ((SolidColorBrush)BtnColorYellow.Background).Color; @@ -5864,6 +5898,7 @@ private void SetLightColors() { BtnColorRed.Background = new SolidColorBrush(StringToColor("#FFFF3333")); BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF1ED760")); + BtnColorBlue.Background = new SolidColorBrush(StringToColor("#FF239AD6")); BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFFFC000")); } } @@ -5882,6 +5917,7 @@ private void SetDarkColors() { BtnColorRed.Background = new SolidColorBrush(Colors.Red); BtnColorGreen.Background = new SolidColorBrush(StringToColor("#FF169141")); + BtnColorBlue.Background = new SolidColorBrush(StringToColor("#FF239AD6")); BtnColorYellow.Background = new SolidColorBrush(StringToColor("#FFF38B00")); } } @@ -6853,6 +6889,8 @@ private void HideSubPanels() BorderTools.Visibility = Visibility.Collapsed; } + bool isLastSwitchColorByFloatBar = false; + private void BorderPenColorBlack_MouseUp(object sender, MouseButtonEventArgs e) { BtnColorBlack_Click(BtnColorBlack, null); @@ -6861,24 +6899,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(); }