AnnCount Example for C#

//This example uses the predefined variable “LEADRasterView1” of type “AxLEADRasterView” from “"LEADTOOLS Toolkit”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestAnnCount()
{
   //This example
   // 1. Opens a dataset with annotations
   // 2. Finds the location of one of the annotation files
   // 3. Loads the annotations
   // 4. Flips the annotations
   // 5. Saves the annotations to index to slots 250 through 255
   // 6. Deletes the annotation files from slot 253

   short nRet = 0;
   short i = 0;
   int hAnnContainer = 0;
   string strMsg = null;
   string strTmp = null;
   short nIndexAnn = 0;
   LTRASTERIOLib.LEADRasterIO RasterIO = new LTRASTERIOLib.LEADRasterIO();
   LTANNLib.LEADRasterAnnotation RasterAnn = new LTANNLib.LEADRasterAnnotation();
   // Open the dataset with annotations
   nRet = LEADDICOM1.LoadDS("e:\\images\\DicomAnn.dic", 0);
   if (nRet != (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
       return;
   RasterIO.EnableMethodErrors = false;
   RasterIO.Load(LEADRasterView1.Raster, "e:\\images\\DicomAnn.dic", 0, 0, 1);
   // Find the location of one of the annotation files
   LEADDICOM1.AnnCount();
   if (nRet != (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS)
      return;
   strMsg = "Private Creator Tag: " + System.Convert.ToString(LEADDICOM1.AnnPrivateCreatorTag, 16).ToUpper() + System.Environment.NewLine;
   for (i = 0; i <= 255; i++)
   {
      if (LEADDICOM1.get_AnnEntries(i) == true)
      {
         nIndexAnn = i;
         strTmp = "\t" + System.Convert.ToString(i).ToString() + System.Environment.NewLine;
         strMsg = strMsg + strTmp;
      }
   }
   MessageBox.Show(strMsg);
   // Loads the annotations LEADDICOM1.AnnLoad(nIndexAnn, 1);
   // Flip the annotations
   RasterAnn.AnnContainer = LEADDICOM1.AnnContainer;
   RasterAnn.AnnFlip(true, LEADRasterView1.Raster.BitmapHeight / 2, false);
   LEADDICOM1.AnnContainer = RasterAnn.AnnContainer;
   // Save the annotations to index to slots 250 through 255
   for (i = 250; i <= 255; i++)
   {
      nRet = LEADDICOM1.AnnSave(i, (short)LTANNLib.AnnFMTConstants.ANN_FMT_NATIVE, false, (short)LTDICLib.DicomAnnSaveModifyConstants.SAVE_OVERWRITE, 1);
   }
   // Delete the annotation files from slot 253 LEADDICOM1.AnnDelete(253, -1);
   // Display file info LEADDICOM1.AnnCount();
   if (nRet != (short)LTDicomKernelLib.DicomErrorCodes.DICOM_SUCCESS) return;
      strMsg = "Private Creator Tag: " + System.Convert.ToString(LEADDICOM1.AnnPrivateCreatorTag, 16).ToUpper() + System.Environment.NewLine;
   for (i = 0; i <= 255; i++)
   {
      if (LEADDICOM1.get_AnnEntries(i) == true)
      {
         strTmp = "\t" + System.Convert.ToString(i).ToString() + System.Environment.NewLine; strMsg = strMsg + strTmp;
      }
   }
   MessageBox.Show(strMsg);
   // Save the data set LEADDICOM1.SaveDS("e:\\erase\\dicom.dic", 0);
}