Hello,

attached is a patch for AutoCompletion properties on Text- and Combobox.

Further steps todo:
1.) implement a "drop-down" for TextBox for "AutoCompleteMode.Suggest"
2.) implement the AutoCompletion algorithm for both controls. (same
codebase for both controls is meaningfully)

Any suggestions?

by,
Daniel

Index: Test/System.Windows.Forms/ComboBoxTest.cs
===================================================================
--- Test/System.Windows.Forms/ComboBoxTest.cs	(Revision 69804)
+++ Test/System.Windows.Forms/ComboBoxTest.cs	(Arbeitskopie)
@@ -54,7 +54,7 @@
 			Assert.AreEqual (8, mycmbbox.MaxDropDownItems, "#8");
 			Assert.AreEqual (0, mycmbbox.MaxLength, "#9");
 			//Assert.AreEqual (20, mycmbbox.PreferredHeight, "#10");
-// Note: Item height depends on the current font.
+			// Note: Item height depends on the current font.
 			Assert.AreEqual (-1, mycmbbox.SelectedIndex, "#11");
 			Assert.AreEqual (null, mycmbbox.SelectedItem, "#12");
 			Assert.AreEqual ("", mycmbbox.SelectedText, "#13");
@@ -62,6 +62,11 @@
 			Assert.AreEqual (0, mycmbbox.SelectionStart, "#15");
 			Assert.AreEqual (false, mycmbbox.Sorted, "#16");
 			Assert.AreEqual ("", mycmbbox.Text, "#17");
+#if NET_2_0
+			Assert.AreEqual (true, mycmbbox.AutoCompleteCustomSource != null, "#18");
+			Assert.AreEqual (AutoCompleteMode.None, mycmbbox.AutoCompleteMode, "#19");
+			Assert.AreEqual (AutoCompleteSource.None, mycmbbox.AutoCompleteSource, "#20");
+#endif
 		}
 
 		[Test]
Index: Test/System.Windows.Forms/TextBoxTest.cs
===================================================================
--- Test/System.Windows.Forms/TextBoxTest.cs	(Revision 69804)
+++ Test/System.Windows.Forms/TextBoxTest.cs	(Arbeitskopie)
@@ -87,6 +87,11 @@
 			Assert.AreEqual (ScrollBars.None, textBox.ScrollBars, "#24");
 			Assert.AreEqual (-1, textBox.SelectionLength, "#25");
 			Assert.AreEqual (HorizontalAlignment.Left , textBox.TextAlign, "#26");
+#if NET_2_0
+			Assert.AreEqual (true, textBox.AutoCompleteCustomSource != null, "#27");
+			Assert.AreEqual (AutoCompleteMode.None, textBox.AutoCompleteMode, "#28");
+			Assert.AreEqual (AutoCompleteSource.None, textBox.AutoCompleteSource, "#29");
+#endif
 		}
 
 #if NET_2_0
Index: System.Windows.Forms/ComboBox.cs
===================================================================
--- System.Windows.Forms/ComboBox.cs	(Revision 69804)
+++ System.Windows.Forms/ComboBox.cs	(Arbeitskopie)
@@ -22,6 +22,7 @@
 // Authors:
 //	Jordi Mas i Hernandez, [EMAIL PROTECTED]
 //	Mike Kestner  <[EMAIL PROTECTED]>
+//	Daniel Nauck    (dna(at)mono-project(dot)de)
 //
 // NOT COMPLETE
 
