| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using SteamAuth;
- using System;
- using System.Text.RegularExpressions;
- using System.Windows.Forms;
- namespace Steam_Desktop_Authenticator
- {
- public partial class PhoneInputForm : Form
- {
- private SteamGuardAccount Account;
- public string PhoneNumber;
- public string CountryCode;
- public bool Canceled;
- public PhoneInputForm(SteamGuardAccount account)
- {
- this.Account = account;
- InitializeComponent();
- }
- private void btnSubmit_Click(object sender, EventArgs e)
- {
- this.PhoneNumber = txtPhoneNumber.Text;
- this.CountryCode = txtCountryCode.Text;
- if (this.PhoneNumber[0] != '+')
- {
- MessageBox.Show("Phone number must start with + and country code.", "Phone Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
- return;
- }
- this.Close();
- }
- private void txtPhoneNumber_KeyPress(object sender, KeyPressEventArgs e)
- {
- // Allow pasting
- if (Char.IsControl(e.KeyChar))
- return;
- // Only allow numbers, spaces, and +
- var regex = new Regex(@"[^0-9\s\+]");
- if (regex.IsMatch(e.KeyChar.ToString()))
- {
- e.Handled = true;
- }
- }
- private void txtCountryCode_KeyPress(object sender, KeyPressEventArgs e)
- {
- // Allow pasting
- if (Char.IsControl(e.KeyChar))
- return;
- // Only allow letters
- var regex = new Regex(@"[^a-zA-Z]");
- if (regex.IsMatch(e.KeyChar.ToString()))
- {
- e.Handled = true;
- }
- }
- private void txtCountryCode_Leave(object sender, EventArgs e)
- {
- // Always uppercase
- txtCountryCode.Text = txtCountryCode.Text.ToUpper();
- }
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Canceled = true;
- this.Close();
- }
- }
- }
|