public virtual void AttachContainer(
AnnContainer container,
AnnAutomationUndoRedoObject undoRedoObject
)
container
The annotation container to attach this automation to. This value cannot be null.
undoRedoObject
Optional undo/redo object that contains the internal data.
You can use this method to attach this AnnAutomation object to an existing container. This could be useful in a multipage annotation application for instance as shown in the example.
undoRedoObject must be either null or the value returned from GetUndoRedoObject that holds the data the previous time container was attached to this automation object.
This example will show how a multipage annotation application would use a single automation object to annotate multiple containers.
using Leadtools.Annotations.Automation;
using Leadtools.Annotations.Engine;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Annotations.Rendering;
using Leadtools.Annotations.WinForms;
public void AnnAutomation_AttachContainer()
{
// create a new annotation object
_automation = new AnnAutomation(_manager, _viewer);
AnnRedactionObject redaction = new AnnRedactionObject();
redaction.Rect = LeadRectD.Create(100, 100, 200, 200);
redaction.Fill = AnnSolidColorBrush.Create("red");
for (int page = 1; page <= _viewer.Image.PageCount; page++)
{
_automation.Container.Children.Add(redaction);
}
//Invalidate the AnnAutomation
_automation.Invalidate(LeadRectD.Empty);
//Realize all AnnRedactionObjects
//Both firstRedaction and secondRedaction are burned to the image
_automation.RealizeAllRedactions();
//Select the first AnnRedactionObject
_automation.SelectObject(redaction);
//Restore the image data that was previously redacted by firstRedaction
//The image data redacted by secondRedaction will remain redacted
_automation.RestoreRedaction();
// AnnAutomation Undo on properties just changed: CanCopy, CanDeleteObject, CanFlip, CanLock
_automation.Undo();
// Create a new annotation container and attach
AnnContainer container = new AnnContainer();
// Size in annotation units (1/720 of an inch) and attaching container
container.Size = LeadSizeD.Create(8.5 * 720, 11 * 720);
AnnAutomationUndoRedoObject annAutomationUndoRedoObject = _automation.GetUndoRedoObject();
_automation.AttachContainer(container, annAutomationUndoRedoObject);
// List of available annotation objects
AnnAutomationManager annAutomationManager = _automation.Manager;
Debug.WriteLine($"\nList of Available Annotation Objects:\n");
foreach (var annAutoManagerObject in annAutomationManager.Objects)
{
Debug.WriteLine($"* {annAutoManagerObject.Name}");
}
}