private void btnPlay_Click(object sender, EventArgs e) { try { string strInFileName = txtBasicVoiceInputFile.Text; if (strInFileName == "" || !File.Exists(strInFileName)) { MessageBox.Show("Please enter a valid input file name"); return; } //Do we need to extract the wave stream from the DICOM file? if (m_bInputDICOMFileNameChanged) { DicomDataSet ds = new DicomDataSet(); DicomWaveformGroup AudioWaveformGroup; ds.Reset(); // Load the dataset ds.Load(strInFileName, DicomDataSetLoadFlags.None); // Do we have any waveforms in the dataset? if (ds.WaveformGroupCount < 1) { MessageBox.Show("This dataset has no waveform groups"); return; } // Extract the first waveform group AudioWaveformGroup = ds.GetWaveformGroup(0); // Extract the wave stream from the waveform group and save it to disk try { AudioWaveformGroup.SaveAudio(m_strWaveFileName); } catch { MessageBox.Show("Couldn't extract wave stream from DICOM file!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } // Play the wave file m_SoundPlayer.SoundLocation = m_strWaveFileName; m_SoundPlayer.Play(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public static DicomWaveformGroup GetWaveForm(DicomDataSet ds) { int WaveformGroupCount = ds.WaveformGroupCount; if (0 == WaveformGroupCount) { return(null); } return(ds.GetWaveformGroup(0)); }
/* * Loads a dataset, checks to make sure it has waveforms, and then builds the tree */ private void OpenDataset(string file) { Cursor = Cursors.WaitCursor; try { m_bLoadedWaveform = false; ds.Load(file, DicomDataSetLoadFlags.LoadAndClose); // Do we have any waveform groups at all if (ds.WaveformGroupCount == 0) { MessageBox.Show("The DICOM file you are trying to load doesn't include any waveforms."); m_bLoadedWaveform = false; return; } else { m_bLoadedWaveform = true; } // There is at least one waveform group in this DS, the first waveform group will be loaded if (m_CurrentWaveformGroup != null) { m_CurrentWaveformGroup.Reset(); } m_CurrentWaveformGroup = ds.GetWaveformGroup(0); // Update the Tree View UpdateTree(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } finally { Cursor = Cursors.Arrow; } if (treeViewElements.Nodes.Count > 0) { treeViewElements.SelectedNode = treeViewElements.Nodes[0]; } }