private void Button_name_test_form_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "" || textBox1.Text == " ")
     {
         csv.writefile("?");
     }
     else
     {
         csv.writefile(textBox1.Text);
     }
     csv.writedata();
     this.Close();
     next_form = new Thread(open1);
     next_form.SetApartmentState(ApartmentState.STA);
     next_form.Start();
 }
        public void testing()
        {
            if (cc[0] + cc[1] + cc[2] == 12)
            {
                form.button1.Enabled = false;
                int [] count = new int[4] {
                    0, 0, 0, 0
                };
                int buftime = 0;
                for (int i = 0; i < 3; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        if (answer[i, j] == answer2[i, j])
                        {
                            edit.writefile("+", timeans[buftime, 0], timeans[buftime++, 1]); count[i]++;
                        }
                        else
                        {
                            edit.writefile("-", timeans[buftime, 0], timeans[buftime++, 1]);
                        }
                    }
                }
                for (int i = 0; i < 3; i++)
                {
                    if (count[i] < 3)
                    {
                        result[i] = "Присутні відхилення";
                    }
                    else
                    {
                        result[i] = "Все добре";
                    }
                }
                edit.writeresult(foultime[0], foultime[1], result[0], result[1], result[2]);
                form.Close();
                form.next_form = new System.Threading.Thread(open1);
                form.next_form.SetApartmentState(System.Threading.ApartmentState.STA);
                form.next_form.Start();
            }
            else
            {
                i = rnd(3);

                if (cc[i - 1] <= 3 && cc[0] + cc[1] + cc[2] != 12)
                {
                    countcolor(i);
                    number           = rnd(100);
                    form.label1.Text = Convert.ToString(number);
                    if (i == 1)
                    {
                        form.Answer1.Text = Convert.ToString(number);
                        form.Answer2.Text = Convert.ToString(rnd(100));
                        form.Answer3.Text = Convert.ToString(rnd(100));
                    }
                    else if (i == 2)
                    {
                        form.Answer1.Text = Convert.ToString(rnd(100));
                        form.Answer2.Text = Convert.ToString(number);
                        form.Answer3.Text = Convert.ToString(rnd(100));
                    }
                    else if (i == 3)
                    {
                        form.Answer1.Text = Convert.ToString(rnd(100));
                        form.Answer2.Text = Convert.ToString(rnd(100));
                        form.Answer3.Text = Convert.ToString(number);
                    }
                    Color c1 = Color.White;
                    if (i == 1)
                    {
                        c1 = Color.Red;
                        form.label1.ForeColor = Color.Red;
                    }
                    else if (i == 2)
                    {
                        c1 = Color.Blue;
                        form.label1.ForeColor = Color.Blue;
                    }
                    else if (i == 3)
                    {
                        c1 = Color.Green;
                        form.label1.ForeColor = Color.Green;
                    }
                    form.label1.BackColor = Color.FromArgb(c1.A,
                                                           (int)(c1.R * c[cc[i - 1]]), (int)(c1.G * c[cc[i - 1]]), (int)(c1.B * c[cc[i - 1]]));
                }
                else
                {
                    testing();
                }
            }
        }
示例#3
0
        public void testing(int i)
        {
            int count   = 0;
            int trueans = 0;

            if (i == 4)
            {
                button1.Enabled = false;
                for (int j = 0; j < 4; j++)
                {
                    if (answer[j] == answer2[j])
                    {
                        otvet[count++] = '+'; trueans++;
                    }
                    else
                    {
                        otvet[count++] = '-';
                    }
                }
                if (color == 0)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        csv.writefile(otvet[j].ToString(), timerfoul[j, 0], timerfoul[j, 1]);
                    }
                    for (int p = 0; p < 8; p++)
                    {
                        csv.writefile(" ");
                    }
                }
                else if (color == 1)
                {
                    for (int p = 0; p < 4; p++)
                    {
                        csv.writefile(" ");
                    }
                    for (int j = 0; j < 4; j++)
                    {
                        csv.writefile(otvet[j].ToString(), timerfoul[j, 0], timerfoul[j, 1]);
                    }
                    for (int p = 0; p < 4; p++)
                    {
                        csv.writefile(" ");
                    }
                }
                else
                {
                    for (int p = 0; p < 8; p++)
                    {
                        csv.writefile(" ");
                    }
                    for (int j = 0; j < 4; j++)
                    {
                        csv.writefile(otvet[j].ToString(), timerfoul[j, 0], timerfoul[j, 1]);
                    }
                }
                if (color == 0)
                {
                    if (trueans > 3)
                    {
                        csv.writeresult(min, sec, "Все добре", " ", " ");
                    }
                    else
                    {
                        csv.writeresult(min, sec, "Присутні відхилення", " ", " ");
                    }
                }
                else if (color == 1)
                {
                    if (trueans > 3)
                    {
                        csv.writeresult(min, sec, " ", "Все добре", " ");
                    }
                    else
                    {
                        csv.writeresult(min, sec, " ", "Присутні відхилення", " ");
                    }
                }
                else
                {
                    if (trueans > 3)
                    {
                        csv.writeresult(min, sec, " ", " ", "Все добре");
                    }
                    else
                    {
                        csv.writeresult(min, sec, " ", " ", "Присутні відхилення");
                    }
                }
                this.Close();
                next_form = new System.Threading.Thread(open);
                next_form.SetApartmentState(System.Threading.ApartmentState.STA);
                next_form.Start();
            }
            else
            {
                number = rnd(100);
                if (color == 0)
                {
                    label2.Text  = Convert.ToString(number);
                    Answer1.Text = Convert.ToString(number);
                    Answer2.Text = Convert.ToString(rnd(100));
                    Answer3.Text = Convert.ToString(rnd(100));
                }
                else if (color == 1)
                {
                    label2.Text  = Convert.ToString(number);
                    Answer1.Text = Convert.ToString(rnd(100));
                    Answer2.Text = Convert.ToString(number);
                    Answer3.Text = Convert.ToString(rnd(100));
                }
                else if (color == 2)
                {
                    label2.Text  = Convert.ToString(number);
                    Answer1.Text = Convert.ToString(rnd(100));
                    Answer2.Text = Convert.ToString(rnd(100));
                    Answer3.Text = Convert.ToString(number);
                }
                Color c1 = Color.White;
                if (color == 0)
                {
                    c1 = Color.Red;
                    label2.ForeColor = Color.Red;
                }
                else if (color == 1)
                {
                    c1 = Color.Blue;
                    label2.ForeColor = Color.Blue;
                }
                else if (color == 2)
                {
                    c1 = Color.Green;
                    label2.ForeColor = Color.Green;
                }
                label2.BackColor = Color.FromArgb(c1.A,
                                                  (int)(c1.R * c[i]), (int)(c1.G * c[i]), (int)(c1.B * c[i]));
            }
        }