Represents an Annotation container.
Object Model
Syntax
Visual Basic (Declaration) | |
---|
Public Class AnnContainer
Inherits Panel |
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 Basic | Copy Code |
---|
Private Class MyWindow1 : Inherits Window
Private container As AnnContainer
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
viewer.Source = New BitmapImage(New Uri(LeadtoolsExamples.Common.ImagesPath.Path + "ScarletMacaws.jpg"))
container = New AnnContainer()
container.Width = viewer.Source.Width
container.Height = viewer.Source.Height
AddHandler container.MouseMove, AddressOf container_MouseMove
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)
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
Inheritance Hierarchy
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows XP, Windows Vista, and Windows Server 2003 family
See Also