←Select platform

ToAnnObject Method

Syntax

C#
VB
C++
public object ToAnnObject( 
   DicomAnnotationObject dicomAnnotationObject 
) 
  
Public Function ToAnnObject( _ 
   ByVal dicomAnnotationObject As Leadtools.Dicom.DicomAnnotationObject _ 
) As Object 

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.

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 object is of type Leadtools.Windows.Annotations.AnnObject

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
    C#
    VB
    Silverlight C#
    Silverlight VB
    using Leadtools; 
    using Leadtools.Annotations; 
    using Leadtools.Dicom; 
    using Leadtools.Dicom.Annotations; 
     
    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; 
    } 
    Imports Leadtools 
    Imports Leadtools.Annotations 
    Imports Leadtools.Dicom 
    Imports Leadtools.Dicom.Annotations 
     
    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 
    using Leadtools; 
    using Leadtools.Dicom; 
    using Leadtools.Dicom.Annotations; 
    using Leadtools.Windows.Annotations; 
    using Leadtools.Examples; 
     
    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; 
    } 
    Imports Leadtools 
    Imports Leadtools.Dicom 
    Imports Leadtools.Dicom.Annotations 
    Imports Leadtools.Windows.Annotations 
     
    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 
Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.