Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Public Sub AnnCodecs_Save()
' 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)
MessageBox.Show(String.Format("Before Save: Container has {0} objects", container.Children.Count))
' create a memory stream to save the objects into
Using ms As MemoryStream = New MemoryStream()
' create a new AnnCodecs class
Dim codecs As AnnCodecs = New AnnCodecs()
' save the objects in this container
codecs.Save(ms, container, AnnCodecsFormat.NativeXml, 1, AnnCodecsSavePageMode.Overwrite)
' clear the container
container.Children.Clear()
MessageBox.Show(String.Format("After Save and Clear: Container has {0} objects, Stream size: {1}", container.Children.Count, ms.Length))
' get information about the stream
' note, the Save method does not seek the stream back to its original position, so do that now
ms.Position = 0
Dim information As AnnCodecsInformation = New AnnCodecsInformation()
codecs.GetInformation(ms, information)
MessageBox.Show(String.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages))
' load the objects back from the stream
codecs.Load(ms, container, 1)
MessageBox.Show(String.Format("After Load: Container has {0} objects", container.Children.Count))
End Using
End Sub
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Demos;
using Leadtools.Help;
public void AnnCodecs_Save()
{
// 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);
MessageBox.Show(string.Format("Before Save: Container has {0} objects", container.Children.Count));
// create a memory stream to save the objects into
using (MemoryStream ms = new MemoryStream())
{
// create a new AnnCodecs class
AnnCodecs codecs = new AnnCodecs();
// save the objects in this container
codecs.Save(ms, container, AnnCodecsFormat.NativeXml, 1, AnnCodecsSavePageMode.Overwrite);
// clear the container
container.Children.Clear();
MessageBox.Show(string.Format("After Save and Clear: Container has {0} objects, Stream size: {1}", container.Children.Count, ms.Length));
// get information about the stream
// note, the Save method does not seek the stream back to its original position, so do that now
ms.Position = 0;
AnnCodecsInformation information = new AnnCodecsInformation();
codecs.GetInformation(ms, information);
MessageBox.Show(string.Format("Format: {0}, Number of pages: {1}", information.Format, information.Pages));
// load the objects back from the stream
codecs.Load(ms, container, 1);
MessageBox.Show(String.Format("After Load: Container has {0} objects", container.Children.Count));
}
}
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Examples;
public void AnnCodecs_Save()
{
// 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);
MessageBox.Show(string.Format("Before Save: Container has {0} objects", container.Children.Count));
// create a memory stream to save the objects into
using (MemoryStream ms = new MemoryStream())
{
// save the objects in this container
AnnCodecs.Save(ms, container);
// clear the container
container.Children.Clear();
MessageBox.Show(string.Format("After Save and Clear: Container has {0} objects, Stream size: {1}", container.Children.Count, ms.Length));
// load the objects back from the stream
AnnCodecs.Save(ms, container);
MessageBox.Show(String.Format("After Load: Container has {0} objects", container.Children.Count));
}
}
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Public Sub AnnCodecs_Save()
' 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.Fill = Colors.Transparent
rectObj.StrokeThickness = 1.0
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)
MessageBox.Show(String.Format("Before Save: Container has {0} objects", container.Children.Count))
' create a memory stream to save the objects into
Using ms As MemoryStream = New MemoryStream()
' save the objects in this container
AnnCodecs.Save(ms, container)
' clear the container
container.Children.Clear()
MessageBox.Show(String.Format("After Save and Clear: Container has {0} objects, Stream size: {1}", container.Children.Count, ms.Length))
' load the objects back from the stream
AnnCodecs.Save(ms, container)
MessageBox.Show(String.Format("After Load: Container has {0} objects", container.Children.Count))
End Using
End Sub