main
1using System.Windows.Forms;
2using gorilla.commons.utility;
3
4namespace MoMoney.Presentation.Winforms.Databinding
5{
6 public class TextPropertyBinding<TypeToBindTo, PropertyType> : IPropertyBinding<PropertyType>
7 {
8 readonly IPropertyBinder<TypeToBindTo, PropertyType> binder;
9
10 public TextPropertyBinding(Control control, IPropertyBinder<TypeToBindTo, PropertyType> binder)
11 {
12 this.binder = binder;
13 control.Text = "{0}".formatted_using(binder.current_value());
14 control.TextChanged +=
15 (o, e) => binder.change_value_of_property_to(control.Text.converted_to<PropertyType>());
16 }
17
18 public PropertyType current_value()
19 {
20 return binder.current_value();
21 }
22 }
23}