Author: calberto
Date: 2008-01-28 19:16:20 -0500 (Mon, 28 Jan 2008)
New Revision: 94198
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingCompleteEventArgs.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
Log:
2008-01-28 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* Binding.cs: Initial implementation bits of FormattingEnabled
property and BindingComplete event (2.0).
* BindingCompleteEventArgs.cs: Internal methods for setting error text
and exception.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
2008-01-29 00:12:47 UTC (rev 94197)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Binding.cs
2008-01-29 00:16:20 UTC (rev 94198)
@@ -54,6 +54,7 @@
//private object null_value;
//private string format_string;
//private IFormatProvider format_info;
+ private bool formatting_enabled;
#endif
#region Public Constructors
#if NET_2_0
@@ -130,6 +131,21 @@
}
}
+#if NET_2_0
+ [DefaultValue (false)]
+ public bool FormattingEnabled {
+ get {
+ return formatting_enabled;
+ }
+ set {
+ if (formatting_enabled == value)
+ return;
+
+ formatting_enabled = value;
+ }
+ }
+#endif
+
public bool IsBinding {
get {
return is_binding;
@@ -145,6 +161,14 @@
#endregion // Public Instance Properties
#region Protected Instance Methods
+#if NET_2_0
+ protected virtual void OnBindingComplete
(BindingCompleteEventArgs args)
+ {
+ if (BindingComplete != null)
+ BindingComplete (this, args);
+ }
+#endif
+
protected virtual void OnFormat (ConvertEventArgs cevent)
{
if (Format!=null)
@@ -208,7 +232,23 @@
return;
data = control_property.GetValue (control);
- SetPropertyValue (data);
+
+ try {
+ SetPropertyValue (data);
+ } catch (Exception e) {
+#if NET_2_0
+ if (formatting_enabled) {
+ FireBindingComplete
(BindingCompleteContext.DataSourceUpdate, e, e.Message);
+ return;
+ }
+#endif
+ throw e;
+ }
+
+#if NET_2_0
+ if (formatting_enabled)
+ FireBindingComplete
(BindingCompleteContext.DataSourceUpdate, null, null);
+#endif
}
internal void PushData ()
@@ -231,8 +271,23 @@
data = pd.GetValue (manager.Current);
}
- data = FormatData (data);
- SetControlValue (data);
+ try {
+ data = FormatData (data);
+ SetControlValue (data);
+ } catch (Exception e) {
+#if NET_2_0
+ if (formatting_enabled) {
+ FireBindingComplete
(BindingCompleteContext.ControlUpdate, e, e.Message);
+ return;
+ }
+#endif
+ throw e;
+ }
+
+#if NET_2_0
+ if (formatting_enabled)
+ FireBindingComplete
(BindingCompleteContext.ControlUpdate, null, null);
+#endif
}
internal void UpdateIsBinding ()
@@ -325,10 +380,27 @@
return null;
}
+#if NET_2_0
+ void FireBindingComplete (BindingCompleteContext context,
Exception exc, string error_message)
+ {
+ BindingCompleteEventArgs args = new
BindingCompleteEventArgs (this,
+ exc == null ?
BindingCompleteState.Success : BindingCompleteState.Exception,
+ context);
+ if (exc != null) {
+ args.SetException (exc);
+ args.SetErrorText (error_message);
+ }
+ OnBindingComplete (args);
+ }
+#endif
+
#region Events
public event ConvertEventHandler Format;
public event ConvertEventHandler Parse;
+#if NET_2_0
+ public event BindingCompleteEventHandler BindingComplete;
+#endif
#endregion // Events
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingCompleteEventArgs.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingCompleteEventArgs.cs
2008-01-29 00:12:47 UTC (rev 94197)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/BindingCompleteEventArgs.cs
2008-01-29 00:16:20 UTC (rev 94198)
@@ -88,6 +88,16 @@
get { return this.exception; }
}
#endregion // Public Instance Properties
+
+ internal void SetErrorText (string error_text)
+ {
+ this.error_text = error_text;
+ }
+
+ internal void SetException (Exception exception)
+ {
+ this.exception = exception;
+ }
}
}
-#endif
\ No newline at end of file
+#endif
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-01-29 00:12:47 UTC (rev 94197)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2008-01-29 00:16:20 UTC (rev 94198)
@@ -1,3 +1,10 @@
+2008-01-28 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+ * Binding.cs: Initial implementation bits of FormattingEnabled
+ property and BindingComplete event (2.0).
+ * BindingCompleteEventArgs.cs: Internal methods for setting error text
+ and exception.
+
2008-01-28 Jonathan Pobst <[EMAIL PROTECTED]>
* TableLayoutPanel.cs: Draw the table border at 0,0 instead of
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches