Enumerating Context Groups Example for C#

private DialogResult DisplayContextGroup(ref LTDICLib.LEADDicomDS objDS)
{
   LTDICLib.DicomContextGroup objGroup = null;
   objGroup = objDS.CurrentContextGroup;
   string sMsg = null;
   // Context ID and name
   sMsg = objGroup.ContextIdentifier + System.Environment.NewLine + objGroup.Name + System.Environment.NewLine;
   // Extensibility
   if (objGroup.Extensible)
      sMsg = sMsg + "Extensible" + System.Environment.NewLine;
   else
      sMsg = sMsg + "Non-extensible" + System.Environment.NewLine;
   // Context Group Version
   string sMonth = null;
   string sYear = null;
   string sDay = null;
   sYear = System.Convert.ToString(objGroup.ContextGroupVersion.Year);
   while (sYear.Length < 4)
   {
      sYear = "0" + sYear;
   }
   sMonth = System.Convert.ToString(objGroup.ContextGroupVersion.Month);
   if (sMonth.Length < 2)
      sMonth = "0" + sMonth;
   sDay = System.Convert.ToString(objGroup.ContextGroupVersion.Day);
   if (sDay.Length < 2)
      sDay = "0" + sDay;
   sMsg = sMsg + sYear + sMonth + sDay + System.Environment.NewLine;
   sMsg = sMsg + System.Environment.NewLine + "Enumerate Coded Concepts?";
   return
   MessageBox.Show(sMsg, "Context Group", MessageBoxButtons.YesNoCancel);
}

private void EnumContextGroups(ref LTDICLib.LEADDicomDS objDS)
{
   bool bRet = false;
   string sMsg = null;
   objDS.ResetContextGroup();
   // Load all the Context Groups
   objDS.LoadContextGroup("");
   // Enumerate them (3 possible ways)
   if (true)
   {
      // One possible way to enumerate the Context Groups
      bRet = objDS.MoveFirstContextGroup();
      while (bRet)
      {
         switch (DisplayContextGroup(ref objDS))
         {
            case DialogResult.Yes:
               // Refer to Enumerating the Coded Concepts of a Context Group
               // Example for the procedure EnumCodedConcepts
               EnumCodedConcepts(ref objDS);
               break;
            case DialogResult.Cancel:
               goto ExitWhile1;
         }
         bRet = objDS.MoveNextContextGroup();
      }
      ExitWhile1: ;
   }
   else  if (false)
   {
      // Another way to enumerate the Context Groups
      for (int I = 0;I < objDS.GetContextGroupCount();I++)
      {
         objDS.FindIndexContextGroup(I);
         switch (DisplayContextGroup(ref objDS))
         {
            case DialogResult.Yes:
               EnumCodedConcepts(ref objDS);
               break;
            case DialogResult.Cancel:
               goto ExitWhile2;
         }
      }
      ExitWhile2: ;
   }
   else if (false)
   {
      // A third way to enumerate the Context Groups
      bRet = objDS.MoveLastContextGroup();
      while (bRet)
      {
         switch (DisplayContextGroup(ref objDS))
         {
            case DialogResult.Yes:
               EnumCodedConcepts(ref objDS);
               break;
            case DialogResult.Cancel:
               goto ExitWhile3;
         }
         bRet = objDS.MovePrevContextGroup();
      }
      ExitWhile3: ;
   }
}