Manages the automation mode for an annotation application.
public class AnnAutomationManager
Public Class AnnAutomationManager
public ref class AnnAutomationManager
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.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Demos;
using Leadtools.Help;
private class MyWindow1 : Window
{
AnnAutomationManager manager;
ImageViewer viewer;
public MyWindow1(string title)
{
this.Title = title;
this.Width = 400;
this.Height = 400;
viewer = new ImageViewer();
// load an image into the viewer
// fix this path to an existing image file on your system
viewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));
viewer.Width = double.NaN;
viewer.Height = double.NaN;
// create and set up the automation manager
manager = new AnnAutomationManager();
// Create only the line and rectangle automation objects
CreateMyAutomationObjects(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();
// create the toolbar and add it to the ToolBarTray
manager.CreateToolBar();
ToolBarTray tbt = new ToolBarTray();
tbt.Orientation = Orientation.Horizontal;
DockPanel.SetDock(tbt, Dock.Top);
tbt.ToolBars.Add(manager.ToolBar.ToolBar);
DockPanel dp = new DockPanel();
dp.Children.Add(tbt);
dp.Children.Add(viewer);
// set the DockPanel as a content of the window.
this.Content = dp;
// set up the automation (will create the container as well)
AnnAutomation automation = new AnnAutomation(manager, viewer);
// set up this automation as the active one
automation.Active = true;
automation.UndoCapacity = 12;
}
private void CreateMyAutomationObjects(AnnAutomationManager manager)
{
// set up the select automation object
AnnAutomationObject selObj = new AnnAutomationObject();
selObj.Id = AnnAutomationManager.SelectObjectId;
selObj.Name = "Select";
selObj.Object = null;
selObj.DrawDesignerType = typeof(AnnRectangleDrawDesigner);
selObj.EditDesignerType = null;
selObj.RunDesignerType = null;
// create the toolbar button (or you can load the image from a disk file or resource)
DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
dc.DrawRectangle(new SolidColorBrush(Color.FromRgb(236, 233, 216)), null, new Rect(0, 0, 24, 24));
dc.DrawLine(new Pen(Brushes.Black, 2), new Point(4, 4), new Point(22, 22));
dc.DrawLine(new Pen(Brushes.Black, 2), new Point(4, 22), new Point(22, 4));
dc.Close();
RenderTargetBitmap bmp = new RenderTargetBitmap(24, 24, 96, 96, PixelFormats.Pbgra32);
bmp.Render(dv);
selObj.ToolBarButtonImage = bmp;
}
selObj.ToolBarButtonToolTip = new ToolTip();
selObj.ToolBarButtonToolTip.Content = "Select";
selObj.DrawCursor = Cursors.Hand;
selObj.ContextMenu = null;
AnnSelectObject selectObj = new AnnSelectObject();
selectObj.Stroke = Colors.White;
selectObj.StrokeThickness = 2.0;
selObj.Object = selectObj;
manager.Objects.Add(selObj);
// set up the line automation object
AnnAutomationObject lineObj = new AnnAutomationObject();
lineObj.Id = AnnAutomationManager.LineObjectId;
lineObj.Name = "Line";
AnnLineObject line = new AnnLineObject();
line.Stroke = Colors.Red;
line.StrokeThickness = 2.0;
lineObj.Object = line;
lineObj.DrawDesignerType = typeof(AnnLineDrawDesigner);
lineObj.EditDesignerType = typeof(AnnLineEditDesigner);
lineObj.RunDesignerType = typeof(AnnRunDesigner);
using (DrawingContext dc = dv.RenderOpen())
{
dc.DrawRectangle(new SolidColorBrush(Color.FromRgb(236, 233, 216)), null, new Rect(0, 0, 24, 24));
dc.DrawLine(new Pen(Brushes.Black, 2), new Point(4, 4), new Point(22, 22));
dc.Close();
RenderTargetBitmap bmp = new RenderTargetBitmap(24, 24, 96, 96, PixelFormats.Pbgra32);
bmp.Render(dv);
lineObj.ToolBarButtonImage = bmp;
}
lineObj.ToolBarButtonToolTip = new ToolTip();
lineObj.ToolBarButtonToolTip.Content = "Draw new line object";
lineObj.DrawCursor = Cursors.Cross;
lineObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(lineObj.Id);
manager.Objects.Add(lineObj);
// set up the rectangle automation object
AnnAutomationObject rectObj = new AnnAutomationObject();
rectObj.Id = AnnAutomationManager.RectangleObjectId;
rectObj.Name = "Rectangle";
AnnRectangleObject rect = new AnnRectangleObject();
rect.StrokeThickness = 2.0;
rect.Stroke = Colors.Red;
rect.Fill = Colors.White;
rectObj.Object = rect;
rectObj.DrawDesignerType = typeof(AnnRectangleDrawDesigner);
rectObj.EditDesignerType = typeof(AnnRectangleEditDesigner);
rectObj.RunDesignerType = typeof(AnnRunDesigner);
using (DrawingContext dc = dv.RenderOpen())
{
dc.DrawRectangle(new SolidColorBrush(Color.FromRgb(236, 233, 216)), null, new Rect(0, 0, 24, 24));
dc.DrawRectangle(null, new Pen(Brushes.Black, 2), new Rect(2, 4, 20, 18));
dc.Close();
RenderTargetBitmap bmp = new RenderTargetBitmap(24, 24, 96, 96, PixelFormats.Pbgra32);
bmp.Render(dv);
rectObj.ToolBarButtonImage = bmp;
}
rectObj.ToolBarButtonToolTip = new ToolTip();
rectObj.ToolBarButtonToolTip.Content = "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(AnnGroupEditDesigner);
groupObj.RunDesignerType = typeof(AnnRunDesigner);
groupObj.ToolBarButtonImage = null; // group is not in the toolbar
groupObj.ToolBarButtonToolTip = null;
groupObj.DrawCursor = null;
groupObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(groupObj.Id);
manager.Objects.Add(groupObj);
}
}
private void AnnAutomationManager_AnnAutomationManager(string title)
{
MyWindow1 window = new MyWindow1(title);
window.ShowDialog();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Private Class MyWindow1 : Inherits Window
Private manager As AnnAutomationManager
Private viewer As ImageViewer
Public Sub New(ByVal title As String)
Me.Title = title
Me.Width = 400
Me.Height = 400
viewer = New ImageViewer()
' load an image into the viewer
' fix this path to an existing image file on your system
viewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))
viewer.Width = Double.NaN
viewer.Height = Double.NaN
' create and set up the automation manager
manager = New AnnAutomationManager()
' Create only the line and rectangle automation objects
CreateMyAutomationObjects(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();
' create the toolbar and add it to the ToolBarTray
manager.CreateToolBar()
Dim tbt As ToolBarTray = New ToolBarTray()
tbt.Orientation = Orientation.Horizontal
DockPanel.SetDock(tbt, Dock.Top)
tbt.ToolBars.Add(manager.ToolBar.ToolBar)
Dim dp As DockPanel = New DockPanel()
dp.Children.Add(tbt)
dp.Children.Add(viewer)
' set the DockPanel as a content of the window.
Me.Content = dp
' 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 one
automation.Active = True
automation.UndoCapacity = 12
End Sub
Private Sub CreateMyAutomationObjects(ByVal manager As AnnAutomationManager)
' set up the select automation object
Dim selObj As AnnAutomationObject = New AnnAutomationObject()
selObj.Id = AnnAutomationManager.SelectObjectId
selObj.Name = "Select"
selObj.Object = Nothing
selObj.DrawDesignerType = GetType(AnnRectangleDrawDesigner)
selObj.EditDesignerType = Nothing
selObj.RunDesignerType = Nothing
' create the toolbar button (or you can load the image from a disk file or resource)
Dim dv As DrawingVisual = New DrawingVisual()
Using dc As DrawingContext = dv.RenderOpen()
dc.DrawRectangle(New SolidColorBrush(Color.FromRgb(236, 233, 216)), Nothing, New Rect(0, 0, 24, 24))
dc.DrawLine(New Pen(Brushes.Black, 2), New System.Windows.Point(4, 4), New System.Windows.Point(22, 22))
dc.DrawLine(New Pen(Brushes.Black, 2), New System.Windows.Point(4, 22), New System.Windows.Point(22, 4))
dc.Close()
Dim bmp As RenderTargetBitmap = New RenderTargetBitmap(24, 24, 96, 96, PixelFormats.Pbgra32)
bmp.Render(dv)
selObj.ToolBarButtonImage = bmp
End Using
selObj.ToolBarButtonToolTip = New ToolTip()
selObj.ToolBarButtonToolTip.Content = "Select"
selObj.DrawCursor = Cursors.Hand
selObj.ContextMenu = Nothing
Dim selectObj As AnnSelectObject = New AnnSelectObject()
selectObj.Stroke = Colors.White
selectObj.StrokeThickness = 2.0
selObj.Object = selectObj
manager.Objects.Add(selObj)
' set up the line automation object
Dim lineObj As AnnAutomationObject = New AnnAutomationObject()
lineObj.Id = AnnAutomationManager.LineObjectId
lineObj.Name = "Line"
Dim line As AnnLineObject = New AnnLineObject()
line.Stroke = Colors.Red
line.StrokeThickness = 2.0
lineObj.Object = line
lineObj.DrawDesignerType = GetType(AnnLineDrawDesigner)
lineObj.EditDesignerType = GetType(AnnLineEditDesigner)
lineObj.RunDesignerType = GetType(AnnRunDesigner)
Using dc As DrawingContext = dv.RenderOpen()
dc.DrawRectangle(New SolidColorBrush(Color.FromRgb(236, 233, 216)), Nothing, New Rect(0, 0, 24, 24))
dc.DrawLine(New Pen(Brushes.Black, 2), New System.Windows.Point(4, 4), New System.Windows.Point(22, 22))
dc.Close()
Dim bmp As RenderTargetBitmap = New RenderTargetBitmap(24, 24, 96, 96, PixelFormats.Pbgra32)
bmp.Render(dv)
lineObj.ToolBarButtonImage = bmp
End Using
lineObj.ToolBarButtonToolTip = New ToolTip()
lineObj.ToolBarButtonToolTip.Content = "Draw new line object"
lineObj.DrawCursor = Cursors.Cross
lineObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(lineObj.Id)
manager.Objects.Add(lineObj)
' set up the rectangle automation object
Dim rectObj As AnnAutomationObject = New AnnAutomationObject()
rectObj.Id = AnnAutomationManager.RectangleObjectId
rectObj.Name = "Rectangle"
Dim rect As AnnRectangleObject = New AnnRectangleObject()
rect.Stroke = Colors.Red
rect.StrokeThickness = 2.0
rect.Fill = Colors.White
rectObj.Object = rect
rectObj.DrawDesignerType = GetType(AnnRectangleDrawDesigner)
rectObj.EditDesignerType = GetType(AnnRectangleEditDesigner)
rectObj.RunDesignerType = GetType(AnnRunDesigner)
Using dc As DrawingContext = dv.RenderOpen()
dc.DrawRectangle(New SolidColorBrush(Color.FromRgb(236, 233, 216)), Nothing, New Rect(0, 0, 24, 24))
dc.DrawRectangle(Nothing, New Pen(Brushes.Black, 2), New Rect(2, 4, 20, 18))
dc.Close()
Dim bmp As RenderTargetBitmap = New RenderTargetBitmap(24, 24, 96, 96, PixelFormats.Pbgra32)
bmp.Render(dv)
rectObj.ToolBarButtonImage = bmp
End Using
rectObj.ToolBarButtonToolTip = New ToolTip()
rectObj.ToolBarButtonToolTip.Content = "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)
Dim groupObj As AnnAutomationObject = New AnnAutomationObject()
groupObj.Id = AnnAutomationManager.GroupObjectId
groupObj.Name = "Group"
groupObj.Object = New AnnGroupObject()
groupObj.DrawDesignerType = Nothing
groupObj.EditDesignerType = GetType(AnnGroupEditDesigner)
groupObj.RunDesignerType = GetType(AnnRunDesigner)
groupObj.ToolBarButtonImage = Nothing ' group is not in the toolbar
groupObj.ToolBarButtonToolTip = Nothing
groupObj.DrawCursor = Nothing
groupObj.ContextMenu = AnnAutomationManager.CreateDefaultObjectContextMenu(groupObj.Id)
manager.Objects.Add(groupObj)
End Sub
End Class
Private Sub AnnAutomationManager_AnnAutomationManager(ByVal title As String)
Dim window As MyWindow1 = New MyWindow1(title)
window.ShowDialog()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools.Windows.Controls;
using Leadtools.Windows.Annotations;
using Leadtools.Examples;
using Leadtools.Silverlight.Demos;
//using Leadtools.Help;
private class MyWindow1 : ChildWindow
{
AnnAutomationManager manager;
ImageViewer viewer;
public MyWindow1(string title)
{
this.Title = title;
this.Width = 400;
this.Height = 400;
viewer = new ImageViewer();
// load an image into the viewer
// fix this path to an existing image file on your system
viewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "ScarletMacaws.jpg"));
viewer.Width = double.NaN;
viewer.Height = double.NaN;
// create and set up the automation manager
manager = new AnnAutomationManager();
// Create only the line and rectangle automation objects
CreateMyAutomationObjects(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();
// create the toolbar and add it to the ToolBarTray
manager.CreateToolBar();
StackPanel dp = new StackPanel();
dp.Children.Add(viewer);
// set the DockPanel as a content of the window.
this.Content = dp;
// set up the automation (will create the container as well)
AnnAutomation automation = new AnnAutomation(manager, viewer);
// set up this automation as the active one
automation.Active = true;
automation.UndoCapacity = 12;
}
private void CreateMyAutomationObjects(AnnAutomationManager manager)
{
// set up the select automation object
AnnAutomationObject selObj = new AnnAutomationObject();
selObj.Id = AnnAutomationManager.SelectObjectId;
selObj.Name = "Select";
selObj.Object = null;
selObj.DrawDesignerType = typeof(AnnRectangleDrawDesigner);
selObj.EditDesignerType = null;
selObj.RunDesignerType = null;
// create the toolbar button (or you can load the image from a disk file or resource)
{
Canvas myCanvas = new Canvas();
WriteableBitmap wb1 = new WriteableBitmap(100, 100);
Rectangle myRect = new Rectangle();
myRect.Width = 24;
myRect.Height = 24;
myRect.Fill = new SolidColorBrush(Color.FromArgb(255, 236, 233, 216));
myCanvas.Children.Add(myRect);
Line line1 = new Line();
line1.Fill = new SolidColorBrush(Colors.Black);
line1.X1 = 4;
line1.Y1 = 4;
line1.X2 = 22;
line1.Y2 = 22;
myCanvas.Children.Add(line1);
Line line2 = new Line();
line2.Fill = new SolidColorBrush(Colors.Black);
line2.X1 = 22;
line2.Y1 = 4;
line2.X2 = 22;
line2.Y2 = 4;
myCanvas.Children.Add(line2);
wb1.Render(myCanvas, null);
wb1.Invalidate();
selObj.ToolBarButtonImage = wb1;
}
selObj.ToolBarButtonToolTip = new ToolTip();
selObj.ToolBarButtonToolTip.Content = "Select";
selObj.DrawCursor = Cursors.Hand;
AnnSelectObject selectObj = new AnnSelectObject();
selectObj.Stroke = Colors.White;
selectObj.StrokeThickness = 2.0;
selObj.Object = selectObj;
manager.Objects.Add(selObj);
// set up the line automation object
AnnAutomationObject lineObj = new AnnAutomationObject();
lineObj.Id = AnnAutomationManager.LineObjectId;
lineObj.Name = "Line";
AnnLineObject line = new AnnLineObject();
line.Stroke = Colors.Red;
line.StrokeThickness = 2.0;
lineObj.Object = line;
lineObj.DrawDesignerType = typeof(AnnLineDrawDesigner);
lineObj.EditDesignerType = typeof(AnnLineEditDesigner);
lineObj.RunDesignerType = typeof(AnnRunDesigner);
{
Canvas myCanvas = new Canvas();
WriteableBitmap wb2 = new WriteableBitmap(100, 100);
Rectangle myRect = new Rectangle();
myRect.Width = 24;
myRect.Height = 24;
myRect.Fill = new SolidColorBrush(Color.FromArgb(255, 236, 233, 216));
myCanvas.Children.Add(myRect);
Line line1 = new Line();
line1.Fill = new SolidColorBrush(Colors.Black);
line1.X1 = 4;
line1.Y1 = 4;
line1.X2 = 22;
line1.Y2 = 22;
myCanvas.Children.Add(line1);
wb2.Render(myCanvas, null);
wb2.Invalidate();
lineObj.ToolBarButtonImage = wb2;
}
lineObj.ToolBarButtonToolTip = new ToolTip();
lineObj.ToolBarButtonToolTip.Content = "Draw new line object";
lineObj.DrawCursor = Cursors.Arrow;
manager.Objects.Add(lineObj);
// set up the rectangle automation object
AnnAutomationObject rectObj = new AnnAutomationObject();
rectObj.Id = AnnAutomationManager.RectangleObjectId;
rectObj.Name = "Rectangle";
AnnRectangleObject rect = new AnnRectangleObject();
rect.StrokeThickness = 2.0;
rect.Stroke = Colors.Red;
rect.Fill = Colors.White;
rectObj.Object = rect;
rectObj.DrawDesignerType = typeof(AnnRectangleDrawDesigner);
rectObj.EditDesignerType = typeof(AnnRectangleEditDesigner);
rectObj.RunDesignerType = typeof(AnnRunDesigner);
{
Canvas myCanvas = new Canvas();
WriteableBitmap wb2 = new WriteableBitmap(100, 100);
Rectangle myRect = new Rectangle();
myRect.Width = 24;
myRect.Height = 24;
myRect.Fill = new SolidColorBrush(Color.FromArgb(255, 236, 233, 216));
myCanvas.Children.Add(myRect);
Line line1 = new Line();
line1.Fill = new SolidColorBrush(Colors.Black);
line1.X1 = 2;
line1.Y1 = 4;
line1.X2 = 20;
line1.Y2 = 18;
myCanvas.Children.Add(line1);
wb2.Render(myCanvas, null);
wb2.Invalidate();
rectObj.ToolBarButtonImage = wb2;
}
rectObj.ToolBarButtonToolTip = new ToolTip();
rectObj.ToolBarButtonToolTip.Content = "Draw new rectangle object";
rectObj.DrawCursor = Cursors.Stylus;
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(AnnGroupEditDesigner);
groupObj.RunDesignerType = typeof(AnnRunDesigner);
groupObj.ToolBarButtonImage = null; // group is not in the toolbar
groupObj.ToolBarButtonToolTip = null;
groupObj.DrawCursor = null;
manager.Objects.Add(groupObj);
}
}
Imports Leadtools.Windows.Controls
Imports Leadtools.Windows.Annotations
Imports Leadtools.Silverlight.Demos
'using Leadtools.Help;
Private Class MyWindow1 : Inherits ChildWindow
Private manager As AnnAutomationManager
Private viewer As ImageViewer
Public Sub New(ByVal title As String)
Me.Title = title
Me.Width = 400
Me.Height = 400
viewer = New ImageViewer()
' load an image into the viewer
' fix this path to an existing image file on your system
viewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path & "ScarletMacaws.jpg"))
viewer.Width = Double.NaN
viewer.Height = Double.NaN
' create and set up the automation manager
manager = New AnnAutomationManager()
' Create only the line and rectangle automation objects
CreateMyAutomationObjects(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();
' create the toolbar and add it to the ToolBarTray
manager.CreateToolBar()
Dim dp As StackPanel = New StackPanel()
dp.Children.Add(viewer)
' set the DockPanel as a content of the window.
Me.Content = dp
' 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 one
automation.Active = True
automation.UndoCapacity = 12
End Sub
Private Sub CreateMyAutomationObjects(ByVal manager As AnnAutomationManager)
' set up the select automation object
Dim selObj As AnnAutomationObject = New AnnAutomationObject()
selObj.Id = AnnAutomationManager.SelectObjectId
selObj.Name = "Select"
selObj.Object = Nothing
selObj.DrawDesignerType = GetType(AnnRectangleDrawDesigner)
selObj.EditDesignerType = Nothing
selObj.RunDesignerType = Nothing
' create the toolbar button (or you can load the image from a disk file or resource)
Dim myCanvas1 As Canvas = New Canvas()
Dim wb1 As WriteableBitmap = New WriteableBitmap(100, 100)
Dim myRect1 As Rectangle = New Rectangle()
myRect1.Width = 24
myRect1.Height = 24
myRect1.Fill = New SolidColorBrush(Color.FromArgb(255, 236, 233, 216))
myCanvas1.Children.Add(myRect1)
Dim myline1 As Line = New Line()
myline1.Fill = New SolidColorBrush(Colors.Black)
myline1.X1 = 4
myline1.Y1 = 4
myline1.X2 = 22
myline1.Y2 = 22
myCanvas1.Children.Add(myline1)
Dim myline2 As Line = New Line()
myline2.Fill = New SolidColorBrush(Colors.Black)
myline2.X1 = 22
myline2.Y1 = 4
myline2.X2 = 22
myline2.Y2 = 4
myCanvas1.Children.Add(myline2)
wb1.Render(myCanvas1, Nothing)
wb1.Invalidate()
selObj.ToolBarButtonImage = wb1
selObj.ToolBarButtonToolTip = New ToolTip()
selObj.ToolBarButtonToolTip.Content = "Select"
selObj.DrawCursor = Cursors.Hand
Dim selectObj As AnnSelectObject = New AnnSelectObject()
selectObj.Stroke = Colors.White
selectObj.StrokeThickness = 2.0
selObj.Object = selectObj
manager.Objects.Add(selObj)
' set up the line automation object
Dim lineObj As AnnAutomationObject = New AnnAutomationObject()
lineObj.Id = AnnAutomationManager.LineObjectId
lineObj.Name = "Line"
Dim line As AnnLineObject = New AnnLineObject()
line.Stroke = Colors.Red
line.StrokeThickness = 2.0
lineObj.Object = line
lineObj.DrawDesignerType = GetType(AnnLineDrawDesigner)
lineObj.EditDesignerType = GetType(AnnLineEditDesigner)
lineObj.RunDesignerType = GetType(AnnRunDesigner)
Dim myCanvas2 As Canvas = New Canvas()
Dim wb2 As WriteableBitmap = New WriteableBitmap(100, 100)
Dim myRect2 As Rectangle = New Rectangle()
myRect2.Width = 24
myRect2.Height = 24
myRect2.Fill = New SolidColorBrush(Color.FromArgb(255, 236, 233, 216))
myCanvas2.Children.Add(myRect2)
Dim line1 As Line = New Line()
line1.Fill = New SolidColorBrush(Colors.Black)
line1.X1 = 4
line1.Y1 = 4
line1.X2 = 22
line1.Y2 = 22
myCanvas2.Children.Add(line1)
wb2.Render(myCanvas2, Nothing)
wb2.Invalidate()
lineObj.ToolBarButtonImage = wb2
lineObj.ToolBarButtonToolTip = New ToolTip()
lineObj.ToolBarButtonToolTip.Content = "Draw new line object"
lineObj.DrawCursor = Cursors.Arrow
manager.Objects.Add(lineObj)
' set up the rectangle automation object
Dim rectObj As AnnAutomationObject = New AnnAutomationObject()
rectObj.Id = AnnAutomationManager.RectangleObjectId
rectObj.Name = "Rectangle"
Dim rect As AnnRectangleObject = New AnnRectangleObject()
rect.StrokeThickness = 2.0
rect.Stroke = Colors.Red
rect.Fill = Colors.White
rectObj.Object = rect
rectObj.DrawDesignerType = GetType(AnnRectangleDrawDesigner)
rectObj.EditDesignerType = GetType(AnnRectangleEditDesigner)
rectObj.RunDesignerType = GetType(AnnRunDesigner)
Dim myCanvas3 As Canvas = New Canvas()
Dim wb3 As WriteableBitmap = New WriteableBitmap(100, 100)
Dim myRect As Rectangle = New Rectangle()
myRect.Width = 24
myRect.Height = 24
myRect.Fill = New SolidColorBrush(Color.FromArgb(255, 236, 233, 216))
myCanvas3.Children.Add(myRect)
Dim ln As Line = New Line()
ln.Fill = New SolidColorBrush(Colors.Black)
ln.X1 = 2
ln.Y1 = 4
ln.X2 = 20
ln.Y2 = 18
myCanvas3.Children.Add(ln)
wb3.Render(myCanvas3, Nothing)
wb3.Invalidate()
rectObj.ToolBarButtonImage = wb2
rectObj.ToolBarButtonToolTip = New ToolTip()
rectObj.ToolBarButtonToolTip.Content = "Draw new rectangle object"
rectObj.DrawCursor = Cursors.Stylus
manager.Objects.Add(rectObj)
' set up the group automation object (always needed)
Dim groupObj As AnnAutomationObject = New AnnAutomationObject()
groupObj.Id = AnnAutomationManager.GroupObjectId
groupObj.Name = "Group"
groupObj.Object = New AnnGroupObject()
groupObj.DrawDesignerType = Nothing
groupObj.EditDesignerType = GetType(AnnGroupEditDesigner)
groupObj.RunDesignerType = GetType(AnnRunDesigner)
groupObj.ToolBarButtonImage = Nothing ' group is not in the toolbar
groupObj.ToolBarButtonToolTip = Nothing
groupObj.DrawCursor = Nothing
manager.Objects.Add(groupObj)
End Sub
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