Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.11.10
|
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() Dim MY_LICENSE_FILE As String = "d:\temp\TestLic.lic" Dim MY_DEVELOPER_KEY As String = "xyz123abc" RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DEVELOPER_KEY) 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(); string MY_LICENSE_FILE = "d:\\temp\\TestLic.lic"; string MY_DEVELOPER_KEY = "xyz123abc"; RasterSupport.SetLicense(MY_LICENSE_FILE, MY_DEVELOPER_KEY); 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.