private DicomDataset GetItemDataset(DcmItem item)
        {
            if (_currentFile.FileMetaInfo.Contains(item.DcmTag))
            {
                return(_currentFile.FileMetaInfo);
            }

            if (_currentFile.Dataset.Contains(item.DcmTag))
            {
                return(_currentFile.Dataset);
            }

            foreach (DcmItem seq in DicomItems.Where(i => i.TagType == DcmTagType.Sequence))
            {
                for (int i = 0; i < seq.SequenceItems.Count; i++)
                {
                    if (seq.SequenceItems[i].SequenceItems.Contains(item))
                    {
                        return(_currentFile.Dataset.GetDicomItem <DicomSequence>(seq.DcmTag).Items[i]);
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        private void InsertDatasetItem(DcmItem item, DicomReadOptions options)
        {
            if (_sds.Count > 0 && _sds.Count == _sqs.Count)
            {
                DcmDataset ds = _sds.Peek();

                if (_tag.Element == 0x0000)
                {
                    if (Flags.IsSet(options, DicomReadOptions.KeepGroupLengths))
                    {
                        ds.AddItem(item);
                    }
                }
                else
                {
                    ds.AddItem(item);
                }

                if (ds.StreamLength != UndefinedLength)
                {
                    long end = ds.StreamPosition + ds.StreamLength;
                    if ((_stream.Position - _offset) >= end)
                    {
                        _sds.Pop();
                    }
                }
            }
            else
            {
                if (_tag.Element == 0x0000)
                {
                    if (Flags.IsSet(options, DicomReadOptions.KeepGroupLengths))
                    {
                        _dataset.AddItem(item);
                    }
                }
                else
                {
                    _dataset.AddItem(item);
                }
            }

            if (_tag == DicomTags.SpecificCharacterSet && item is DcmCodeString)
            {
                DcmCodeString cs = (DcmCodeString)item;
                if (cs.Length > 0)
                {
                    string[] values = cs.GetValues();
                    for (int i = 0; i < values.Length; i++)
                    {
                        if (String.IsNullOrEmpty(values[i]))
                        {
                            continue;
                        }
                        _encoding = DcmEncoding.GetEncodingForSpecificCharacterSet(values[i]);
                        break;
                    }
                }
            }
        }
        public void EditDicomItem(DcmItem item)
        {
            _currentItem = item;

            var editor = _viewModelFactory.GetEditDicomItemViewModel();

            editor.Initialize(GetItemDataset(item), item.DcmTag);

            _windowManager.ShowDialog(editor, this);
        }
        public void ShowDcmImage(DcmItem item)
        {
            _currentItem = item;

            var preview = _viewModelFactory.GetPreviewImageViewModel();

            preview.Initialize(GetItemDataset(item));

            _windowManager.ShowDialog(preview, this);
        }
        public void DcmItemTapped(DcmItem item)
        {
            if (item.TagType != DcmTagType.Tag)
            {
                return;
            }

            if (IsPixelDataItem(item))
            {
                ShowDcmImage(item);
            }
            else
            {
                EditDicomItem(item);
            }
        }
 public bool IsPixelDataItem(DcmItem item)
 {
     return(item.DcmTag.CompareTo(DicomTag.PixelData) == 0);
 }
Esempio n. 7
0
 public DicomNode(Image image, DcmItem elem)
     : base()
 {
     _image = image;
     _elem  = elem;
 }