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;
50 internal EventHandler onCurrentItemChangedHandler;
52 #endregion // Protected Instance Fields
54 #region Public Instance Properties
55 public BindingsCollection Bindings {
57 if (bindings == null) {
58 bindings = new BindingsCollection ();
64 public abstract int Count {
68 public abstract object Current {
73 public bool IsBindingSuspended {
80 public abstract int Position {
83 #endregion // Public Instance Properties
85 #region Public Instance Methods
86 public abstract void AddNew();
88 public abstract void CancelCurrentEdit();
90 public abstract void EndCurrentEdit();
93 public virtual PropertyDescriptorCollection GetItemProperties()
95 throw new NotImplementedException ();
98 public abstract PropertyDescriptorCollection GetItemProperties();
101 public abstract void RemoveAt(int index);
103 public abstract void ResumeBinding();
105 public abstract void SuspendBinding();
106 #endregion // Public Instance Methods
108 internal virtual bool IsSuspended {
114 #region Protected Instance Methods
116 protected internal virtual PropertyDescriptorCollection GetItemProperties (ArrayList dataSources, ArrayList listAccessors)
118 throw new NotImplementedException();
122 protected virtual PropertyDescriptorCollection GetItemProperties (Type listType, int offset, ArrayList dataSources, ArrayList listAccessors)
124 throw new NotImplementedException();
127 protected internal abstract string GetListName (ArrayList listAccessors);
129 protected internal abstract void OnCurrentChanged (EventArgs e);
131 protected void PullData()
134 if (!transfering_data) {
135 transfering_data = true;
138 foreach (Binding binding in Bindings) {
142 transfering_data = false;
146 protected void PushData()
149 if (!transfering_data) {
150 transfering_data = true;
153 foreach (Binding binding in Bindings) {
157 transfering_data = false;
163 protected void OnBindingComplete (BindingCompleteEventArgs args)
165 if (BindingComplete != null)
166 BindingComplete (this, args);
169 protected abstract void OnCurrentItemChanged (EventArgs e);
171 protected void OnDataError (Exception e)
173 if (DataError != null)
174 DataError (this, new BindingManagerDataErrorEventArgs (e));
178 protected abstract void UpdateIsBinding();
179 #endregion // Protected Instance Methods
181 internal void AddBinding (Binding binding)
183 if (Bindings.Contains (binding))
185 Bindings.Add (binding);
189 public event EventHandler CurrentChanged {
190 add { onCurrentChangedHandler += value; }
191 remove { onCurrentChangedHandler -= value; }
194 public event EventHandler PositionChanged {
195 add { onPositionChangedHandler += value; }
196 remove { onPositionChangedHandler -= value; }
200 public event EventHandler CurrentItemChanged {
201 add { onCurrentItemChangedHandler += value; }
202 remove { onCurrentItemChangedHandler -= value; }
205 public event BindingCompleteEventHandler BindingComplete;
206 public event BindingManagerDataErrorEventHandler DataError;