Leadtools.Windows.Annotations Namespace : AnnContainer Class |
public class AnnContainer : System.Windows.Controls.Canvas, IAnnContainer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
'Declaration Public Class AnnContainer Inherits System.Windows.Controls.Canvas Implements IAnnContainer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
'Usage Dim instance As AnnContainer
public sealed class AnnContainer : IAnnContainer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
function Leadtools.Windows.Annotations.AnnContainer()
public ref class AnnContainer : public System.Windows.Controls.Canvas, IAnnContainer, System.ComponentModel.ISupportInitialize, System.Windows.IFrameworkInputElement, System.Windows.IInputElement, System.Windows.Markup.IAddChild, System.Windows.Markup.IQueryAmbient, System.Windows.Media.Animation.IAnimatable
For XAML example, refer to AnnGroupObject.
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
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"; }
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(); }
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
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2