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



annObject
The LEAD annotation object that is being converted

The FromAnnObject Method is available in LEADTOOLS Medical Imaging toolkits.

annObject
The LEAD annotation object that is being converted
Converts a LEADTOOLS AnnObject System.Object to a Leadtools.Dicom.DicomAnnotationObject. Supported in Silverlight, Windows Phone 7

Syntax

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

Parameters

annObject
The LEAD annotation object that is being converted

Return Value

A DICOM annotation Leadtools.Dicom.DicomAnnotationObject if successful; null if the Leadtools.Annotations.AnnObjectcannot be converted.

Example

This sample does the following:

  1. Creates a LEAD Leadtools.Annotations.AnnRectangleObject annotation
  2. Creates a converter
  3. Converts to a Leadtools.Dicom.DicomAnnotationObject annotation
  4. Converts back to a LEAD AnnObject

Visual BasicCopy Code
Public Sub DicomAnnotationsUtilities_FromAnnObject()
   ' Create an AnnRectangleObject
   Dim annObject As New AnnRectangleObject()
   annObject.Pen = New AnnPen(Color.Purple, New AnnLength(5, AnnUnit.Pixel))
   annObject.Brush = New AnnSolidBrush(Color.White)
   annObject.Bounds = New AnnRectangle(400, 100, 500, 200)
   ' Create an instance of the converter, and set some properties
   Dim du As New DicomAnnotationsUtilities()
   du.LayerName = "Test Layer Name"

   Dim defaultAnnObject As New AnnTextObject()
   defaultAnnObject.Pen = annObject.Pen
   defaultAnnObject.Brush = annObject.Brush
   du.DefaultObject = defaultAnnObject

   ' Convert to a DicomAnnotationObject
   ' Note that there is no DicomAnnotationObject rectangle type, so it is converted to a polyline
   Dim dicomAnnotationObject As DicomAnnotationObject = du.FromAnnObject(annObject)

   ' Convert back to a LEAD AnnObject
   ' Now the LEAD object will be a polyline, even though the original object was a rectangle
   Dim annObjectNew As AnnObject = TryCast(du.ToAnnObject(dicomAnnotationObject), AnnObject)

   If annObjectNew IsNot Nothing Then
      Dim msg As String = String.Format("Original type [{0}]     New type [{1}]", annObject.GetType(), annObjectNew.GetType())
      MessageBox.Show(msg)
   End If
End Sub
C#Copy Code
public void DicomAnnotationsUtilities_FromAnnObject()
{
   // Create an AnnRectangleObject
   AnnRectangleObject annObject = new AnnRectangleObject();
   annObject.Pen = new AnnPen(Color.Purple, new AnnLength(5, AnnUnit.Pixel));
   annObject.Brush = new AnnSolidBrush(Color.White);
   annObject.Bounds = new AnnRectangle(400, 100, 500, 200);
   // Create an instance of the converter, and set some properties
   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();
   du.LayerName = "Test Layer Name";

   AnnTextObject defaultAnnObject = new AnnTextObject();
   defaultAnnObject.Pen = annObject.Pen;
   defaultAnnObject.Brush = annObject.Brush;
   du.DefaultObject = defaultAnnObject;

   // Convert to a DicomAnnotationObject
   // Note that there is no DicomAnnotationObject rectangle type, so it is converted to a polyline
   DicomAnnotationObject dicomAnnotationObject = du.FromAnnObject(annObject);

   // Convert back to a LEAD AnnObject
   // Now the LEAD object will be a polyline, even though the original object was a rectangle
   AnnObject annObjectNew = du.ToAnnObject(dicomAnnotationObject) as AnnObject;

   if (annObjectNew != null)
   {
      string msg = string.Format("Original type [{0}]     New type [{1}]", annObject.GetType(), annObjectNew.GetType());
      MessageBox.Show(msg);
   }
}
SilverlightCSharpCopy Code
public void DicomAnnotationsUtilities_FromAnnObject()
{
   // Create an AnnRectangleObject
   AnnRectangleObject annObject = new AnnRectangleObject();
   annObject.Stroke = Color.FromArgb(0xFF, 0x80, 0x00, 0x80); // purple
   annObject.StrokeThickness = 5;
   annObject.Fill = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF); // white
   annObject.Rect = new Rect(400, 100, 500, 200);

   // Create an instance of the converter, and set some properties
   DicomAnnotationsUtilities du = new DicomAnnotationsUtilities();
   AnnTextObject defaultAnnObject = new AnnTextObject();
   defaultAnnObject.Stroke = annObject.Stroke;
   defaultAnnObject.StrokeThickness = annObject.StrokeThickness;
   defaultAnnObject.Fill = annObject.Fill;

   du.DefaultObject = defaultAnnObject;
   du.LayerName = "Test Layer Name";

   // Convert to a DicomAnnotationObject
   DicomAnnotationObject dicomAnnotationObject = du.FromAnnObject(annObject);

   // Convert back to a LEAD AnnObject
   AnnObject annObjectNew = du.ToAnnObject(dicomAnnotationObject) as AnnObject;

   string msg = string.Format("Original type [{0}]     New type [{1}]", annObject.GetType(), annObjectNew.GetType());
   Console.WriteLine(msg);
}
SilverlightVBCopy Code
Public Sub DicomAnnotationsUtilities_FromAnnObject()
   ' Create an AnnRectangleObject
   Dim annObject As AnnRectangleObject = New AnnRectangleObject()
   annObject.Stroke = Color.FromArgb(&HFF, &H80, &H00, &H80) ' purple
   annObject.StrokeThickness = 5
   annObject.Fill = Color.FromArgb(&HFF, &HFF, &HFF, &HFF) ' white
   annObject.Rect = New Rect(400, 100, 500, 200)

   ' Create an instance of the converter, and set some properties
   Dim du As DicomAnnotationsUtilities = New DicomAnnotationsUtilities()
   Dim defaultAnnObject As AnnTextObject = New AnnTextObject()
   defaultAnnObject.Stroke = annObject.Stroke
   defaultAnnObject.StrokeThickness = annObject.StrokeThickness
   defaultAnnObject.Fill = annObject.Fill

   du.DefaultObject = defaultAnnObject
   du.LayerName = "Test Layer Name"

   ' Convert to a DicomAnnotationObject
   Dim dicomAnnotationObject As DicomAnnotationObject = du.FromAnnObject(annObject)

   ' Convert back to a LEAD AnnObject
   Dim annObjectNew As AnnObject = TryCast(du.ToAnnObject(dicomAnnotationObject), AnnObject)

   Dim msg As String = String.Format("Original type [{0}]     New type [{1}]", annObject.GetType(), annObjectNew.GetType())
   Console.WriteLine(msg)
End Sub

Remarks

A Leadtools.Dicom.DicomAnnotationObject has a layer name, but an Leadtools.Annotations.AnnObject does not. Set the LayerName property prior to calling this method. Note that the annObject"annObject"/> is of type Leadtools.Annotations.AnnObject

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