←Select platform

AnnObjectCollection Class

Summary

Represents an ordered collection of AnnObject.

Syntax

C#
VB
C++
public sealed class AnnObjectCollection : ObservableCollection<AnnObject> 
  
Public NotInheritable Class AnnObjectCollection  
   Inherits System.Collections.ObjectModel.ObservableCollection(Of AnnObject) 
   Implements System.Collections.Generic.ICollection(Of AnnObject), System.Collections.Generic.IEnumerable(Of AnnObject), System.Collections.Generic.IList(Of AnnObject), System.Collections.Generic.IReadOnlyCollection(Of AnnObject), System.Collections.Generic.IReadOnlyList(Of AnnObject), System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged  
public ref class AnnObjectCollection sealed : public System.Collections.ObjectModel.ObservableCollection<AnnObject>, System.Collections.Generic.ICollection<AnnObject>, System.Collections.Generic.IEnumerable<AnnObject>, System.Collections.Generic.IList<AnnObject>, System.Collections.Generic.IReadOnlyCollection<AnnObject>, System.Collections.Generic.IReadOnlyList<AnnObject>, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList, System.Collections.Specialized.INotifyCollectionChanged, System.ComponentModel.INotifyPropertyChanged   

Example

C#
VB
Silverlight C#
Silverlight VB
using Leadtools.Windows.Controls; 
using Leadtools.Windows.Annotations; 
using Leadtools.Demos; 
using Leadtools.Help; 
 
public void AnnObjectCollectionExample(AnnContainer container) 
{ 
   container.ObjectAdded += new EventHandler<AnnObjectCollectionEventArgs>(container_ObjectAdded); 
   container.ObjectRemoved += new EventHandler<AnnObjectCollectionEventArgs>(container_ObjectRemoved); 
 
   // add a few objects 
   AnnLineObject lineObj = new AnnLineObject(); 
   lineObj.Start = new Point(100, 100); 
   lineObj.End = new Point(200, 200); 
   lineObj.Stroke = Colors.Blue; 
   lineObj.StrokeThickness = 2.0; 
   lineObj.Header = "Object 1"; 
 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   rectObj.Rect = new Rect(200, 200, 100, 100); 
   rectObj.Stroke = Colors.Blue; 
   rectObj.Fill = Colors.Transparent; 
   rectObj.StrokeThickness = 2.0; 
   rectObj.Header = "Object 2"; 
 
   AnnEllipseObject ellipseObj = new AnnEllipseObject(); 
   ellipseObj.Rect = new Rect(200, 200, 150, 100); 
   ellipseObj.Stroke = Colors.Yellow; 
   ellipseObj.Fill = Colors.Green; 
   ellipseObj.StrokeThickness = 2.0; 
   ellipseObj.Header = "Object 3"; 
 
   container.Children.Add(lineObj); 
   container.Children.Add(rectObj); 
   container.Children.Add(ellipseObj); 
 
   // insert new Object 
   AnnLineObject newLineObj = lineObj.Clone() as AnnLineObject; 
   newLineObj.Start = new Point(110, 110); 
   newLineObj.End = new Point(210, 210); 
   newLineObj.Stroke = Colors.Red; 
   newLineObj.StrokeThickness = 2.0; 
   newLineObj.Header = "New Object"; 
 
   container.Children.Insert(1, newLineObj); 
 
   // check if collection contains this new item  
   System.Diagnostics.Debug.Assert(container.Children.Contains(newLineObj)); 
 
   // remove this new item  
   container.Children.Remove(newLineObj); 
   System.Diagnostics.Debug.Assert(!container.Children.Contains(newLineObj)); 
 
   // remove the last item  
   container.Children.RemoveAt(container.Children.Count - 1); 
   System.Diagnostics.Debug.Assert(container.Children.Count == 2); 
 
   // send the first item to the end of the collection  
   container.Children.SendToBack(lineObj, true); 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) == container.Children.Count - 1); 
 
   // bring it back to the front  
   container.Children.BringToFront(lineObj, true); 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) == 0); 
 
   // clean the collection  
   container.Children.Clear(); 
   System.Diagnostics.Debug.Assert(container.Children.Count == 0); 
} 
 
private void container_ObjectAdded(object sender, AnnObjectCollectionEventArgs e) 
{ 
   Console.WriteLine("The Object ((" + e.Object.Header + ")) Has been added to the collection"); 
} 
 
private void container_ObjectRemoved(System.Object sender, AnnObjectCollectionEventArgs e) 
{ 
   Console.WriteLine("The Object ((" + e.Object.Header + ")) Has been removed from the collection"); 
} 
Imports Leadtools.Windows.Controls 
Imports Leadtools.Windows.Annotations 
 
