Saves an array of AnnContainer to a multipage annotation disk file
public void Save(string fileName,Leadtools.Annotations.AnnContainer[] containers,Leadtools.Annotations.AnnCodecsFormat format)
Public Overloads Sub Save( _ByVal fileName As String, _ByVal containers() As Leadtools.Annotations.AnnContainer, _ByVal format As Leadtools.Annotations.AnnCodecsFormat _)
public:void Save(String^ fileName,Leadtools.Annotations.array<AnnContainer^>^ containers,Leadtools.Annotations.AnnCodecsFormat format)
fileName
The output file name.
containers
An array of AnnContainer containing the objects to be saved.
format
An AnnCodecsFormat value that specifies the annotation format to use when saving.
This method saves the entire array of AnnContainer as a multipage annotation file, with each page corresponding to one of the AnnContainer. If fileName already exists, it will be overwritten. If containers contain many AnnContainer, then this method will create the multipage annotation file much faster than repeated calls to Save(String,AnnContainer,AnnCodecsFormat,Int32,AnnCodecsSavePageMode)
This method only supports the AnnCodecsFormat.Xml format. All other AnnCodecsFormat are not supported.
For more information, refer to Annotation Files (Deprecated).
using Leadtools;using Leadtools.Annotations;using Leadtools.Codecs;using Leadtools.WinForms;public void AnnCodecs_Save2(){// create three annotation containers// The first container contains a rectangle objectAnnContainer container0 = new AnnContainer();AnnRectangleObject rectObj = new AnnRectangleObject();rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));rectObj.Brush = null;container0.Objects.Add(rectObj);// The second container contains a line objectAnnContainer container1 = new AnnContainer();AnnLineObject lineObj = new AnnLineObject();lineObj.StartPoint = new AnnPoint(100, 100, AnnUnit.Pixel);lineObj.EndPoint = new AnnPoint(200, 200, AnnUnit.Pixel);lineObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));container1.Objects.Add(lineObj);// The third container contains a ellipse objectAnnContainer container2 = new AnnContainer();AnnEllipseObject ellipseObj = new AnnEllipseObject();ellipseObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);ellipseObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));ellipseObj.Brush = null;container2.Objects.Add(ellipseObj);// create a file to save both annotation containersstring annFileName = Path.GetTempFileName();// create a new AnnCodecs classAnnCodecs codecs = new AnnCodecs();// save both AnnContainers into the streamcodecs.Save(annFileName, container0, AnnCodecsFormat.Xml, 1, AnnCodecsSavePageMode.Overwrite);codecs.Save(annFileName, container1, AnnCodecsFormat.Xml, 2, AnnCodecsSavePageMode.Insert);// Now load both containers from the stream, and verify that there are two containersAnnContainer[] containersTwo = codecs.Load(annFileName);MessageBox.Show(String.Format("After Load: there should be 2 containers. Total number of containers: {0}", containersTwo.Length));// Add another container, and save to the streamAnnContainer[] containersNew = new AnnContainer[containersTwo.Length + 1];Array.Copy(containersTwo, containersNew, containersTwo.Length);containersNew[2] = container2;codecs.Save(annFileName, containersNew, AnnCodecsFormat.Xml);// Load and verify that there are three containersAnnContainer[] containersThree = codecs.Load(annFileName);MessageBox.Show(String.Format("After Load: there should be 3 containers. Total number of containers: {0}", containersThree.Length));}
Imports LeadtoolsImports Leadtools.AnnotationsImports Leadtools.CodecsImports Leadtools.WinFormsPublic Sub AnnCodecs_Save2()' create three annotation containers' The first container contains a rectangle objectDim container0 As New AnnContainer()Dim rectObj As New AnnRectangleObject()rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))rectObj.Brush = Nothingcontainer0.Objects.Add(rectObj)' The second container contains a line objectDim container1 As New AnnContainer()Dim lineObj As New AnnLineObject()lineObj.StartPoint = New AnnPoint(100, 100, AnnUnit.Pixel)lineObj.EndPoint = New AnnPoint(200, 200, AnnUnit.Pixel)lineObj.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))container1.Objects.Add(lineObj)' The third container contains a ellipse objectDim container2 As New AnnContainer()Dim ellipseObj As New AnnEllipseObject()ellipseObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)ellipseObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))ellipseObj.Brush = Nothingcontainer2.Objects.Add(ellipseObj)' create a file to save both annotation containersDim annFileName As String = Path.GetTempFileName()' create a new AnnCodecs classDim codecs As New AnnCodecs()' save both AnnContainers into the streamcodecs.Save(annFileName, container0, AnnCodecsFormat.Xml, 1, AnnCodecsSavePageMode.Overwrite)codecs.Save(annFileName, container1, AnnCodecsFormat.Xml, 2, AnnCodecsSavePageMode.Insert)' Now load both containers from the stream, and verify that there are two containersDim containersTwo() As AnnContainer = codecs.Load(annFileName)MessageBox.Show(String.Format("After Load: there should be 2 containers. Total number of containers: {0}", containersTwo.Length))' Add another container, and save to the streamDim containersNew(containersTwo.Length) As AnnContainerArray.Copy(containersTwo, containersNew, containersTwo.Length)containersNew(2) = container2codecs.Save(annFileName, containersNew, AnnCodecsFormat.Xml)' Load and verify that there are three containersDim containersThree() As AnnContainer = codecs.Load(annFileName)MessageBox.Show(String.Format("After Load: there should be 3 containers. Total number of containers: {0}", containersThree.Length))End Sub
|
Products |
Support |
Feedback: Save(String,AnnContainer[],AnnCodecsFormat) Method - Leadtools.Annotations |
Introduction |
Help Version 19.0.2017.6.20
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.