Take the following steps to start a project and to add some code that will demonstrate the automated annotation features of the LEADTOOLS Silverlight Control.
[XAML]
<UserControl x:Class="Load_And_Display.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Leadtools_Windows_Controls="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls" Width="800" Height="800"> <Grid x:Name="LayoutRoot" Background="White"> <StackPanel Orientation="Vertical" x:Name="stackPanel" > <Leadtools_Windows_Controls:RasterImageViewer x:Name="viewerControl" SizeMode="Normal" Width="500" Height="500"></Leadtools_Windows_Controls:RasterImageViewer> <Button Name="myButton" Content="Load" FontSize="30" Click="Button_Click"></Button> <RadioButton x:Name="_rbRunMode" Content="Run Mode" Checked="AnnotationMode_Changed" HorizontalAlignment="Center" FontSize="20"></RadioButton> <RadioButton x:Name="_rbDesignMode" Content="Design Mode" Checked="AnnotationMode_Changed" HorizontalAlignment="Center" FontSize="20"></RadioButton> </StackPanel> </Grid> </UserControl>
[Visual Basic]
Imports Leadtools.Windows.Annotations
[C#]
using Leadtools.Windows.Annotations;
[Visual Basic]
Dim _automation As AnnAutomation
[C#]
AnnAutomation _automation;
[Visual Basic]
Public Sub New() InitializeComponent() RasterSupport.SetLicense(RasterSupportType.Document, "Your Document unlock key here") Dim manager As AnnAutomationManager = New AnnAutomationManager() manager.CreateDefaultObjects() manager.CreateToolBar() stackPanel.Children.Insert(0, manager.ToolBar) manager.ToolBar.Orientation = Orientation.Horizontal manager.ToolBar.HorizontalAlignment = HorizontalAlignment.Center _automation = New AnnAutomation(manager, viewerControl) _rbDesignMode.IsChecked = True End Sub
[C#]
public MainPage() { InitializeComponent(); RasterSupport.SetLicense(RasterSupportType.Document, "Your Document unlock key here"); AnnAutomationManager manager = new AnnAutomationManager(); manager.CreateDefaultObjects(); manager.CreateToolBar(); stackPanel.Children.Insert(0, manager.ToolBar); manager.ToolBar.Orientation = Orientation.Horizontal; manager.ToolBar.HorizontalAlignment = HorizontalAlignment.Center; _automation = new AnnAutomation(manager, viewerControl); _rbDesignMode.IsChecked = true; }
[Visual Basic]
Private Sub AnnotationMode_Changed(ByVal sender As Object, ByVal e As RoutedEventArgs) If CBool(_rbDesignMode.IsChecked) Then _automation.Manager.UserMode = AnnUserMode.Design Else _automation.Manager.UserMode = AnnUserMode.Run End If End Sub
[C#]
private void AnnotationMode_Changed(object sender, RoutedEventArgs e) { _automation.Manager.UserMode = (bool)_rbDesignMode.IsChecked ? AnnUserMode.Design : AnnUserMode.Run; }
Build, and Run the program to test it.
Click the "Load" button and select a valid image.
NOTE: if you encounter and "Invalid File Format" or "Feature Not Supported" exception, please refer to the topic Invalid File Format/Feature Not Supported.
Use the toolbar above the viewer to select annotations. The radio buttons will allow you to switch between design and run mode.