Public Sub AnnObjectCollectionExample(ByVal container As AnnContainer) 
   AddHandler container.ObjectAdded, AddressOf container_ObjectAdded 
   AddHandler container.ObjectRemoved, AddressOf container_ObjectRemoved 
 
   ' add a few objects 
   Dim lineObj As AnnLineObject = New AnnLineObject() 
   lineObj.Start = New Point(100, 100) 
   lineObj.End = New Point(200, 200) 
   lineObj.Stroke = Colors.Blue 
   lineObj.StrokeThickness = 2.0 
   lineObj.Header = "Object 1" 
 
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject() 
   rectObj.Rect = New Rect(200, 200, 100, 100) 
   rectObj.Stroke = Colors.Blue 
   rectObj.StrokeThickness = 2.0 
   rectObj.Fill = Colors.Transparent 
   rectObj.Header = "Object 2" 
 
   Dim ellipseObj As AnnEllipseObject = New AnnEllipseObject() 
   ellipseObj.Rect = New Rect(200, 200, 150, 100) 
   ellipseObj.Stroke = Colors.Yellow 
   ellipseObj.StrokeThickness = 2.0 
   ellipseObj.Fill = Colors.Green 
   ellipseObj.Header = "Object 3" 
 
   container.Children.Add(lineObj) 
   container.Children.Add(rectObj) 
   container.Children.Add(ellipseObj) 
 
   ' insert new Object 
   Dim newLineObj As AnnLineObject = DirectCast(lineObj.Clone(), AnnLineObject) 
   newLineObj.Start = New Point(110, 110) 
   newLineObj.End = New Point(210, 210) 
   newLineObj.Stroke = Colors.Red 
   newLineObj.StrokeThickness = 2.0 
   newLineObj.Header = "New Object" 
 
   container.Children.Insert(1, newLineObj) 
 
   ' check if collection contains this new item  
   System.Diagnostics.Debug.Assert(container.Children.Contains(newLineObj)) 
 
   ' remove this new item  
   container.Children.Remove(newLineObj) 
   System.Diagnostics.Debug.Assert((Not container.Children.Contains(newLineObj))) 
 
   ' remove the last item  
   container.Children.RemoveAt(container.Children.Count - 1) 
   System.Diagnostics.Debug.Assert(container.Children.Count = 2) 
 
   ' send the first item to the end of the collection  
   container.Children.SendToBack(lineObj, True) 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) = container.Children.Count - 1) 
 
   ' bring it back to the front  
   container.Children.BringToFront(lineObj, True) 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) = 0) 
 
   ' clean the collection  
   container.Children.Clear() 
   System.Diagnostics.Debug.Assert(container.Children.Count = 0) 
End Sub 
 
Private Sub container_ObjectAdded(ByVal sender As Object, ByVal e As AnnObjectCollectionEventArgs) 
   Console.WriteLine("The Object ((" & e.Object.Header & ")) Has been added to the collection") 
End Sub 
 
Private Sub container_ObjectRemoved(ByVal sender As System.Object, ByVal e As AnnObjectCollectionEventArgs) 
   Console.WriteLine("The Object ((" & e.Object.Header & ")) Has been removed from the collection") 
End Sub 
using Leadtools.Windows.Controls; 
using Leadtools.Windows.Annotations; 
using Leadtools.Examples; 
//using Leadtools.Help; 
 
public void AnnObjectCollectionExample(AnnContainer container) 
{ 
   container.ObjectAdded += new EventHandler<AnnObjectCollectionEventArgs>(container_ObjectAdded); 
   container.ObjectRemoved += new EventHandler<AnnObjectCollectionEventArgs>(container_ObjectRemoved); 
 
   // add a few objects 
   AnnLineObject lineObj = new AnnLineObject(); 
   lineObj.Start = new Point(100, 100); 
   lineObj.End = new Point(200, 200); 
   lineObj.Stroke = Colors.Blue; 
   lineObj.StrokeThickness = 2.0; 
   lineObj.Header = "Object 1"; 
 
   AnnRectangleObject rectObj = new AnnRectangleObject(); 
   rectObj.Rect = new Rect(200, 200, 100, 100); 
   rectObj.Stroke = Colors.Blue; 
   rectObj.Fill = Colors.Transparent; 
   rectObj.StrokeThickness = 2.0; 
   rectObj.Header = "Object 2"; 
 
   AnnEllipseObject ellipseObj = new AnnEllipseObject(); 
   ellipseObj.Rect = new Rect(200, 200, 150, 100); 
   ellipseObj.Stroke = Colors.Yellow; 
   ellipseObj.Fill = Colors.Green; 
   ellipseObj.StrokeThickness = 2.0; 
   ellipseObj.Header = "Object 3"; 
 
   container.Children.Add(lineObj); 
   container.Children.Add(rectObj); 
   container.Children.Add(ellipseObj); 
 
   // insert new Object 
   AnnLineObject newLineObj = lineObj.Clone() as AnnLineObject; 
   newLineObj.Start = new Point(110, 110); 
   newLineObj.End = new Point(210, 210); 
   newLineObj.Stroke = Colors.Red; 
   newLineObj.StrokeThickness = 2.0; 
   newLineObj.Header = "New Object"; 
 
   container.Children.Insert(1, newLineObj); 
 
   // check if collection contains this new item  
   System.Diagnostics.Debug.Assert(container.Children.Contains(newLineObj)); 
 
   // remove this new item  
   container.Children.Remove(newLineObj); 
   System.Diagnostics.Debug.Assert(!container.Children.Contains(newLineObj)); 
 
   // remove the last item  
   container.Children.RemoveAt(container.Children.Count - 1); 
   System.Diagnostics.Debug.Assert(container.Children.Count == 2); 
 
   // send the first item to the end of the collection  
   container.Children.SendToBack(lineObj, true); 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) == container.Children.Count - 1); 
 
   // bring it back to the front  
   container.Children.BringToFront(lineObj, true); 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) == 0); 
 
   // clean the collection  
   container.Children.Clear(); 
   System.Diagnostics.Debug.Assert(container.Children.Count == 0); 
} 
 
