public static FinalizedExercise[] LoadFromFile() { if (!File.Exists(FileName)) { return new FinalizedExercise[] { } } ; string s; using (var file = File.OpenText(FileName)) { s = file.ReadToEnd(); } string[] exercises = s.Split(ExerciseDelimeter); FinalizedExercise[] result = new FinalizedExercise[exercises.Length - 1]; for (int i = 0; i < exercises.Length - 1; i++) { result[i] = new FinalizedExercise(exercises[i], i); } return(result); }
public static void Save(FinalizedExercise result) { var sb = new StringBuilder(); sb.Append(result.Date); sb.Append(AttributeDelimeter); sb.Append(result.TextTitle); sb.Append(AttributeDelimeter); sb.Append(result.PassedChars); sb.Append(AttributeDelimeter); sb.Append(result.Errors); sb.Append(AttributeDelimeter); sb.Append(result.Time); sb.Append(AttributeDelimeter); sb.Append(result.Rhythmicity); sb.Append(ExerciseDelimeter); using (var file = File.AppendText(FileName)) { file.Write(sb); } }
public ResultForm(FinalizedExercise result, SourceText source) { InitializeComponent(); if (source.Length == result.PassedChars) { buttonContinue.Enabled = false; CancelButton = buttonEnd; } textBoxAvSpeed.Text = result.Speed.ToString("F") + " зн/мин"; textBoxErrors.Text = result.ErrorsPercent.ToString("F2") + " %"; textBoxTime.Text = result.FormattedTime; textBoxRhithmicity.Text = result.Rhythmicity.ToString() + " %"; graph.AddInstantSpeed(result.Keystrokes, "instantspeed"); graph.AddAverageSpeed(result.Keystrokes, "averagespeed"); }