Error processing SSI file
LEADTOOLS Annotations for WPF and Silverlight (Leadtools.Windows.Annotations assembly)

Show in webframe

AnnContainer Class






Members 
Represents an Annotation container.
Object Model
Syntax
Remarks
The annotation container is a Panel that holds annotation objects. The container is responsible for maintaining these objects as well as rendering them.
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.

Copy Code  
Imports Leadtools.Windows.Annotations
Imports Leadtools.Windows.Controls
Imports Leadtools
Imports Leadtools.Codecs

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
      ' fix this path to an existing image file on your system
      viewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))

      ' 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)

      'attach container to the viewer
      viewer.Content = container

   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
using Leadtools;
using Leadtools.Windows.Annotations;
using Leadtools.Windows.Controls;
using Leadtools.Codecs;

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
      // fix this path to an existing image file on your system
      viewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));  

      // 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);

      //attach container to the viewer
      viewer.Content = container;
   }


   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";
}
using Leadtools.Windows.Annotations;
using Leadtools.Windows.Controls;
using Leadtools.Examples;

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 , assume that cannon.jpg was added to your project
      Uri uri = new Uri(@"cannon.jpg", UriKind.Relative);
      viewer.Source = new BitmapImage(uri);  

      // 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);

      //attach container to the viewer
      viewer.Content = container;
   }


   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();
}
Imports Leadtools.Windows.Annotations
Imports Leadtools.Windows.Controls

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 , assume that cannon.jpg was added to your project
      Dim uri As Uri = New Uri("cannon.jpg", UriKind.Relative)
      viewer.Source = New BitmapImage(uri)

      ' 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)

      'attach container to the viewer
      viewer.Content = container

   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
Requirements

Target Platforms

See Also

Reference

AnnContainer Members
Leadtools.Windows.Annotations Namespace

Error processing SSI file
   Leadtools.Windows.Annotations requires a Document or Medical toolkit license and unlock key. For more information, refer to: LEADTOOLS Toolkit Features