public OtpInputDialog() { InitializeComponent(); this.DataContext = new OtpInputDialogViewModel(); OtpTextBox.Focus(); if (App.Settings.OtpServerEnabled) { _otpListener = new OtpListener(); _otpListener.OnOtpReceived += otp => { Result = otp; Dispatcher.Invoke(() => { Close(); _otpListener?.Stop(); }); }; try { // Start Listen Task.Run(() => _otpListener.Start()); Log.Debug("OTP server started..."); } catch (Exception ex) { Log.Error(ex, "Could not start OTP HTTP listener."); } } }
public OtpInputDialog() { InitializeComponent(); OtpTextBox.Focus(); _otpListener = new OtpListener(); _otpListener.OnOtpReceived += otp => { Result = otp; Dispatcher.Invoke(() => { Close(); _otpListener.Stop(); }); }; try { // Start Listen Task.Run(() => _otpListener.Start()); } catch (Exception ex) { Log.Error(ex, "Could not start OTP HTTP listener."); } }
public void Reset() { OtpInputPrompt.Text = ViewModel.OtpInputPromptLoc; OtpInputPrompt.Foreground = _otpInputPromptDefaultBrush; OtpTextBox.Text = ""; OtpTextBox.Focus(); }
public OtpInputDialog() { InitializeComponent(); _otpInputPromptDefaultBrush = OtpInputPrompt.Foreground; this.DataContext = new OtpInputDialogViewModel(); MouseMove += OtpInputDialog_OnMouseMove; Activated += (_, _) => OtpTextBox.Focus(); GotFocus += (_, _) => OtpTextBox.Focus(); }
public void TryAcceptOtp(string otp) { if (otp.Length != 6) { Log.Error("Malformed OTP: {Otp}", otp); Dispatcher.Invoke(() => { OtpInputPrompt.Text = ViewModel.OtpInputPromptBadLoc; OtpInputPrompt.Foreground = Brushes.Red; Storyboard myStoryboard = (Storyboard)OtpInputPrompt.Resources["InvalidShake"]; Storyboard.SetTarget(myStoryboard.Children.ElementAt(0), OtpInputPrompt); myStoryboard.Begin(); OtpTextBox.Focus(); }); return; } _ignoreCurrentOtp = false; OnResult?.Invoke(otp); Dispatcher.Invoke(() => { if (_ignoreCurrentOtp) { Storyboard myStoryboard = (Storyboard)OtpInputPrompt.Resources["InvalidShake"]; Storyboard.SetTarget(myStoryboard.Children.ElementAt(0), OtpInputPrompt); myStoryboard.Begin(); OtpTextBox.Focus(); } else { _otpListener?.Stop(); DialogResult = true; Hide(); } }); }
public new bool?ShowDialog() { OtpTextBox.Focus(); if (App.Settings.OtpServerEnabled) { _otpListener = new OtpListener("legacy-" + AppUtil.GetAssemblyVersion()); _otpListener.OnOtpReceived += TryAcceptOtp; try { // Start Listen Task.Run(() => _otpListener.Start()); Log.Debug("OTP server started..."); } catch (Exception ex) { Log.Error(ex, "Could not start OTP HTTP listener."); } } return(base.ShowDialog()); }
public OtpInputDialog() { InitializeComponent(); OtpTextBox.Focus(); }