private void comboBoxEncoding_SelectedIndexChanged(object sender, EventArgs e) { lbNameEncoder.Text = $"Шифр : {(string)comboBoxEncoding.SelectedItem}"; QuestionByTestingHolder.UpdateResult(); _guid = Guid.NewGuid(); FileStream fs = null; EncoderType enc = EncodingTypes.GetEncodingType(comboBoxEncoding.SelectedItem.ToString()); string path = $"Theory/{enc.ToString()}.txt"; if (File.Exists(path)) { fs = new FileStream(path, FileMode.Open); using (StreamReader sr = new StreamReader(fs)) { tbTheory.Text = sr.ReadToEnd(); } } Control cntrl = (enc == EncoderType.DiffiHelman || (enc == EncoderType.SHA1) || (enc == EncoderType.MD5)) ? new BaseEncodeControl(this, enc) : (Control) new DecodeEncodeControl(enc); SelectEncodingControl(cntrl); GetAnotherTest(); }
private void ChangeEncoder() { panel2.Controls.Clear(); UserControl cntrl = null; var type = EncodingTypes.GetEncodingType(comboBox1.Text); switch (type) { case EncoderType.Caesar: cntrl = new CaesarCalculatorControl(); break; case EncoderType.Trithemius: cntrl = new TrithemiusCalculatorControl(); break; } var baseCntrl = new BaseCalculatorControl(cntrl, this, type); baseCntrl.panel1.Controls.Add(cntrl); panel2.Controls.Add(baseCntrl); }
public void GetAnotherTest() { EncoderType enc = EncodingTypes.GetEncodingType(comboBoxEncoding.SelectedItem.ToString()); _currentquestionByTesting = QuestionByTestingHolder.GetQuestionByTestings(enc) .FirstOrDefault(p => p.AnswerType == AnswerType.Defoult); //if (_currentquestionByTesting == null) //{ // return; //} if (_testingCach != null) { tabPage3.Controls.Clear(); tabPage3.Controls.Add(_testingCach); } if (_currentquestionByTesting == null) { return; } lbDescription.Text = _currentquestionByTesting.Description; _testingCount = QuestionByTestingHolder.GetQuestionByTestings(enc).Count; lbAllQuestions.Text = _testingCount.ToString(); _currentTask = 0; lbCurrentTask.Text = _currentTask.ToString(); cLB.Items.Clear(); foreach (var s in _currentquestionByTesting.Questions) { cLB.Items.Add($"{s.Key}-{s.Value}"); } }
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}"); } }