void SaveState() { DisplayScore displayScore = new DisplayScore(); displayScore.Notes = textBox1.Text; displayScore.ScoreState.Points = Convert.ToInt32(Score.Text); displayScore.ScoreState.Questions = Convert.ToInt32(QuestionScore.Text); displayScore.TestState.Points = Convert.ToInt32(MaxScore.Text); displayScore.TestState.Questions = Convert.ToInt32(Questions.Text); string msg = JsonConvert.SerializeObject(displayScore); File.WriteAllText(SaveFile, msg); }
void LoadState() { if (!File.Exists(SaveFile)) { return; } string msg = File.ReadAllText(SaveFile); DisplayScore displayScore = JsonConvert.DeserializeObject <DisplayScore>(msg); textBox1.Text = displayScore.Notes; Score.Text = displayScore.ScoreState.Points.ToString(); QuestionScore.Text = displayScore.ScoreState.Questions.ToString(); MaxScore.Text = displayScore.TestState.Points.ToString(); Questions.Text = displayScore.TestState.Questions.ToString(); }