The ToAnnObject Method is available in LEADTOOLS Medical Imaging toolkits.
Converts a
Leadtools.Dicom.DicomAnnotationObject to an
System.Object that is of type AnnObject.
Supported in Silverlight, Windows Phone 7
Syntax
Example
This sample does the following:
- Creates a Leadtools.Dicom.DicomTextObject text object with an anchor
- Creates a converter
- Converts to a LEAD annotation
Visual Basic | Copy 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;
} |
SilverlightCSharp | 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.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;
} |
SilverlightVB | Copy 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
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