private void button1_Click_1(object sender, EventArgs e) { try { if (keyType == TrithemiusKey.LinearAquestion) { TrithemiusKeyArgs = new TrithemiusCipher.LinKey(); ((TrithemiusCipher.LinKey)TrithemiusKeyArgs).A = checkNumber(ref textBox1); ((TrithemiusCipher.LinKey)TrithemiusKeyArgs).B = checkNumber(ref textBox2); } else if (keyType == TrithemiusKey.NonLinearAquestion) { TrithemiusKeyArgs = new TrithemiusCipher.NonLinKey(); ((TrithemiusCipher.NonLinKey)TrithemiusKeyArgs).A = checkNumber(ref textBox5); ((TrithemiusCipher.NonLinKey)TrithemiusKeyArgs).B = checkNumber(ref textBox4); ((TrithemiusCipher.NonLinKey)TrithemiusKeyArgs).C = checkNumber(ref textBox6); } else if (keyType == TrithemiusKey.Gaslo) { TrithemiusKeyArgs = new TrithemiusCipher.Gaslo(); if (CaesarCipher.CheckInput(textBox3.Text, out MatchCollection matches)) { ((TrithemiusCipher.Gaslo)TrithemiusKeyArgs).gaslo = matches[0].Value; } else { textBox3.Text = "0"; textBox3.BackColor = Color.Red; MessageBox.Show("Invalid symbol in 'global'!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); textBox3.BackColor = Color.White; throw new ArgumentException(); } } ((TrithemiusCipher.Key)TrithemiusKeyArgs).keyType = keyType; retry = false; } catch (Exception) { retry = true; } }