Private Class MyForm1 : Inherits Form
Private manager As AnnAutomationManager
Private viewer As RasterImageViewer
Private codecs As RasterCodecs
Public Sub New(ByVal title As String)
Text = title
Size = New Size(400, 400)
viewer = New RasterImageViewer()
viewer.Dock = DockStyle.Fill
Controls.Add(viewer)
viewer.BringToFront()
RasterCodecs.Startup()
codecs = New RasterCodecs()
viewer.Image = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "image1.cmp")
RasterCodecs.Shutdown()
manager = New AnnAutomationManager()
CreateMyAutomationObjects(manager)
manager.HidePropertiesTabs = AnnAutomationHidePropertiesTabs.Hyperlink Or AnnAutomationHidePropertiesTabs.Fixed
manager.CreateToolBar()
Controls.Add(manager.ToolBar)
Dim automation As AnnAutomation = New AnnAutomation(manager, viewer)
automation.Active = True
End Sub
Private Sub CreateMyAutomationObjects(ByVal manager As AnnAutomationManager)
Dim selObj As AnnAutomationObject = New AnnAutomationObject()
selObj.Id = AnnAutomationManager.SelectObjectId
selObj.Name = "Select"
selObj.Object = Nothing
selObj.DrawDesignerType = Nothing
selObj.EditDesignerType = Nothing
selObj.RunDesignerType = Nothing
Dim btmp As Bitmap = New Bitmap(16, 16)
Dim g As Graphics = Graphics.FromImage(btmp)
Try
g.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)
Finally
CType(g, IDisposable).Dispose()
End Try
selObj.ToolBarImage = btmp
selObj.ToolBarToolTipText = "Select"
selObj.DrawCursor = Cursors.Default
selObj.ContextMenu = Nothing
manager.Objects.Add(selObj)
Dim lineObj As AnnAutomationObject = New AnnAutomationObject()
lineObj.Id = AnnAutomationManager.LineObjectId
lineObj.Name = "Line"
Dim line As AnnLineObject = New AnnLineObject()
line.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))
lineObj.Object = line
lineObj.DrawDesignerType = GetType(AnnLineDrawDesigner)
lineObj.EditDesignerType = GetType(AnnLineEditDesigner)
lineObj.RunDesignerType = GetType(AnnRunDesigner)
btmp = New Bitmap(16, 16)
g = Graphics.FromImage(btmp)
Try
g.FillRectangle(SystemBrushes.Control, New Rectangle(0, 0, 16, 16))
g.DrawLine(Pens.Black, 4, 12, 12, 4)
Finally
CType(g, IDisposable).Dispose()
End Try
lineObj.ToolBarImage = btmp
lineObj.ToolBarToolTipText = "Draw new line object"
lineObj.DrawCursor = Cursors.Cross
lineObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(lineObj.Id)
manager.Objects.Add(lineObj)
Dim rectObj As AnnAutomationObject = New AnnAutomationObject()
rectObj.Id = AnnAutomationManager.RectangleObjectId
rectObj.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 = rect
rectObj.DrawDesignerType = GetType(AnnRectangleDrawDesigner)
rectObj.EditDesignerType = GetType(AnnRectangleEditDesigner)
rectObj.RunDesignerType = GetType(AnnRunDesigner)
btmp = New Bitmap(16, 16)
g = Graphics.FromImage(btmp)
Try
g.FillRectangle(SystemBrushes.Control, New Rectangle(0, 0, 16, 16))
g.DrawRectangle(Pens.Black, 2, 4, 10, 8)
Finally
CType(g, IDisposable).Dispose()
End Try
rectObj.ToolBarImage = btmp
rectObj.ToolBarToolTipText = "Draw new rectangle object"
rectObj.DrawCursor = Cursors.Cross
rectObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(rectObj.Id)
manager.Objects.Add(rectObj)
Dim groupObj As AnnAutomationObject = New AnnAutomationObject()
groupObj.Id = AnnAutomationManager.GroupObjectId
groupObj.Name = "Group"
groupObj.Object = New AnnGroupObject()
groupObj.DrawDesignerType = Nothing
groupObj.EditDesignerType = GetType(AnnNewGroupEditDesigner)
groupObj.RunDesignerType = GetType(AnnRunDesigner)
groupObj.ToolBarImage = Nothing
groupObj.ToolBarToolTipText = Nothing
groupObj.DrawCursor = Nothing
groupObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(groupObj.Id)
manager.Objects.Add(groupObj)
End Sub
End Class
Public Sub AnnAutomationManager_AnnAutomationManager(ByVal title As String)
Dim form As MyForm1 = New MyForm1(title)
form.ShowDialog()
End Sub |