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; }
private void button1_Click_1(object sender, EventArgs e) { if (_currentquestionByTesting == null) { return; } string answer = (string)cLB.SelectedItem; if (answer == null) { return; } if (answer != null) { string[] splitAnswe = answer.Split('-'); int index = int.Parse(splitAnswe[0]); if (index == _currentquestionByTesting.Answer) { _currentquestionByTesting.AnswerType = AnswerType.Correct; } else { _currentquestionByTesting.AnswerType = AnswerType.NotCorrect; } } _historyPresentation.AddHistory(new RequestHistory() { CodingType = CodingType.Test, Question = _currentquestionByTesting.Description, Answer = answer, CorrectAnswer = _currentquestionByTesting.Questions .FirstOrDefault(p => p.Key == _currentquestionByTesting.Answer).Value, GuidId = _guid, Mark = _currentquestionByTesting.AnswerType == AnswerType.Correct ? 1 : 0, Name = (string)comboBoxEncoding.SelectedItem }); var enc = EncodingTypes.GetEncodingType(comboBoxEncoding.SelectedItem.ToString()); var correct = QuestionByTestingHolder.GetQuestionByTestings(enc) .Count(p => p.AnswerType == AnswerType.Correct); lbCorrectAnswer.Text = correct.ToString(); _currentquestionByTesting = QuestionByTestingHolder.GetQuestionByTestings(enc) .FirstOrDefault(p => p.AnswerType == AnswerType.Defoult); if (_currentquestionByTesting == null) { _testingCach = panel2; lbCorrectAnswer.Text = "0"; tabPage3.Controls.Clear(); var testingCntrl = new TestingResultControl(correct, _testingCount, this); tabPage3.Controls.Add(testingCntrl); // Resize var cntrlResize = new ControlWithResizes { Control = testingCntrl, Resizes = { SetLocationCentredToParrent, cntrl => SetYIndentToForm(this,cntrl, 0.07) } }; _controlsWithResizes.Add(cntrlResize); cntrlResize.Resize(); _currentTask = 0; _currentquestionByTesting = null; QuestionByTestingHolder.UpdateResult(); return; } _currentTask++; lbCurrentTask.Text = _currentTask.ToString(); lbDescription.Text = _currentquestionByTesting.Description; cLB.Items.Clear(); foreach (var s in _currentquestionByTesting.Questions) { cLB.Items.Add($"{s.Key}-{s.Value}"); } }