←Select platform

AttachContainer Method

Summary
Attaches this AnnAutomation object to a container and optional undo/redo object.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public virtual void AttachContainer( 
   AnnContainer container, 
   AnnAutomationUndoRedoObject undoRedoObject 
) 
- (void)attachContainer:(nullable LTAnnContainer *)container undoRedo:(nullable LTAnnAutomationUndoRedoObject *)undoRedoObject NS_SWIFT_NAME(attach(_:undoRedo:)); 
public void attachContainer(AnnContainer container, AnnAutomationUndoRedoObject undoRedoObject); 
public:  
   virtual void AttachContainer( 
      AnnContainer^ container, 
      AnnAutomationUndoRedoObject^ undoRedoObject 
   ) 
def AttachContainer(self,container,undoRedoObject): 

Parameters

container
The annotation container to attach this automation to. This value cannot be null.

undoRedoObject
Optional undo/redo object that contains the internal data.

Remarks

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.

Example

This example will show how a multipage annotation application would use a single automation object to annotate multiple containers.

C#
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}"); 
   } 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Annotations.Automation Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.