Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            DicomCodec.RegisterCodecs();
            DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec*.dll");

            if (File.Exists("dicom.dic"))
            {
                DcmDictionary.ImportDictionary("dicom.dic");
            }
            else
            {
                DcmDictionary.LoadInternalDictionary();
            }

            if (File.Exists("private.dic"))
            {
                DcmDictionary.ImportDictionary("private.dic");
            }

            DicomDumpForm form = new DicomDumpForm();

            foreach (string file in args)
            {
                form.AddFile(file);
            }

            Application.Run(form);
        }
Exemplo n.º 2
0
 public MainForm()
 {
     InitializeComponent();
     if (File.Exists("dicom.dic"))
     {
         DcmDictionary.ImportDictionary("dicom.dic");
     }
     else
     {
         DcmDictionary.LoadInternalDictionary();
     }
 }
Exemplo n.º 3
0
        public void OnLoad(object sender, EventArgs e)
        {
            InitializeLog();

            DicomCodec.RegisterCodecs();
            DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec*.dll");

            if (File.Exists("dicom.dic"))
            {
                DcmDictionary.ImportDictionary("dicom.dic");
            }
            else
            {
                DcmDictionary.LoadInternalDictionary();
            }

            if (File.Exists("private.dic"))
            {
                DcmDictionary.ImportDictionary("private.dic");
            }
        }
Exemplo n.º 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DicomCodec.RegisterCodecs();
            DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec*.dll");

            if (File.Exists("dicom.dic"))
            {
                DcmDictionary.ImportDictionary("dicom.dic");
            }
            else
            {
                DcmDictionary.LoadInternalDictionary();
            }

            if (File.Exists("private.dic"))
            {
                DcmDictionary.ImportDictionary("private.dic");
            }

            Debug.InitializeConsoleDebugLogger();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            if (!(args.Length == 1 || args.Length == 2))
            {
                Console.WriteLine("usage: TagChecker <DCM-Directory> [txt-output]");
                return;
            }

            String RootDirectoryPath = args[0];

            String TextOutputPath = null;

            if (args.Length == 2)
            {
                TextOutputPath = args[1];
            }

            //Check to see that it exists
            DirectoryInfo RootDirectoryInfo = new DirectoryInfo(RootDirectoryPath);

            if (!RootDirectoryInfo.Exists)
            {
                Console.WriteLine("The directory '" + RootDirectoryPath + "' does not exist.");
                return;
            }

            //Load internal dictionary
            DcmDictionary.LoadInternalDictionary();


            TextWriter output;

            try
            {
                if (args.Length == 2)
                {
                    output = new StreamWriter(TextOutputPath);
                }
                else
                {
                    output = Console.Out;
                }

                var DicomTagsToCheck = CalculateDicomTagsToCheck();
                var TagTovalues      = new Dictionary <DicomTag, List <String> >();
                CheckDirectory(RootDirectoryInfo, output, DicomTagsToCheck, TagTovalues);

                output.WriteLine("All values");
                foreach (var tag in TagTovalues.Keys)
                {
                    List <String> values = TagTovalues[tag];
                    output.WriteLine(tag.Entry);
                    foreach (var value in values)
                    {
                        output.WriteLine(" = " + value);
                    }
                    output.WriteLine();
                }

                output.Flush();
                output.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("CheckTag: Failed, reason: {0}.", e.Message);
            }

            Console.In.Read();
        }
Exemplo n.º 6
0
        private static void Main(string[] args)
        {
            if (args.Length == 0 || args.Length > 2 ||
                (args.Length == 2 && args[0].Equals(args[1], StringComparison.InvariantCultureIgnoreCase)))
            {
                Console.WriteLine("usage: dcm2txt dcmfile-in [txtfile-out]");
                return;
            }

            var dcmFileName = args[0];

            if (!File.Exists(dcmFileName))
            {
                Console.WriteLine("dcm2txt: Specified DICOM file '{0}' does not exist or cannot be accessed.",
                                  dcmFileName);
                return;
            }

            if (File.Exists("dicom.dic"))
            {
                DcmDictionary.ImportDictionary("dicom.dic");
            }
            else
            {
                DcmDictionary.LoadInternalDictionary();
            }

            if (File.Exists("private.dic"))
            {
                DcmDictionary.ImportDictionary("private.dic");
            }

            string dump;

            try
            {
                var dcmFile = new DicomFileFormat();
                if (dcmFile.Load(dcmFileName, DicomReadOptions.Default) == DicomReadStatus.Success)
                {
                    var sb = new StringBuilder();

                    if (dcmFile.FileMetaInfo != null)
                    {
                        dcmFile.FileMetaInfo.Dump(sb, String.Empty, DicomDumpOptions.None);
                    }

                    if (dcmFile.Dataset != null)
                    {
                        dcmFile.Dataset.Dump(sb, String.Empty, DicomDumpOptions.None);
                    }
                    else
                    {
                        Console.WriteLine("dcm2txt: Missing dataset in DICOM file '{0}'.", dcmFileName);
                        return;
                    }
                    dump = sb.ToString();
                }
                else
                {
                    Console.WriteLine("dcm2txt: '{0}' does not appear to be a DICOM file.", dcmFileName);
                    return;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("dcm2txt: Dumping DICOM file to text failed, reason: {0}.", e.Message);
                return;
            }

            try
            {
                if (args.Length == 2)
                {
                    var txtFileName = args[1];
                    File.WriteAllText(txtFileName, dump);
                }
                else
                {
                    Console.Write(dump);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("dcm2txt: Writing DICOM dump to file/console failed, reason: {0}.", e.Message);
            }
        }