Ver Fonte

2006-12-21 Daniel Nauck <[email protected]>

	* ComboBox.cs,
	TextBox.cs: Implemented AutoComplete properties.
	* Locale.cs: Added Locale.GetText (string msg, params object [] args).


svn path=/trunk/mcs/; revision=69848
Daniel Nauck há 19 anos atrás
pai
commit
e6f845c3ce

+ 4 - 0
mcs/class/Managed.Windows.Forms/Assembly/ChangeLog

@@ -1,3 +1,7 @@
+2006-12-21  Daniel Nauck  <[email protected]>
+
+	* Locale.cs: Added Locale.GetText (string msg, params object [] args).
+
 2005-02-13  Peter Bartok  <[email protected]>
 
 	* Locale.cs: Implemented support for reading resources from

+ 5 - 0
mcs/class/Managed.Windows.Forms/Assembly/Locale.cs

@@ -67,6 +67,11 @@ namespace System.Windows.Forms {
 			return msg;
 		}
 
+		public static string GetText (string msg, params object [] args)
+		{
+			return String.Format (GetText (msg), args);
+		}
+
 		public static object GetResource(string name) {
 			return rm.GetObject(name);
 		}

+ 5 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,8 @@
+2006-12-21  Daniel Nauck  <[email protected]>
+
+	* ComboBox.cs,
+	TextBox.cs: Implemented AutoComplete properties.
+
 2006-12-20  Chris Toshok  <[email protected]>
 
 	* DataGridView*.cs: some corecompare work.

+ 78 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ComboBox.cs

@@ -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 @@ using System.Runtime.InteropServices;
 
 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 @@ namespace System.Windows.Forms
 		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 @@ namespace System.Windows.Forms
 		#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((value < AutoCompleteMode.None) || (value > AutoCompleteMode.SuggestAppend))
+					throw new InvalidEnumArgumentException (Locale.GetText ("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 (Locale.GetText ("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 @@ namespace System.Windows.Forms
 		#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; }

+ 81 - 2
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs

@@ -21,7 +21,7 @@
 //
 // Authors:
 //	Peter Bartok	[email protected]
-//
+//     Daniel Nauck    (dna(at)mono-project(dot)de)
 //
 
 // NOT COMPLETE
@@ -30,8 +30,15 @@ using System;
 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 @@ namespace System.Windows.Forms {
 		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,11 +93,77 @@ namespace System.Windows.Forms {
 		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((value < AutoCompleteMode.None) || (value > AutoCompleteMode.SuggestAppend))
+					throw new InvalidEnumArgumentException (Locale.GetText ("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 (Locale.GetText ("Enum argument value '{0}' is not valid for AutoCompleteSource", value));
+
+				auto_complete_source = value;
+			}
+		}
 
 		[DefaultValue(false)]
 		public bool UseSystemPasswordChar {

+ 5 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog

@@ -1,3 +1,8 @@
+2006-12-21  Daniel Nauck  <[email protected]>
+
+	* ComboBoxTest.cs,
+	TextBoxTest.cs: Added AutoComplete property tests.
+
 2006-12-20  Rolf Bjarne Kvinge  <[email protected]>
 	
 	* DateTimePickerTest.cs: Created.

+ 9 - 1
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ComboBoxTest.cs

@@ -54,7 +54,7 @@ namespace MonoTests.System.Windows.Forms
 			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,14 @@ namespace MonoTests.System.Windows.Forms
 			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");
+
+			mycmbbox.AutoCompleteCustomSource = null;
+			Assert.AreEqual (true, mycmbbox.AutoCompleteCustomSource != null, "#21");
+#endif
 		}
 
 		[Test]

+ 8 - 0
mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TextBoxTest.cs

@@ -87,6 +87,14 @@ namespace MonoTests.System.Windows.Forms
 			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");
+
+			textBox.AutoCompleteCustomSource = null;
+			Assert.AreEqual (true, textBox.AutoCompleteCustomSource != null, "#30");
+#endif
 		}
 
 #if NET_2_0