예제 #1
0
        //测试用
        public static void Main0(string[] args)
        {
            ProcManager pm = new ProcManager();

            pm.init();
            pm.gameList.Add("TIM");
            int i = 0;

            while (i <= 20)
            {
                pm.onceMonitor();
                i++;
                if (!pm.checkGameTime())
                {
                    Console.WriteLine("Game above the required time!!!");
                    break;
                }
            }
            pm.countResult();
        }
예제 #2
0
파일: Timer.xaml.cs 프로젝트: 12Jack21/Tide
        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--;
            }
        }
예제 #3
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--;
            }
        }