LEADTOOLS Medical (Leadtools.Dicom.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
ToAnnObject Method
See Also 
Leadtools.Dicom.Annotations Namespace > DicomAnnotationsUtilities Class : ToAnnObject Method



dicomAnnotationObject
The DICOM annotation object that is being converted.

The ToAnnObject Method is available in LEADTOOLS Medical Imaging toolkits.

dicomAnnotationObject
The DICOM annotation object that is being converted.
Converts a Leadtools.Dicom.DicomAnnotationObject to an System.Object that is of type AnnObject. Supported in Silverlight, Windows Phone 7

Syntax

Visual Basic (Declaration) 
Public Function ToAnnObject( _
   ByVal dicomAnnotationObject As DicomAnnotationObject _
) As Object
Visual Basic (Usage)Copy Code
Dim instance As DicomAnnotationsUtilities
Dim dicomAnnotationObject As DicomAnnotationObject
Dim value As Object
 
value = instance.ToAnnObject(dicomAnnotationObject)
C# 
public object ToAnnObject( 
   DicomAnnotationObject dicomAnnotationObject
)
C++/CLI 
public:
Object^ ToAnnObject( 
   DicomAnnotationObject^ dicomAnnotationObject
) 

Parameters

dicomAnnotationObject
The DICOM annotation object that is being converted.

Return Value

An AnnObject System.Object representation of the DICOM annotation if successful; null if the Leadtools.Dicom.DicomAnnotationObject cannot be converted.

Example

This sample does the following:

  1. Creates a Leadtools.Dicom.DicomTextObject text object with an anchor
  2. Creates a converter
  3. Converts to a LEAD annotation

Visual BasicCopy Code
Public Function DicomAnnotationsUtilities_ToAnnObject() As AnnObject
   ' Create a DicomTextAnnotation object -- text object with an anchor
   Dim dicomAnnotationObject As DicomTextObject = New Leadtools.Dicom.DicomTextObject()
   dicomAnnotationObject.TLHCorner = New DicomAnnotationPoint(100, 250)
   dicomAnnotationObject.BRHCorner = New DicomAnnotationPoint(200, 350)
   dicomAnnotationObject.AnchorPointVisible = True
   dicomAnnotationObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel
   dicomAnnotationObject.AnchorPoint = New DicomAnnotationPoint(300, 300)
   dicomAnnotationObject.AnchorPointVisible = True
   dicomAnnotationObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel
   dicomAnnotationObject.TextJustification = TextAnnotationJustificationType.Right
   dicomAnnotationObject.TextValue = "Right justified with blue border"
   ' Create an instance of the converter, and customize the defaults for the annotations by
   ' creating a default object and assigning it to the DefaultObject property
   Dim du As New DicomAnnotationsUtilities()

   Dim defaultAnnObject As New AnnTextObject()

   ' Pen
   defaultAnnObject.Pen = New AnnPen(Color.Blue, New AnnLength(3))
   defaultAnnObject.Brush = New AnnSolidBrush(Color.Purple)

   ' Font
   defaultAnnObject.Font = New AnnFont("Courier", New AnnLength(16), FontStyle.Bold)

   ' Text
   defaultAnnObject.Alignment = StringAlignment.Far
   defaultAnnObject.TextColor = Color.Green

   du.DefaultObject = defaultAnnObject


   ' Convert to a LEAD AnnObject
   Dim annObject As AnnObject = TryCast(du.ToAnnObject(dicomAnnotationObject), AnnObject)
   Return annObject
End Function
C#Copy Code
public AnnObject DicomAnnotationsUtilities_ToAnnObject()
{
   // Create a DicomTextAnnotation object -- text object with an anchor
   DicomTextObject dicomAnnotationObject = new Leadtools.Dicom.DicomTextObject();
   dicomAnnotationObject.TLHCorner = new DicomAnnotationPoint(100, 250);
   dicomAnnotationObject.BRHCorner = new DicomAnnotationPoint(200, 350);
   dicomAnnotationObject.AnchorPointVisible = true;
   dicomAnnotationObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel;
   dicomAnnotationObject.AnchorPoint = new DicomAnnotationPoint(300, 300);
   dicomAnnotationObject.AnchorPointVisible = true;
   dicomAnnotationObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel;
   dicomAnnotationObject.TextJustification = TextAnnotationJustificationType.Right;
   dicomAnnotationObject.TextValue = "Right justified with blue border";
   // Create an instance of the converter, and customize the defaults for the annotations by
   // creating a default object and assigning it to the DefaultObject property
   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();

   AnnTextObject defaultAnnObject = new AnnTextObject();

   // Pen
   defaultAnnObject.Pen = new AnnPen(Color.Blue, new AnnLength(3));
   defaultAnnObject.Brush = new AnnSolidBrush(Color.Purple);

   // Font
   defaultAnnObject.Font = new AnnFont("Courier", new AnnLength(16), FontStyle.Bold);

   // Text
   defaultAnnObject.Alignment = StringAlignment.Far;
   defaultAnnObject.TextColor = Color.Green;

   du.DefaultObject = defaultAnnObject;


   // Convert to a LEAD AnnObject
   AnnObject annObject = du.ToAnnObject(dicomAnnotationObject) as AnnObject;
   return annObject;
}
SilverlightCSharpCopy Code
public AnnObject DicomAnnotationsUtilities_ToAnnObject()
{
   // Create a DicomTextAnnotation object -- text object with an anchor
   DicomTextObject dicomAnnotationObject = new Leadtools.Dicom.DicomTextObject();
   dicomAnnotationObject.TLHCorner = new DicomAnnotationPoint(100, 250);
   dicomAnnotationObject.BRHCorner = new DicomAnnotationPoint(200, 350);
   dicomAnnotationObject.AnchorPointVisible = true;
   dicomAnnotationObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel;
   dicomAnnotationObject.AnchorPoint = new DicomAnnotationPoint(300, 300);
   dicomAnnotationObject.AnchorPointVisible = true;
   dicomAnnotationObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel;
   dicomAnnotationObject.TextJustification = TextAnnotationJustificationType.Right;
   dicomAnnotationObject.TextValue = "Right justified with blue border";
   // Create an instance of the converter, and customize the defaults for the annotations by
   // creating a default object and assigning it to the DefaultObject property
   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();

   AnnTextObject defaultAnnObject = new AnnTextObject();

   // Pen
   defaultAnnObject.Stroke = Color.FromArgb(255, 0, 0, 255);
   defaultAnnObject.StrokeThickness = 3;
   defaultAnnObject.Fill = Color.FromArgb(128, 0, 255, 255);

   // Font
   defaultAnnObject.FontFamilyName = "Courier";
   defaultAnnObject.FontSize = 16;
   defaultAnnObject.FontStretch = AnnFontStretches.Normal;
   defaultAnnObject.FontStyle = AnnFontStyle.Italic;
   defaultAnnObject.FontWeight = AnnFontWeight.Bold;

   // Text
   defaultAnnObject.TextHorizontalAlignment = AnnTextAlignment.Far;
   defaultAnnObject.Foreground = Color.FromArgb(255, 255, 0, 255);

   du.DefaultObject = defaultAnnObject;

   // Convert to a LEAD AnnObject
   AnnObject annObject = du.ToAnnObject(dicomAnnotationObject) as AnnObject;
   return annObject;
}
SilverlightVBCopy Code
Public Function DicomAnnotationsUtilities_ToAnnObject() As AnnObject
   ' Create a DicomTextAnnotation object -- text object with an anchor
   Dim dicomAnnotationObject As DicomTextObject = New DicomTextObject()
   dicomAnnotationObject.TLHCorner = New DicomAnnotationPoint(100, 250)
   dicomAnnotationObject.BRHCorner = New DicomAnnotationPoint(200, 350)
   dicomAnnotationObject.AnchorPointVisible = True
   dicomAnnotationObject.AnchorPointUnits = DicomAnnotationUnitsRelativityType.Pixel
   dicomAnnotationObject.AnchorPoint = New DicomAnnotationPoint(300, 300)
   dicomAnnotationObject.AnchorPointVisible = True
   dicomAnnotationObject.BoundingBoxUnits = DicomAnnotationUnitsRelativityType.Pixel
   dicomAnnotationObject.TextJustification = TextAnnotationJustificationType.Right
   dicomAnnotationObject.TextValue = "Right justified with blue border"
   ' Create an instance of the converter, and customize the defaults for the annotations by
   ' creating a default object and assigning it to the DefaultObject property
   Dim du As DicomAnnotationsUtilities = New DicomAnnotationsUtilities()

   Dim defaultAnnObject As AnnTextObject = New AnnTextObject()

   ' Pen
   defaultAnnObject.Stroke = Color.FromArgb(255, 0, 0, 255)
   defaultAnnObject.StrokeThickness = 3
   defaultAnnObject.Fill = Color.FromArgb(128, 0, 255, 255)

   ' Font
   defaultAnnObject.FontFamilyName = "Courier"
   defaultAnnObject.FontSize = 16
   defaultAnnObject.FontStretch = AnnFontStretches.Normal
   defaultAnnObject.FontStyle = AnnFontStyle.Italic
   defaultAnnObject.FontWeight = AnnFontWeight.Bold

   ' Text
   defaultAnnObject.TextHorizontalAlignment = AnnTextAlignment.Far
   defaultAnnObject.Foreground = Color.FromArgb(255, 255, 0, 255)

   du.DefaultObject = defaultAnnObject

   ' Convert to a LEAD AnnObject
   Dim annObject As AnnObject = TryCast(du.ToAnnObject(dicomAnnotationObject), AnnObject)
   Return annObject
End Function

Remarks

The returned System.Object is of type Leadtools.Annotations.AnnObject. An Leadtools.Annotations.AnnObjecthas properties (i.e. color, font) that a Leadtools.Dicom.DicomAnnotationObject does not. Set the Leadtools.Annotations.AnnObject defaults prior to calling this method by setting the DefaultObject

Note: for Silverlight users, the System.Object is of type Leadtools.Windows.Annotations.AnnObject

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also

Leadtools.Dicom.Annotations requires a Medical toolkit license and unlock key. For more information, refer to: Raster Pro/Document/Medical Features