Author: lpage
Date: 2008-02-10 06:24:43 -0500 (Sun, 10 Feb 2008)
New Revision: 95366

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MaskedTextBox.cs
Log:
2008-02-10  Luke Page <[EMAIL PROTECTED]>

        * MaskedTextBox.cs: UseSystemPasswordChar updates PasswordChar, 
PasswordChar
        updates the provider and if not using a provider, uses the internal 
document
        class implementation of password char. Also when showing text, uses 
display string
        from the provider, instead of the actual text.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2008-02-10 10:28:31 UTC (rev 95365)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2008-02-10 11:24:43 UTC (rev 95366)
@@ -1,3 +1,10 @@
+2008-02-10  Luke Page <[EMAIL PROTECTED]>
+
+       * MaskedTextBox.cs: UseSystemPasswordChar updates PasswordChar, 
PasswordChar
+       updates the provider and if not using a provider, uses the internal 
document
+       class implementation of password char. Also when showing text, uses 
display string
+       from the provider, instead of the actual text.
+
 2008-02-09  Carlos Alberto Cortez <[EMAIL PROTECTED]>
 
        * Binding.cs: Ooooops, forgot to take into account the data_source

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MaskedTextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MaskedTextBox.cs 
2008-02-10 10:28:31 UTC (rev 95365)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MaskedTextBox.cs 
2008-02-10 11:24:43 UTC (rev 95366)
@@ -131,6 +131,7 @@
                                throw new ArgumentNullException ();
                        }
                        provider = maskedTextProvider;
+                       is_empty_mask = false;
                        Init ();
                }
 
@@ -140,6 +141,7 @@
                                throw new ArgumentNullException ();
                        }
                        provider = new MaskedTextProvider (mask, 
CultureInfo.CurrentCulture);
+                       is_empty_mask = false;
                        Init ();
                }
                private void Init ()
@@ -508,6 +510,7 @@
                                }
                                
                                provider = new MaskedTextProvider (value, 
provider.Culture, provider.AllowPromptAsInput, provider.PromptChar, 
provider.PasswordChar, provider.AsciiOnly);
+                               ReCalculatePasswordChar ();
                                UpdateVisibleText ();
                        }
                }
@@ -565,10 +568,22 @@
                [DefaultValue ('\0')]
                public char PasswordChar {
                        get {
+                               if (use_system_password_char)
+                                       return '*';
+
                                return provider.PasswordChar;
                        }
                        set {
                                provider.PasswordChar = value;
+
+                               if (value != '\0') {
+                                       provider.IsPassword = true;
+                               } else 
+                                       provider.IsPassword = false;
+
+                               ReCalculatePasswordChar (true);
+                               CalculateDocument ();
+
                                UpdateVisibleText ();
                        }
                }
@@ -730,7 +745,14 @@
                                return use_system_password_char;
                        }
                        set {
-                               use_system_password_char = value;
+                               if (use_system_password_char != value) {
+                                       use_system_password_char = value;
+
+                                       if (use_system_password_char)
+                                               PasswordChar = PasswordChar;
+                                       else
+                                               PasswordChar = '\0';
+                               }
                        }
                }
                
@@ -757,6 +779,21 @@
                }
 #endregion
 #region Internal and private members
+
+               private void ReCalculatePasswordChar ()
+               {
+                       ReCalculatePasswordChar (PasswordChar != '\0');
+               }
+
+               private void ReCalculatePasswordChar (bool using_password)
+               {
+                       if (using_password)
+                               if (is_empty_mask)
+                                       document.PasswordChar = 
PasswordChar.ToString ();
+                               else
+                                       document.PasswordChar = string.Empty;
+               }
+
                internal override void OnPaintInternal (PaintEventArgs pevent)
                {
                        base.OnPaintInternal (pevent);
@@ -772,8 +809,16 @@
                
                private void UpdateVisibleText ()
                {
-                       string text = Text;
+                       string text = null;
 
+                       if (is_empty_mask || setting_text)
+                               text = base.Text;
+                       else
+                               if (provider == null)
+                                       text = string.Empty;
+                               else
+                                       text = provider.ToDisplayString ();
+
                        setting_text = true;
                        if (base.Text != text) {
                                int selstart = SelectionStart;

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

Reply via email to