public void SaveData(TaskFrame Frame) { if (App.tsList == null) { App.tsList = new List<TaskShellInfo>(); } List<TaskShellInfo> tsList = App.tsList; tsList.Clear(); var list = Frame.TaskShellList(); foreach (TaskShell ts in list) { TaskShellInfo tsInfo; tsInfo.Name = ts.TaskShellName; tsInfo.ItemList = new List<TaskItemlInfo>(); var TaskItemList = ts.TaskItemList(); foreach (TaskItem ti in TaskItemList) { TaskItemlInfo tiInfo; tiInfo.Content = ti.TaskContent; tiInfo.IsCompleted = ti.IsCompleted; tsInfo.ItemList.Add(tiInfo); } tsList.Add(tsInfo); } DataStorage ds = new DataStorage(); ds.SaveData(tsList); }
private void Application_Exit_1(object sender, ExitEventArgs e) { if (tsList == null) { MessageBox.Show("数据文件损坏,无法保存!"); } DataStorage ds = new DataStorage(); ds.SaveData(tsList); }