public void resultOfCheck(List <int> correctPos, double newStatistic, List <string> correctAnswers) { int wrong = 0; int i = 0; toolTipForAnswers = new ToolTip(); foreach (object o in studyBox.Controls) { TextBox tb = (o as TextBox); tb.ReadOnly = true; if (correctPos.Contains(Int32.Parse(tb.Name))) { tb.BackColor = Color.FromArgb(160, 250, 170); } else { tb.BackColor = Color.FromArgb(255, 175, 175); wrong++; toolTipForAnswers.SetToolTip(tb, correctAnswers[i]); } i++; } correctLabel.Text = correctPos.Count.ToString(); wrongLabel.Text = wrong.ToString(); resultPanel.Visible = true; StatisticLabel.Text = newStatistic.ToString() + "%"; StatisticLabel.Focus(); }
public void setTextAndStatistic(string text, string header, List <int> positionList, List <string> answerList, double statistic) { headerBox.Text = header; StatisticLabel.Text = statistic.ToString() + "%"; studyBox.Text = text; List <TextBox> tbList = new List <TextBox>(); for (int i = 0; i < positionList.Count; i++) { tbList.Add(new TextBox()); tbList[i].Multiline = true; tbList[i].KeyDown += (object sender, KeyEventArgs e) => { if (e.KeyCode == Keys.Right && (sender as TextBox).SelectionStart == (sender as TextBox).Text.Length) { studyBox.SelectNextControl(sender as TextBox, true, false, false, false); } else if (e.KeyCode == Keys.Left && (sender as TextBox).SelectionStart == 0) { studyBox.SelectNextControl(sender as TextBox, false, false, false, false); } }; #region //tbList[i].Font = new Font(studyBox.Font.FontFamily, 17f, GraphicsUnit.Pixel); //Size size = TextRenderer.MeasureText(answerList[i], studyBox.Font); //tbList[i].Size = new Size((int)size.Width - 10, (int)(studyBox.Font.Size * 1.34)); #endregion tbList[i].Size = new Size((int)studyBox.Font.Size * answerList[i].Length + 2, (int)(studyBox.Font.Size * 1.34) + 1); tbList[i].Name = positionList[i].ToString(); Point location = studyBox.GetPositionFromCharIndex(positionList[i]); tbList[i].Location = new Point(location.X - 1, location.Y - 1); studyBox.Controls.Add(tbList[i]); } StatisticLabel.Focus(); }