public void IfFocusPasswordHintUnable(object sender, RoutedEventArgs e)
        {
            PasswordBox passwordBox = (PasswordBox)(sender);

            if (passwordBox.Equals(txt_PW))
            {
                label_PW.Visibility = Visibility.Hidden;
                passwordBox.Focus();
            }
            else
            {
                label_PW_check.Visibility = Visibility.Hidden;
                passwordBox.Focus();
            }
        }
Example #2
0
        /// <summary> Completes a login process. </summary>
        private void ConfirmLogin()
        {
            var oneTimeUseCode = PasswordBox.Password;

            if (string.IsNullOrWhiteSpace(oneTimeUseCode))
            {
                Utilities.ShowValidationErrorDialog("You must enter the authentication code.");
                return;
            }
            PasswordBox.Clear();

            AuthToken authToken;

            try
            {
                authToken = clients.Auth.FinishLogin(handshake, new SecondFactor
                {
                    OneTimeUseCode = oneTimeUseCode
                });
            }
            catch (FaultException fe)
            {
                Utilities.Log($"Error on ConfirmLogin: {fe}");
                Utilities.ShowErrorDialog($"Login failed because \"{fe.Message}\". Please check your credentials and try again.", "Login failed");
                return;
            }

            HandshakeToken = null;

            RunUserSession(authToken);

            PasswordBox.Focus(); // focus back on the password, because the username will remain populated
        }
Example #3
0
        private void InputBox_OnKeyUp(object sender, KeyRoutedEventArgs e)
        {
            if (sender == PhoneNumberBox)
            {
                if (PhoneNumberBox.Text.Length == 10)
                {
                    EmailBox.Focus(FocusState.Programmatic);
                    return;
                }
            }

            if (e.Key == VirtualKey.Enter)
            {
                if (sender == NameBox)
                {
                    SurnameBox.Focus(FocusState.Programmatic);
                }
                if (sender == SurnameBox)
                {
                    CommandBar.Focus(FocusState.Programmatic);
                }
                else if (sender == EmailBox)
                {
                    PasswordBox.Focus(FocusState.Programmatic);
                }
                else if (sender == PasswordBox)
                {
                    PasswordRepeatBox.Focus(FocusState.Programmatic);
                }
                else if (sender == PasswordRepeatBox)
                {
                    CommandBar.Focus(FocusState.Programmatic);
                }
            }
        }
Example #4
0
 private void UserNameTextBox_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Return)
     {
         PasswordBox.Focus();
     }
 }
Example #5
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            var userName = UserNameTextBox.Text.Trim();
            var password = PasswordBox.Password;

            MessageTextBlock.Text       = string.Empty;
            MessageTextBlock.Foreground = Brushes.Red;
            if (string.IsNullOrWhiteSpace(userName))
            {
                MessageTextBlock.Text = "* 请输入用户名";
                UserNameTextBox.Focus();
                return;
            }
            else if (password.Length == 0)
            {
                PasswordBox.Focus();
                return;
            }

            string mErrorMsg = string.Empty;

            if (LoginViewModel.Instance.Login(userName, password, out mErrorMsg))
            {
                MessageTextBlock.Text       = "登录成功,正在加载数据...";
                MessageTextBlock.Foreground = Brushes.Blue;
                this.DialogResult           = true;
                Close();
            }
            else
            {
                MessageTextBlock.Text       = mErrorMsg;
                MessageTextBlock.Foreground = Brushes.Red;
            }
        }
Example #6
0
        public LoginPage()
        {
            InitializeComponent();
            _SerializationService = Template10.Services.SerializationService.SerializationService.Json;

            Loaded += (sender, args) =>
            {
                if (string.IsNullOrEmpty(UserNameBox.Text))
                {
                    UserNameBox.Focus(FocusState.Keyboard);
                }
                else
                {
                    PasswordBox.Focus(FocusState.Keyboard);
                }
            };

            KeyUp += (sender, args) =>
            {
                if (args.Key == VirtualKey.Enter)
                {
                    LoginButton_OnClick(sender, args);
                }
            };
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //启动线程登录
            //验证输入
            if (string.IsNullOrEmpty(NameTextBox.Text))
            {
                SetInformationString("请输入用户名");
                NameTextBox.Focus();
                return;
            }

            if (string.IsNullOrEmpty(PasswordBox.Password))
            {
                SetInformationString("请输入密码");
                PasswordBox.Focus();
                return;
            }

            SetInformationString("正在验证维护状态...");
            UISettings(false);

            UserName     = NameTextBox.Text;
            UserPassword = PasswordBox.Password;
            IsChecked    = (bool)Remember.IsChecked;

            ThreadAccountLogin = new Thread(ThreadCheckAccount);
            ThreadAccountLogin.IsBackground = true;
            ThreadAccountLogin.Start();
        }
