public void SaveWithAudio(string fileName) { if (Recorder == null || Recorder.State != RecorderState.Finished) { throw new InvalidOperationException(); } string replay = Game.Replay.Save(); Stream audio = Recorder.Data; audio.Position = 0; AudioLessonFile.Save(fileName, replay, audio); SetUnmodified(); }
private void FinishButton_Click(object sender, EventArgs e) { //Fixme: Check Error handling bool wasPaused = false; if (audioRecorder != null) { wasPaused = audioRecorder.Paused; audioRecorder.Paused = true; } if (audioRecorder != null) { using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.DefaultExt = ".GoLesson"; dlg.Filter = "Go Audio Lesson|*.GoLesson|All Files|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { string replay = goRecorder.Replay.Save(); audioRecorder.Finish(); Stream audio = audioRecorder.Data; audio.Position = 0; AudioLessonFile.Save(dlg.FileName, replay, audio); FinishButton.Enabled = false; goRecorder = null; audioRecorder = null; } } } else { using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.DefaultExt = ".GoReplay"; dlg.Filter = "Go Replay|*.GoReplay|All Files|*.*"; if (dlg.ShowDialog() == DialogResult.OK) { goRecorder.Replay.Save(dlg.FileName); FinishButton.Enabled = false; goRecorder = null; } } } if (audioRecorder != null) { audioRecorder.Paused = wasPaused; } }