BindingsCollection.cs 2.6 KB

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