private void container_ObjectAdded(object sender, AnnObjectCollectionEventArgs e) 
{ 
   Console.WriteLine("The Object ((" + e.Object.Header + ")) Has been added to the collection"); 
} 
 
private void container_ObjectRemoved(System.Object sender, AnnObjectCollectionEventArgs e) 
{ 
   Console.WriteLine("The Object ((" + e.Object.Header + ")) Has been removed from the collection"); 
} 
Imports Leadtools.Windows.Controls 
Imports Leadtools.Windows.Annotations 
 
Public Sub AnnObjectCollectionExample(ByVal container As AnnContainer) 
   AddHandler container.ObjectAdded, AddressOf container_ObjectAdded 
   AddHandler container.ObjectRemoved, AddressOf container_ObjectRemoved 
 
   ' add a few objects 
   Dim lineObj As AnnLineObject = New AnnLineObject() 
   lineObj.Start = New Point(100, 100) 
   lineObj.End = New Point(200, 200) 
   lineObj.Stroke = Colors.Blue 
   lineObj.StrokeThickness = 2.0 
   lineObj.Header = "Object 1" 
 
   Dim rectObj As AnnRectangleObject = New AnnRectangleObject() 
   rectObj.Rect = New Rect(200, 200, 100, 100) 
   rectObj.Stroke = Colors.Blue 
   rectObj.Fill = Colors.Transparent 
   rectObj.StrokeThickness = 2.0 
   rectObj.Header = "Object 2" 
 
   Dim ellipseObj As AnnEllipseObject = New AnnEllipseObject() 
   ellipseObj.Rect = New Rect(200, 200, 150, 100) 
   ellipseObj.Stroke = Colors.Yellow 
   ellipseObj.Fill = Colors.Green 
   ellipseObj.StrokeThickness = 2.0 
   ellipseObj.Header = "Object 3" 
 
   container.Children.Add(lineObj) 
   container.Children.Add(rectObj) 
   container.Children.Add(ellipseObj) 
 
   ' insert new Object 
   Dim newLineObj As AnnLineObject = TryCast(lineObj.Clone(), AnnLineObject) 
   newLineObj.Start = New Point(110, 110) 
   newLineObj.End = New Point(210, 210) 
   newLineObj.Stroke = Colors.Red 
   newLineObj.StrokeThickness = 2.0 
   newLineObj.Header = "New Object" 
 
   container.Children.Insert(1, newLineObj) 
 
   ' check if collection contains this new item  
   System.Diagnostics.Debug.Assert(container.Children.Contains(newLineObj)) 
 
   ' remove this new item  
   container.Children.Remove(newLineObj) 
   System.Diagnostics.Debug.Assert((Not container.Children.Contains(newLineObj))) 
 
   ' remove the last item  
   container.Children.RemoveAt(container.Children.Count - 1) 
   System.Diagnostics.Debug.Assert(container.Children.Count = 2) 
 
   ' send the first item to the end of the collection  
   container.Children.SendToBack(lineObj, True) 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) = container.Children.Count - 1) 
 
   ' bring it back to the front  
   container.Children.BringToFront(lineObj, True) 
   System.Diagnostics.Debug.Assert(container.Children.IndexOf(lineObj) = 0) 
 
   ' clean the collection  
   container.Children.Clear() 
   System.Diagnostics.Debug.Assert(container.Children.Count = 0) 
End Sub 
 
Private Sub container_ObjectAdded(ByVal sender As Object, ByVal e As AnnObjectCollectionEventArgs) 
   Console.WriteLine("The Object ((" & e.Object.Header & ")) Has been added to the collection") 
End Sub 
 
Private Sub container_ObjectRemoved(ByVal sender As System.Object, ByVal e As AnnObjectCollectionEventArgs) 
   Console.WriteLine("The Object ((" & e.Object.Header & ")) Has been removed from the collection") 
End Sub 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Windows.Annotations Assembly