示例#1
0
 //更新计时
 private void timer_tick(object sender, EventArgs e)
 {
     try
     {
         long currentTime  = DateTransform.ConvertDataTimeToLong(DateTime.Now);
         long time_consume = currentTime - answer.start_time;
         if (time_consume > 0)
         {
             long hour   = 0;
             long minute = 0;
             long second = 0;
             second = time_consume / 1000;
             if (second > 60)
             {
                 minute = second / 60;
                 second = second % 60;
             }
             if (minute > 60)
             {
                 hour   = minute / 60;
                 minute = minute % 60;
             }
             TestTimer.Text = toTimeStr(hour) + " : " + toTimeStr(minute) + " : " + toTimeStr(second);
         }
     }
     catch (Exception)
     {
         return;
     }
 }
示例#2
0
        //当前题目激活
        internal void Active(int timeRemain)
        {
            actived = true;
            Btn_Submit.Visibility = Visibility.Visible;
            Btn_Submit.IsEnabled  = false;
            Btn_Next.Visibility   = Visibility.Collapsed;
            record.start_time     = DateTransform.ConvertDataTimeToLong(DateTime.Now);
            QCBox.BorderBrush     = Brushes.ForestGreen;
            QCBox.BorderThickness = new Thickness(5);
            //后门
            //CanAnswer();

            //播放当前题目音频
            mediaPlayer = new MediaPlayer();
            string audios_path = "TEMP/" + question.audio.src.Substring(question.audio.src.LastIndexOf("/"));

            mediaPlayer.Open(new Uri(audios_path, UriKind.Relative));
            mediaPlayer.MediaEnded += Player_MediaEnded;
            mediaPlayer.Volume      = Setting.SYSTEM_VOLUME;

            Task t = new Task(() =>
            {
                //模拟工作过程
                Thread.Sleep(1000 * timeRemain);
                Action PlaySoundAction = new Action(PlaySound);
                Dispatcher.BeginInvoke(PlaySoundAction);
            });

            t.Start();
        }
示例#3
0
        private void Init(object sender, RoutedEventArgs e)
        {
            Answer     anstemp = new Answer();
            MainWindow mainwin = (MainWindow)Application.Current.MainWindow;

            anstemp.test = mainwin.ListeningTest;
            anstemp      = anstemp.LoadAnswer();
            if (anstemp != null && anstemp.account.id == answer.account.id && anstemp.test.id == answer.test.id)
            {
                //之前中断过
                answer    = anstemp;
                currentQn = answer.records.Count;
            }
            else
            {
                currentQn         = 0;
                answer.start_time = DateTransform.ConvertDataTimeToLong(DateTime.Now);
            }
            ToNextQue();

            //设置计时器
            timer          = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += new EventHandler(timer_tick);
            timer.Start();
        }
示例#4
0
        static void IllionDateTransform()
        {
            var input = new List <string> {
                "2010/03/30", "15/12/2016", "11-15-2012", "20130720"
            };

            DateTransform.ChangeDateFormat(input).ForEach(Console.WriteLine);
        }
示例#5
0
        public void ChangeDateFormat_BaseCase_Success()
        {
            var input = new List <string> {
                "2010/03/30", "15/12/2016", "11-15-2012", "20130720"
            };

            CollectionAssert.AreEqual(new List <string> {
                "20161215", "20121115", "20130720"
            }, DateTransform.ChangeDateFormat(input));
        }
示例#6
0
        //当前题目提交答案
        private void Btn_Submit_Click(object sender, RoutedEventArgs e)
        {
            //回答
            //第一次回答,记录时间
            if (record.answers.Count == 0)
            {
                record.answer_time = DateTransform.ConvertDataTimeToLong(DateTime.Now);
            }

            int op = 0;

            //查找选项
            for (int i = 1; i <= 5; i++)
            {
                RadioButton rb = FindName("rb_opt" + i.ToString()) as RadioButton;
                if (rb.IsEnabled == true && rb.IsChecked == true)
                {
                    op = i;
                }
            }
            //未回答
            if (op == 0)
            {
                MessageBox.Show(@"请选择答案后再提交哦\(^o^)/~", "提示");
                return;
            }
            //记录回答过程
            record.answers.Add(op);
            //是否答对
            if (op == question.answer)
            {
                //记录时间
                record.end_time = DateTransform.ConvertDataTimeToLong(DateTime.Now);
                Answered();
                ShowIntervention(0);
            }
            else
            {
                RadioButton rb = FindName("rb_opt" + op.ToString()) as RadioButton;
                rb.IsEnabled = false;
                rb.IsChecked = false;
                ShowIntervention(record.answers.Count);
            }
        }
示例#7
0
        //生成向后台传递的信息
        public Dictionary <string, string> GetParamUpload()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("tid", test.id);
            parameters.Add("uid", account.id.ToString());
            parameters.Add("type", "0");
            parameters.Add("states", states);

            parameters.Add("records", FormatRecordsString());
            parameters.Add("reasons", FormatReasonsString());
            parameters.Add("timecon", FormatTimeConString());
            parameters.Add("timereact", FormatTimeReactString());

            DateTime st = DateTransform.ConvertLongToDateTime(start_time);

            parameters.Add("start_time", st.ToString("yyyy-M-d H:m:s"));
            DateTime et = DateTransform.ConvertLongToDateTime(end_time);

            parameters.Add("end_time", et.ToString("yyyy-M-d H:m:s"));
            return(parameters);
        }
示例#8
0
        private void SubmitInspection_Click(object sender, RoutedEventArgs e)
        {
            if (!ValidateInfo())
            {
                MessageBox.Show("请回答所有问题。", "提示");
                return;
            }
            answer.states   = FormatQuestionaire();
            answer.end_time = DateTransform.ConvertDataTimeToLong(DateTime.Now);

            answer.SaveLocal();
            MainWindow mainwin = (MainWindow)Application.Current.MainWindow;

            if (mainwin.ListeningTest.testno == 3 && (mainwin.User.questionaireAF == "" || mainwin.User.questionaireAF == null))
            {
                TestQuestionaire testQuestionaire = new TestQuestionaire(mainwin.ListeningTest.testno);
                testQuestionaire.Owner = mainwin;
                testQuestionaire.ShowDialog();
            }
            MessageBox.Show("恭喜您!已经完成测试!");
            mainwin.FrameNavigator("funclist");
            Close();
            return;
        }
示例#9
0
 //播放结束事件
 private void Player_MediaEnded(object sender, EventArgs e)
 {
     //播放结束
     CanAnswer();
     record.start_time = DateTransform.ConvertDataTimeToLong(DateTime.Now);
 }