Example #1
0
        private void tbAffineKeyA_TextChanged(object sender, EventArgs e)
        {
            if (!regexAffineKeyAText.IsMatch(this.tbAffineKeyA.Text))
            {
                this.errorProvider1.SetError(this.tbAffineKeyA,
                                             $"数据格式错误,数据为0-25之间的整数");
                this.myCipherKeys.AffineKeyA = MyCipherKeys.InvalidIntValue;
                return;
            }

            int affineKeyA = int.Parse(tbAffineKeyA.Text);

            if (!AffineCipher.IsKeyASuitable(affineKeyA, out string message))
            {
                this.errorProvider1.SetError(this.tbAffineKeyA, message);
                this.myCipherKeys.AffineKeyA = MyCipherKeys.InvalidIntValue;
                return;
            }

            this.myCipherKeys.AffineKeyA = affineKeyA;

            this.errorProvider1.SetError(this.tbAffineKeyA, null);
        }