main
1using System;
2using System.Linq.Expressions;
3using gorilla.commons.utility;
4
5namespace MoMoney.Presentation.Winforms.Helpers
6{
7 static public class BindableTextBoxExtensions
8 {
9 static public IBindableTextBox<ItemToBindTo> rebind_with<ItemToBindTo>(
10 this ITextControl<ItemToBindTo> text_control, Expression<Func<string, ItemToBindTo>> rebind)
11 {
12 return text_control.apply(new RebindTextBoxCommand<ItemToBindTo>(rebind));
13 }
14
15 static public IBindableTextBox<ItemToBindTo> apply<ItemToBindTo>(this ITextControl<ItemToBindTo> text_control,
16 params ITextBoxCommand<ItemToBindTo>[] commands)
17 {
18 return new BindableTextBox<ItemToBindTo>(text_control).apply(commands);
19 }
20
21 static public IBindableTextBox<ItemToBindTo> apply<ItemToBindTo>(this IBindableTextBox<ItemToBindTo> textbox,
22 params ITextBoxCommand<ItemToBindTo>[] commands)
23 {
24 commands.each(x => textbox.on_leave(y => x.run(y)));
25 return textbox;
26 }
27 }
28}