コード例 #1
0
ファイル: DICOMSniffer.cs プロジェクト: ewcasas/DVTK
        private void menuItemShowPixelData_Click(object sender, System.EventArgs e)
        {
            bool ok = false;
            menuItemShowPixelData.Visible = false;

            //Save the selected PDU in a temp DCM file
            PDU_DETAIL pdu = null;
            string tempFile = Application.StartupPath + @"\temp.dcm";
            if(reqPduList.SelectedIndex != -1)
            {
                pdu = (PDU_DETAIL)reqList[reqPduList.SelectedIndex];
            }

            if((pdu != null) && (pdu.ByteDataDump.Count != 0))
            {
                uint DatasetLength = 0;
                foreach(byte[] p in pdu.ByteDataDump)
                    DatasetLength += (uint)p.Length;

                byte[] Bytes = new byte[DatasetLength];

                DatasetLength = 0;
                foreach(byte[] p in pdu.ByteDataDump)
                {
                    p.CopyTo(Bytes,DatasetLength);
                    DatasetLength += (uint)p.Length;
                }

                try
                {
                    ok = assocHandle.DumpAsDCMFile(Bytes, pdu.TransferSyntaxDataset, tempFile);
                }
                catch (Exception)
                {
                    ok = false;
                }
            }

            //Start the process & display the temp DCM file to DICOM viewer application
            if(ok)
            {
                UserOptions optionDlg = new UserOptions();
                Process process  = new Process();

                process.StartInfo.FileName= optionDlg.DICOMViewerPath;

                if (!File.Exists(process.StartInfo.FileName))
                {
                    MessageBox.Show("DICOM Viewer not found.\nUnable to display pixel data.");
                }
                else
                {
                    try
                    {
                        process.StartInfo.Arguments = "\"" + tempFile + "\"";
                        process.Start();
                        process.WaitForExit();
                    }
                    catch (Exception except)
                    {
                        string msg = string.Format("The DICOM Viewer is not able to handle DICOM object,{0}\n", except.Message);
                        MessageBox.Show(this, msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                string msg = "Error in pixel data saving to a DCM file.\r\n";
                MessageBox.Show(this, msg, "Error",MessageBoxButtons.OK, MessageBoxIcon.Error );
            }

            //Delete the temp file
            FileInfo tempfileInfo = new FileInfo(tempFile);
            if(tempfileInfo.Exists)
                tempfileInfo.Delete();
        }
コード例 #2
0
ファイル: DICOMSniffer.cs プロジェクト: ewcasas/DVTK
 private void menuItemOptions_Click(object sender, System.EventArgs e)
 {
     UserOptions optionDlg = new UserOptions();
     optionDlg.ShowDialog();
 }