Пример #1
0
        private void Button4_Click(object sender, RoutedEventArgs e)
        {
            Solution sol = new Solution();

            sol.Show();
        }
Пример #2
0
        private void Button3_Click(object sender, RoutedEventArgs e) //提交
        {
            if (Datapass.practice == 1)                              //练习
            {
                if (textBox1.Text == null || textBox1.Text == "")
                {
                    MessageBox.Show("不可为空!");
                }
                else
                {
                    ProgressBar1.Value += 1;
                    try
                    {
                        input1.Add(Convert.ToInt32(textBox1.Text));
                        if ((Convert.ToInt32(Answer[j - 1]) == Convert.ToInt32(input1[j - 1])))
                        {
                            Label2.Content    = "恭喜你答对啦!";
                            Label2.Visibility = Visibility.Visible;
                            right[j - 1]      = "正确";
                        }
                        else
                        {
                            Label2.Content    = "答错啦!正确答案是" + (Convert.ToInt32(Answer[j - 1]));
                            Label2.Visibility = Visibility.Visible;
                            Datapass.Mistake_Number.Add(j);
                            Datapass.Mistake_Equation.Add(Equation[j - 1]);
                            Datapass.Mistake_Youranswer.Add(input1[j - 1]);
                            Datapass.Mistake_Rightanswer.Add(Answer[j - 1]);
                            Datapass.wrong++;
                            right[j - 1] = "错误";
                        }
                        Button3.IsEnabled = false;
                        if (j != Datapass.N)
                        {
                            Button2.IsEnabled = true;
                        }
                        if (j > 1)
                        {
                            Button1.IsEnabled = true;
                        }
                        if (j == Datapass.N)
                        {
                            Button4.Visibility = Visibility.Visible;
                        }
                    }
                    catch
                    {
                        MessageBox.Show("请输入正确的格式!");
                    }
                }
            }
            else
            {
                if (MessageBox.Show("考题或许未全部完成,确定要提交吗?", "三思呀!", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    sw.Stop();
                    timer.Stop();
                    Button3.IsEnabled = false;
                    input[j - 1]      = textBox1.Text;
                    for (int k = 1; k <= 50; k++)
                    {
                        int tryy;
                        if (input[k - 1].ToString() == "")
                        {
                            right[k - 1] = "错误";
                            Datapass.Mistake_Number.Add(k);
                            Datapass.Mistake_Equation.Add(Equation[k - 1]);
                            Datapass.Mistake_Youranswer.Add(input[k - 1]);
                            Datapass.Mistake_Rightanswer.Add(Convert.ToString(Answer[k - 1]));
                            Datapass.wrong++;
                            continue;
                        }
                        try
                        {
                            tryy = Convert.ToInt32(input[k - 1]);
                        }
                        catch
                        {
                            right[k - 1] = "错误";
                            Datapass.Mistake_Number.Add(k);
                            Datapass.Mistake_Equation.Add(Equation[k - 1]);
                            Datapass.Mistake_Youranswer.Add(input[k - 1]);
                            Datapass.Mistake_Rightanswer.Add(Convert.ToString(Answer[k - 1]));
                            Datapass.wrong++;
                            continue;
                        }
                        if ((Convert.ToInt32(input[k - 1]) == Answer[k - 1]))
                        {
                            right[k - 1]    = "正确";
                            Datapass.Grade += 2;
                        }
                        else
                        {
                            right[k - 1] = "错误";
                            Datapass.Mistake_Number.Add(k);
                            Datapass.Mistake_Equation.Add(Equation[k - 1]);
                            Datapass.Mistake_Youranswer.Add(input[k - 1]);
                            Datapass.Mistake_Rightanswer.Add(Convert.ToString(Answer[k - 1]));
                            Datapass.wrong++;
                        }
                    }
                    Datapass.time = Label2.Content.ToString();
                    Solution sol = new Solution();
                    sol.Show();

                    //考虑此窗口是否隐藏
                }
            }
        }