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)); }
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; }
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; }
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; }
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; }
private static IEnumerable <DicomEditorTag> 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); yield return(editorSq); DicomSequenceItem[] items = (DicomSequenceItem[])attribute.Values; if (items.Length != 0) { for (int i = 0; i < items.Length; i++) { var sequenceItem = items[i]; var editorSqItem = new DicomEditorTag("fffe", "e000", "Sequence Item", editorSq, i, nestingLevel + 1); yield return(editorSqItem); foreach (var tag in ReadAttributeCollection(sequenceItem, editorSqItem, nestingLevel + 2)) { yield return(tag); } //add SQ Item delimiter yield return(new DicomEditorTag("fffe", "e00d", "Item Delimitation Item", editorSqItem, i, nestingLevel + 1)); } } //add SQ delimiter yield return(new DicomEditorTag("fffe", "e0dd", "Sequence Delimitation Item", editorSq, items.Length, nestingLevel)); } else { yield return(new DicomEditorTag(attribute, parent, nestingLevel)); } } }
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)); } } }
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; }
public static int TagCompare(DicomEditorTag one, DicomEditorTag two, SortType type) { return(one.SortKey(type).CompareTo(two.SortKey(type))); }
public static int TagCompare(DicomEditorTag one, DicomEditorTag two, SortType type) { return one.SortKey(type).CompareTo(two.SortKey(type)); }
public DicomEditorComponent() { var setTagValueDelegate = new TableColumn <DicomEditorTag, string> .SetColumnValueDelegate <DicomEditorTag, string>((d, value) => { if (d.IsEditable()) { d.Value = value; _dirtyFlags[_position] = true; EventsHelper.Fire(_tagEditedEvent, this, EventArgs.Empty); } }); if (!LicenseInformation.IsFeatureAuthorized(FeatureTokens.DicomEditing)) { setTagValueDelegate = null; } _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); }, setTagValueDelegate, 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 | ValidationOptions.AllowUnchangedValues; }