private void StopDocumentReview() { if (Document != null) { Document.Reviews = null; bool retry = true; string folder = Properties.Settings.Default.ReviewsDirectory; while (retry) { if (folder.Length == 0 || !Directory.Exists(folder)) { FolderBrowserDialog fbd = new FolderBrowserDialog(); if (fbd.ShowDialog() == DialogResult.OK) { folder = fbd.SelectedPath; Properties.Settings.Default.ReviewsDirectory = folder; Properties.Settings.Default.Save(); } } if (Directory.Exists(folder)) { string path = Path.Combine(folder, Path.GetFileNameWithoutExtension(Document.Book.FilePath) + ".smr"); try { SaveData(path); retry = false; } catch (Exception ex) { ErrorCatcher.Add("Message from saving review file: {0}", ex.Message); } } if (retry) { if (MessageBox.Show("Review file was not saved. Do you want to try different folder?", "Unsuccessful saving", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error) == DialogResult.Yes) { retry = true; folder = ""; } else { retry = false; } } } } }
public void Play() { ErrorCatcher.currentOperation = "PlaySound "; try { if (sound != null && sound.GetData() != null) { ErrorCatcher.currentOperation = "PlaySound " + sound.Name; if (Playing == true) { Stop(); } if (p_memoryStream == null) { p_memoryStream = new MemoryStream(sound.GetData()); } if (p_audioFileReader != null) { p_audioFileReader.Dispose(); p_audioFileReader = null; } if (p_audioFileReader == null) { p_audioFileReader = GetAudioStream(); } if (p_audioFileReader != null) { TimeSpan length = p_audioFileReader.TotalTime; if (timer1 == null) { timer1 = new Timer(); } timer1.Interval = Convert.ToInt32(length.TotalMilliseconds); timer1.Start(); if (p_waveChannel == null) { p_waveChannel = new WaveChannel32(p_audioFileReader); } if (p_waveOut == null) { p_waveOut = new DirectSoundOut(); p_waveOut.Init(p_waveChannel); } if (p_waveOut != null) { Debugger.Log(0, "", "Audio Player start.\n"); p_waveOut.Play(); Playing = true; } } } } catch (Exception ex) { ErrorCatcher.Add("Exception: {0}\n\nStackTrace: {1}\n\n\n", ex.Message, ex.StackTrace); } finally { ErrorCatcher.currentOperation = ""; } }