Esempio 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();
            }
        }
Esempio n. 2
0
        private void Button_Click_6(object sender, RoutedEventArgs e)  //查询学习记录
        {
            LearningRecordWindow lrw = new LearningRecordWindow();

            lrw.ShowDialog();
            LearningRecordService.ShowAll();
        }
Esempio n. 3
0
        private void FindButton_Click(object sender, RoutedEventArgs e)
        {
            switch (selectComboBox.SelectedValue)
            {
            case 0:
                RecordList.ItemsSource = recordList;
                break;

            case 1:
                int id = 0;
                int.TryParse(textBox.Text, out id);
                RecordList.ItemsSource = LearningRecordService.FindByRecordNo(id);
                if (LearningRecordService.FindByRecordNo(id) == null)
                {
                    MessageBox.Show("无匹配的学习记录,请重新搜索。");
                }
                RecordList.ItemsSource = recordList;
                break;

            case 2:
                string datetime = textBox.Text;
                RecordList.ItemsSource = LearningRecordService.FindByLearnDate(datetime);
                if (LearningRecordService.FindByLearnDate(datetime) == null)
                {
                    MessageBox.Show("无匹配的学习记录,请重新搜索。");
                }
                RecordList.ItemsSource = recordList;
                break;

            case 3:
                RecordList.ItemsSource = LearningRecordService.FindByLearnState(true);
                break;
            }
        }
Esempio n. 4
0
        public LearningRecordWindow(int nowNo, bool IsFinal, String timeLength, List <Proc> pr, int c)
        {
            this.nowNo = nowNo;
            this.coin  = c;
            InitializeComponent();

            init();

            if (IsFinal == true)  //如果完成学习
            {
                if (recordList.Count == 0)
                {
                    DateTime dt1 = DateTime.Now;
                    TimeSpan ts1 = TimeSpan.Parse(timeLength);

                    recordList.Add(new LearningRecordManager(nowNo, dt1, ts1, true, pr, coin));
                }
                else
                {
                    nowNo = recordList[recordList.Count - 1].recordNo + 1;
                    DateTime dt2 = DateTime.Now;
                    TimeSpan ts2 = TimeSpan.Parse(timeLength);

                    recordList.Add(new LearningRecordManager(nowNo, dt2, ts2, true, pr, coin));
                }
            }
            if (IsFinal == false)   //代表没有查询,放弃本次学习。
            {
                if (recordList.Count == 0)
                {
                    DateTime dt1 = DateTime.Now;
                    TimeSpan ts1 = TimeSpan.Parse(timeLength);

                    recordList.Add(new LearningRecordManager(nowNo, dt1, ts1, false, pr, coin));
                }
                else
                {
                    nowNo = recordList[recordList.Count - 1].recordNo + 1;
                    DateTime dt2 = DateTime.Now;
                    TimeSpan ts2 = TimeSpan.Parse(timeLength);

                    recordList.Add(new LearningRecordManager(nowNo, dt2, ts2, false, pr, coin));
                }
            }
            foreach (var n in recordList)
            {
                procResult.Add(n.pm);
            }

            RecordList.ItemsSource = recordList;

            //传递给learningRecordService的数据(dictionary转化为list)
            LearningRecordService.RecordDictionary = recordList.ToDictionary(key => key.recordNo, value => value);
            //保存数据
            String filename = LearningRecordService.ExportDocumentName();

            LearningRecordService.Export(filename);
        }
Esempio n. 5
0
        public void init()
        {
            MinWidth  = MaxWidth = Width;
            MinHeight = MaxHeight = Height;
            //combobox的选项
            categoryList.Add(new CategoryInfo {
                Name = "按照日期查询", Value = 2
            });
            categoryList.Add(new CategoryInfo {
                Name = "按照记录序号查询", Value = 1
            });
            categoryList.Add(new CategoryInfo {
                Name = "显示所有记录", Value = 0
            });
            categoryList.Add(new CategoryInfo {
                Name = "显示成功的记录", Value = 3
            });
            categoryList.Add(new CategoryInfo {
                Name = "按照低于某金币数查询", Value = 4
            });
            selectComboBox.ItemsSource        = categoryList;
            selectComboBox.DisplayMemberPath  = "Name";
            selectComboBox.SelectedValuePath  = "Value";
            this.selectComboBox.SelectedIndex = 2;
            //数据初始化
            string      path = @"..\..\bin\Debug\";//指定目录
            NewFileInfo nf   = NewFileInfo.GetLastFile(path, ".xml");

            if (nf == null)//如果没有xml文件,先生成一个空的xml
            {
                String fileName = LearningRecordService.ExportDocumentName();
                LearningRecordService.Export(fileName);
                NewFileInfo nf2     = NewFileInfo.GetLastFile(path, ".xml");
                string      newPath = nf2.FileName;
                recordList = LearningRecordService.Import(newPath);
            }
            else//如果已有则直接导入
            {
                string newPath = nf.FileName;
                recordList = LearningRecordService.Import(newPath);
            }
            //添加图片
            ImageBrush b = new ImageBrush();

            b.ImageSource   = new BitmapImage(new Uri(System.IO.Directory.GetCurrentDirectory() + @"\Picture\learningrecordbg.png"));
            b.Stretch       = Stretch.Fill;
            this.Background = b;
        }
Esempio n. 6
0
        public void init()
        {
            //combobox的选项
            categoryList.Add(new CategoryInfo {
                Name = "按照学习日期查询", Value = 2
            });
            categoryList.Add(new CategoryInfo {
                Name = "按照学习记录序号查询", Value = 1
            });
            categoryList.Add(new CategoryInfo {
                Name = "显示所有学习记录", Value = 0
            });
            categoryList.Add(new CategoryInfo {
                Name = "显示学习成功的记录", Value = 3
            });
            selectComboBox.ItemsSource       = categoryList;
            selectComboBox.DisplayMemberPath = "Name";
            selectComboBox.SelectedValuePath = "Value";
            //数据初始化
            string      path = @"..\..\bin\Debug\";//指定目录
            NewFileInfo nf   = NewFileInfo.GetLastFile(path, ".xml");

            if (nf == null)//如果没有xml文件,先生成一个空的xml
            {
                String fileName = LearningRecordService.ExportDocumentName();
                LearningRecordService.Export(fileName);
                NewFileInfo nf2     = NewFileInfo.GetLastFile(path, ".xml");
                string      newPath = nf2.FileName;
                recordList = LearningRecordService.Import(newPath);
            }
            else//如果已有则直接导入
            {
                string newPath = nf.FileName;
                recordList = LearningRecordService.Import(newPath);
            }
        }
Esempio n. 7
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--;
            }
        }
Esempio n. 8
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--;
            }
        }