Commit 3ae4fd5
Changed files (5)
product
Gorilla.Commons.Windows.Forms
Gorilla.Commons.Windows.Forms.ThirdParty
product/Gorilla.Commons.Windows.Forms/Databinding/TextBoxExtensions.cs
@@ -0,0 +1,13 @@
+using System.Windows.Forms;
+using Gorilla.Commons.Windows.Forms.Helpers;
+
+namespace Gorilla.Commons.Windows.Forms.Databinding
+{
+ static public class TextBoxExtensions
+ {
+ static public ITextControl<T> text_control<T>(this TextBox textbox)
+ {
+ return new TextControl<T>(textbox);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms/Gorilla.Commons.Windows.Forms.csproj
@@ -75,6 +75,7 @@
<Compile Include="Databinding\PropertyInspectorFactory.cs" />
<Compile Include="Databinding\PropertyInspectorSpecs.cs" />
<Compile Include="Databinding\TextBoxDataBindingSpecs.cs" />
+ <Compile Include="Databinding\TextBoxExtensions.cs" />
<Compile Include="Databinding\TextPropertyBinding.cs" />
<Compile Include="Helpers\BindableListBox.cs" />
<Compile Include="Helpers\BindableListBoxSpecs.cs" />
product/Gorilla.Commons.Windows.Forms.ThirdParty/Krypton/KryptonTextControl.cs
@@ -0,0 +1,37 @@
+using System;
+using ComponentFactory.Krypton.Toolkit;
+using Gorilla.Commons.Windows.Forms.Helpers;
+
+namespace Gorilla.Commons.Windows.Forms.Krypton
+{
+ public class KryptonTextControl<T> : ITextControl<T>
+ {
+ readonly KryptonTextBox textbox;
+ T bound_item;
+
+ public KryptonTextControl(KryptonTextBox textbox)
+ {
+ this.textbox = textbox;
+ when_text_is_changed = () => { };
+ textbox.TextChanged += (sender, args) => when_text_is_changed();
+ }
+
+ public void set_selected_item(T item)
+ {
+ textbox.Text = item.ToString();
+ bound_item = item;
+ }
+
+ public T get_selected_item()
+ {
+ return bound_item;
+ }
+
+ public string text()
+ {
+ return textbox.Text;
+ }
+
+ public Action when_text_is_changed { get; set; }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms.ThirdParty/Krypton/TextBoxExtensions.cs
@@ -0,0 +1,13 @@
+using ComponentFactory.Krypton.Toolkit;
+using Gorilla.Commons.Windows.Forms.Helpers;
+
+namespace Gorilla.Commons.Windows.Forms.Krypton
+{
+ static public class TextBoxExtensions
+ {
+ static public ITextControl<T> text_control<T>(this KryptonTextBox textbox)
+ {
+ return new KryptonTextControl<T>(textbox);
+ }
+ }
+}
\ No newline at end of file
product/Gorilla.Commons.Windows.Forms.ThirdParty/Gorilla.Commons.Windows.Forms.ThirdParty.csproj
@@ -53,6 +53,8 @@
<Compile Include="Krypton\BindableListExtensions.cs" />
<Compile Include="Krypton\KryptonComboBoxListControl.cs" />
<Compile Include="Krypton\KryptonListBoxListControl.cs" />
+ <Compile Include="Krypton\KryptonTextControl.cs" />
+ <Compile Include="Krypton\TextBoxExtensions.cs" />
<Compile Include="Krypton\ListboxExtensions.cs" />
</ItemGroup>
<ItemGroup>