private async void AddAccountFromUrl(object sender, RoutedEventArgs e) { string uriString = await this.ShowInputAsync("Auth URI", "Please enter the Auth URI:", new MetroDialogSettings { ColorScheme = MetroDialogColorScheme.Accented }); if (string.IsNullOrWhiteSpace(uriString)) { return; } try { var uri = new Uri(uriString); if (uri.Host != "totp") { await this.ShowMessageAsync("Error adding the account", "Only TOTP is supported for now.", MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "OK" }); return; } var account = TOTP.ParseUrl(uriString); await SaveAccountToDb(account); } catch (Exception exception) { await this.ShowMessageAsync("Error", $"Error adding that account: {exception.Message}", MessageDialogStyle.Affirmative, new MetroDialogSettings { AffirmativeButtonText = "Cancel", AnimateHide = false, AnimateShow = false }); } }
private async void AddAccountButton_OnClick(object sender, RoutedEventArgs e) { var uri = $"otpauth://totp/{LabelTextBox.Text}?secret={SharedSecretTextBox.Text}&issuer={IssuerTextBox.Text}&=algorithm={AlgorithmComboBox.Text}&digits={DigitsNumericUpDown.Value}&period={PeriodNumericUpDown.Value}"; await SaveAccountToDb(TOTP.ParseUrl(uri)); var currFlyout = Flyouts.Items[0] as Flyout; if (currFlyout != null) { currFlyout.IsOpen = false; } }