Provides support for loading and saving objects to annotation files.
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 Basic | Copy Code |
---|
Public Sub AnnCodecs_AnnCodecs(ByVal fileName As String)
Dim container As AnnContainer = New AnnContainer()
Dim rectObj As AnnRectangleObject = New AnnRectangleObject()
rectObj.Left = 100
rectObj.Top = 100
rectObj.Width = 100
rectObj.Height = 100
rectObj.Stroke = Brushes.Blue
rectObj.StrokeThickness = 1.0
rectObj.Fill = Nothing
container.Children.Add(rectObj)
Dim lineObj As AnnLineObject = New AnnLineObject()
lineObj.X1 = 100
lineObj.Y1 = 100
lineObj.X2 = 200
lineObj.Y2 = 200
lineObj.Stroke = Brushes.Red
lineObj.StrokeThickness = 1.0
container.Children.Add(lineObj)
Dim codecs As AnnCodecs = New AnnCodecs()
codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 1, AnnCodecsSavePageMode.Overwrite)
Dim information As AnnCodecsInformation = New AnnCodecsInformation()
codecs.GetInformation(fileName, information)
MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))
codecs.Save(fileName, container, AnnCodecsFormat.Serialize, 2, AnnCodecsSavePageMode.Insert)
information = New AnnCodecsInformation()
codecs.GetInformation(fileName, information)
MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))
codecs.DeletePage(fileName, 1)
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.Left = 100; rectObj.Top = 100; rectObj.Width = 100; rectObj.Height = 100; rectObj.Stroke = Brushes.Blue; rectObj.StrokeThickness = 1.0; rectObj.Fill = null; container.Children.Add(rectObj); AnnLineObject lineObj = new AnnLineObject(); lineObj.X1 = 100; lineObj.Y1 = 100; lineObj.X2 = 200; lineObj.Y2 = 200; lineObj.Stroke = Brushes.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.Serialize, 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.Serialize, 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)); } |
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also