Take the following steps to start a project and to add some code that demonstrates the LEADTOOLS annotation features in Windows Phone 7.
[XAML]
<phone:PhoneApplicationPage x:Class="LoadingAndDisplayingAnImageWindowsPhone.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True" xmlns:my="clr-namespace:Leadtools.Windows.Controls;assembly=Leadtools.Windows.Controls" Loaded="PhoneApplicationPage_Loaded"> <!--LayoutRoot is the root grid where all page content is placed--> <Grid x:Name="LayoutRoot" Background="Transparent"> <StackPanel Orientation="Vertical"> <my:RasterImageViewer Name="rasterImageViewer" Height="480" Width="480" SizeMode="Fit" InteractiveMode="None"/> <Button Name="_btnLoadFromLibrary" Click="_btnLoadFromLibrary_Click" Content="Load From Library"></Button> <Button Name="_btnLoadFromURL" Click="_btnLoadFromURL_Click" Content="Load From URL"></Button> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <Button Name="_btnDrawRectangle" Content="Draw Rectangle" Click="_btnDrawRectangle_Click" Width="230"></Button> <Button Name="_btnDrawEllipse" Content="Draw Ellipse" Click="_btnDrawEllipse_Click" Width="230"></Button> </StackPanel> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <Button Name="_btnDrawHilite" Content="Draw Hilite" Click="_btnDrawHilite_Click" Width="230"></Button> <Button Name="_btnDrawFreehand" Content="Draw Freehand" Click="_btnDrawFreehand_Click" Width="230"></Button> </StackPanel> </StackPanel> </Grid> </phone:PhoneApplicationPage>
[C#]
using Leadtools.Windows.Annotations;
[C#]
AnnAutomationManager annAutomationManager = null; AnnAutomation annAutomation = null;
[C#]
private void InitAnnotationAutomation() { try { // create and setup the automation manager annAutomationManager = new AnnAutomationManager(); // Instruct the manager to create the default (all) automation objects. annAutomationManager.CreateDefaultObjects(); annAutomationManager.UserMode = AnnUserMode.Design; // setup the automation (will create the container as well) annAutomation = new AnnAutomation(annAutomationManager, rasterImageViewer); // setup this automation as the active one annAutomation.Active = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
[C#]
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { codecs = new RasterCodecs(); codecs.LoadAsyncCompleted += new EventHandler<CodecsLoadAsyncCompletedEventArgs>(codecs_LoadAsyncCompleted); InitAnnotationAutomation(); rasterImageViewer.AnnotationMode = true; }
Build, and Run the program to test it.
Click the "Load From URL" button to load an image from a URL.
Click the "Load From Library" button to load an image from the Windows Phone photo library.
Click the various buttons to draw annotations.
NOTE: This tutorial demonstrates how to implement basic annotation features in LEADTOOLS. It does not include all annotation features. For a complete demo, see the "AutomationDemo" located in the LEADTOOLS 17.5\Examples\SilverlightPhone\CS directory.
NOTE: If you encounter and "Invalid File Format" or "Feature Not Supported" exception, please refer to the topic Invalid File Format/Feature Not Supported.