Working with Automated Annotation (Deprecated)

Summary

Take the following steps to create and run a program that implements Automated Annotations:

  1. Start Visual Studio .NET.
  2. Choose File->New->Project… from the menu.
  3. In the New Project dialog box, choose either "Visual C# Projects" or "VB Projects" in the Projects Type List, and choose "Windows Application " in the Templates List.
  4. Type the project name as "Working With Automated Annotations" in the Project Name field, and then choose OK. If desired, type a new location for your project or select a directory using the Browse button, and then choose OK .
  5. In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference…" from the context menu. In the "Add Reference" dialog box, select the ".NET" tab and browse to the "<LEADTOOLS_INSTALLDIR>\Bin\DotNet\Win32 " folder and select the following DLLs:

    • Leadtools.dll
    • Leadtools.Annotations.dll
    • Leadtools.Codecs.dll
    • Leadtools.Codecs.Cmp.dll
    • Leadtools.WinForms.dll
  6. Click the Select button and then press the OK button to add the above DLLs to the application. Make sure Form1 is in design view. Go to the toolbox (View->Toolbox) and Drag and drop an instance of RasterImageViewer to the form. If you do not have RasterImageViewer in your toolbox, select Tools->Add Remove Toolbox Items from the menu. Click Browse and then select Leadtools.WinForms.DLL from the "C:\LEADTOOLS 19\Bin\DotNet\Win32" folder and then click Open and then click OK.

  7. Go to the toolbox (View->Toolbox) and Drag and drop 2 instances of RadioButton control to the bottom of the form, and set the following properties for them:
Text Name Checked
Design Mode radioButton1 True
Run Mode radioButton2 False
  1. Switch to Form1 code view (right-click Form1 in the solution explorer then select View Code ) and add the following lines at the beginning of the file:

    C#
    VB
    Imports Leadtools 
    .Annotations 
    .Codecs 
    .WinForms 
    using Leadtools; 
    nnotations; 
    odecs; 
    inForms; 

  2. Declare the following private variable:

    C#
    VB
    ger used in managing the automation mode. 
    tionManager As AnnAutomationManager 
    ager used in managing the automation mode. 
    tionManager annAutomationManager; 

  3. Add an event handler to the Form1 Load event and code it as follows:

    C#
    VB
    _Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load 
    a new RasterCodecs object 
    New RasterCodecs() 
    n image into our viewer 
    wer1.Image = codecs.Load("C:\Users\Public\Documents\LEADTOOLS Images\Sample1.cmp") 
       
    ing(RasterImageViewer1.Image)) Then 
    d setup the automation manager 
    onManager = New AnnAutomationManager 
          
    the manager to create the default (all) automation objects. 
    onManager.CreateDefaultObjects() 
          
    e toolbar and add it to the form 
    onManager.CreateToolBar() 
    d(annAutomationManager.ToolBar) 
          
     automation (will create the container as well) 
    ion As AnnAutomation = New AnnAutomation(annAutomationManager, RasterImageViewer1) 
          
    s automation as the active one 
    Active = True 
       End If 
    End Sub 
    1_Load(object sender, System.EventArgs e) 
    { 
     a new RasterCodecs object 
    odecs = new RasterCodecs(); 
    in image into our viewer 
    wer1.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\Sample1.cmp"); 
       
    Viewer1.Image != null) 
       { 
    nd setup the automation manager 
    onManager = new AnnAutomationManager(); 
          
     the manager to create the default (all) automation objects. 
    onManager.CreateDefaultObjects(); 
          
    he toolbar and add it to the form 
    onManager.CreateToolBar(); 
    d(annAutomationManager.ToolBar); 
          
    e automation (will create the container as well) 
    on automation = new AnnAutomation(annAutomationManager, rasterImageViewer1); 
          
    vent handler for changes to the current designer 
    CurrentDesignerChanged += new EventHandler(automation_CurrentDesignerChanged); 
          
    is automation as the active one 
    Active = true; 
       } 
    } 

  4. Add an event handler to the radioButton1 CheckedChanged event and code it as follows:

    C#
    VB
    Button1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged 
    d(sender) 
    End Sub 
    oButton1_CheckedChanged(object sender, System.EventArgs e) 
    { 
    d(sender); 
    } 

  5. Add an event handler to the radioButton2 CheckedChanged event and code it as follows:

    C#
    VB
    Button2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged 
    d(sender) 
    End Sub 
    oButton2_CheckedChanged(object sender, System.EventArgs e) 
    { 
    d(sender); 
    } 

  6. Add the following function code to class Form1:

    C#
    VB
    odeChanged(ByVal sender As Object) 
    ing(annAutomationManager)) Then 
    Is radioButton1) Then 
    ationManager.UserMode = AnnUserMode.Design 
          Else 
    ationManager.UserMode = AnnUserMode.Run 
          End If 
       End If 
    End Sub 
    ModeChanged(object sender) 
    { 
    anager.UserMode = (sender == radioButton1)?AnnUserMode.Design: AnnUserMode.Run; 
    } 

  7. Add the following function code to class Form1:

    C#
    VB
    ' if the current designer is a button run designer, add a handler for Run 
    Private Sub automation_CurrentDesignerChanged(ByVal sender As Object, ByVal e As EventArgs) 
       Dim automation As AnnAutomation = DirectCast(sender, AnnAutomation) 
       If (TypeOf (automation.CurrentDesigner) Is AnnButtonRunDesigner) Then 
          Dim buttonRunDesigner As AnnButtonRunDesigner = DirectCast(automation.CurrentDesigner, AnnButtonRunDesigner) 
          AddHandler buttonRunDesigner.Run, AddressOf buttonRunDesigner_Run 
       End If 
    End Sub 
    Private Sub buttonRunDesigner_Run(ByVal sender As Object, ByVal e As AnnRunDesignerEventArgs) 
       If (e.OperationStatus = AnnDesignerOperationStatus.End) Then 
          Dim btn As AnnButtonObject = DirectCast(e.Object, AnnButtonObject) 
          MessageBox.Show(String.Format("Button with text = {0} was clicked!", btn.Text)) 
       End If 
    End Sub 
    // if the current designer is a button run designer, add a handler for Run 
    private void automation_CurrentDesignerChanged(object sender, EventArgs e) 
    { 
       AnnAutomation automation = sender as AnnAutomation; 
       AnnButtonRunDesigner buttonRunDesigner = automation.CurrentDesigner as AnnButtonRunDesigner; 
       if(buttonRunDesigner != null) 
          buttonRunDesigner.Run += new EventHandler<AnnRunDesignerEventArgs>(buttonRunDesigner_Run); 
    } 
    private void buttonRunDesigner_Run(object sender, AnnRunDesignerEventArgs e) 
    { 
       if(e.OperationStatus == AnnDesignerOperationStatus.End) 
       { 
          AnnButtonObject btn = e.Object as AnnButtonObject; 
          MessageBox.Show(string.Format("Button with text = {0} was clicked!", btn.Text));  
       } 
    } 

  8. Build, and Run the program to test it. You can now select objects from the toolbar, draw objects on top of the image, select the objects and move/change them. Right-click on any object to show its properties, etc. Create an audio annotation. Right-click on the annotation and set the file to any .wav file available on your system. Create a button annotation. Right-click on the annotation and change any of the button properties you wish. Select Run Mode Radio button. As you move the cursor over the audio annotation and the button annotation, the cursor changes to a hand. Click on the audio annotation to hear the .wav file. Click on the button annotation to call the program listed in the Hyperlink field.
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
{TOC}
Click or drag to resize