Example #8
0
 private void UsernameBox_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         PasswordBox.Focus();
     }
 }
        private static void TextBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            TextBox box = sender as TextBox;

            if (box != null)
            {
                if (!box.IsKeyboardFocusWithin)
                {
                    box.Focus();
                    e.Handled = true;
                }
                return;
            }

            PasswordBox pass = sender as PasswordBox;

            if (pass != null)
            {
                if (!pass.IsKeyboardFocusWithin)
                {
                    pass.Focus();
                    e.Handled = true;
                }
                return;
            }
        }
 void ProfileBox_Tap(object sender, GestureEventArgs e)
 {
     if (checkboxTapped)
     {
         checkboxTapped = false;
         return;
     }
     if (Profile.HasPassword)
     {
         if (!passwordShowing)
         {
             if (VisualStateManager.GoToState(this, "PasswordShowing", true))
             {
                 if (passwordBox != null)
                 {
                     passwordBox.Focus();
                 }
                 passwordShowing = true;
             }
         }
     }
     else
     {
         DoLogin();
     }
 }
Example #11
0
        private static MessageBoxResult ShowPasswordPrompt(string text, string title, out string input, Window owner = null)
        {
            var dlg = new ModernDialog
            {
                Title   = title,
                Content = new BBCodeBlock {
                    BBCode = text, Margin = new Thickness(0, 0, 0, 8)
                },
                MinHeight = 0,
                MinWidth  = 0,
                MaxHeight = 480,
                MaxWidth  = 640,
            };

            if (owner != null)
            {
                dlg.Owner = owner;
            }

            dlg.Buttons = GetButtons(dlg);
            var tb = new PasswordBox();

            dlg.Content = tb;
            tb.Focus();
            dlg.ShowDialog();
            if (dlg.MessageBoxResult == MessageBoxResult.OK)
            {
                input = tb.Password;
            }
            else
            {
                input = "";
            }
            return(dlg.MessageBoxResult);
        }
Example #12
0
        private void LogginButton_Click(object sender, RoutedEventArgs e)
        {
            ErrorMessage.Text = "";

            string UserMail     = MailTextBox.Text;
            string userPassword = PasswordBox.Password;


            if (userPassword.Length == 0)
            {
                ErrorMessage.Text = "Nebylo zadáno heslo";
                PasswordBox.Focus();
                return;
            }

            if (UserMail.Length == 0)
            {
                ErrorMessage.Text = "Nebyl zadán přihlašovací email";
                MailTextBox.Focus();
                return;
            }
            if (AutentizationVerify(UserMail, userPassword))
            {
                LoggedUserID.LoggedUserMail = UserMail; //  Který uživatel je přihlášený
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                LoggedUserID.mainWindow = mainWindow;
                Close();
            }
        }
Example #13
0
        /// <summary>
        /// Valida que se ingrese quien hizo el cambio y su contraseña
        /// </summary>
        /// <param name="ptxtChangedBy">Control de tipo TextBox en donde se ingresa el usuario</param>
        /// <param name="ptxtPwd">Control de tipo PaswordBox en donde se ingresa el password del usuario</param>
        /// <param name="pstrUserType">Cadena en donde se ingresa el tipo de usuario por ejemplo "PR"</param>
        /// <history>
        /// [jorcanche] 24/03/2016 Created.
        /// [aalcocer] 12/08/2016 Modified. Se corrige la validación
        /// </history>
        /// <returns></returns>

        public static bool ValidateChangedBy(TextBox ptxtChangedBy, PasswordBox ptxtPwd, string pstrUserType = "")
        {
            string strDescription = string.Empty;
            string strMessage     = string.Empty;

            //establecemos el mensaje de error de quin hizo el cambio
            if (pstrUserType == "")
            {
                strMessage = "Specify who is making the change.";
            }
            else
            {
                strDescription = pstrUserType;
            }
            //validamos quien hizo el cambio
            if (!ValidateRequired(ptxtChangedBy, strDescription, strMessage))
            {
                ptxtChangedBy.Focus();
                return(false);
            }
            //Validamos la contraseña de quin hizo el cambio
            else if (!ValidateRequired(ptxtPwd, "Specify your password."))
            {
                ptxtPwd.Focus();
                return(false);
            }
            return(true);
        }
Example #14
0
        public async Task <SecureString> GetPasswordAsync()
        {
            // Use keylogger prevention.
            // Maybe: 1-3-5 character of the passphrase first
            // then 2-4-6...

            _taskCompletionSource = new TaskCompletionSource <SecureString>();

            Visibility = Visibility.Visible;

            await Dispatcher.BeginInvoke
            (
                DispatcherPriority.Input,
                (Action)(() =>
            {
                PasswordBox.Focus();
                Keyboard.Focus(PasswordBox);
            })
            );

            var secureString = await _taskCompletionSource.Task;

            Visibility = Visibility.Collapsed;

            return(secureString);
        }
