LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.31
AnnContainer Class
See Also  Members  
Leadtools.Windows.Annotations Namespace : AnnContainer Class



The AnnContainer Class supports WPF/Silverlight.

The AnnContainer Class is available in LEADTOOLS Document and Medical Imaging toolkits.

Represents an Annotation container. Supported in Silverlight, Windows Phone 7

Object Model

AnnContainer ClassAnnObjectCollection ClassAnnObject ClassAnnSnapToGridOptions Class

Syntax

Visual Basic (Declaration) 
Public Class AnnContainer 
   Inherits System.Windows.Controls.Canvas
   Implements IAnnContainerISupportInitializeIFrameworkInputElementIInputElementIAddChildIAnimatable 
Visual Basic (Usage)Copy Code
Dim instance As AnnContainer

Example

For XAML example, refer to AnnGroupObject.

This example creates a new AnnContainer object, links it to a Leadtools.Windows.Controls.ImageViewer 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 ImageViewer
      Public Sub New(ByVal title As String)
         Me.Title = title
         Me.Width = 500
         Me.Height = 200

         viewer = New ImageViewer()

         Me.Content = viewer

         ' load an image into the viewer
         viewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.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 = Colors.Red
         line.StrokeThickness = 1.0
         line.Start = New Point(0, 0)
         line.End = New Point(100, 100)
         container.Children.Add(line)

         Dim rect As AnnRectangleObject = New AnnRectangleObject()
         rect.Header = "Rectangle1"
         rect.Stroke = Colors.Blue
         rect.StrokeThickness = 1.0
         rect.Fill = Colors.White
         rect.Rect = New Rect(25, 25, 50, 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 AnnObject = 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


Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
class MyWindow1 : Window
   {
      AnnContainer container;
      //AnnAutomationManager manager;
      ImageViewer viewer;
      public MyWindow1(string title)
      {
         this.Title = title;
         this.Width = 500;
         this.Height = 200;

         viewer = new ImageViewer();
         this.Content = viewer;

         // load an image into the viewer
         viewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.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 = Colors.Red;
         line.Start = new Point(0, 0);
         line.End = new Point(100, 100);
         line.StrokeThickness = 1.0;
         container.Children.Add(line);

         AnnRectangleObject rect = new AnnRectangleObject();
         rect.Header = "Rectangle1";
         rect.Stroke = Colors.Blue;
         rect.Fill = Colors.White;
         rect.Rect = new Rect(25, 25, 50, 50);
         rect.StrokeThickness = 1.0;
         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);
         AnnObject 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();
   }


static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
class MyWindow1 : ChildWindow 
{
   AnnContainer container;
   //AnnAutomationManager manager;
   ImageViewer viewer;
   public MyWindow1(string title)
   {
      this.Title = title;
      this.Width = 500;
      this.Height = 200;

      viewer = new ImageViewer();
      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 = ((BitmapSource) viewer.Source).PixelWidth;
      container.Height = ((BitmapSource)viewer.Source).PixelHeight;

      container.MouseMove += new MouseEventHandler(container_MouseMove);

      // add a few objects to the container
      AnnLineObject line = new AnnLineObject();
      line.Header = "Line1";
      line.Stroke = Colors.Red;
      line.Start = new Point(0, 0);
      line.End = new Point(100, 100);
      line.StrokeThickness = 1.0;
      container.Children.Add(line);

      AnnRectangleObject rect = new AnnRectangleObject();
      rect.Header = "Rectangle1";
      rect.Stroke = Colors.Blue;
      rect.Fill = Colors.White;
      rect.Rect = new Rect(25, 25, 50, 50);
      rect.StrokeThickness = 1.0;
      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);
      AnnObject 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.Show();
}
SilverlightVBCopy Code
Private Class MyWindow1 : Inherits ChildWindow
   Private container As AnnContainer
   'AnnAutomationManager manager;
   Private viewer As ImageViewer
   Public Sub New(ByVal title As String)
      Me.Title = title
      Me.Width = 500
      Me.Height = 200

      viewer = New ImageViewer()
      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 = (CType(viewer.Source, BitmapSource)).PixelWidth
      container.Height = (CType(viewer.Source, BitmapSource)).PixelHeight

      AddHandler container.MouseMove, AddressOf container_MouseMove

      ' add a few objects to the container
      Dim line As AnnLineObject = New AnnLineObject()
      line.Header = "Line1"
      line.Stroke = Colors.Red
      line.Start = New Point(0, 0)
      line.End = New Point(100, 100)
      line.StrokeThickness = 1.0
      container.Children.Add(line)

      Dim rect As AnnRectangleObject = New AnnRectangleObject()
      rect.Header = "Rectangle1"
      rect.Stroke = Colors.Blue
      rect.Fill = Colors.White
      rect.Rect = New Rect(25, 25, 50, 50)
      rect.StrokeThickness = 1.0
      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 Point = e.GetPosition(container)
      Dim obj As AnnObject = 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.Show()
End Sub

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
                     System.Windows.Controls.Canvas
                        Leadtools.Windows.Annotations.AnnContainer

Requirements

Target Platforms: Silverlight 3.0, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

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.