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

Show in webframe

AnnObjectCollection Class






Members 
Represents an ordered collection of AnnObject.
Object Model
Syntax
'Usage
 
Dim instance As AnnObjectCollection

            

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

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

See Also

Reference

AnnObjectCollection 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