LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
AnnCodecs Class
See Also  Members  
Leadtools.Windows.Annotations Namespace : AnnCodecs Class



The AnnCodecs Class supports WPF/Silverlight.

The AnnCodecs Class is available in LEADTOOLS Document and Medical Imaging toolkits.

Provides support for loading and saving objects to annotation files. Supported in Silverlight, Windows Phone 7

Object Model

AnnCodecs Class

Syntax

Visual Basic (Declaration) 
Public Class AnnCodecs 
Visual Basic (Usage)Copy Code
Dim instance As AnnCodecs
C# 
public class AnnCodecs 
C++/CLI 
public ref class AnnCodecs 

Example

This example saves the objects from an existing container to a disk file and loads them back.

Visual BasicCopy Code
Public Sub AnnCodecs_AnnCodecs(ByVal fileName As String)
   ' create a new annotation container
   Dim container As AnnContainer = New AnnContainer()
   ' add a few objects into the container

   Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
   rectObj.Rect = New Rect(100, 100, 100, 100)
   rectObj.Stroke = Colors.Blue
   rectObj.StrokeThickness = 1.0
   rectObj.Fill = Nothing
   container.Children.Add(rectObj)

   Dim lineObj As AnnLineObject = New AnnLineObject()
   lineObj.Start = New Point(100, 100)
   lineObj.End = New Point(200, 200)
   lineObj.Stroke = Colors.Red
   lineObj.StrokeThickness = 1.0

   container.Children.Add(lineObj)

   ' create a new AnnCodecs class
   Dim codecs As AnnCodecs = New AnnCodecs()

   ' save this container into a file
   ' save the objects in this container
   codecs.Save(fileName, container, AnnCodecsFormat.NativeXml, 1, AnnCodecsSavePageMode.Overwrite)

   ' get information about the file
   Dim information As AnnCodecsInformation = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))

   ' save the objects again (as a second page)
   codecs.Save(fileName, container, AnnCodecsFormat.NativeXml, 2, AnnCodecsSavePageMode.Insert)

   ' get information about the file
   information = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))

   ' delete the first page
   codecs.DeletePage(fileName, 1)

   ' get information about the file
   information = New AnnCodecsInformation()
   codecs.GetInformation(fileName, information)
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))
End Sub
C#Copy Code
public void AnnCodecs_AnnCodecs(string fileName)
{
   // create a new annotation container
   AnnContainer container = new AnnContainer();
   // add a few objects into the container

   AnnRectangleObject rectObj = new AnnRectangleObject();

   rectObj.Rect = new Rect(100,100,100,100);
   rectObj.Stroke = Colors.Blue;
   rectObj.Fill = Colors.Transparent;
   rectObj.StrokeThickness = 1.0;
   container.Children.Add(rectObj);

   AnnLineObject lineObj = new AnnLineObject();
   lineObj.Start = new Point(100,100);
   lineObj.End = new Point(200, 200);
   lineObj.Stroke = Colors.Red;
   lineObj.StrokeThickness = 1.0;

   container.Children.Add(lineObj);

   // create a new AnnCodecs class
   AnnCodecs codecs = new AnnCodecs();

   // save this container into a file
   // save the objects in this container
   codecs.Save(fileName, container, AnnCodecsFormat.NativeXml, 1, AnnCodecsSavePageMode.Overwrite);

   // get information about the file
   AnnCodecsInformation information = new AnnCodecsInformation();
   codecs.GetInformation(fileName, information);
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));

   // save the objects again (as a second page)
   codecs.Save(fileName, container, AnnCodecsFormat.NativeXml, 2, AnnCodecsSavePageMode.Insert);

   // get information about the file
   information = new AnnCodecsInformation();
   codecs.GetInformation(fileName, information);
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));

   // delete the first page
   codecs.DeletePage(fileName, 1);

   // get information about the file
   information = new AnnCodecsInformation();
   codecs.GetInformation(fileName, information);
   MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));
}
SilverlightCSharpCopy Code
SilverlightVBCopy Code

Remarks

This class supports loading and saving annotation objects from and to disk files and to memory stream as well as getting information on information objects saved in a disk file or a memory stream.

This class also supports saving and loading multi-page annotation files or streams.

Inheritance Hierarchy

System.Object
   Leadtools.Windows.Annotations.AnnCodecs

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

AnnCodecs requires a Document/Medical product license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features and Unlocking Special LEAD Features.