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.
Open the Page.xaml file and copy the below XAML code into the editor:
[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>
Switch to Page.xaml code view (right-click Page.xaml in the solution explorer then select View Code) and add the following lines at the beginning of the file:
Imports Leadtools.Windows.Annotations
using Leadtools.Windows.Annotations;
Switch to Page.xaml code view (right-click Page.xaml in the solution explorer then select View Code) and add the following class level variable:
Dim _automation As AnnAutomation
AnnAutomation _automation;
Update the MainPage() function as shown below:
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
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;
}
Add the following class function:
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
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.
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