Leadtools.Windows.Annotations Namespace : AnnObjectCollection Class |
public sealed class AnnObjectCollection : 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
'Declaration 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
'Usage Dim instance As AnnObjectCollection
public sealed sealed class AnnObjectCollection : System.Collections.Generic.ICollection<AnnObject>, Windows.Foundation.Collections.IIterable //In WinRT the IEnumerableinterface is replaced by IIterable <AnnObject>, Windows.Foundation.Collections.IVector //In WinRT the IListinterface is replaced by IVector <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
function Leadtools.Windows.Annotations.AnnObjectCollection()
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
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
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"); }
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"); }
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
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