Beispiel #1
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        olvFileTags.ClearObjects();

        try
        {
            var dicom = DicomFile.Open(_fileInfo.FullName, FileReadOption.ReadAll);

            try
            {
                using var renderedImage = new DicomImage(dicom.Dataset).RenderImage().AsSharpImage();
                using MemoryStream ms   = new();
                renderedImage.Save(ms, renderedImage.GetConfiguration().ImageFormatsManager.FindEncoder(PngFormat.Instance));
                ms.Seek(0, SeekOrigin.Begin);
                DicomImage        = new(ms);
                pictureBox1.Image = DicomImage;
            }
            catch (Exception)
            {
                //no picture
                splitContainer1.Panel1Collapsed = true;
            }

            foreach (DicomItem item in dicom.Dataset)
            {
                var value = DicomTypeTranslater.Flatten(DicomTypeTranslaterReader.GetCSharpValue(dicom.Dataset, item));

                olvFileTags.AddObject(new TagValueNode(item.Tag, value));
            }
        }
        catch (Exception exception)
        {
            MessageBox.Show(exception.ToString(), "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
    }