Exemplo n.º 1
0
        private void GiveUp(object sender, RoutedEventArgs e)  //放弃
        {
            //存放当前一次学习中使用的程序信息,用List存储,并将其传到学习记录窗口
            List <Proc> procResult = pm.countResult();

            mc.Puase();
            disTimer.Stop();

            MessageBoxResult quit = MessageBox.Show("你确定要放弃本次学习吗?", "提示", MessageBoxButton.OKCancel);

            if (quit == MessageBoxResult.OK)
            {
                disTimer.Tick -= new EventHandler(disTimer_Tick);

                int length = learningTime - CountSecond;  //已学习时长
                                                          //转换为字符串,传入参数
                String timeRecord        = String.Format("{0:D2}", length / 60 / 60) + ":" + String.Format("{0:D2}", (length / 60) % 60) + ":" + String.Format("{0:D2}", length % 60);
                LearningRecordWindow lrw = new LearningRecordWindow(NowNo, false, timeRecord, procResult);
                lrw.ShowDialog();
                NowNo++;
                LearningRecordService.ShowAll();
                //实现主界面的显示,本界面的关闭
                this.Close();
                main.Visibility = Visibility.Visible;
                main.InitializeComponent();
            }
            else
            {
                disTimer.Start();
                mc.play();
            }
        }
Exemplo n.º 2
0
        private void Button_Click_6(object sender, RoutedEventArgs e)  //查询学习记录
        {
            LearningRecordWindow lrw = new LearningRecordWindow();

            lrw.ShowDialog();
            LearningRecordService.ShowAll();
        }
Exemplo n.º 3
0
        void disTimer_Tick(object sender, EventArgs e)
        {
            pm.onceMonitor();
            //游戏超时
            if (!pm.checkGameTime())
            {
                mc.Puase();
                disTimer.Stop();
                MessageBoxResult result = MessageBox.Show("你的游戏时间太长了,需要结束学习吗?", "End confirm", MessageBoxButton.OKCancel);
                if (result == MessageBoxResult.OK)
                {
                    disTimer.Stop(); //关闭计时器
                    mc.StopT();      //关闭音乐

                    this.Close();    //关闭当前窗口
                    //存放当前一次学习中使用的程序信息,用List存储,并将其传到学习记录窗口
                    List <Proc>          procResult = pm.countResult();
                    String               timeRecord = String.Format("{0:D2}", learningTime / 60 / 60) + ":" + String.Format("{0:D2}", (learningTime / 60) % 60) + ":" + String.Format("{0:D2}", learningTime % 60);
                    LearningRecordWindow lrw        = new LearningRecordWindow(NowNo, false, timeRecord, procResult);
                    lrw.ShowDialog();
                    NowNo++;
                    LearningRecordService.ShowAll();

                    disTimer.Tick -= new EventHandler(disTimer_Tick);

                    main.Visibility = Visibility.Visible;  //显示主窗口
                }
                else
                {
                    pm.clearGameTime();
                    mc.play();
                    disTimer.Start();
                    return;
                }
            }

            int temp = CountSecond;

            if (CountSecond == 57)  //为了显示效果,故此处设置为-1
            {
                MessageBox.Show("你已成功完成本次学习。");
                disTimer.Stop(); //关闭计时器
                mc.StopT();      //关闭音乐

                this.Close();    //关闭当前窗口
                //存放当前一次学习中使用的程序信息,用List存储,并将其传到学习记录窗口
                List <Proc>          procResult = pm.countResult();
                String               timeRecord = String.Format("{0:D2}", learningTime / 60 / 60) + ":" + String.Format("{0:D2}", (learningTime / 60) % 60) + ":" + String.Format("{0:D2}", learningTime % 60);
                LearningRecordWindow lrw        = new LearningRecordWindow(NowNo, true, timeRecord, procResult);
                lrw.ShowDialog();
                NowNo++;
                LearningRecordService.ShowAll();

                disTimer.Tick -= new EventHandler(disTimer_Tick);

                main.Visibility = Visibility.Visible;  //显示主窗口
            }
            else
            {
                second         = CountSecond % 60;
                minute         = (CountSecond / 60) % 60;
                hour           = CountSecond / 60 / 60;
                timer2.Content = String.Format("{0:D2}", hour) + ":" + String.Format("{0:D2}", minute) + ":" + String.Format("{0:D2}", second);
                CountSecond--;
            }
        }
Exemplo n.º 4
0
        //时钟Tick
        void disTimer_Tick(object sender, EventArgs e)
        {
            pm.onceMonitor();
            //游戏超时
            if (!pm.checkGameTime())
            {
                mc.Puase();
                disTimer.Stop();

                //显示警告框
                showAlertDialog();
                if (alert.isConfirm) //确定不学了
                {
                    disTimer.Stop(); //关闭计时器
                    mc.StopT();      //关闭音乐

                    this.Close();    //关闭当前窗口
                    //存放当前一次学习中使用的程序信息,用List存储,并将其传到学习记录窗口
                    List <Proc>          procResult = pm.countResult();
                    String               timeRecord = String.Format("{0:D2}", learningTime / 60 / 60) + ":" + String.Format("{0:D2}", (learningTime / 60) % 60) + ":" + String.Format("{0:D2}", learningTime % 60);
                    LearningRecordWindow lrw        = new LearningRecordWindow(NowNo, false, timeRecord, procResult, 0);
                    lrw.ShowDialog();
                    NowNo++;
                    LearningRecordService.ShowAll();

                    disTimer.Tick  -= new EventHandler(disTimer_Tick);
                    main.Visibility = Visibility.Visible;  //显示主窗口
                }
                else
                {
                    pm.clearGameTime();
                    mc.play();
                    disTimer.Start();
                    return;
                }
            }

            int temp = CountSecond;

            if (CountSecond == 40)  //为了显示效果,故此处设置为-1
            {
                MessageBox.Show("你已成功完成本次学习,金币加 " + timeSpan + " !");
                disTimer.Stop(); //关闭计时器
                mc.StopT();      //关闭音乐
                this.Close();    //关闭当前窗口
                //存放当前一次学习中使用的程序信息,用List存储,并将其传到学习记录窗口
                List <Proc> procResult = pm.countResult();
                String      timeRecord = String.Format("{0:D2}", learningTime / 60 / 60) + ":" + String.Format("{0:D2}", (learningTime / 60) % 60) + ":" + String.Format("{0:D2}", learningTime % 60);

                main.coin += timeSpan;
                LearningRecordWindow lrw = new LearningRecordWindow(NowNo, true, timeRecord, procResult, timeSpan);
                lrw.ShowDialog();
                NowNo++;
                LearningRecordService.ShowAll();

                disTimer.Tick  -= new EventHandler(disTimer_Tick);
                main.Visibility = Visibility.Visible;  //显示主窗口
                StreamWriter sw2 = new StreamWriter(@"1.txt", false, Encoding.UTF8);
                sw2.WriteLine(main.coin);
                sw2.WriteLine(main.lock1);
                sw2.WriteLine(main.lock2);
                sw2.Close();
                main.MoneyL.Content = "当前金币数:" + main.coin;
            }
            else
            {
                second         = CountSecond % 60;
                minute         = (CountSecond / 60) % 60;
                hour           = CountSecond / 60 / 60;
                timer2.Content = String.Format("{0:D2}", hour) + ":" + String.Format("{0:D2}", minute) + ":" + String.Format("{0:D2}", second);
                CountSecond--;
            }
        }