diff --git a/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs b/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs index 55e9a77..49d67ce 100644 --- a/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs +++ b/ZongziTEK_Blackboard_Sticker/MainWindow.xaml.cs @@ -66,7 +66,6 @@ public MainWindow() // 加载文件 LoadSettings(); LoadStrokes(); - LoadTimetableOrCurriculum(); Task.Run(() => { Dispatcher.BeginInvoke(() => @@ -93,10 +92,11 @@ public MainWindow() frameInfoNavigationTimer.Interval = TimeSpan.FromSeconds(4); frameInfoNavigationTimer.Start(); + // 课程表 timetableTimer = new DispatcherTimer(); timetableTimer.Tick += CheckTimetable; timetableTimer.Interval = new TimeSpan(0, 0, 1); - timetableTimer.Start(); + LoadTimetableOrCurriculum(); // 颜色主题 SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged; diff --git a/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml b/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml index b9739b2..d3c8506 100644 --- a/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml +++ b/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml @@ -97,7 +97,7 @@ diff --git a/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs b/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs index 06d0f80..d207dac 100644 --- a/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs +++ b/ZongziTEK_Blackboard_Sticker/TimetableEditor.xaml.cs @@ -27,8 +27,8 @@ public partial class TimetableEditor : Window { public TimetableEditor() { - InitializeComponent(); - + InitializeComponent(); + if (File.Exists(MainWindow.GetDataPath() + MainWindow.timetableFileName)) { try @@ -47,13 +47,21 @@ public TimetableEditor() private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { - if (!isCloseWithoutWarning) + if (!isCloseWithoutWarning && isEdited) { e.Cancel = true; - if (!isEdited || MessageBox.Show("确定要直接关闭课程表编辑器吗\n这将丢失未保存的课程", "关闭而不保存", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.OK) + if (MessageBox.Show("部分修改仍未保存,是否保存这些更改?", "是否保存更改", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { + ButtonSave_Click(null, null); e.Cancel = false; } + else + { + if (MessageBox.Show("此操作将导致刚才的更改丢失,确定不要保存课表吗?", "关闭而不保存", MessageBoxButton.OKCancel) == MessageBoxResult.OK) + { + e.Cancel = false; + } + } } } @@ -65,9 +73,10 @@ private void ButtonSave_Click(object sender, RoutedEventArgs e) File.WriteAllText(MainWindow.GetDataPath() + MainWindow.timetableFileName, text); } catch { } + isEdited = false; - isCloseWithoutWarning = true; - Close(); + //isCloseWithoutWarning = true; + //Close(); } private void ButtonClose_Click(object sender, RoutedEventArgs e)