Ejemplo n.º 1
0
        private string SortKey(SortType type)
        {
            DicomEditorTag parentTag = _parentTag;
            string         typeSpecificModifier;

            switch (type)
            {
            case SortType.GroupElement:
                if (_parentTag == null)
                {
                    return(String.Format("({0:x4},", _group) + String.Format("{0:x4})", _element) + _postitionOrdinal.ToString());
                }
                else
                {
                    return(_parentTag.SortKey(type) + String.Format("({0:x4},", _group) + String.Format("{0:x4})", _element) + _postitionOrdinal.ToString());
                }

            case SortType.TagName:
                typeSpecificModifier = _tagName;
                while (parentTag != null)
                {
                    typeSpecificModifier = parentTag._tagName;
                    parentTag            = parentTag._parentTag;
                }
                break;

            case SortType.Vr:
                typeSpecificModifier = this.Vr;
                while (parentTag != null)
                {
                    typeSpecificModifier = parentTag.Vr;
                    parentTag            = parentTag._parentTag;
                }
                break;

            case SortType.Length:
                typeSpecificModifier = this.Length;
                while (parentTag != null)
                {
                    typeSpecificModifier = parentTag.Length;
                    parentTag            = parentTag._parentTag;
                }
                break;

            case SortType.Value:
                typeSpecificModifier = this.Value;
                while (parentTag != null)
                {
                    typeSpecificModifier = parentTag.Value;
                    parentTag            = parentTag._parentTag;
                }
                break;

            default:
                typeSpecificModifier = String.Format("({0:x4},", _group) + String.Format("{0:x4})", _element) + _postitionOrdinal.ToString();
                break;
            }

            return(typeSpecificModifier + this.SortKey(SortType.GroupElement));
        }
Ejemplo n.º 2
0
        public DicomEditorTag(string group, string element, string tagName, DicomEditorTag parentTag, int positionOrdinal, int displayLevel)
        {
            _attribute = null;

            _group   = ushort.Parse(group, System.Globalization.NumberStyles.HexNumber);
            _element = ushort.Parse(element, System.Globalization.NumberStyles.HexNumber);
            _tagName = tagName;

            _parentTag        = parentTag;
            _postitionOrdinal = positionOrdinal;
            _nestingLevel     = displayLevel;
        }
Ejemplo n.º 3
0
        public DicomEditorTag(DicomAttribute attribute, DicomEditorTag parentTag, int nestingLevel)
        {
            _attribute = attribute;

            _group   = _attribute.Tag.Group;
            _element = _attribute.Tag.Element;
            _tagName = _attribute.Tag.Name;

            _parentTag        = parentTag;
            _nestingLevel     = nestingLevel;
            _postitionOrdinal = 0;
        }
Ejemplo n.º 4
0
        private void ReadAttributeCollection(DicomAttributeCollection set, DicomEditorTag parent, int nestingLevel)
        {
            foreach (DicomAttribute attribute in set)
            {
                if (attribute.IsEmpty)
                {
                    continue;
                }

                if (attribute is DicomAttributeSQ)
                {
                    DicomEditorTag editorSq = new DicomEditorTag(attribute, parent, nestingLevel);
                    _dicomTagData.Items.Add(editorSq);

                    DicomSequenceItem[] items = (DicomSequenceItem[])((DicomAttributeSQ)attribute).Values;
                    if (items.Length != 0)
                    {
                        DicomEditorTag    editorSqItem;
                        DicomSequenceItem sequenceItem;
                        for (int i = 0; i < items.Length; i++)
                        {
                            sequenceItem = items[i];

                            editorSqItem = new DicomEditorTag("fffe", "e000", "Sequence Item", editorSq, i, nestingLevel + 1);
                            _dicomTagData.Items.Add(editorSqItem);

                            this.ReadAttributeCollection(sequenceItem, editorSqItem, nestingLevel + 2);
                            //add SQ Item delimiter
                            _dicomTagData.Items.Add(new DicomEditorTag("fffe", "e00d", "Item Delimitation Item", editorSqItem, i, nestingLevel + 1));
                        }
                    }
                    //add SQ delimiter
                    _dicomTagData.Items.Add(new DicomEditorTag("fffe", "e0dd", "Sequence Delimitation Item", editorSq, items.Length, nestingLevel));
                }
                else
                {
                    _dicomTagData.Items.Add(new DicomEditorTag(attribute, parent, nestingLevel));
                }
            }
        }
Ejemplo n.º 5
0
        public DicomEditorComponent()
        {
            _dicomTagData = new Table <DicomEditorTag>();
            _dicomTagData.Columns.Add(new TableColumn <DicomEditorTag, string>(SR.ColumnHeadingGroupElement, delegate(DicomEditorTag d) { return(d.DisplayKey); }, null, 1.0f, delegate(DicomEditorTag one, DicomEditorTag two) { return(DicomEditorTag.TagCompare(one, two, SortType.GroupElement)); }));
            _dicomTagData.Columns.Add(new TableColumn <DicomEditorTag, string>(SR.ColumnHeadingTagName, delegate(DicomEditorTag d) { return(d.TagName); }, null, 1.0f, delegate(DicomEditorTag one, DicomEditorTag two) { return(DicomEditorTag.TagCompare(one, two, SortType.TagName)); }));
            _dicomTagData.Columns.Add(new TableColumn <DicomEditorTag, string>(SR.ColumnHeadingVR, delegate(DicomEditorTag d) { return(d.Vr); }, null, 1.0f, delegate(DicomEditorTag one, DicomEditorTag two) { return(DicomEditorTag.TagCompare(one, two, SortType.Vr)); }));
            _dicomTagData.Columns.Add(new TableColumn <DicomEditorTag, string>(SR.ColumnHeadingLength, delegate(DicomEditorTag d) { return(d.Length); }, null, 1.0f, delegate(DicomEditorTag one, DicomEditorTag two) { return(DicomEditorTag.TagCompare(one, two, SortType.Length)); }));
            _dicomTagData.Columns.Add(new TableColumn <DicomEditorTag, string>(SR.ColumnHeadingValue, delegate(DicomEditorTag d) { return(d.Value); }, delegate(DicomEditorTag d, string value)
            {
                if (d.IsEditable())
                {
                    d.Value = value;
                    _dirtyFlags[_position] = true;
                    EventsHelper.Fire(_tagEditedEvent, this, EventArgs.Empty);
                }
            }, 1.0f, delegate(DicomEditorTag one, DicomEditorTag two) { return(DicomEditorTag.TagCompare(one, two, SortType.Value)); }));
            _title       = "";
            _loadedFiles = new List <DicomFile>();
            _position    = 0;
            _dirtyFlags  = new List <bool>();

            _anonymizer = new DicomAnonymizer();
            _anonymizer.ValidationOptions = ValidationOptions.RelaxAllChecks;
        }
Ejemplo n.º 6
0
 public static int TagCompare(DicomEditorTag one, DicomEditorTag two, SortType type)
 {
     return(one.SortKey(type).CompareTo(two.SortKey(type)));
 }