private void btnRandomKey_Click(object sender, EventArgs e)
        {
            RadioButton chosenMethod;

            if (groupBoxTransMethods.Enabled == false)
            {
                chosenMethod = groupBoxSubsMethods.Controls.OfType <TableLayoutPanel>().Where(x => x.Name.Contains("Subs")).Single().Controls.OfType <RadioButton>().Where(x => x.Checked).Single();
            }
            else
            {
                chosenMethod = groupBoxTransMethods.Controls.OfType <TableLayoutPanel>().Where(x => x.Name.Contains("Trans")).Single().Controls.OfType <RadioButton>().Where(x => x.Checked).Single();
            }

            try
            {
                switch (chosenMethod.Name)
                {
                case "radioButtonPolySub":
                    textBoxKey.Text = PolyalphabeticSubstitution.GenerateKey();
                    PolyalphabeticSubstitution.Key = textBoxKey.Text;
                    break;

                case "radioButtonMatrixSub":
                    textBoxKey.Text        = MatrixSubstitution.GenerateKey();
                    MatrixSubstitution.Key = textBoxKey.Text;
                    break;

                case "radioButtonBlock":
                    textBoxKey.Text     = new string(TextBlockCipher.GenerateKey());
                    TextBlockCipher.Key = textBoxKey.Text.ToCharArray();
                    break;

                case "radioButtonFormat":
                    textBoxKey.Text         = new string(ColumnTransposition.GenerateKey());
                    ColumnTransposition.Key = textBoxKey.Text.ToCharArray();
                    break;

                default:
                    break;
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            textBoxKey.Focus();
        }
        private void btnAction_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBoxInput.Text == string.Empty)
                {
                    MessageBox.Show("Моля въведете входен текст преди да започнете процеса на криптиране/декриптиране.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    textBoxInput.Focus();
                    return;
                }

                RadioButton chosenMethod;

                if (groupBoxTransMethods.Enabled == false)
                {
                    chosenMethod = groupBoxSubsMethods.Controls.OfType <TableLayoutPanel>().Where(x => x.Name.Contains("Subs")).Single().Controls.OfType <RadioButton>().Where(x => x.Checked).Single();
                }
                else
                {
                    chosenMethod = groupBoxTransMethods.Controls.OfType <TableLayoutPanel>().Where(x => x.Name.Contains("Trans")).Single().Controls.OfType <RadioButton>().Where(x => x.Checked).Single();
                }

                if (radioButtonEncrypt.Checked)
                {
                    switch (chosenMethod.Name)
                    {
                    case "radioButtonCaesar":
                        if (textBoxM.Text.ToCharArray() != CaesarCipher.M)
                        {
                            CaesarCipher.M = textBoxM.Text.ToCharArray();
                        }
                        textBoxResult.Text = CaesarCipher.Encrypt(textBoxInput.Text);
                        break;

                    case "radioButtonDirectSubs":
                        textBoxResult.Text = DirectSubstitution.Encrypt(textBoxInput.Text).Item2;

                        break;

                    case "radioButtonPolySub":
                        textBoxResult.Text = PolyalphabeticSubstitution.Encrypt(textBoxInput.Text);

                        break;

                    case "radioButtonMatrixSub":
                        textBoxResult.Text = MatrixSubstitution.Encrypt(textBoxInput.Text);

                        break;

                    case "radioButtonBlock":
                        textBoxResult.Text = TextBlockCipher.Encrypt(textBoxInput.Text);
                        break;

                    case "radioButtonFormat":
                        textBoxResult.Text = ColumnTransposition.Encrypt(textBoxInput.Text);
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    switch (chosenMethod.Name)
                    {
                    case "radioButtonCaesar":
                        if (textBoxM.Text.ToCharArray() != CaesarCipher.M)
                        {
                            CaesarCipher.M = textBoxM.Text.ToCharArray();
                        }
                        textBoxResult.Text = CaesarCipher.Decrypt(textBoxInput.Text);
                        break;

                    case "radioButtonDirectSubs":
                        textBoxResult.Text = DirectSubstitution.Decrypt(textBoxInput.Text);

                        break;

                    case "radioButtonPolySub":
                        textBoxResult.Text = PolyalphabeticSubstitution.Decrypt(textBoxInput.Text);

                        break;

                    case "radioButtonMatrixSub":
                        textBoxResult.Text = MatrixSubstitution.Decrypt(textBoxInput.Text);

                        break;

                    case "radioButtonBlock":
                        textBoxResult.Text = TextBlockCipher.Decrypt(textBoxInput.Text);
                        break;

                    case "radioButtonFormat":
                        textBoxResult.Text = ColumnTransposition.Decrypt(textBoxInput.Text);
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message, "Грешка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }