void getFromServerDlg_Closed(object sender, EventArgs e) { var dlg = sender as DicomServerGetDialog; if (dlg != null && dlg.DialogResult.GetValueOrDefault()) { var dataset = dlg.GetSelectedDataset(); if (dataset != null) { StringBuilder sb = new StringBuilder(); dataset.Dump(sb, String.Empty, DicomDumpOptions.Default); RawDump = sb.ToString(); var xmlDoc = XDicom.ToXML(dataset, XDicomOptions.None); var txtWriter = new StringWriter(); xmlDoc.Save(txtWriter); XmlDump = txtWriter.ToString(); DicomImage = dataset.Contains(DicomTags.PixelData) ? GetImageSource(dataset) : null; } else { RawDump = XmlDump = String.Format(Resources["noDicomObjectDataMsg"].ToString(), dlg.SelectedImageSopInstanceUid); DicomImage = null; } } UpdateLog(); }
private void DumpDisplayDataset(string instanceName, DcmDataset dataset) { if (dataset != null) { var xmlDoc = XDicom.ToXML(dataset, XDicomOptions.None); var txtWriter = new StringWriter(); xmlDoc.Save(txtWriter); dicomDumpTextBox.Text = txtWriter.ToString(); dicomImage.Source = dataset.Contains(DicomTags.PixelData) ? GetImageSource(dataset) : null; } else { dicomDumpTextBox.Text = String.Format(Resources["noDicomDataMsg"].ToString(), instanceName); dicomImage.Source = null; } }
private void fileNameButton_Click(object sender, RoutedEventArgs e) { OpenFileDialog dlg = Resources["dicomFileDialog"] as OpenFileDialog; if (dlg != null && dlg.ShowDialog().GetValueOrDefault()) { using (var memStream = new MemoryStream()) { using (var fileStream = dlg.File.OpenRead()) { fileStream.CopyTo(memStream); } DicomFileFormat ff = new DicomFileFormat(); ff.Load(memStream, DicomReadOptions.Default); if (ff.Dataset != null) { StringBuilder sb = new StringBuilder(); ff.Dataset.Dump(sb, String.Empty, DicomDumpOptions.Default); RawDump = sb.ToString(); var xmlDoc = XDicom.ToXML(ff.Dataset, XDicomOptions.None); var txtWriter = new StringWriter(); xmlDoc.Save(txtWriter); XmlDump = txtWriter.ToString(); DicomImage = ff.Dataset.Contains(DicomTags.PixelData) ? GetImageSource(ff.Dataset) : null; } else { RawDump = XmlDump = String.Format(Resources["noDicomFileDataMsg"].ToString(), dlg.File.Name); DicomImage = null; } } UpdateLog(); } }