If you have two buttons (previous and Next) to show the TIFF file pages, you can handle the annotation objects by using the following code:
+-----------------------+
MemoryStream AnnStream = new MemoryStream();
private void PreviousButton_Click(object sender, EventArgs e)
{
Leadtools.Annotations.AnnCodecs annCodecs = new AnnCodecs();
AnnCodecsInformation AnnInformation = new AnnCodecsInformation();
AnnStream.Seek(0, System.IO.SeekOrigin.Begin);
annCodecs.GetInformation(AnnStream, AnnInformation);
try
{
if (AnnInformation.Pages < rasterImageViewer1.Image.Page)
annCodecs.Save(AnnStream, AutomationAnn.Container, AnnCodecsFormat.Xml, rasterImageViewer1.Image.Page, AnnCodecsSavePageMode.Insert);
else
annCodecs.Save(AnnStream, AutomationAnn.Container, AnnCodecsFormat.Xml, rasterImageViewer1.Image.Page, AnnCodecsSavePageMode.Replace);
}
catch (Exception ex1)
{
}
rasterImageViewer1.Image.Page = rasterImageViewer1.Image.Page - 1;
AutomationAnn.Container.Objects.Clear();
try
{
AnnStream.Seek(0, System.IO.SeekOrigin.Begin);
annCodecs.Load(AnnStream, AutomationAnn.Container, rasterImageViewer1.Image.Page);
}
catch (Exception ex2)
{
}
}
private void NextButton_Click(object sender, EventArgs e)
{
Leadtools.Annotations.AnnCodecs annCodecs = new AnnCodecs();
AnnCodecsInformation AnnInformation = new AnnCodecsInformation();
AnnStream.Seek(0, System.IO.SeekOrigin.Begin);
annCodecs.GetInformation(AnnStream, AnnInformation);
try
{
if (AnnInformation.Pages < rasterImageViewer1.Image.Page)
annCodecs.Save(AnnStream, AutomationAnn.Container, AnnCodecsFormat.Xml, rasterImageViewer1.Image.Page, AnnCodecsSavePageMode.Insert);
else
annCodecs.Save(AnnStream, AutomationAnn.Container, AnnCodecsFormat.Xml, rasterImageViewer1.Image.Page, AnnCodecsSavePageMode.Replace);
}
catch (Exception ex1)
{
}
rasterImageViewer1.Image.Page = rasterImageViewer1.Image.Page + 1;
AutomationAnn.Container.Objects.Clear();
try
{
AnnStream.Seek(0, System.IO.SeekOrigin.Begin);
annCodecs.Load(AnnStream, AutomationAnn.Container, rasterImageViewer1.Image.Page);
}
catch(Exception ex2)
{
}
}
+-----------------------+
Thanks,
Maen Badwan
LEADTOOLS Technical Support