Example #15
0
        private bool Validacija()
        {
            if (string.IsNullOrWhiteSpace(UsernameBox.Text))
            {
                MessageBox.Show("Username polje mora biti popunjeno");
                UsernameBox.Focus();
                return(false);
            }

            if (string.IsNullOrWhiteSpace(PasswordBox.Text))
            {
                MessageBox.Show("Password polje mora biti popunjeno");
                PasswordBox.Focus();
                return(false);
            }

            if (Combo.SelectedIndex < 0)
            {
                MessageBox.Show("Status polje mora biti izabrano");
                Combo.Focus();
                return(false);
            }


            return(true);
        }
Example #16
0
 private void PlaceholderPasswordBox_GotFocus(object sender, RoutedEventArgs e)
 {
     if (passwordBox != null)
     {
         passwordBox.Focus();
     }
 }
Example #17
0
        private void ButtonEnter_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TextBoxLogin.Text))
            {
                MessageBox.Show(" Введите ваш логин", "Внимание");
                TextBoxLogin.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(PasswordBox.Password))
            {
                MessageBox.Show(" Введите ваш пароль", "Внимание");
                PasswordBox.Focus();
                return;
            }

            foreach (Administrator admin in context.Administrators)
            {
                if ((admin.Login == TextBoxLogin.Text) && (admin.Password == PasswordBox.Password.Trim()))
                {
                    Administrator currentAdmin = admin;
                    var           display      = new AdminDisplay(context, currentAdmin);
                    display.Show();
                    this.Close();
                    return;
                }
            }

            MessageBox.Show(" Логин или пароль были введены некорректно\n Повторите ввод", "Администратор не найден");
            return;
        }
Example #18
0
 private void Username_KeyDown(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         PasswordBox.Focus(FocusState.Keyboard);
     }
 }
 private void NameTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         PasswordBox.Focus();
     }
 }
Example #20
0
        public MessageBoxWithPasswordBox(string message, string title, string password, params string[] buttons) : base(title, buttons)
        {
            StackPanel sp = new StackPanel();

            if (message != null)
            {
                sp.Children.Add(MessageGenerator.Generate(message));
            }

            PasswordBox = new PasswordBox()
            {
                Password   = (password == null) ? "" : password,
                Margin     = new Windows.UI.Xaml.Thickness(0, -18, 0, 24),
                Background = new SolidColorBrush(Color.FromArgb(255, 204, 204, 204))
            };

            sp.Children.Add(PasswordBox);

            //focus on the text box
            PasswordBox.Loaded += delegate { PasswordBox.Focus(Windows.UI.Xaml.FocusState.Programmatic); };

            PasswordBox.KeyUp += TextBox_KeyUp;

            Content = sp;
        }
Example #21
0
        private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(TextBoxEmail.Text))
            {
                MessageBox.Show(" Введите вашу почту", "Внимание");
                TextBoxEmail.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(PasswordBox.Password))
            {
                MessageBox.Show(" Введите ваш пароль", "Внимание");
                PasswordBox.Focus();
                return;
            }

            foreach (var user in context.Users)
            {
                if ((user.Email == TextBoxEmail.Text) && (user.Password == User.GetHash(PasswordBox.Password.Trim())))
                {
                    User currentUser = user;
                    var  display     = new Display(context, currentUser);
                    display.Show();
                    this.Close();
                    return;
                }
            }

            MessageBox.Show(" Почта или пароль были введены некорректно\n Повторите ввод или зарегистрируйтесь", "Пользователь не найден");
            return;
        }
Example #22
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            LoginBox.Text    = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            PasswordBox.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();

            if (Convert.ToBoolean(dataGridView1.CurrentRow.Cells[3].Value) == true)
            {
                comboBox1.SelectedIndex = 1;
            }
            else
            {
                comboBox1.SelectedIndex = 0;
            }
            label3.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
            PasswordBox.SelectionStart  = 0;
            PasswordBox.SelectionLength = LoginBox.Text.Length;
            PasswordBox.Focus();

            SqlConnection conn = new SqlConnection(Program.st_connect);

            conn.Open();
            int k = dataGridView1.CurrentRow.Index;

            Program.id_user = Convert.ToInt32(dataGridView1[0, k].Value);
            string        s    = "SELECT photo_user FROM USERS WHERE Id_user = " + Program.id_user;
            SqlCommand    comm = new SqlCommand(s, conn);
            SqlDataReader read = comm.ExecuteReader();

            read.Read();
            string s1 = read.GetString(0);

            pictureBox1.Image = Image.FromFile(s1);
        }
