private void ViaButton_Click(object sender, EventArgs e) { if (ViaComboBox.Text == @"KIBOTTER") { Session = OAuth.Authorize(Settings.Default.ConsumerKey, Settings.Default.ConsumerSecret); Process.Start(Session.AuthorizeUri.AbsoluteUri); } else { using (StreamReader sr = new StreamReader(FileName)) { while (sr.Peek() >= 1) { var readLine = sr.ReadLine(); if (readLine != null) { string[] via = readLine.Split('|'); if (ViaComboBox.Text == via[0]) { Session = OAuth.Authorize(via[1], via[2]); Process.Start(Session.AuthorizeUri.AbsoluteUri); break; } } } } } ViaComboBox.Visible = false; ViaButton.Visible = false; PinTextBox.Visible = true; AuthButton.Visible = true; Label.Text = @"Pin"; PinTextBox.Focus(); }
private void OnGotFocus(object sender, RoutedEventArgs e) { if (Simple) { PinTextBox.Focus(); } else { PasswordBox.Focus(); } }
private void Window_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && !LoadingPanel.IsVisible) { Button_Click(sender, e); } else if (!PinTextBox.IsFocused) { PinTextBox.Focus(); } }
private void SwitchToPinMode() { Password = string.Empty; PinPanel.Visibility = Visibility.Visible; PasswordBox.Visibility = Visibility.Collapsed; var focusedElement = FocusManager.GetFocusedElement(); if (focusedElement == PasswordBox) { PinTextBox.Focus(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { if (PinTextBox.Text.Length > 2) { LoadingPanel.Visibility = Visibility.Visible; ErrorLabel.Visibility = Visibility.Hidden; PinBorder.BorderBrush = (Brush)FindResource("grayBrush"); PinBorder.BorderThickness = new Thickness(1); try { var userName = JsonConvert.DeserializeObject <User>(await WebRequestHelper.PostAsync(ConfigurationManager.AppSettings["ApiUri"] + "/user/login", $"{{ \"pin\": {PinTextBox.Text}}}", "application/json")); var docTypes = JsonConvert.DeserializeObject <ObservableCollection <DocType> >(await WebRequestHelper.GetAsync(ConfigurationManager.AppSettings["ApiUri"] + "/document/types")); new MainWindow(userName, docTypes).Show(); Close(); } catch (Exception ex) { LoadingPanel.Visibility = Visibility.Hidden; if (ex.Message.Contains("Not Found")) { ErrorLabel.Content = "Błędny PIN"; PinBorder.BorderBrush = Brushes.Red; PinBorder.BorderThickness = new Thickness(2); ErrorLabel.Visibility = Visibility.Visible; } else { ErrorLabel.Content = "Błąd połączenia. Spróbuj ponownie później."; PinBorder.BorderBrush = Brushes.Red; PinBorder.BorderThickness = new Thickness(2); ErrorLabel.Visibility = Visibility.Visible; Console.WriteLine(ex.Message); } PinTextBox.Focus(); } } }
private void UIElement_OnTap(object sender, GestureEventArgs e) { PinTextBox.Focus(); }