private void UsernameTextbox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { if (UsernameTextbox.Text.Length <= 0 && PasswordTextbox.Text.Length <= 0) { LoginButton_Click(sender, e); } else if (UsernameTextbox.Text.Length > 0 && PasswordTextbox.Text.Length <= 0) { PasswordTextbox.Focus(); } else if (UsernameTextbox.Text.Length <= 0 && PasswordTextbox.Text.Length > 0) { LoginButton_Click(sender, e); } else if (UsernameTextbox.Text.Length > 0 && PasswordTextbox.Text.Length > 0) { LoginButton_Click(sender, e); } } else if (e.KeyData == Keys.F12) { SqlServerSettingsButton_Click(sender, e); } else if (e.KeyData == Keys.Escape) { this.Close(); } }
private void LoginPage_Loaded(object sender, RoutedEventArgs e) { // Automatically insert the user name last entered as the login, retrieved // from isolated storage UserNameTextbox.Text = ConfigurationSettings.LastUserName; if (string.IsNullOrEmpty(UserNameTextbox.Text)) { UserNameTextbox.Focus(); } else { PasswordTextbox.Focus(); } }
//------------------------------ Private -------------------------------------- void loginPageLoaded(object sender, RoutedEventArgs e) { System.Windows.Browser.HtmlPage.Plugin.Focus(); UserNameTextbox.Focus(); //var _tbap = new TextBoxAutomationPeer(UserNameTextbox); //( (IValueProvider) _tbap ).SetValue("?"); // Automatically insert the user name last entered as the login, retrieved from isolated storage //UserNameTextbox.Text = ConfigurationSettings.LastUserName; if (UserNameTextbox.Text.Length == 0) { UserNameTextbox.Focus(); } else { PasswordTextbox.Focus(); } }
private void PasswordTextbox_TextChanged(object sender, TextChangedEventArgs e) { //if textbox contains characters if ((PasswordTextbox.Text.Length > 0) && (!PasswordTextbox.Text.Equals("Password")) && (!IsStringAllAsterisk(PasswordTextbox.Text))) { //append last character in textbox to variable Password += PasswordTextbox.Text[PasswordTextbox.Text.Length - 1].ToString(); //Password.Insert((PasswordTextbox.Text.Length - 1), PasswordTextbox.Text[PasswordTextbox.Text.Length - 1].ToString()); //change all textbox' characters to asterisks int tempNumAsterisks = PasswordTextbox.Text.Length; PasswordTextbox.Text = ""; for (int i = 0; i < tempNumAsterisks; i++) { PasswordTextbox.Text += "*"; } PasswordTextbox.Focus(); PasswordTextbox.SelectionStart = 9; PasswordTextbox.SelectionLength++; } }