1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
24 // Jackson Harper jackson@ximian.com
30 using System.ComponentModel;
31 using System.Collections;
33 namespace System.Windows.Forms
35 public abstract class BindingManagerBase
37 private BindingsCollection bindings;
38 internal bool transfering_data; /* true if we're pushing or pulling data */
40 #region Public Constructors
41 public BindingManagerBase()
44 #endregion // Public Constructors
46 #region Protected Instance Fields
47 protected EventHandler onCurrentChangedHandler;
48 protected EventHandler onPositionChangedHandler;
49 internal EventHandler onCurrentItemChangedHandler;
50 #endregion // Protected Instance Fields
52 #region Public Instance Properties
53 public BindingsCollection Bindings {
55 if (bindings == null) {
56 bindings = new BindingsCollection ();
62 public abstract int Count {
66 public abstract object Current {
70 public bool IsBindingSuspended {
76 public abstract int Position {
79 #endregion // Public Instance Properties
81 #region Public Instance Methods
82 public abstract void AddNew();
84 public abstract void CancelCurrentEdit();
86 public abstract void EndCurrentEdit();
88 public virtual PropertyDescriptorCollection GetItemProperties()
90 return GetItemPropertiesInternal ();
93 internal virtual PropertyDescriptorCollection GetItemPropertiesInternal ()
95 throw new NotImplementedException ();
98 public abstract void RemoveAt(int index);
100 public abstract void ResumeBinding();
102 public abstract void SuspendBinding();
103 #endregion // Public Instance Methods
105 internal virtual bool IsSuspended {
111 #region Protected Instance Methods
112 [MonoTODO ("Not implemented, will throw NotImplementedException")]
113 protected internal virtual PropertyDescriptorCollection GetItemProperties (ArrayList dataSources, ArrayList listAccessors)
115 throw new NotImplementedException();
118 [MonoTODO ("Not implemented, will throw NotImplementedException")]
119 protected virtual PropertyDescriptorCollection GetItemProperties (Type listType, int offset, ArrayList dataSources, ArrayList listAccessors)
121 throw new NotImplementedException();
124 protected internal abstract string GetListName (ArrayList listAccessors);
126 protected internal abstract void OnCurrentChanged (EventArgs e);
128 protected void PullData()
131 if (!transfering_data) {
132 transfering_data = true;
135 foreach (Binding binding in Bindings) {
139 transfering_data = false;
143 protected void PushData()
146 if (!transfering_data) {
147 transfering_data = true;
150 foreach (Binding binding in Bindings) {
154 transfering_data = false;
159 protected void OnBindingComplete (BindingCompleteEventArgs args)
161 if (BindingComplete != null)
162 BindingComplete (this, args);
165 protected abstract void OnCurrentItemChanged (EventArgs e);
167 protected void OnDataError (Exception e)
169 if (DataError != null)
170 DataError (this, new BindingManagerDataErrorEventArgs (e));
173 protected abstract void UpdateIsBinding();
174 #endregion // Protected Instance Methods
176 internal void AddBinding (Binding binding)
178 if (Bindings.Contains (binding))
180 Bindings.Add (binding);
184 public event EventHandler CurrentChanged {
185 add { onCurrentChangedHandler += value; }
186 remove { onCurrentChangedHandler -= value; }
189 public event EventHandler PositionChanged {
190 add { onPositionChangedHandler += value; }
191 remove { onPositionChangedHandler -= value; }
194 public event EventHandler CurrentItemChanged {
195 add { onCurrentItemChangedHandler += value; }
196 remove { onCurrentItemChangedHandler -= value; }
199 public event BindingCompleteEventHandler BindingComplete;
200 public event BindingManagerDataErrorEventHandler DataError;