Leadtools.Windows.Annotations Requires Document/Medical license. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
AnnContainer Class
See Also  Members   Example 
Leadtools.Windows.Annotations Namespace : AnnContainer Class





Represents an Annotation container.

Object Model



Syntax

Visual Basic (Declaration) 
Public Class AnnContainer 
   Inherits Panel
Visual Basic (Usage)Copy Code
Dim instance As AnnContainer
C# 
public class AnnContainer : Panel 
C++/CLI 
public ref class AnnContainer : public Panel 
XAML Object Element Usage 

<AnnContainer .../>

XAML Object Element Usage 

<AnnContainer .../>

Example

For XAML example, refer to AnnGroupObject.

This example creates a new AnnContainer object, links it to a BitmapSourceViewer object, adds a few objects and then adds the container on as a content of the viewer. Moving the mouse over an object displays the object type in the title bar.

Visual BasicCopy Code
Private Class MyWindow1 : Inherits Window
  Private container As AnnContainer
  'AnnAutomationManager manager;
  Private viewer As BitmapSourceViewer
  Public Sub New(ByVal title As String)
    Me.Title = title
    Me.Width = 500
    Me.Height = 200

    viewer = New BitmapSourceViewer()

    Me.Content = viewer

    ' load an image into the viewer
           viewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "ScarletMacaws.jpg")) ' fix this path to an existing image file on your system

    ' create and set up the container
    container = New AnnContainer()
    container.Width = viewer.Source.Width
    container.Height = viewer.Source.Height

    AddHandler container.MouseMove, AddressOf container_MouseMove

    ' add a few objects to the container
    Dim line As AnnLineObject = New AnnLineObject()
    line.Header = "Line1"
    line.Stroke = Brushes.Red
    line.StrokeThickness = 1.0
    line.X1 = 0
    line.Y1 = 0
    line.X2 = 100
    line.Y2 = 100
    container.Children.Add(line)

    Dim rect As AnnRectangleObject = New AnnRectangleObject()
    rect.Header = "Rectangle1"
    rect.Stroke = Brushes.Blue
    rect.StrokeThickness = 1.0
    rect.Fill = Brushes.White
    rect.Left = 25
    rect.Top = 25
    rect.Width = 50
    rect.Height = 50
    container.Children.Add(rect)
  End Sub


  Private Sub container_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
    ' perform hit-testing and update the status bar
       Dim pt As System.Windows.Point = e.GetPosition(container)
    Dim obj As AnnObjectBase = container.HitTest(pt)
    If Not obj Is Nothing Then
       Me.Title = String.Format("Type: {0}, Header: {1}, OverHeader: {2}", obj.GetType().Name, obj.Header, obj.HitTestHeader(pt))
    Else
       Me.Title = String.Empty
    End If
  End Sub
End Class

Private Sub AnnContainer_AnnContainer(ByVal title As String)
  Dim window As MyWindow1 = New MyWindow1(title)
  window.ShowDialog()
End Sub
C#Copy Code
class MyWindow1 : Window 

   AnnContainer container; 
   //AnnAutomationManager manager; 
   BitmapSourceViewer viewer; 
   public MyWindow1(string title) 
   { 
      this.Title = title; 
      this.Width = 500; 
      this.Height = 200; 
 
      viewer = new BitmapSourceViewer(); 
 
      this.Content = viewer; 
 
      // load an image into the viewer 
      viewer.Source = new BitmapImage(new Uri(LeadtoolsExamples.Common.ImagesPath.Path + "ScarletMacaws.jpg"));  // fix this path to an existing image file on your system 
 
      // create and set up the container 
      container = new AnnContainer(); 
      container.Width = viewer.Source.Width; 
      container.Height = viewer.Source.Height; 
 
      container.MouseMove += new MouseEventHandler(container_MouseMove); 
 
      // add a few objects to the container 
      AnnLineObject line = new AnnLineObject(); 
      line.Header = "Line1"; 
      line.Stroke = Brushes.Red; 
      line.StrokeThickness = 1.0; 
      line.X1 = 0; 
      line.Y1 = 0; 
      line.X2 = 100; 
      line.Y2 = 100; 
      container.Children.Add(line); 
 
      AnnRectangleObject rect = new AnnRectangleObject(); 
      rect.Header = "Rectangle1"; 
      rect.Stroke = Brushes.Blue; 
      rect.StrokeThickness = 1.0; 
      rect.Fill = Brushes.White; 
      rect.Left = 25; 
      rect.Top = 25; 
      rect.Width = 50; 
      rect.Height = 50; 
      container.Children.Add(rect); 
   } 
 
 
   private void container_MouseMove(object sender, MouseEventArgs e) 
   { 
      // perform hit-testing and update the status bar 
      Point pt = e.GetPosition(container); 
      AnnObjectBase obj = container.HitTest(pt); 
      if(obj != null) 
         this.Title = string.Format("Type: {0}, Header: {1}, OverHeader: {2}", obj.GetType().Name, obj.Header, obj.HitTestHeader(pt)); 
      else 
         this.Title = string.Empty; 
   } 

 
private void AnnContainer_AnnContainer(string title) 

   MyWindow1 window = new MyWindow1(title); 
   window.ShowDialog(); 
}

Remarks

The annotation container is a Panel that holds annotation objects. The container is responsible for maintaining these objects as well as rendering them.

Inheritance Hierarchy

System.Object
   System.Windows.Threading.DispatcherObject
      System.Windows.DependencyObject
         System.Windows.Media.Visual
            System.Windows.UIElement
               System.Windows.FrameworkElement
                  System.Windows.Controls.Panel
                     Leadtools.Windows.Annotations.AnnContainer

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family

See Also

AnnContainer requires a Document/Medical product license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features and Unlocking Special LEAD Features.