From d60ef9752509f84325e44d27b3e21a665e18d65a Mon Sep 17 00:00:00 2001 From: wangxiner55 <47072643+wangxiner55@users.noreply.github.com> Date: Mon, 23 Dec 2024 22:13:46 +0800 Subject: [PATCH] CursonQuestionsTable --- StudentManager/Common/FileSystem.cs | 5 ++ StudentManager/Data/QuestionLib.cs | 5 ++ StudentManager/Editor/AddHomeWork.xaml | 106 +++++++++++++++++-------- StudentManager/Editor/DetailView.xaml | 8 +- StudentManager/Model/Students.cs | 13 ++- 5 files changed, 93 insertions(+), 44 deletions(-) diff --git a/StudentManager/Common/FileSystem.cs b/StudentManager/Common/FileSystem.cs index 0995257..0f0d155 100644 --- a/StudentManager/Common/FileSystem.cs +++ b/StudentManager/Common/FileSystem.cs @@ -11,6 +11,7 @@ namespace StudentManager.Common public class FileSystem : Singleton { public Action AutoSaveInvoke { get; set; } + public Action SavedInvoke { get; set; } @@ -19,6 +20,8 @@ namespace StudentManager.Common { StudentLib.Save(); QuestionLib.Instance.Save(); + + SavedInvoke?.Invoke(); } public void FreashAllInfo() @@ -36,6 +39,8 @@ namespace StudentManager.Common await Task.Delay(10000); SaveAll(); + SavedInvoke?.Invoke(); + AutoSave(time); } diff --git a/StudentManager/Data/QuestionLib.cs b/StudentManager/Data/QuestionLib.cs index 19f2054..4b946c3 100644 --- a/StudentManager/Data/QuestionLib.cs +++ b/StudentManager/Data/QuestionLib.cs @@ -37,6 +37,9 @@ namespace StudentManager.Data { QuestionDic.Clear(); + + if(!Path.Exists(StudentLib.LibPath)) + Directory.CreateDirectory(Path.GetFullPath( StudentLib.LibPath)); Debug.Assert(Path.Exists(StudentLib.LibPath)); if (!Path.Exists(StudentLib.LibPath + FileName)) @@ -102,6 +105,8 @@ namespace StudentManager.Data } public ObservableCollection GetAllQuestionByLesson(uint lesson) { + if (!QuestionTableDic.ContainsKey(lesson)) return new ObservableCollection(); + var list = new ObservableCollection(); foreach (QuestionData data in QuestionTableDic[lesson].Values) { diff --git a/StudentManager/Editor/AddHomeWork.xaml b/StudentManager/Editor/AddHomeWork.xaml index ca093be..ec24fe9 100644 --- a/StudentManager/Editor/AddHomeWork.xaml +++ b/StudentManager/Editor/AddHomeWork.xaml @@ -57,48 +57,84 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + - - - + + - + + + + + + + + - - - - - - - - +