Author: gert
Date: 2006-11-19 08:27:26 -0500 (Sun, 19 Nov 2006)
New Revision: 68148

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs
Log:
* NumericUpDown.cs: Use NegativeSign, NumberDecimalSeparator and
NumberGroupSeparator of current culture instead of assuming en-US.
Fixed bug #79967.


Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-19 12:46:46 UTC (rev 68147)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-19 13:27:26 UTC (rev 68148)
@@ -1,3 +1,9 @@
+2006-11-19  Gert Driesen  <[EMAIL PROTECTED]>
+
+       * NumericUpDown.cs: Use NegativeSign, NumberDecimalSeparator and
+       NumberGroupSeparator of current culture instead of assuming en-US.
+       Fixed bug #79967.
+
 2006-11-17  Mike Kestner  <[EMAIL PROTECTED]>
 
        * Control.cs: Add the concept of implicit bounds setting so that

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs 
2006-11-19 12:46:46 UTC (rev 68147)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs 
2006-11-19 13:27:26 UTC (rev 68148)
@@ -32,6 +32,7 @@
 using System.Collections;
 using System.ComponentModel;
 using System.Drawing;
+using System.Globalization;
 using System.Runtime.InteropServices;
 using System.Text;
 using System.Windows.Forms;
@@ -315,11 +316,17 @@
                                return;
                        }
 
-                       string acceptable = hexadecimal ? 
"\b-.,0123456789abcdefABCDEF" : "\b-.,0123456789";
+                       NumberFormatInfo nfi = 
CultureInfo.CurrentCulture.NumberFormat;
+                       string pressedKey = e.KeyChar.ToString ();
 
-                       if (acceptable.IndexOf(e.KeyChar) < 0) {
-                               // prevent the key from reaching the text box
-                               e.Handled = true;
+                       if ((pressedKey != nfi.NegativeSign) && (pressedKey != 
nfi.NumberDecimalSeparator) && 
+                               (pressedKey != nfi.NumberGroupSeparator)) {
+                               string acceptable = hexadecimal ? 
"\b0123456789abcdefABCDEF" : "\b0123456789";
+                               if (acceptable.IndexOf (e.KeyChar) == -1) {
+                                       // FIXME: produce beep to signal that 
"invalid" key was pressed
+                                       // prevent the key from reaching the 
text box
+                                       e.Handled = true;
+                               }
                        }
 
                        base.OnTextBoxKeyPress(source, e);
@@ -335,10 +342,10 @@
                        UserEdit = false;
 
                        try {
-                               string user_edit_text = Text.Replace(",", 
"").Trim();
+                               string user_edit_text = Text;
 
                                if (!hexadecimal) {
-                                       dvalue = decimal.Parse(user_edit_text);
+                                       dvalue = decimal.Parse(user_edit_text, 
CultureInfo.CurrentCulture);
                                } else {
                                        dvalue = 0M;
 
@@ -385,7 +392,7 @@
                                format_string += decimal_places;
 
                                ChangingText = true;
-                               Text = dvalue.ToString(format_string);
+                               Text = dvalue.ToString(format_string, 
CultureInfo.CurrentCulture);
                        }
                        else {
                                // Decimal.ToString doesn't know the "X" 
formatter, and

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to