Пример #1
0
        private void btnCreateContact_Click(object sender, EventArgs e)
        {
            bool isValidEmail = true;

            if (String.IsNullOrEmpty(txtContacts.Text))
            {
                isValidEmail = false;
            }
            else
            {
                if (!Regex.IsMatch(txtContacts.Text,
                                   @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                                   @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$",
                                   RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)))
                {
                    isValidEmail = false;
                }
            }

            if (!isValidEmail)
            {
                MessageBox.Show("Ooops, you forgot to provide a valid email address.");
                this.DialogResult = DialogResult.None;
                return;
            }

            if (chkAgreeTandCs.Checked)
            {
                if (vaultManager != null)
                {
                    var vaultConfig = vaultManager.GetVaultConfig();
                    if (vaultConfig != null)
                    {
                        //TODO: check for dupe registration
                    }

                    btnCreateContact.Enabled = false;
                    this.Cursor = Cursors.WaitCursor;
                    vaultManager.AddNewRegistration("mailto:" + txtContacts.Text);
                    this.Cursor = Cursors.Default;
                }
            }
            else
            {
                MessageBox.Show("You need to agree to the latest LetsEncrypt.org Subscriber Agreement.");
                this.DialogResult = DialogResult.None;
            }
        }