private void LoadItems() { ProjectsList.Items.Clear(); ProjectsList.Text = "Загрузка..."; TimerSettings.MakeEnvironment(); ProjectsDirs = Directory.GetDirectories(TimerSettings.CompetitionProjects); Projects = new CompetitionsContainer[ProjectsDirs.Length]; for (int i = 0; i < ProjectsDirs.Length; i++) { try { Projects[i] = JsonSerializer.Deserialize <CompetitionsContainer>(File.ReadAllText(Directory.GetFiles(ProjectsDirs[i])[0])); //Projects[i] = JsonConvert.DeserializeObject<CompetitionsContainer>(File.ReadAllText(Directory.GetFiles(ProjectsDirs[i])[0])); } catch { Directory.Delete(ProjectsDirs[i], true); LoadItems(); } } ProjectsList.Items.Clear(); foreach (CompetitionsContainer CC in Projects) { ProjectsList.Items.Add("Название: " + CC.Name + (CC.Competition.Finished ? " (Завершено)" : "")); } if (Projects.Length == 0) { ProjectsList.Items.Add("Проектов нет"); ProjectsList.SelectedIndex = 0; Continue.Visible = false; DeleteCompetition.Visible = false; ModelStartBox.Visible = false; InfoBox.Visible = false; CompetitionLabel.Visible = false; } else { ProjectsList.SelectedIndex = ProjectsList.Items.Count - 1; CompetitionLabel.Text = Projects[ProjectsList.SelectedIndex].Competition.ToString(); InfoBox.Visible = true; UpdateData(); } }
public static void SaveData() { //return; var Saver = new Thread(new ThreadStart(() => { TimerSettings.MakeEnvironment(); Directory.CreateDirectory(Path.Combine(TimerSettings.CurrentProjectFolder)); var ProjectFile = File.CreateText(Path.Combine(TimerSettings.CurrentProjectFolder, TimerSettings.Container.Name + ".json")); //string data = TimerSettings.jsonEngine ? : JsonSerializer.Serialize(TimerSettings.Container); //JsonSerializer.Serialize(TimerSettings.Container) ProjectFile.Write(JsonSerializer.Serialize(TimerSettings.Container)); //ProjectFile.Write(JsonConvert.SerializeObject(TimerSettings.Container)); ProjectFile.Close(); })); Saver.IsBackground = true; Saver.Start(); }