LabelType: Formatted

A recently added LabelType "Formatted" in .NET version of DicomObjects provides a very useful way to access the value of any DicomImage property. For property which has a shortcut name, you can just put the name of the property after the "$" sign. You can also specify the "Group" and "Element" of any particular attribute. Following VB.NET codes show how to use the formatted label:

$PropertyName:

Dim l As New DicomObjects.DicomLabel
l.LabelType = DicomObjects.Enums.LabelType.Formatted
l.Area = New RectangleF(110, 50, 10, 30)
l.TextBrush = Brushes.Yellow
l.ShowTextBox = True
l.Text = "Frame : $Frame \ $FrameCount"	' $ + PropertyName gives you the value of that property
l.ScaleMode = DicomObjects.Enums.ScaleMode.Image
DicomViewer1.CurrentImage.Labels.Add(l)

$(gggg,eeee):

Dim l As New DicomObjects.DicomLabel
l.LabelType = DicomObjects.Enums.LabelType.Formatted
l.Area = New RectangleF(110, 50, 10, 30)
l.TextBrush = Brushes.Yellow
l.ShowTextBox = True
l.Text = "PatientName : $(0010,0010)"	' you can specify any attribute you like by using $(gggg,eeee)
l.ScaleMode = DicomObjects.Enums.ScaleMode.Image
DicomViewer1.CurrentImage.Labels.Add(l)

Please NOTE, both property name and (gggg,eeee) formats are case sensitive and there is no space between "," and "eeee". To get the date time properties displayed right, it's better to use the $(gggg,eeee) format as the VR is accessible so the output will be narrowed down to "Date" or "Time". Using the property name format would not have such distinction as the VR is not accessible and a general DateTime data will be returned.

Relevance: