Represents an Annotation container.
public class AnnContainer : IAnnContainer, Canvas Public Class AnnContainerInherits System.Windows.Controls.CanvasImplements Leadtools.Windows.Annotations.IAnnContainer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
public ref class AnnContainer : public System.Windows.Controls.Canvas, Leadtools.Windows.Annotations.IAnnContainer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable The annotation container is a Panel that holds annotation objects. The container is responsible for maintaining these objects as well as rendering them.
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.
using Leadtools;using Leadtools.Windows.Annotations;using Leadtools.Windows.Controls;using Leadtools.Codecs;//using Leadtools.Demos;//using Leadtools.Help;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 systemviewer.Source = new BitmapImage(new Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")));// create and set up the containercontainer = new AnnContainer();container.Width = viewer.Source.Width;container.Height = viewer.Source.Height;container.MouseMove += new MouseEventHandler(container_MouseMove);// add a few objects to the containerAnnLineObject 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 viewerviewer.Content = container;}private void container_MouseMove(object sender, MouseEventArgs e){// perform hit-testing and update the status barPoint 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));elsethis.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";}
Imports Leadtools.Windows.AnnotationsImports Leadtools.Windows.ControlsImports LeadtoolsImports Leadtools.CodecsPrivate Class MyWindow1 : Inherits WindowPrivate container As AnnContainer'AnnAutomationManager manager;Private viewer As ImageViewerPublic Sub New(ByVal title As String)Me.Title = titleMe.Width = 500Me.Height = 200viewer = New ImageViewer()Me.Content = viewer' load an image into the viewer' fix this path to an existing image file on your systemviewer.Source = New BitmapImage(New Uri(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")))' create and set up the containercontainer = New AnnContainer()container.Width = viewer.Source.Widthcontainer.Height = viewer.Source.HeightAddHandler container.MouseMove, AddressOf container_MouseMove' add a few objects to the containerDim line As AnnLineObject = New AnnLineObject()line.Header = "Line1"line.Stroke = Colors.Redline.StrokeThickness = 1.0line.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.Bluerect.StrokeThickness = 1.0rect.Fill = Colors.Whiterect.Rect = New Rect(25, 25, 50, 50)container.Children.Add(rect)'attach container to the viewerviewer.Content = containerEnd SubPrivate Sub container_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)' perform hit-testing and update the status barDim pt As System.Windows.Point = e.GetPosition(container)Dim obj As AnnObject = container.HitTest(pt)If Not obj Is Nothing ThenMe.Title = String.Format("Type: {0}, Header: {1}, OverHeader: {2}", obj.GetType().Name, obj.Header, obj.HitTestHeader(pt))ElseMe.Title = String.EmptyEnd IfEnd SubEnd ClassPrivate Sub AnnContainer_AnnContainer(ByVal title As String)Dim window As MyWindow1 = New MyWindow1(title)window.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
using Leadtools.Windows.Annotations;using Leadtools.Windows.Controls;using Leadtools.Examples;//using Leadtools.Help;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 projectUri uri = new Uri(@"cannon.jpg", UriKind.Relative);viewer.Source = new BitmapImage(uri);// create and set up the containercontainer = 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 containerAnnLineObject 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 viewerviewer.Content = container;}private void container_MouseMove(object sender, MouseEventArgs e){// perform hit-testing and update the status barPoint 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));elsethis.Title = string.Empty;}}private void AnnContainer_AnnContainer(string title){MyWindow1 window = new MyWindow1(title);window.Show();}
Imports Leadtools.Windows.AnnotationsImports Leadtools.Windows.ControlsPrivate Class MyWindow1 : Inherits ChildWindowPrivate container As AnnContainer'AnnAutomationManager manager;Private viewer As ImageViewerPublic Sub New(ByVal title As String)Me.Title = titleMe.Width = 500Me.Height = 200viewer = New ImageViewer()Me.Content = viewer'load an image into the viewer , assume that cannon.jpg was added to your projectDim uri As Uri = New Uri("cannon.jpg", UriKind.Relative)viewer.Source = New BitmapImage(uri)' create and set up the containercontainer = New AnnContainer()container.Width = (CType(viewer.Source, BitmapSource)).PixelWidthcontainer.Height = (CType(viewer.Source, BitmapSource)).PixelHeightAddHandler container.MouseMove, AddressOf container_MouseMove' add a few objects to the containerDim line As AnnLineObject = New AnnLineObject()line.Header = "Line1"line.Stroke = Colors.Redline.Start = New Point(0, 0)line.End = New Point(100, 100)line.StrokeThickness = 1.0container.Children.Add(line)Dim rect As AnnRectangleObject = New AnnRectangleObject()rect.Header = "Rectangle1"rect.Stroke = Colors.Bluerect.Fill = Colors.Whiterect.Rect = New Rect(25, 25, 50, 50)rect.StrokeThickness = 1.0container.Children.Add(rect)'attach container to the viewerviewer.Content = containerEnd SubPrivate Sub container_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)' perform hit-testing and update the status barDim pt As Point = e.GetPosition(container)Dim obj As AnnObject = container.HitTest(pt)If Not obj Is Nothing ThenMe.Title = String.Format("Type: {0}, Header: {1}, OverHeader: {2}", obj.GetType().Name, obj.Header, obj.HitTestHeader(pt))ElseMe.Title = String.EmptyEnd IfEnd SubEnd ClassPrivate Sub AnnContainer_AnnContainer(ByVal title As String)Dim window As MyWindow1 = New MyWindow1(title)window.Show()End Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
