* UnsafeNativeMethods.cs: added IEnumVariant interface,
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / BindingsCollection.cs
1 //
2 // System.Windows.Forms.BindingsCollection.cs
3 //
4 // Author:
5 //   stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 //   Dennis Hayes (dennish@Raytek.com)
7 //
8 // (C) 2002/3 Ximian, Inc
9 //
10
11 using System.Collections;
12 using System.ComponentModel;
13
14 namespace System.Windows.Forms {
15
16         /// <summary>
17         /// Represents a collection of Binding objects for a control.
18         ///
19         /// </summary>
20         
21         public class BindingsCollection : BaseCollection {
22
23                 #region Constructors
24                 protected internal BindingsCollection () 
25                 {
26                 }
27                 #endregion
28
29                 // --- public and protected Properties ---
30                 public override int Count {
31                         get {
32                                 return base.Count;
33                         }
34                 }
35                 
36                 public Binding this[int index] {
37                         get {
38                                 return (Binding)(base.List[index]);
39                         }
40                 }
41                 
42                 [MonoTODO]
43                 protected override ArrayList List {
44                         get {
45                                 return base.List;
46  }
47                 }
48                 
49                 // --- public Methods ---
50                 [MonoTODO]
51                 protected virtual void AddCore(Binding dataBinding) {
52                 }
53
54                 [MonoTODO]
55                 protected virtual void ClearCore(){
56                 }
57
58                 [MonoTODO]
59                 protected virtual void RemoveCore(Binding dataBinding){
60                 }
61
62                 // 
63                 // CollectionChanged event:
64                 // Though it was not documented, here methods Add and Remove 
65                 // cause the CollectionChanged event to occur, similarily as Clear.
66                 // Would be nice if someone checked the exact event behavior of .NET implementation.
67                 
68                 protected internal void Add(Binding binding) 
69                 {
70                         base.List.Add(binding);
71                         OnCollectionChanged(new CollectionChangeEventArgs(
72                                 CollectionChangeAction.Add,
73                                 base.List
74                         ));
75                 }
76                 
77                 protected internal void Clear() 
78                 {
79                         base.List.Clear();
80                         OnCollectionChanged(new CollectionChangeEventArgs(
81                                 CollectionChangeAction.Refresh,
82                                 base.List
83                         ));
84                 }
85
86                 protected virtual void OnCollectionChanged(CollectionChangeEventArgs ccevent) 
87                 {
88                         if (CollectionChanged != null)
89                                 CollectionChanged(this, ccevent);
90                 }
91
92                 protected internal void Remove(Binding binding) 
93                 {
94                         base.List.Remove(binding);
95                         OnCollectionChanged(new CollectionChangeEventArgs(
96                                 CollectionChangeAction.Remove,
97                                 base.List
98                         ));
99                 }
100
101                 protected internal void RemoveAt(int index) 
102                 {
103                         base.List.RemoveAt(index);
104                         OnCollectionChanged(new CollectionChangeEventArgs(
105                                 CollectionChangeAction.Remove,
106                                 base.List
107                         ));
108                 }
109                 
110                 protected internal bool ShouldSerializeMyAll() 
111                 {
112                         if (this.Count>0) return true;
113                         else return false;
114                 }
115                 
116                 // public events
117                 public event CollectionChangeEventHandler CollectionChanged;
118         }
119 }