Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 8939eb1
Author: XY Wang <[email protected]>
Date:   Thu Mar 14 16:09:31 2024 +0800

    Update MainWindow.xaml.cs

commit b8b9e7a
Merge: f84a4f2 80c57dc
Author: XY Wang <[email protected]>
Date:   Thu Mar 14 16:06:29 2024 +0800

    Merge branch 'master' into master

commit f84a4f2
Author: STBBRD <[email protected]>
Date:   Sat Dec 23 20:51:22 2023 +0800

    解决 MainWindow.xaml 冲突

commit f0c44fe
Author: STBBRD <[email protected]>
Date:   Sat Dec 2 20:14:48 2023 +0800

    修复当使用橡皮时隐藏再显示画板导致显示浅色画笔的问题,恢复对关闭确认的修改

commit 7668ad3
Author: STBBRD <[email protected]>
Date:   Sat Nov 25 20:33:47 2023 +0800

    将第一个关闭警告修改为普通的 MessageBox,以防止 Windows 关机时出现警告音

commit 525cc8e
Author: STBBRD <[email protected]>
Date:   Sun Nov 19 12:27:31 2023 +0800

    修正 屏幕批注下按两次 Alt+E 变成浅色画笔 的问题

commit 01aad1f
Author: STBBRD <[email protected]>
Date:   Sun Nov 19 11:29:05 2023 +0800

    将贡献者中的 STBBRD(我) 改为 ZongziTEK(我)

commit 21d8a84
Merge: 228b687 c054e85
Author: ZongziTEK <[email protected]>
Date:   Sun Nov 19 11:17:31 2023 +0800

    Merge branch 'WXRIW:master' into master

commit 228b687
Author: STBBRD <[email protected]>
Date:   Sat Nov 4 20:09:32 2023 +0800

    做了读取画笔颜色配置文件时的错误处理

commit acc3a0c
Author: STBBRD <[email protected]>
Date:   Sun Oct 29 09:19:48 2023 +0800

    完成深浅色切换、根据配置文件自定义颜色功能

    - 修复了加载颜色的所有问题
    - 新增对更改颜色请求是否从浮动工具栏发出的判断

commit 02fa775
Author: STBBRD <[email protected]>
Date:   Sun Oct 29 08:44:37 2023 +0800

    修复昨天的问题

commit 51c6127
Author: STBBRD <[email protected]>
Date:   Sat Oct 28 22:53:04 2023 +0800

    初步适配了浮动工具栏UI中 黑板 屏幕批注 的画笔颜色模式切换,但是仍有问题

    问题:从黑板直接到屏幕批注时浅色画笔不会变成深色画笔

commit d7d3f02
Author: STBBRD <[email protected]>
Date:   Sat Oct 28 22:42:06 2023 +0800

    更正一个注释中的错别字

commit 5f06a07
Author: STBBRD <[email protected]>
Date:   Sat Oct 28 22:40:54 2023 +0800

    新增 加载两种画笔颜色模式的配置文件,并应用于 Old UI 深浅色切换
  • Loading branch information
WXRIW committed Mar 14, 2024
1 parent 47cda3b commit 145cadc
Showing 1 changed file with 137 additions and 30 deletions.
167 changes: 137 additions & 30 deletions Ink Canvas/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public MainWindow()
{
InitializeComponent();


BorderSettings.Visibility = Visibility.Collapsed;
StackPanelToolButtons.Visibility = Visibility.Collapsed;
BorderDrawShape.Visibility = Visibility.Collapsed;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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();
}
Expand Down Expand Up @@ -6984,6 +7084,8 @@ private async void SymbolIconCursor_Click(object sender, RoutedEventArgs e)
}
}
}

SetDarkColors();
}

private void SymbolIconDelete_MouseUp(object sender, MouseButtonEventArgs e)
Expand Down Expand Up @@ -7074,6 +7176,9 @@ private void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e)
{
BorderPenColorWhite_MouseUp(BorderPenColorWhite, null);
}

if (Settings.Canvas.UsingWhiteboard) SetDarkColors(); //在白板上用深色墨迹
else SetLightColors(); //在黑板上用浅色墨迹
}
else
{
Expand All @@ -7100,6 +7205,8 @@ private void ImageBlackboard_MouseUp(object sender, MouseButtonEventArgs e)
})).Start();
}
BorderPenColorRed_MouseUp(BorderPenColorRed, null);

SetDarkColors();
}

BtnSwitch_Click(BtnSwitch, null);
Expand Down

0 comments on commit 145cadc

Please sign in to comment.