@@ -37,10 +38,12 @@
 
 namespace System.Windows.Forms
 {
-
 	[DefaultProperty("Items")]
 	[DefaultEvent("SelectedIndexChanged")]
 	[Designer ("System.Windows.Forms.Design.ComboBoxDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
+#if NET_2_0
+	[ComVisible(true)]
+#endif
 	public class ComboBox : ListControl
 	{
 		private DrawMode draw_mode = DrawMode.Normal;
@@ -67,6 +70,11 @@
 		private Rectangle button_area;
 		private Rectangle listbox_area;
 		private const int button_width = 16;
+#if NET_2_0
+		private AutoCompleteStringCollection auto_complete_custom_source = null;
+		private AutoCompleteMode auto_complete_mode = AutoCompleteMode.None;
+		private AutoCompleteSource auto_complete_source = AutoCompleteSource.None;
+#endif
 
 		[ComVisible(true)]
 		public class ChildAccessibleObject : AccessibleObject {
@@ -155,6 +163,68 @@
 		#endregion Events
 
 		#region Public Properties
+#if NET_2_0
+		[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
+		[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+		[Browsable (true)]
+		[EditorBrowsable (EditorBrowsableState.Always)]
+		[Localizable (true)]
+		public AutoCompleteStringCollection AutoCompleteCustomSource { 
+			get {
+				if(auto_complete_custom_source == null) {
+					auto_complete_custom_source = new AutoCompleteStringCollection ();
+					auto_complete_custom_source.CollectionChanged += new CollectionChangeEventHandler (OnAutoCompleteCustomSourceChanged);
+				}
+				return auto_complete_custom_source;
+			}
+			set {
+				if(auto_complete_custom_source == value)
+					return;
+
+				if(auto_complete_custom_source != null) //remove eventhandler from old collection
+					auto_complete_custom_source.CollectionChanged -= new CollectionChangeEventHandler (OnAutoCompleteCustomSourceChanged);
+
+				auto_complete_custom_source = value;
+
+				if(auto_complete_custom_source != null)
+					auto_complete_custom_source.CollectionChanged += new CollectionChangeEventHandler (OnAutoCompleteCustomSourceChanged);
+			}
+		}
+
+		[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
+		[Browsable (true)]
+		[EditorBrowsable (EditorBrowsableState.Always)]
+		[DefaultValue (AutoCompleteMode.None)]
+		public AutoCompleteMode AutoCompleteMode {
+			get { return auto_complete_mode; }
+			set {
+				if(auto_complete_mode == value)
+					return;
+
+				if(!Enum.IsDefined (typeof (AutoCompleteMode), value))
+					throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for AutoCompleteMode", value));
+
+				auto_complete_mode = value;
+			}
+		}
+
+		[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
+		[Browsable (true)]
+		[EditorBrowsable (EditorBrowsableState.Always)]
+		[DefaultValue (AutoCompleteSource.None)]
+		public AutoCompleteSource AutoCompleteSource {
+			get { return auto_complete_source; }
+			set {
+				if(auto_complete_source == value)
+					return;
+
+				if(!Enum.IsDefined (typeof (AutoCompleteSource), value))
+					throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for AutoCompleteSource", value));
+
+				auto_complete_source = value;
+			}
+		}
+#endif
 		public override Color BackColor {
 			get { return base.BackColor; }
 			set {
@@ -1020,6 +1090,13 @@
 		#endregion Public Methods
 
 		#region Private Methods
+#if NET_2_0
+		void OnAutoCompleteCustomSourceChanged(object sender, CollectionChangeEventArgs e) {
+			if(auto_complete_source == AutoCompleteSource.CustomSource) {
+				//FIXME: handle add, remove and refresh events in AutoComplete algorithm.
+			}
+		}
+#endif
 
 		internal override bool InternalCapture {
 			get { return Capture; }
Index: System.Windows.Forms/TextBox.cs
===================================================================
--- System.Windows.Forms/TextBox.cs	(Revision 69804)
+++ System.Windows.Forms/TextBox.cs	(Arbeitskopie)
@@ -21,8 +21,8 @@
 //
 // Authors:
 //	Peter Bartok	[EMAIL PROTECTED]
+//     Daniel Nauck    (dna(at)mono-project(dot)de)
 //
-//
 
 // NOT COMPLETE
 
@@ -30,8 +30,15 @@
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.Drawing;
+#if NET_2_0
+using System.Runtime.InteropServices;
+#endif
 
 namespace System.Windows.Forms {
+
+#if NET_2_0
+	[ComVisible(true)]
+#endif
 	public class TextBox : TextBoxBase {
 		#region Variables
 		private ContextMenu	menu;
@@ -41,6 +48,12 @@
 		private MenuItem	paste;
 		private MenuItem	delete;
 		private MenuItem	select_all;
+#if NET_2_0
+		private bool use_system_password_char = false;
+		private AutoCompleteStringCollection auto_complete_custom_source = null;
+		private AutoCompleteMode auto_complete_mode = AutoCompleteMode.None;
+		private AutoCompleteSource auto_complete_source = AutoCompleteSource.None;
+#endif
 		#endregion	// Variables
 
 		#region Public Constructors
@@ -80,12 +93,78 @@
 		private void TextBox_LostFocus(object sender, EventArgs e) {
 			Invalidate();
 		}
+#if NET_2_0
+		void OnAutoCompleteCustomSourceChanged(object sender, CollectionChangeEventArgs e) {
+			if(auto_complete_source == AutoCompleteSource.CustomSource) {
+				//FIXME: handle add, remove and refresh events in AutoComplete algorithm.
+			}
+		}
+#endif
 		#endregion	// Private & Internal Methods
 
 		#region Public Instance Properties
 #if NET_2_0
-		private bool use_system_password_char = false;
+		[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
+		[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+		[Browsable (true)]
+		[EditorBrowsable (EditorBrowsableState.Always)]
+		[Localizable (true)]
+		public AutoCompleteStringCollection AutoCompleteCustomSource { 
+			get {
+				if(auto_complete_custom_source == null) {
+					auto_complete_custom_source = new AutoCompleteStringCollection ();
+					auto_complete_custom_source.CollectionChanged += new CollectionChangeEventHandler (OnAutoCompleteCustomSourceChanged);
+				}
+				return auto_complete_custom_source;
+			}
+			set {
+				if(auto_complete_custom_source == value)
+					return;
 
+				if(auto_complete_custom_source != null) //remove eventhandler from old collection
+					auto_complete_custom_source.CollectionChanged -= new CollectionChangeEventHandler (OnAutoCompleteCustomSourceChanged);
+
+				auto_complete_custom_source = value;
+
+				if(auto_complete_custom_source != null)
+					auto_complete_custom_source.CollectionChanged += new CollectionChangeEventHandler (OnAutoCompleteCustomSourceChanged);
+			}
+		}
+
+		[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
+		[Browsable (true)]
+		[EditorBrowsable (EditorBrowsableState.Always)]
+		[DefaultValue (AutoCompleteMode.None)]
+		public AutoCompleteMode AutoCompleteMode {
+			get { return auto_complete_mode; }
+			set {
+				if(auto_complete_mode == value)
+					return;
+
+				if(!Enum.IsDefined (typeof (AutoCompleteMode), value))
+					throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for AutoCompleteMode", value));
+
+				auto_complete_mode = value;
+			}
+		}
+
+		[MonoTODO("AutoCompletion algorithm is currently not implemented.")]
+		[Browsable (true)]
+		[EditorBrowsable (EditorBrowsableState.Always)]
+		[DefaultValue (AutoCompleteSource.None)]
+		public AutoCompleteSource AutoCompleteSource {
+			get { return auto_complete_source; }
+			set {
+				if(auto_complete_source == value)
+					return;
+
+				if(!Enum.IsDefined (typeof (AutoCompleteSource), value))
+					throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for AutoCompleteSource", value));
+
+				auto_complete_source = value;
+			}
+		}
+
 		[DefaultValue(false)]
 		public bool UseSystemPasswordChar {
 			get {
_______________________________________________
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to