Exemplo n.º 1
0
 /// <summary>
 /// Creates an instance of PasswordDialog and uses it to obtain the user's password.
 /// </summary>
 /// <returns>Returns the user's password as entered, or null if he/she clicked Cancel.</returns>
 public static string GetPassword()
 {
     using (var dialog = new PasswordDialog())
     {
         // If the user clicks Cancel, return null and not the empty string.
         return(dialog.ShowDialog() == DialogResult.OK ? dialog.Password : null);
     }
 }
 /// <summary>
 /// Creates an instance of PasswordDialog and uses it to obtain the user's password.
 /// </summary>
 /// <returns>Returns the user's password as entered, or null if he/she clicked Cancel.</returns>
 public static string GetPassword()
 {
     using(PasswordDialog dialog = new PasswordDialog()) {
         if (dialog.ShowDialog() == DialogResult.OK) {
             return dialog.Password;
         } else {
             // If the user clicks Cancel, return null and not the empty string.
             return null;
         }
     }
 }
 /// <summary>
 /// Creates an instance of PasswordDialog and uses it to obtain the user's password.
 /// </summary>
 /// <returns>Returns the user's password as entered, or null if he/she clicked Cancel.</returns>
 public static string GetPassword()
 {
     using (PasswordDialog dialog = new PasswordDialog()) {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             return(dialog.Password);
         }
         else
         {
             // If the user clicks Cancel, return null and not the empty string.
             return(null);
         }
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Creates an instance of PasswordDialog and uses it to obtain the user's password.
 /// </summary>
 /// <returns>Returns the user's password as entered, or null if he/she clicked Cancel.</returns>
 public static SecureString GetPassword()
 {
     using(PasswordDialog dialog = new PasswordDialog()) {
         if (dialog.ShowDialog() == DialogResult.OK) {
             SecureString Result = new SecureString();
             for (int i = 0; i < dialog.Password.Length; i++) {
                 Result.AppendChar(dialog.Password[i]);
             }
             return Result;
         } else {
             // If the user clicks Cancel, return null and not the empty string.
             return null;
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates an instance of PasswordDialog and uses it to obtain the user's password.
 /// </summary>
 /// <returns>Returns the user's password as entered, or null if he/she clicked Cancel.</returns>
 public static SecureString GetPassword()
 {
     using (PasswordDialog dialog = new PasswordDialog()) {
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             SecureString Result = new SecureString();
             for (int i = 0; i < dialog.Password.Length; i++)
             {
                 Result.AppendChar(dialog.Password[i]);
             }
             return(Result);
         }
         else
         {
             // If the user clicks Cancel, return null and not the empty string.
             return(null);
         }
     }
 }