Examining Annotations (1) Example for C#

private void ExamineAnnotations1(ref LTDICLib.LEADDicomDS objPresStateDS)
{
   string sMsg = null;
   // Get the attributes that describe the "Presentation State Module"
   if (objPresStateDS.GetPresStateAttributes(0) == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
   {
      // Display some
      sMsg = "Instance Number: " + objPresStateDS.PresStateAttributes.InstanceNumber + System.Environment.NewLine + "Presentation Label: " + objPresStateDS.PresStateAttributes.PresLabel + System.Environment.NewLine + "Presentation Description: " + objPresStateDS.PresStateAttributes.PresDescription + System.Environment.NewLine + "Presentation Creator’s Name: " + objPresStateDS.PresStateAttributes.PresCreatorName;
      MessageBox.Show(sMsg, "Presentation State Attributes");
   }
   int I = 0;
   int lCount = 0;
   int J = 0;
   // Display the SOP Instance UIDs of all the images referenced in the
   // "Presentation State Module"
   if (objPresStateDS.FindFirstPresStateRefSeriesItem() == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
   {
      sMsg = "";
      do
      {
         lCount = objPresStateDS.GetPresStateImageRefCount();
         for (I = 0; I < lCount; I++)
         {
            sMsg = sMsg + objPresStateDS.GetPresStateImageRefInstanceUID(I) + System.Environment.NewLine;
         }
         sMsg = sMsg + System.Environment.NewLine;
      } while (objPresStateDS.MoveNextPresStateRefSeriesItem() == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS);
      MessageBox.Show(sMsg, "Referenced SOP Instance UID(s)");
   }
   // Enumerate all the layers defined
   lCount = objPresStateDS.LayerCount;
   MessageBox.Show("Layer Count: " + lCount);
   for (I = 0; I < lCount; I++)
   {
      // Display some of the attributes
      if (objPresStateDS.GetLayerAttributes(I) == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
      {
         sMsg = "Graphic Layer: " + objPresStateDS.LayerAttributes.LayerName + System.Environment.NewLine + "Graphic Layer Order: " + objPresStateDS.LayerAttributes.LayerOrder + System.Environment.NewLine + "Graphic Layer Description: " + objPresStateDS.LayerAttributes.LayerDescription;
         MessageBox.Show(sMsg, "Graphic Layer Attributes");
      }
   }
   int lGraphicObjectCount = 0;
   int lTextObjectCount = 0;
   // Enumerate all the Graphic Annotation Items
   if (objPresStateDS.FindFirstGraphicAnnItem() == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
   {
      do
      {
         lGraphicObjectCount = objPresStateDS.GetGraphicObjectCount();
         // Or:
         //lGraphicObjectCount = objPresStateDS.GetLayerGraphicObjectCount ()
         lTextObjectCount = objPresStateDS.GetTextObjectCount();
         // Or:
         //lTextObjectCount = objPresStateDS.GetLayerTextObjectCount()
sMsg = "Graphic Layer: " + objPresStateDS.GetLayerName() + System.Environment.NewLine + "Graphic object count: " + lGraphicObjectCount + System.Environment.NewLine + "Text object count: " + lTextObjectCount + System.Environment.NewLine + System.Environment.NewLine;
         lCount = objPresStateDS.GetLayerImageRefCount();
         if (lCount == 0)
              sMsg = sMsg + "The annotations defined in this Item apply to all the " + "images listed in the \"Presentation State Module\".";
         else
         {
            sMsg = sMsg + "Referenced SOP Instance UID(s):" + System.Environment.NewLine;
            for (I = 0; I < lCount; I++)
            {
               sMsg = sMsg + " " + objPresStateDS.GetLayerImageRefInstanceUID(I) + System.Environment.NewLine;
            }
         }
         MessageBox.Show(sMsg, "Graphic Annotation Item");
         // Enumerate all the graphic objects in the current Item
         for (I = 0; I < lGraphicObjectCount; I++)
         {
            objPresStateDS.GetGraphicObjectAttributes(I);
            sMsg = "Graphic Annotation Units: ";
            switch ( objPresStateDS.GraphicObjectAttributes.Units )
            {
               case LTDICLib.DicomMeasureUnits.DICOM_UNIT_PIXEL:
                  sMsg = sMsg + "PIXEL" + System.Environment.NewLine;
                  break;
               case LTDICLib.DicomMeasureUnits.DICOM_UNIT_DISPLAY:
                  sMsg = sMsg + "DISPLAY" + System.Environment.NewLine;
                  break;
            }
            sMsg = sMsg + "Graphic Type: ";
            switch ( objPresStateDS.GraphicObjectAttributes.Type )
            {
               case LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_POINT:
                  sMsg = sMsg + "POINT" + System.Environment.NewLine;
                  break;
               case LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_POLYLINE:
                  sMsg = sMsg + "POLYLINE" + System.Environment.NewLine;
                  break;
               case LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_INTERPOLATED:
                  sMsg = sMsg + "INTERPOLATED" + System.Environment.NewLine;
                  break;
               case LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_CIRCLE:
                  sMsg = sMsg + "CIRCLE" + System.Environment.NewLine;
                  break;
               case LTDICLib.DicomGraphicObjectTypes.DICOM_GRAPHIC_OBJECT_TYPE_ELLIPSE:
                  sMsg = sMsg + "ELLIPSE" + System.Environment.NewLine;
                  break;
            }
            if (objPresStateDS.GraphicObjectAttributes.Filled)
                sMsg = sMsg + "Graphic Filled: Y" + System.Environment.NewLine;
            else
               sMsg = sMsg + "Graphic Filled: N" + System.Environment.NewLine;
            lCount = objPresStateDS.GraphicObjectAttributes.PointCount;
            sMsg = sMsg + "Number of Graphic Points: " + lCount + System.Environment.NewLine;
            if (lCount < 10)
            {
               sMsg = sMsg + "Graphic Data: " + System.Environment.NewLine;
               for (J = 0; J < lCount; J++)
               {
                  sMsg = sMsg + " " + "X" + J + 1 + ", Y" + J + 1 + " = " + objPresStateDS.GraphicObjectAttributes.get_PointsX(J) + ", " + objPresStateDS.GraphicObjectAttributes.get_PointsY(J) + System.Environment.NewLine;
               }
            }
            MessageBox.Show(sMsg, "Graphic Annotation Object");
         }
         // Enumerate all the text objects in the current Item
         for (I = 0; I < lTextObjectCount; I++)
         {
            objPresStateDS.GetTextObjectAttributes(I);
            if (objPresStateDS.TextObjectAttributes.BoundingBoxUsed)
            {
               sMsg = "Unformatted Text Value: " + objPresStateDS.TextObjectAttributes.TextValue + System.Environment.NewLine;
               sMsg = sMsg + "Bounding Box Annotation Units: ";
               switch ( objPresStateDS.TextObjectAttributes.BoundingBoxUnits )
               {
                  case LTDICLib.DicomMeasureUnits.DICOM_UNIT_PIXEL:
                     sMsg = sMsg + "PIXEL" + System.Environment.NewLine;
                     break;
                  case LTDICLib.DicomMeasureUnits.DICOM_UNIT_DISPLAY:
                     sMsg = sMsg + "DISPLAY" + System.Environment.NewLine;
                     break;
               }
               sMsg = sMsg + "Bounding Box Top Left Hand Corner: " + objPresStateDS.TextObjectAttributes.BoundingBoxTLHCornerX + ", " + objPresStateDS.TextObjectAttributes.BoundingBoxTLHCornerY + System.Environment.NewLine;
               sMsg = sMsg + "Bounding Box Bottom Right Hand Corner: " + objPresStateDS.TextObjectAttributes.BoundingBoxBRHCornerX + ", " + objPresStateDS.TextObjectAttributes.BoundingBoxBRHCornerY + System.Environment.NewLine;
               sMsg = sMsg + "Bounding Box Text Horizontal Justification: ";
               switch (objPresStateDS.TextObjectAttributes.BoundingBoxTextJustification)
               {
                  case LTDICLib.DicomTextJustificationTypes.DICOM_TEXT_JUSTIFICATION_LEFT:
                     sMsg = sMsg + "LEFT" + System.Environment.NewLine;
                     break;
                  case LTDICLib.DicomTextJustificationTypes.DICOM_TEXT_JUSTIFICATION_RIGHT:
                     sMsg = sMsg + "RIGHT" + System.Environment.NewLine;
                     break;
                  case LTDICLib.DicomTextJustificationTypes.DICOM_TEXT_JUSTIFICATION_CENTER:
                     sMsg = sMsg + "CENTER" + System.Environment.NewLine;
                     break;
               }
            }
            else
            {
               sMsg = "Unformatted Text Value: " + objPresStateDS.TextObjectAttributes.TextValue + System.Environment.NewLine;
               sMsg = sMsg + "Anchor Point Annotation Units: ";
               switch (objPresStateDS.TextObjectAttributes.AnchorPointUnits)
               {
                  case LTDICLib.DicomMeasureUnits.DICOM_UNIT_PIXEL:
                     sMsg = sMsg + "PIXEL" + System.Environment.NewLine;
                     break;
                  case LTDICLib.DicomMeasureUnits.DICOM_UNIT_DISPLAY:
                     sMsg = sMsg + "DISPLAY" + System.Environment.NewLine;
                     break;
               }
               sMsg = sMsg + "Anchor Point: " + objPresStateDS.TextObjectAttributes.AnchorPointX + ", " + objPresStateDS.TextObjectAttributes.AnchorPointY + System.Environment.NewLine;
               if (objPresStateDS.TextObjectAttributes.AnchorPointVisible)
                  sMsg = sMsg + "Anchor Point Visibility: Y";
               else
                  sMsg = sMsg + "Anchor Point Visibility: N";
            }
            MessageBox.Show(sMsg, "Text Annotation Object");
         }
      } while (objPresStateDS.MoveNextGraphicAnnItem() == (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS);
   }
}