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 Leadtools
Imports Leadtools.Annotations.Engine
Imports Leadtools.Annotations.Designers
Imports Leadtools.Annotations.Automation
Imports Leadtools.Codecs
Imports Leadtools.Controls
Imports 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 ImageViewerAutomationControl
Private viewer As ImageViewer
' The Automation Manager is used to manage the automation mode.
Private annAutomationManager As AnnAutomationManager
Private 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.Load
viewer = New ImageViewer()
viewer.Dock = DockStyle.Fill
automationControl = New ImageViewerAutomationControl()
automationControl.ImageViewer = viewer
' initialize a new RasterCodecs object
Dim codecs As New RasterCodecs()
' load the main image into the viewer
viewer.Image = codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\Sample1.cmp")
'initialize the interactive mode for the viewer
Dim automationInteractiveMode As AutomationInteractiveMode = New AutomationInteractiveMode()
automationInteractiveMode.AutomationControl = automationControl
'add the interactive mode to the viewer
viewer.InteractiveModes.BeginUpdate()
viewer.InteractiveModes.Add(automationInteractiveMode)
viewer.InteractiveModes.EndUpdate()
If(Not IsNothing(viewer.Image)) Then
' create and set up the automation manager
annAutomationManager = New AnnAutomationManager
annAutomationManager.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 one
automation.Active = True
automation.Container.Size = automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(viewer.Image.ImageWidth, viewer.Image.ImageHeight))
End If
End 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 object
RasterCodecs codecs = new RasterCodecs();
// load the main image into the viewer
viewer.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\Sample1.cmp");
// initialize the interactive mode for the viewer
AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();
automationInteractiveMode.AutomationControl = automationControl;
// add the interactive mode to the viewer
viewer.InteractiveModes.BeginUpdate();
viewer.InteractiveModes.Add(automationInteractiveMode);
viewer.InteractiveModes.EndUpdate();
if (viewer.Image != null)
{
// create and set up the automation manager
annAutomationManager = 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 controls
AutomationManagerHelper 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 one
automation.Active = true;
//set the size of the container to the size of the viewer
automation.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
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.