Manages the automation mode for an annotation application.
public class AnnAutomationManager : IDisposable Public Class AnnAutomationManagerImplements System.IDisposable
public ref class AnnAutomationManager : public System.IDisposable The AnnAutomationManager class holds the collection of all AnnAutomation objects in the application as well the annotation toolbar. Cursor, keyboard, context sensitive menus, property dialogs and various other user interface options and settings are stored here as well.
An automated annotation application usually creates one AnnAutomationManager object per application.
This example creates an automated annotation application. This example will only use the line and rectangle objects. The example lets you select objects from the toolbar, draw objects on top of the image, select objects and move them or change them, right click on any object to show its properties, etc.
using Leadtools;using Leadtools.Annotations;using Leadtools.WinForms;using Leadtools.Codecs;class MyForm1 : Form{AnnAutomationManager manager;RasterImageViewer viewer;RasterCodecs codecs;public MyForm1(string title){Text = title;Size = new Size(400, 400);viewer = new RasterImageViewer();viewer.Dock = DockStyle.Fill;Controls.Add(viewer);viewer.BringToFront();// load an image into the viewercodecs = new RasterCodecs();string fileName = Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp");viewer.Image = codecs.Load(fileName);// create and set up the automation managermanager = new AnnAutomationManager();// Create only the line and rectangle automation objectsCreateMyAutomationObjects(manager);// You can instruct the manager to create the default (all) automation objects.// comment out the call to CreateMyAutomationObjects and call this instead://theManager.CreateDefaultObjects();// Disable some of the property dialogs// In this case, we hide the 'Hyperlink' and 'Fixed' annotation property pagesmanager.HidePropertiesTabs = AnnAutomationHidePropertiesTabs.Hyperlink | AnnAutomationHidePropertiesTabs.Fixed;// create the toolbar and add it to the formmanager.CreateToolBar();Controls.Add(manager.ToolBar);// set up the automation (will create the container as well)AnnAutomation automation = new AnnAutomation(manager, viewer);// set up this automation as the active oneautomation.Active = true;}private void CreateMyAutomationObjects(AnnAutomationManager manager){// set up the select automation objectAnnAutomationObject selObj = new AnnAutomationObject();selObj.Id = AnnAutomationManager.SelectObjectId;selObj.Name = "Select";selObj.Object = null;selObj.DrawDesignerType = null;selObj.EditDesignerType = null;selObj.RunDesignerType = null;// create the toolbar button (or you can load the image from a disk file or resource)Bitmap btmp = new Bitmap(16, 16);using (Graphics graphics = Graphics.FromImage(btmp)){graphics.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, 16, 16));graphics.DrawLine(Pens.Black, 4, 4, 12, 12);graphics.DrawLine(Pens.Black, 4, 12, 12, 4);}selObj.ToolBarImage = btmp;selObj.ToolBarToolTipText = "Select";selObj.DrawCursor = Cursors.Default;selObj.ContextMenu = null;manager.Objects.Add(selObj);// set up the line automation objectAnnAutomationObject lineObj = new AnnAutomationObject();lineObj.Id = AnnAutomationManager.LineObjectId;lineObj.Name = "Line";AnnLineObject line = new AnnLineObject();line.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));lineObj.Object = line;lineObj.DrawDesignerType = typeof(AnnLineDrawDesigner);lineObj.EditDesignerType = typeof(AnnLineEditDesigner);lineObj.RunDesignerType = typeof(AnnRunDesigner);btmp = new Bitmap(16, 16);using (Graphics graphics = Graphics.FromImage(btmp)){graphics.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, 16, 16));graphics.DrawLine(Pens.Black, 4, 12, 12, 4);}lineObj.ToolBarImage = btmp;lineObj.ToolBarToolTipText = "Draw new line object";lineObj.DrawCursor = Cursors.Cross;lineObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(lineObj.Id);manager.Objects.Add(lineObj);// set up the rectangle automation objectAnnAutomationObject rectObj = new AnnAutomationObject();rectObj.Id = AnnAutomationManager.RectangleObjectId;rectObj.Name = "Rectangle";AnnRectangleObject rect = new AnnRectangleObject();rect.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));rect.Brush = new AnnSolidBrush(Color.White);rectObj.Object = rect;rectObj.DrawDesignerType = typeof(AnnRectangleDrawDesigner);rectObj.EditDesignerType = typeof(AnnRectangleEditDesigner);rectObj.RunDesignerType = typeof(AnnRunDesigner);btmp = new Bitmap(16, 16);using (Graphics graphics = Graphics.FromImage(btmp)){graphics.FillRectangle(SystemBrushes.Control, new Rectangle(0, 0, 16, 16));graphics.DrawRectangle(Pens.Black, 2, 4, 10, 8);}rectObj.ToolBarImage = btmp;rectObj.ToolBarToolTipText = "Draw new rectangle object";rectObj.DrawCursor = Cursors.Cross;rectObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(rectObj.Id);manager.Objects.Add(rectObj);// set up the group automation object (always needed)AnnAutomationObject groupObj = new AnnAutomationObject();groupObj.Id = AnnAutomationManager.GroupObjectId;groupObj.Name = "Group";groupObj.Object = new AnnGroupObject();groupObj.DrawDesignerType = null;groupObj.EditDesignerType = typeof(AnnNewGroupEditDesigner);groupObj.RunDesignerType = typeof(AnnRunDesigner);groupObj.ToolBarImage = null; // group is not in the toolbargroupObj.ToolBarToolTipText = null;groupObj.DrawCursor = null;groupObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(groupObj.Id);manager.Objects.Add(groupObj);}}public void AnnAutomationManager_AnnAutomationManager(string title){MyForm1 form = new MyForm1(title);form.ShowDialog();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports LeadtoolsImports Leadtools.AnnotationsImports Leadtools.WinFormsImports Leadtools.CodecsPrivate Class MyForm1 : Inherits FormPrivate manager As AnnAutomationManagerPrivate viewer As RasterImageViewerPrivate codecs As RasterCodecsPublic Sub New(ByVal title As String)Text = titleSize = New Size(400, 400)viewer = New RasterImageViewer()viewer.Dock = DockStyle.FillControls.Add(viewer)viewer.BringToFront()' load an image into the viewercodecs = New RasterCodecs()viewer.Image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "image1.cmp")) ' fix this path to an existing image file on your system' create and set up the automation managermanager = New AnnAutomationManager()' Create only the line and rectangle automation objectsCreateMyAutomationObjects(manager)' You can instruct the manager to create the default (all) automation objects.' comment out the call to CreateMyAutomationObjects and call this instead:'theManager.CreateDefaultObjects();' Disable some of the property dialogs' In this case, we hide the 'Hyperlink' and 'Fixed' annotation property pagesmanager.HidePropertiesTabs = AnnAutomationHidePropertiesTabs.Hyperlink Or AnnAutomationHidePropertiesTabs.Fixed' create the toolbar and add it to the formmanager.CreateToolBar()Controls.Add(manager.ToolBar)' set up the automation (will create the container as well)Dim automation As AnnAutomation = New AnnAutomation(manager, viewer)' set up this automation as the active oneautomation.Active = TrueEnd SubPrivate Sub CreateMyAutomationObjects(ByVal manager As AnnAutomationManager)' set up the select automation objectDim selObj As AnnAutomationObject = New AnnAutomationObject()selObj.Id = AnnAutomationManager.SelectObjectIdselObj.Name = "Select"selObj.Object = NothingselObj.DrawDesignerType = NothingselObj.EditDesignerType = NothingselObj.RunDesignerType = Nothing' create the toolbar button (or you can load the image from a disk file or resource)Dim btmp As Bitmap = New Bitmap(16, 16)Dim g As Graphics = Graphics.FromImage(btmp)Tryg.FillRectangle(SystemBrushes.Control, New Rectangle(0, 0, 16, 16))g.DrawLine(Pens.Black, 4, 4, 12, 12)g.DrawLine(Pens.Black, 4, 12, 12, 4)FinallyCType(g, IDisposable).Dispose()End TryselObj.ToolBarImage = btmpselObj.ToolBarToolTipText = "Select"selObj.DrawCursor = Cursors.DefaultselObj.ContextMenu = Nothingmanager.Objects.Add(selObj)' set up the line automation objectDim lineObj As AnnAutomationObject = New AnnAutomationObject()lineObj.Id = AnnAutomationManager.LineObjectIdlineObj.Name = "Line"Dim line As AnnLineObject = New AnnLineObject()line.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))lineObj.Object = linelineObj.DrawDesignerType = GetType(AnnLineDrawDesigner)lineObj.EditDesignerType = GetType(AnnLineEditDesigner)lineObj.RunDesignerType = GetType(AnnRunDesigner)btmp = New Bitmap(16, 16)g = Graphics.FromImage(btmp)Tryg.FillRectangle(SystemBrushes.Control, New Rectangle(0, 0, 16, 16))g.DrawLine(Pens.Black, 4, 12, 12, 4)FinallyCType(g, IDisposable).Dispose()End TrylineObj.ToolBarImage = btmplineObj.ToolBarToolTipText = "Draw new line object"lineObj.DrawCursor = Cursors.CrosslineObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(lineObj.Id)manager.Objects.Add(lineObj)' set up the rectangle automation objectDim rectObj As AnnAutomationObject = New AnnAutomationObject()rectObj.Id = AnnAutomationManager.RectangleObjectIdrectObj.Name = "Rectangle"Dim rect As AnnRectangleObject = New AnnRectangleObject()rect.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))rect.Brush = New AnnSolidBrush(Color.White)rectObj.Object = rectrectObj.DrawDesignerType = GetType(AnnRectangleDrawDesigner)rectObj.EditDesignerType = GetType(AnnRectangleEditDesigner)rectObj.RunDesignerType = GetType(AnnRunDesigner)btmp = New Bitmap(16, 16)g = Graphics.FromImage(btmp)Tryg.FillRectangle(SystemBrushes.Control, New Rectangle(0, 0, 16, 16))g.DrawRectangle(Pens.Black, 2, 4, 10, 8)FinallyCType(g, IDisposable).Dispose()End TryrectObj.ToolBarImage = btmprectObj.ToolBarToolTipText = "Draw new rectangle object"rectObj.DrawCursor = Cursors.CrossrectObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(rectObj.Id)manager.Objects.Add(rectObj)' set up the group automation object (always needed)Dim groupObj As AnnAutomationObject = New AnnAutomationObject()groupObj.Id = AnnAutomationManager.GroupObjectIdgroupObj.Name = "Group"groupObj.Object = New AnnGroupObject()groupObj.DrawDesignerType = NothinggroupObj.EditDesignerType = GetType(AnnNewGroupEditDesigner)groupObj.RunDesignerType = GetType(AnnRunDesigner)groupObj.ToolBarImage = Nothing ' group is not in the toolbargroupObj.ToolBarToolTipText = NothinggroupObj.DrawCursor = NothinggroupObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(groupObj.Id)manager.Objects.Add(groupObj)End SubEnd ClassPublic Sub AnnAutomationManager_AnnAutomationManager(ByVal title As String)Dim form As MyForm1 = New MyForm1(title)form.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
