2006-06-26 Chris Toshok <toshok@ximian.com>
authorChris Toshok <toshok@novell.com>
Mon, 26 Jun 2006 16:31:38 +0000 (16:31 -0000)
committerChris Toshok <toshok@novell.com>
Mon, 26 Jun 2006 16:31:38 +0000 (16:31 -0000)
* Binding.cs: make this work bi-directionally.  also, clear up
other mixups between Push/Pull Data (e.g. we're supposed to pull
data when validating).

* BindingManagerBase.cs: trim some fully qualified collection
types.

* PropertyManager.cs (get_IsSuspended): oops, fix this check.

svn path=/trunk/mcs/; revision=62056

mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingManagerBase.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/PropertyManager.cs

index 6383442358e5d242774b3ba06554a47304e0fdcb..c693671d4a7aaf858a4dc9571b3143aa63724db0 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Windows.Forms {
                private Control control;
 
                private BindingManagerBase manager;
-               private PropertyDescriptor prop_desc;
+               private PropertyDescriptor control_property;
                private PropertyDescriptor is_null_desc;
 
                private EventDescriptor changed_event;
@@ -124,14 +124,14 @@ namespace System.Windows.Forms {
                        if (control == this.control)
                                return;
 
-                       prop_desc = TypeDescriptor.GetProperties (control).Find (property_name, true);                  
+                       control_property = TypeDescriptor.GetProperties (control).Find (property_name, true);                   
                        
-                       if (prop_desc == null)
+                       if (control_property == null)
                                throw new ArgumentException (String.Concat ("Cannot bind to property '", property_name, "' on target control."));
-                       if (prop_desc.IsReadOnly)
+                       if (control_property.IsReadOnly)
                                throw new ArgumentException (String.Concat ("Cannot bind to property '", property_name, "' because it is read only."));
                                
-                       data_type = prop_desc.PropertyType; // Getting the PropertyType is kinda slow and it should never change, so it is cached
+                       data_type = control_property.PropertyType; // Getting the PropertyType is kinda slow and it should never change, so it is cached
                        control.Validating += new CancelEventHandler (ControlValidatingHandler);
 
                        this.control = control;
@@ -149,8 +149,7 @@ namespace System.Windows.Forms {
 
                        manager.AddBinding (this);
                        manager.PositionChanged += new EventHandler (PositionChangedHandler);
-
-                       WirePropertyValueChangedEvent ();
+                       manager.CurrentChanged += new EventHandler (CurrentChangedHandler);
 
                        is_null_desc = TypeDescriptor.GetProperties (manager.Current).Find (property_name + "IsNull", false);
 
@@ -162,8 +161,8 @@ namespace System.Windows.Forms {
                        if (IsBinding == false || manager.Current == null)
                                return;
 
-                       data = prop_desc.GetValue (control);
-                       data = FormatData (data);
+                       data = control_property.GetValue (control);
+                       data = ParseData (data, manager.Current.GetType());
                        SetPropertyValue (data);
                }
 
@@ -182,12 +181,10 @@ namespace System.Windows.Forms {
 
                        PropertyDescriptor pd = TypeDescriptor.GetProperties (manager.Current).Find (binding_member_info.BindingField, true);
                        if (pd == null) {
-                               object pulled = manager.Current;
-                               data = ParseData (pulled, pulled.GetType ());
+                               data = ParseData (manager.Current, manager.Current.GetType ());
                        }
                        else {
-                               object pulled = pd.GetValue (manager.Current);
-                               data = ParseData (pulled, pd.PropertyType);
+                               data = ParseData (pd.GetValue (manager.Current), pd.PropertyType);
                        }
 
                        data = FormatData (data);
@@ -201,46 +198,25 @@ namespace System.Windows.Forms {
 
                private void SetControlValue (object data)
                {
-                       prop_desc.SetValue (control, data);
+                       control_property.SetValue (control, data);
                }
 
                private void SetPropertyValue (object data)
                {
-                       PropertyDescriptor pd = TypeDescriptor.GetProperties (manager.Current).Find (binding_member_info.BindingField, true);
+                       PropertyDescriptor pd = TypeDescriptor.GetProperties (data_source).Find (binding_member_info.BindingField, true);
                        if (pd.IsReadOnly)
                                return;
-                       pd.SetValue (manager.Current, data);
-               }
-
-               private void CurrentChangedHandler ()
-               {
-                       if (changed_event != null) {
-                               changed_event.RemoveEventHandler (event_current, property_value_changed_handler);
-                               WirePropertyValueChangedEvent ();
-                       }
-               }
-
-               private void WirePropertyValueChangedEvent ()
-               {
-                       if (manager.Current == null)
-                               return;
-                       EventDescriptor changed_event = TypeDescriptor.GetEvents (manager.Current).Find (property_name + "Changed", false);
-                       if (changed_event == null)
-                               return;
-                       property_value_changed_handler = new EventHandler (PropertyValueChanged);
-                       changed_event.AddEventHandler (manager.Current, property_value_changed_handler);
-
-                       event_current = manager.Current;
+                       pd.SetValue (data_source, data);
                }
 
-               private void PropertyValueChanged (object sender, EventArgs e)
+               private void CurrentChangedHandler (object sender, EventArgs e)
                {
                        PushData ();
                }
 
                private void ControlValidatingHandler (object sender, CancelEventArgs e)
                {
-                       PushData ();
+                       PullData ();
                }
 
                private void PositionChangedHandler (object sender, EventArgs e)
index 73c70d6580704358a5a68eae23de85baba542ab8..9d33131bf33e3a6e3ebfddd5391582fc962ad8c2 100644 (file)
@@ -90,16 +90,16 @@ namespace System.Windows.Forms {
 
                #region Protected Instance Methods
                [MonoTODO]
-               protected internal virtual PropertyDescriptorCollection GetItemProperties(System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors) {
+               protected internal virtual PropertyDescriptorCollection GetItemProperties(ArrayList dataSources, ArrayList listAccessors) {
                        throw new NotImplementedException();
                }
 
                [MonoTODO]
-               protected virtual PropertyDescriptorCollection GetItemProperties(Type lisType, int offset, System.Collections.ArrayList dataSources, System.Collections.ArrayList listAccessors) {
+               protected virtual PropertyDescriptorCollection GetItemProperties(Type lisType, int offset, ArrayList dataSources, ArrayList listAccessors) {
                        throw new NotImplementedException();
                }
 
-               protected internal abstract string GetListName (System.Collections.ArrayList listAccessors);
+               protected internal abstract string GetListName (ArrayList listAccessors);
 
                protected internal abstract void OnCurrentChanged (EventArgs e);
 
index 82973808c63c6ee398f7becde86491ac1fcd0fb2..6e0e11a65455bce0702e807325f562e809d28ef0 100644 (file)
@@ -1,3 +1,14 @@
+2006-06-26  Chris Toshok  <toshok@ximian.com>
+
+       * Binding.cs: make this work bi-directionally.  also, clear up
+       other mixups between Push/Pull Data (e.g. we're supposed to pull
+       data when validating).
+
+       * BindingManagerBase.cs: trim some fully qualified collection
+       types.
+
+       * PropertyManager.cs (get_IsSuspended): oops, fix this check.
+
 2006-06-23  Chris Toshok  <toshok@ximian.com>
 
        * PropertyManager.cs: It appears (according to the unit tests)
index c13bcd3da74534912d65553d8e8444502caa0ad4..c92df20e2fa2343829190b26b6ffadfb7ca17fa7 100644 (file)
@@ -134,7 +134,7 @@ namespace System.Windows.Forms {
                }
 
                 internal override bool IsSuspended {
-                        get { return data_source != null; }
+                        get { return data_source == null; }
                 }
 
                protected internal override string GetListName (ArrayList list)