Enumerating Context Groups Example for VB.NET

Private Function DisplayContextGroup(ByRef objDS As LTDICLib.LEADDicomDS) As DialogResult
   
Dim objGroup As LTDICLib.DicomContextGroup
   
objGroup = objDS.CurrentContextGroup
   
Dim sMsg As String
   
' Context ID and name
   
sMsg = objGroup.ContextIdentifier & vbNewLine & objGroup.Name & vbNewLine
   
' Extensibility
   
If objGroup.Extensible Then
      
sMsg = sMsg & "Extensible" & vbNewLine
   
Else
      
sMsg = sMsg & "Non-extensible" & vbNewLine
   
End If
   
' Context Group Version
   
Dim sMonth, sYear, sDay As String
   
With objGroup.ContextGroupVersion
      
sYear = CStr(.Year)
      
Do While Len(sYear) < 4
         
sYear = "0" & sYear
      
Loop
      
sMonth = CStr(.Month)
      
If Len(sMonth) < 2 Then
         
sMonth = "0" & sMonth
      
sDay = CStr(.Day)
      
If Len(sDay) < 2 Then
         
sDay = "0" & sDay
   
End With
   
sMsg = sMsg & sYear & sMonth & sDay & vbNewLine
   
sMsg = sMsg & vbNewLine & "Enumerate Coded Concepts?"
   
Return DisplayContextGroup = MessageBox.Show(sMsg, "Context Group", MessageBoxButtons.YesNoCancel)
End Function

Private Sub EnumContextGroups(ByRef objDS As LTDICLib.LEADDicomDS)
   
Dim bRet As Boolean
   
Dim sMsg As String
   
objDS.ResetContextGroup()
   
' Load all the Context Groups
   
objDS.LoadContextGroup()
   
' Enumerate them (3 possible ways)
   
Dim I As Integer
   
If True Then
      
' One possible way to enumerate the Context Groups
      
bRet = objDS.MoveFirstContextGroup()
      
Do While bRet
         
Select Case DisplayContextGroup(objDS)
            
Case DialogResult.Yes
               
' Refer to Enumerating the Coded Concepts of a Context Group
               
' Example for the procedure EnumCodedConcepts
               
EnumCodedConcepts(objDS)
            
Case DialogResult.Cancel
               
Exit Do
         
End Select
         
bRet = objDS.MoveNextContextGroup()
      
Loop
   
ElseIf False Then
      
' Another way to enumerate the Context Groups
      
For I = 0 To objDS.GetContextGroupCount() - 1
         
objDS.FindIndexContextGroup(I)
         
Select Case DisplayContextGroup(objDS)
            
Case DialogResult.Yes
               
EnumCodedConcepts(objDS)
            
Case DialogResult.Cancel
               
Exit For
         
End Select
      
Next
   
ElseIf False Then
      
' A third way to enumerate the Context Groups
      
bRet = objDS.MoveLastContextGroup()
      
Do While bRet
         
Select Case DisplayContextGroup(objDS)
            
Case DialogResult.Yes
               
EnumCodedConcepts(objDS)
            
Case DialogResult.Cancel
               
Exit Do
         
End Select
         
bRet = objDS.MovePrevContextGroup()
      
Loop
   
End If
End Sub