private void btnCheck_Click(object sender, EventArgs e) { string answer = String.Empty; string descript = String.Empty; switch (_codingType) { case CodingType.Decoding: answer = $"{ tbO.Text},{ tbW.Text}"; descript = tbMessage.Text; break; case CodingType.Encoding: answer = tbMessage.Text; descript = $"{ tbO.Text},{ tbW.Text}"; break; } Tuple <AnswerType, string> answerType = _mainPresentation.CheckAnswer(new Question() { Description = new QuestionValue() { Description = descript }, Answer = new AnswerValue() { Answer = answer }, CodingType = _codingType, EncodingType = EncoderType.Elgamal }, MonoAlphabet.ENG, PolyAlphabet.Default, Convert.ToInt32(tbP.Text), Convert.ToInt32(tbA.Text), Convert.ToInt32(tbB.Text), Convert.ToInt32(tbR.Text)); _countCorrectQuestion = AnswerType.Correct == answerType.Item1 ? _countCorrectQuestion + 1 : _countCorrectQuestion; lbCorrectAnswer.Text = _countCorrectQuestion.ToString(); _historyPresentation.AddHistory(new RequestHistory() { CodingType = _codingType, CorrectAnswer = answerType.Item2, Answer = answer, Name = StringConstants.EncodingTypes.GetName(EncoderType.Elgamal), GuidId = _guid, Mark = AnswerType.Correct == answerType.Item1 ? 1 : 0, Question = descript }); btnCheck.Visible = false; button1.Visible = true; }
private void btnCheck_Click(object sender, EventArgs e) { int valueConfig = (int)numericUpDownStep.Value; Tuple <AnswerType, string> answerType = _mainPresentation.CheckAnswer(new Question() { Description = new QuestionValue() { Description = lbDescription.Text }, Answer = new AnswerValue() { Answer = tbAnswer.Text }, CodingType = _codingType, EncodingType = EncoderType.Caesar }, MonoAlphabet.ENG, PolyAlphabet.Default, valueConfig); if (answerType.Item1 == AnswerType.Correct) { _correctQuestionCount++; lblAnswerInfo.ForeColor = Color.Green; lblAnswerInfo.Text = Messages.Right; } else { lblAnswerInfo.ForeColor = Color.Red; lblAnswerInfo.Text = Messages.Wrong; lbCorrectAnsw.Text = $"{Messages.Answer} {answerType.Item2}"; } //lbCorrectAnswer.Text = _countCorrectQuestion.ToString(); _historyPresentation.AddHistory(new RequestHistory() { CodingType = _codingType, CorrectAnswer = answerType.Item2, Answer = tbAnswer.Text, Name = StringConstants.EncodingTypes.GetName(EncoderType.Caesar), GuidId = _guid, Mark = AnswerType.Correct == answerType.Item1 ? 1 : 0, Question = lbDescription.Text }); btnCheck.Visible = false; button1.Visible = true; }
private void btnCheck_Click(object sender, EventArgs e) { string valueConfig = lbKey.Text; Tuple <AnswerType, string> answerType = _mainPresentation.CheckAnswer(new Question() { Description = new QuestionValue() { Description = lbDescription.Text }, Answer = new AnswerValue() { Answer = tbAnswer.Text }, CodingType = _codingType, EncodingType = EncoderType.Vigenere }, MonoAlphabet.ENG, PolyAlphabet.VigenereTable, valueConfig); _countCorrectQuestion = AnswerType.Correct == answerType.Item1 ? _countCorrectQuestion + 1 : _countCorrectQuestion; lbCorrectAnswer.Text = _countCorrectQuestion.ToString(); lbCorrectAnsw.Text = answerType.Item2; _historyPresentation.AddHistory(new RequestHistory() { CodingType = _codingType, CorrectAnswer = answerType.Item2, Answer = tbAnswer.Text, Name = StringConstants.EncodingTypes.GetName(EncoderType.Vigenere), GuidId = _guid, Mark = AnswerType.Correct == answerType.Item1 ? 1 : 0, Question = lbDescription.Text }); btnCheck.Visible = false; btnNext.Visible = true; }
private void btnCheck_Click(object sender, EventArgs e) { Tuple <AnswerType, string> answerType = _mainPresentation.CheckAnswer(new Question() { Answer = new AnswerValue() { Answer = tbKey.Text }, Description = new QuestionValue() { Description = tbKey.Text }, CodingType = CodingType.Decoding, EncodingType = EncoderType.DiffiHelman }, MonoAlphabet.ENG, PolyAlphabet.Default, Convert.ToInt32(tbN.Text), Convert.ToInt32(tbG.Text), new List <int>() { Convert.ToInt32(tbX.Text), Convert.ToInt32(tbY.Text) }); _countCorrectQuestion = AnswerType.Correct == answerType.Item1 ? _countCorrectQuestion + 1 : _countCorrectQuestion; lbCorrectAnswer.Text = _countCorrectQuestion.ToString(); _historyPresentation.AddHistory(new RequestHistory() { CodingType = CodingType.Decoding, CorrectAnswer = answerType.Item2, Answer = tbKey.Text, Name = StringConstants.EncodingTypes.GetName(EncoderType.DiffiHelman), GuidId = _guid, Mark = AnswerType.Correct == answerType.Item1 ? 1 : 0, }); tbKey.Text = answerType.Item2; btnCheck.Visible = false; btnNext.Visible = true; }