Example #23
0
 private void RegisterButton_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(PhoneTextBox.Text) && !string.IsNullOrEmpty(NameTextBox.Text) && !string.IsNullOrEmpty(PasswordBox.Password) && !string.IsNullOrEmpty(ConfirmPasswordBox.Password))
     {
         if (PasswordBox.Password == ConfirmPasswordBox.Password)
         {
             if (!service.SignUpEmployee(NameTextBox.Text, PhoneTextBox.Text, PasswordBox.Password, "default", out string message, out Employee user))
             {
                 Close();
             }
             else
             {
                 PhoneTextBox.Clear();
                 NameTextBox.Clear();
                 PasswordBox.Clear();
                 ConfirmPasswordBox.Clear();
             }
         }
         else
         {
             MessageBox.Show("Passwords in to fields should be equal");
             PasswordBox.Clear();
             ConfirmPasswordBox.Clear();
             PasswordBox.Focus();
         }
     }
Example #24
0
 private void CreateUser_OnClick(object sender, RoutedEventArgs e)
 {
     PasswordBox.Focus();
     Phone.Focus();
     Name.Focus();
     if (CheckPrivacy.IsChecked == false)
     {
         Privacy.Fill = (SolidColorBrush)TryFindResource("ErrorButtonText");
         return;
     }
     if (!Validation.GetHasError(PasswordBox) & !Validation.GetHasError(Phone) & !Validation.GetHasError(Name))
     {
         if (Context.CheckPhone())
         {
             Context.CreateUser();
             (App.Current.MainWindow as MainWindow).MainFrame.Content = new SuccessRegistrationPage(new SuccessRegistrationViewModel(Context.User));
         }
         else
         {
             ErrorPhone.Visibility   = Visibility.Visible;
             BorderPhone.BorderBrush = (SolidColorBrush)TryFindResource("ButtonOutline");
             ErrorPhone.Text         = "Аккаунт с таким номером телефона существует";
         }
     }
 }
 public void EmailTextBoxChangeFocusToPasswordTextBox(ActionExecutionContext context)
 {
     if (((Windows.UI.Xaml.Input.KeyRoutedEventArgs)context.EventArgs).Key == VirtualKey.Enter)
     {
         _passwordBox.Focus(FocusState.Keyboard);
     }
 }
Example #26
0
        private void SignIn_Click(object sender, EventArgs e)
        {
            if (LoginBox.Text.Length == 0)
            {
                Message.Warning("Empty login!", Text);
                return;
            }
            if (PasswordBox.Text.Length == 0)
            {
                Message.Warning("Empty password!", Text);
                return;
            }
            bool success = DB.Login(LoginBox.Text, PasswordBox.Text);

            if (!success)
            {
                Message.Error(DB.Status, Text);
                PasswordBox.Clear();
                PasswordBox.Focus();
            }
            else
            {
                LoginBox.Clear();
                PasswordBox.Clear();
                MainForm form = new MainForm();
                form.Show(this);
                Hide();
            }
        }
Example #27
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (AccountText == null || AccountText.Length == 0)
            {
                MessageBox.Show("Account login required!");
                UsernameBox.Focus();
                return;
            }
            if (PasswordText == null || PasswordText.Length == 0)
            {
                MessageBox.Show("Account password required!");
                PasswordBox.Focus();
                return;
            }

            if (autoLogCheckBox.IsChecked == true)
            {
                AutoLogAccountIndex = true;
            }
            else
            {
                AutoLogAccountIndex = false;
            }

            DialogResult = true;
        }
 public void SetInputFocus()
 {
     if (passwordBox != null)
     {
         passwordBox.Focus();
     }
 }
Example #29
0
        private void EntrarButton_Click(object sender, RoutedEventArgs e)
        {
            string usuario  = this.UsuarioTextBox.Text;
            string password = this.PasswordBox.Password;

            if (usuario == "" && password == "")
            {
                MessageBox.Show(usuario, "Ingrese Datos Correctos", MessageBoxButton.OKCancel, MessageBoxImage.Information);
                MessageBox.Show("Favor Llene los campos");
            }

            if (password == "")
            {
                MessageBox.Show("Debe agregar una Contraseña", "Aviso", MessageBoxButton.OK, MessageBoxImage.Error);
                PasswordBox.Focus();
            }
            else

            if (usuario == "Admin" && password == "1234")
            {
                MenuPrincipal menuP = new MenuPrincipal();
                menuP.Show();
                this.Close();
                return;
            }
        }
 private void EmailBox_OnKeyUp(object sender, KeyRoutedEventArgs e)
 {
     if (e.Key == VirtualKey.Enter)
     {
         PasswordBox.Focus(FocusState.Keyboard);
     }
 }