コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: xiaotie/mdcm
        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();
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: xiaotie/mdcm
        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;
            }
        }
コード例 #3
0
ファイル: MainPage.xaml.cs プロジェクト: xiaotie/mdcm
        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();
            }
        }