/// <summary> /// Updates the textbox with the appropriate value /// </summary> private void UpdateTextBox() { var Plans = CostCtrl.GetPlans(); var percent = Percent.Checked; var maxPay = MaxPay.Checked; bool percentValid = false; if (PlanList.SelectedItem != null) { var plan = CostCtrl.GetPlan(PlanList.SelectedItem.ToString()); if (PlanQueries.SelectedItem != null) { percentValid = (CostCtrl.GetNum(PlanQueries.SelectedItem.ToString(), plan.Type, percent, maxPay) <= 1); } if (percent && percentValid) { Cost.Text = (100 * CostCtrl.GetNum(PlanQueries.SelectedItem.ToString(), plan.Type, percent, maxPay)).ToString(); DollarLabel.Hide(); PercentLabel.Show(); } else { if (PlanQueries.SelectedItem != null) { Cost.Text = CostCtrl.GetNum(PlanQueries.SelectedItem.ToString(), plan.Type, percent, maxPay).ToString(); } DollarLabel.Show(); PercentLabel.Hide(); } } }
void NextButton_Click(object sender, EventArgs e) { List <int> ids = new List <int>(); for (int i = 0; i < questions.Count; i++) { if (questions[Count].Answers[i].Correct) { ids.Add(i); if (questions[Count].Single_type) { break; } } } if (questions[Count].Single_type) { CorrectAnswers.Add(AnswersSingle.SelectedIndex == ids[0]); NextButton.Text = Count == questions.Count - 1 ? "Завершить" : "Далее"; } else { bool fail = false; foreach (int id in ids) { if (!AnswersMultiple.CheckedIndices.Contains(id)) { CorrectAnswers.Add(false); fail = true; } } if (!fail) { CorrectAnswers.Add(true); } } if (Count >= questions.Count - 1) { hiding.Invoke(); BackColor = Color.Bisque; QuestionTextBox.BackColor = BackColor; Progress.Show(); int count = 0; foreach (bool q in CorrectAnswers) { if (q) { count++; } } double percent = 100 / questions.Count * count; Progress.Value = (int)percent; QuestionTextBox.Text = "Тест завершён, вот ваш результат:"; PercentLabel.Text = percent + "%"; PercentLabel.Show(); } else { QuestionTextBox.Text = questions[++Count].Text; } Refreshing(); ShowingElements(); }