Skip to content

Commit 228b687

Browse files
committed
做了读取画笔颜色配置文件时的错误处理
1 parent acc3a0c commit 228b687

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

Ink Canvas/MainWindow.xaml.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,12 @@ private void TimerKillProcess_Elapsed(object sender, ElapsedEventArgs e)
147147
}
148148
}
149149
catch { }
150-
}
150+
}
151151

152152
#endregion Timer
153153

154154
#region Ink Canvas Functions
155-
155+
156156
DrawingAttributes drawingAttributes;
157157
private void loadPenCanvas()
158158
{
@@ -5888,11 +5888,15 @@ private void SetLightColors()
58885888
{
58895889
if (File.Exists(App.RootPath + "Colors\\Light.ini"))
58905890
{
5891-
string[] lightColors = File.ReadAllLines(App.RootPath + "Colors\\Light.ini");
5892-
BtnColorRed.Background = new SolidColorBrush(StringToColor(lightColors[0]));
5893-
BtnColorGreen.Background = new SolidColorBrush(StringToColor(lightColors[1]));
5894-
BtnColorBlue.Background = new SolidColorBrush(StringToColor(lightColors[2]));
5895-
BtnColorYellow.Background = new SolidColorBrush(StringToColor(lightColors[3]));
5891+
try
5892+
{
5893+
string[] lightColors = File.ReadAllLines(App.RootPath + "Colors\\Light.ini");
5894+
BtnColorRed.Background = new SolidColorBrush(StringToColor(lightColors[0]));
5895+
BtnColorGreen.Background = new SolidColorBrush(StringToColor(lightColors[1]));
5896+
BtnColorBlue.Background = new SolidColorBrush(StringToColor(lightColors[2]));
5897+
BtnColorYellow.Background = new SolidColorBrush(StringToColor(lightColors[3]));
5898+
}
5899+
catch (Exception) { ShowNotification("读取亮色画笔颜色配置文件时遇到问题"); }
58965900
}
58975901
else
58985902
{
@@ -5907,11 +5911,15 @@ private void SetDarkColors()
59075911
{
59085912
if (File.Exists(App.RootPath + "Colors\\Dark.ini"))
59095913
{
5910-
string[] darkColors = File.ReadAllLines(App.RootPath + "Colors\\Dark.ini");
5911-
BtnColorRed.Background = new SolidColorBrush(StringToColor(darkColors[0]));
5912-
BtnColorGreen.Background = new SolidColorBrush(StringToColor(darkColors[1]));
5913-
BtnColorBlue.Background = new SolidColorBrush(StringToColor(darkColors[2]));
5914-
BtnColorYellow.Background = new SolidColorBrush(StringToColor(darkColors[3]));
5914+
try
5915+
{
5916+
string[] darkColors = File.ReadAllLines(App.RootPath + "Colors\\Dark.ini");
5917+
BtnColorRed.Background = new SolidColorBrush(StringToColor(darkColors[0]));
5918+
BtnColorGreen.Background = new SolidColorBrush(StringToColor(darkColors[1]));
5919+
BtnColorBlue.Background = new SolidColorBrush(StringToColor(darkColors[2]));
5920+
BtnColorYellow.Background = new SolidColorBrush(StringToColor(darkColors[3]));
5921+
}
5922+
catch (Exception) { ShowNotification("读取深色画笔颜色配置文件时遇到问题"); }
59155923
}
59165924
else
59175925
{

0 commit comments

Comments
 (0)