Gets or sets the id of this AnnAutomationObject.
Object.defineProperty(AnnAutomationObject.prototype, 'id',get: function(),set: function(value))
The id of this AnnAutomationObject. The default value is 0.
Each automation object must have an object id that is a unique integer value. The AnnAutomationManager class defines the object ids for the default annotation objects such as EllipseObjectId and RectangleObjectId. For user-defined objects, use UserObjectId first then add 1 to this value for each new user object.
export class AutomationHelper {private automation: lt.Annotations.Automation.AnnAutomation = null;constructor() {lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null);}public run(callback?: (automation: lt.Annotations.Automation.AnnAutomation) => void): void {// Create the viewerconst imageViewerDiv = document.getElementById("imageViewerDiv");const createOptions: lt.Controls.ImageViewerCreateOptions = new lt.Controls.ImageViewerCreateOptions(imageViewerDiv);const viewer: lt.Controls.ImageViewer = new lt.Controls.ImageViewer(createOptions);viewer.autoCreateCanvas = true;// PanZoom interactive modeconst panZoom: lt.Controls.ImageViewerPanZoomInteractiveMode = new lt.Controls.ImageViewerPanZoomInteractiveMode();// Create an instance of the Automation control object that works with LEADTOOLS ImageViewerconst imageViewerAutomationControl: lt.Demos.Annotations.ImageViewerAutomationControl = new lt.Demos.Annotations.ImageViewerAutomationControl();// Attach our image viewerimageViewerAutomationControl.imageViewer = viewer;// Set the image viewer interactive modeconst automationInteractiveMode: lt.Demos.Annotations.AutomationInteractiveMode = new lt.Demos.Annotations.AutomationInteractiveMode();automationInteractiveMode.automationControl = imageViewerAutomationControl;// Set the image URLviewer.imageUrl = "http://demo.leadtools.com/images/png/pngimage.png";// Create and set up the automation manager using the HTML5 rendering engineconst renderingEngine: lt.Annotations.Rendering.AnnHtml5RenderingEngine = new lt.Annotations.Rendering.AnnHtml5RenderingEngine();const manager: lt.Annotations.Automation.AnnAutomationManager = lt.Annotations.Automation.AnnAutomationManager.create(renderingEngine);// Create only the line and rectangle automation objectsthis.createMyAutomationObjects(manager);// You can instruct the manager to create the default (all) automation objects.// comment out the call to CreateMyAutomationObjects and call this instead://manager.createDefaultObjects();// Add the objects to the objects select elementconst currentObjectIdSelect = document.getElementById("currentObjectIdSelect") as HTMLSelectElement;// Add the PanZoom optioncurrentObjectIdSelect.options[currentObjectIdSelect.options.length] = new Option("Pan/Zoom", lt.Annotations.Engine.AnnObject.none.toString());const automationObjCount: number = manager.objects.count;for (let i = 0; i < automationObjCount; i++) {// Get the objectconst automationObj: lt.Annotations.Automation.AnnAutomationObject = manager.objects.item(i);// Add its name to the select elementconst name: string = automationObj.name;const id: number = automationObj.id;currentObjectIdSelect.options[currentObjectIdSelect.options.length] = new Option(name, id.toString());}// Hook to its change eventcurrentObjectIdSelect.addEventListener("change", () => {// Get the object IDconst id: number = parseInt(currentObjectIdSelect.options[currentObjectIdSelect.selectedIndex].value);// Set it as the current object in the managermanager.currentObjectId = id;// If this is the "Pan/Zoom" option, then back to pan zoom, otherwise, set our automation controlif (id == lt.Annotations.Engine.AnnObject.none) {viewer.defaultInteractiveMode = panZoom;}else {viewer.defaultInteractiveMode = automationInteractiveMode;}});// When the current object ID changes, we need to update our selectmanager.add_currentObjectIdChanged((sender, e) => {const currentObjectId: number = manager.currentObjectId;for (let i = 0; i < currentObjectIdSelect.options.length; i++) {const id: number = parseInt(currentObjectIdSelect.options[i].value);if (id === currentObjectId) {currentObjectIdSelect.selectedIndex = i;break;}}});// Pan zoom by defaultviewer.defaultInteractiveMode = panZoom;// Set up the automation (will create the container as well)const automation: lt.Annotations.Automation.AnnAutomation = new lt.Annotations.Automation.AnnAutomation(manager, imageViewerAutomationControl);this.automation = automation;// Add handler to update the container size when the image size changesviewer.itemChanged.add((sender, e) => {const container: lt.Annotations.Engine.AnnContainer = automation.container;container.size = container.mapper.sizeToContainerCoordinates(viewer.imageSize);// Create new canvas data provider for the new imageconst canvasDataProvider: lt.Demos.Annotations.CanvasDataProvider = new lt.Demos.Annotations.CanvasDataProvider(viewer.activeItem.canvas);imageViewerAutomationControl.automationDataProvider = canvasDataProvider;});// Set up this automation as the active onethis.automation.active = true;if(callback)callback(this.automation);}private createMyAutomationObjects(manager): void {// Get the automation objects collectionconst automationObjects = manager.objects;// Set up the select automation objectconst selectAutomationObj: lt.Annotations.Automation.AnnAutomationObject = new lt.Annotations.Automation.AnnAutomationObject();selectAutomationObj.id = lt.Annotations.Engine.AnnObject.selectObjectId;selectAutomationObj.name = "Select";selectAutomationObj.drawDesignerType = lt.Annotations.Designers.AnnRectangleDrawDesigner;selectAutomationObj.editDesignerType = lt.Annotations.Designers.AnnSelectionEditDesigner;selectAutomationObj.runDesignerType = null;// Create the object template for itconst selectObj: lt.Annotations.Engine.AnnSelectionObject = new lt.Annotations.Engine.AnnSelectionObject();selectObj.stroke = lt.Annotations.Engine.AnnStroke.create(lt.Annotations.Engine.AnnSolidColorBrush.create("darkgreen"), lt.LeadLengthD.create(2));selectAutomationObj.objectTemplate = selectObj;// Add it to the automation objects of the managerautomationObjects.add(selectAutomationObj);// Set up the line automation objectconst lineAutomationObj: lt.Annotations.Automation.AnnAutomationObject = new lt.Annotations.Automation.AnnAutomationObject();lineAutomationObj.id = lt.Annotations.Engine.AnnObject.lineObjectId;lineAutomationObj.name = "Line";lineAutomationObj.drawDesignerType = lt.Annotations.Designers.AnnLineDrawDesigner;lineAutomationObj.editDesignerType = lt.Annotations.Designers.AnnPolylineEditDesigner;lineAutomationObj.runDesignerType = lt.Annotations.Designers.AnnRunDesigner;// Create the object template for it, use the default strokeconst lineObj: lt.Annotations.Engine.AnnPolylineObject = new lt.Annotations.Engine.AnnPolylineObject();lineAutomationObj.objectTemplate = lineObj;// Add it to the automation objects of the managerautomationObjects.add(lineAutomationObj);// Set up the rectangle automation objectconst rectAutomationObj: lt.Annotations.Automation.AnnAutomationObject = new lt.Annotations.Automation.AnnAutomationObject();rectAutomationObj.id = lt.Annotations.Engine.AnnObject.rectangleObjectId;rectAutomationObj.name = "Rectangle";rectAutomationObj.drawDesignerType = lt.Annotations.Designers.AnnRectangleDrawDesigner;rectAutomationObj.editDesignerType = lt.Annotations.Designers.AnnRectangleEditDesigner;rectAutomationObj.runDesignerType = lt.Annotations.Designers.AnnRunDesigner;// Create the object template for it, use the default stroke and fillconst rectObj: lt.Annotations.Engine.AnnRectangleObject = new lt.Annotations.Engine.AnnRectangleObject();rectAutomationObj.set_objectTemplate(rectObj);// Add it to the automation objects of the managerautomationObjects.add(rectAutomationObj);const textAutomationObj: lt.Annotations.Automation.AnnAutomationObject = new lt.Annotations.Automation.AnnAutomationObject();textAutomationObj.id = lt.Annotations.Engine.AnnObject.textObjectId;textAutomationObj.name = "Text";textAutomationObj.drawDesignerType = lt.Annotations.Designers.AnnRectangleDrawDesigner;textAutomationObj.editDesignerType = lt.Annotations.Designers.AnnTextEditDesigner;textAutomationObj.runDesignerType = lt.Annotations.Designers.AnnRunDesigner;// Create the object template for it, use the default stroke, fill, text and fontconst textObj: lt.Annotations.Engine.AnnTextObject = new lt.Annotations.Engine.AnnTextObject();textAutomationObj.objectTemplate = textObj;// Add it to the automation objects of the managerautomationObjects.add(textAutomationObj);}}