Perform the following steps to create and run a program that implements Automated Annotations:
In the "Solution Explorer" window, right-click the "References" folder, and choose "Add Reference…" from the context menu. In the "Add Reference" dialog box, select the ".NET" tab and browse to the "<LEADTOOLS_INSTALLDIR>\Bin\DotNet4\Win32 " folder and select the following DLLs:
Click Add and then click OK to add the above DLLs to the application.
Switch to Form1 code view (right-click Form1 in the Solution Explorer and then choose View Code) and add the following lines at the beginning of the file:
Imports LeadtoolsImports Leadtools.Annotations.EngineImports Leadtools.Annotations.DesignersImports Leadtools.Annotations.AutomationImports Leadtools.CodecsImports Leadtools.ControlsImports Leadtools.Annotations.WinForms
using Leadtools;using Leadtools.Annotations.Engine;using Leadtools.Annotations.Designers;using Leadtools.Annotations.Automation;using Leadtools.Codecs;using Leadtools.Controls;using Leadtools.Annotations.WinForms;
Declare the following private variables:
Private automationControl As ImageViewerAutomationControlPrivate viewer As ImageViewer' The Automation Manager is used to manage the automation mode.Private annAutomationManager As AnnAutomationManagerPrivate WithEvents automation As AnnAutomation
private ImageViewer viewer;private ImageViewerAutomationControl automationControl;// The Automation Manager is used to manage the automation mode.private AnnAutomationManager annAutomationManager;private AnnAutomation automation;
Add an event handler to the Form1 Load event and code it as follows:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Loadviewer = New ImageViewer()viewer.Dock = DockStyle.FillautomationControl = New ImageViewerAutomationControl()automationControl.ImageViewer = viewer' initialize a new RasterCodecs objectDim codecs As New RasterCodecs()' load the main image into the viewerviewer.Image = codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\Sample1.cmp")'initialize the interactive mode for the viewerDim automationInteractiveMode As AutomationInteractiveMode = New AutomationInteractiveMode()automationInteractiveMode.AutomationControl = automationControl'add the interactive mode to the viewerviewer.InteractiveModes.BeginUpdate()viewer.InteractiveModes.Add(automationInteractiveMode)viewer.InteractiveModes.EndUpdate()If(Not IsNothing(viewer.Image)) Then' create and set up the automation managerannAutomationManager = New AnnAutomationManagerannAutomationManager.RestrictDesigners = True' Instruct the manager to create all of the default automation objects.annAutomationManager.CreateDefaultObjects()Dim managerHelper As AutomationManagerHelper = New AutomationManagerHelper(annAutomationManager)managerHelper.CreateToolBar()Controls.Add(managerHelper.ToolBar)Controls.Add(viewer)' set up the automation (it will create the container as well)automation = New AnnAutomation(annAutomationManager, automationControl)' set this automation as the active oneautomation.Active = Trueautomation.Container.Size = automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(viewer.Image.ImageWidth, viewer.Image.ImageHeight))End IfEnd Sub
private void Form1_Load(object sender, System.EventArgs e){viewer = new ImageViewer();viewer.Dock = DockStyle.Fill;automationControl = new ImageViewerAutomationControl();automationControl.ImageViewer = viewer;// initialize a new RasterCodecs objectRasterCodecs codecs = new RasterCodecs();// load the main image into the viewerviewer.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\Sample1.cmp");// initialize the interactive mode for the viewerAutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();automationInteractiveMode.AutomationControl = automationControl;// add the interactive mode to the viewerviewer.InteractiveModes.BeginUpdate();viewer.InteractiveModes.Add(automationInteractiveMode);viewer.InteractiveModes.EndUpdate();if (viewer.Image != null){// create and set up the automation managerannAutomationManager = new AnnAutomationManager();annAutomationManager.RestrictDesigners = true;// Instruct the manager to create all of the default automation objects.annAutomationManager.CreateDefaultObjects();// initialize the manager helper and create the toolbar and add it then the viewer to the controlsAutomationManagerHelper managerHelper = new AutomationManagerHelper(annAutomationManager);managerHelper.CreateToolBar();Controls.Add(managerHelper.ToolBar);Controls.Add(viewer);// set up the automation (it will create the container as well)automation = new AnnAutomation(annAutomationManager, automationControl);// set this automation as the active oneautomation.Active = true;//set the size of the container to the size of the viewerautomation.Container.Size = automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(viewer.Image.ImageWidth, viewer.Image.ImageHeight));}}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
