Ejemplo n.º 1
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo()
        {
            //初始化
            TxtPlayingTime    = PlayTime = 0;
            TxtTotalTime      = TotalTime = PaperInfoItem.items[0].item_answer_second * 10;
            _audioPlayTimes   = 0;
            _item_repet_times = 1;
            _Recording        = RecordState.UnRecord;

            //默认取第一题
            //PaperItems
            SyncQsContent       = PaperInfoItem.items[0].item_content;
            _syncQsContentAudio = PaperInfoItem.items[0].source_content;

            PredView.QsItemContent.Children.Clear();

            var txt = new TextBlock();

            txt.Text = SyncQsContent;
            txt.HorizontalAlignment = HorizontalAlignment.Center;
            txt.TextWrapping        = TextWrapping.Wrap;
            txt.FontSize            = 28;
            txt.Foreground          = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#353535"));
            PredView.QsItemContent.Children.Add(txt);

            if (!string.IsNullOrEmpty(PaperInfoItem.items[0].img_source_content) &&
                MediaPic.Contains(PaperInfoItem.items[0].img_source_content.ToUpper().Split('.').LastOrDefault()))
            {
                string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperInfoItem.items[0].img_source_content}");
                SyncQsInfoImage = new BitmapImage(new Uri(url));
            }

            BindUserScoreBox();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo()
        {
            //初始化
            TxtPlayingTime    = PlayTime = 0;
            TxtTotalTime      = TotalTime = PaperInfoItem.items[0].item_answer_second * 10;
            _audioPlayTimes   = 0;
            _item_repet_times = 1;
            _Recording        = RecordState.UnRecord;

            //默认取第一题
            //PaperItems
            SyncQsContent       = PaperInfoItem.items[0].item_content;
            _syncQsContentAudio = PaperInfoItem.items[0].source_content;

            WordView.QsItemContent.Children.Clear();
            var txt = new TextBlock();

            txt.Text         = SyncQsContent;
            txt.TextWrapping = TextWrapping.Wrap;
            txt.FontSize     = 28;
            txt.Margin       = new Thickness(0, 0, 6, 0);
            //BrushConverter brushConverter = new BrushConverter();
            //Brush brush = (Brush)brushConverter.ConvertFromString("#333333");
            txt.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#353535"));
            WordView.QsItemContent.Children.Add(txt);

            try
            {
                KeyWordEx keyWord = JsonHelper.FromJson <KeyWordEx>(PaperInfoItem.items[0].item_keyword);
                SyncQsYbContent  = $"[ {keyWord.yb} ]";
                SyncQsZhContent  = keyWord.desc;
                SyncQsExEContent = keyWord.ex_en;
                SyncQsExZContent = keyWord.ex_zh;

                if (string.IsNullOrEmpty(keyWord.sp))
                {
                    _IsSpell = true;
                }
            }
            catch (Exception ex)
            {
                Log4NetHelper.Error($"单词 KeyWord 绑定异常:{PaperInfoItem.items[0].item_keyword}", ex);
            }

            if (!string.IsNullOrEmpty(PaperInfoItem.items[0].img_source_content) &&
                MediaPic.Contains(PaperInfoItem.items[0].img_source_content.ToUpper().Split('.').LastOrDefault()))
            {
                string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperInfoItem.items[0].img_source_content}");
                SyncQsInfoImage = new BitmapImage(new Uri(url));
            }


            BindUserScoreBox();

            //BeginExam(_NextFlowType);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo(string item_id = null)
        {
            if (_itemIndex >= PaperItems.Count)
            {
                //进入 下一道大题
                NextQsView();
            }
            else
            {
                TitleTwo = PaperItems[_itemIndex].info_content;

                //if (_itemIndex > 0)
                //{
                //    _showIndexNum = _showIndexNum + PaperItems[0].items.Count;
                //}

                _subChoiceQsContent.Children.Clear();

                QsInfoImage = null;
                if (!string.IsNullOrEmpty(PaperItems[_itemIndex].info_content_img) &&
                    MediaPic.Contains(PaperItems[_itemIndex].info_content_img.ToUpper().Split('.').LastOrDefault()))
                {
                    string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperItems[_itemIndex].info_content_img}");
                    QsInfoImage = new BitmapImage(new Uri(url));
                }

                int idx = 0;

                if (_itemIndex > 0)
                {
                    idx = PaperItems[_itemIndex - 1].items.Count;
                }

                for (int i = 0; i < PaperItems[_itemIndex].items.Count; i++)
                {
                    var subChoiceView = new SubTextChoice1View();
                    subChoiceView.DataContext =
                        new SubTextChoice1ViewModel(PaperItems[_itemIndex].items[i], 0, (idx + i + 1));

                    _subChoiceQsContent.Children.Add(subChoiceView);
                }

                //初始化
                PlayTime          = 0;
                TotalTime         = 0;
                _audioPlayTimes   = 0;
                _prepareTime      = 0;
                _answerTime       = 0;
                _item_repet_times = 1;

                BeginExam(_NextFlowType);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo(int item_id = 0)
        {
            if (_itemIndex >= PaperItems[_infoIndex].items.Count())
            {
                _itemIndex = 0;
                _infoIndex++;

                _NextFlowType = ExamFlowType.PromptAudio;
            }


            if (_infoIndex >= PaperItems.Count)
            {
                _dTimer.Stop();
                _dTimer = null;
                //进入 下一道大题
                NextQsView();
            }
            else
            {
                //默认取第一题
                //PaperItems
                QsItemContent = PaperItems[_infoIndex].info_content;

                QsItemContent1 = "";
                for (int i = 0; i < PaperItems[_infoIndex].items.Count; i++)
                {
                    QsItemContent1 += PaperItems[_infoIndex].items[i].item_content + "\r\n\r\n";
                }

                if (!string.IsNullOrEmpty(PaperItems[_infoIndex].items[0].img_source_content) && MediaPic.Contains(
                        PaperItems[_infoIndex].items[0].img_source_content.ToUpper().Split('.')
                        .LastOrDefault()))
                {
                    string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperItems[_infoIndex].items[0].img_source_content}");
                    QsInfoImage = new BitmapImage(new Uri(url));
                }


                //初始化
                PlayTime          = 0;
                TotalTime         = 0;
                _audioPlayTimes   = 0;
                _info_repet_times = 1;
                _item_repet_times = 1;
                _Recording        = RecordState.UnRecord;

                BeginExam(_NextFlowType);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsSubItemInfo()
        {
            QsItemContent = $"{_paperSubItemDetail.item_content}";//{_showIndexNum}、

            string urla = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{_paperSubItemDetail.answers[0].source_content}");

            QsItemOptionA = new BitmapImage(new Uri(urla));

            string urlb = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{_paperSubItemDetail.answers[1].source_content}");

            QsItemOptionB = new BitmapImage(new Uri(urlb));

            string urlc = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{_paperSubItemDetail.answers[2].source_content}");

            QsItemOptionC = new BitmapImage(new Uri(urlc));
            CurrentOption = "0";
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo(string item_id = null)
        {
            if (_itemIndex >= PaperItems.Count)
            {
                _dTimer.Stop();
                _dTimer = null;
                //进入 下一道大题
                NextQsView();
            }
            else
            {
                //默认取第一题
                //PaperItems
                QsItemContent = $"{_itemIndex + 1}、{PaperItems[_itemIndex].items[0].item_content}";
                try
                {
                    KeyWordEx keyWord = JsonHelper.FromJson <KeyWordEx>(PaperItems[_itemIndex].items[0].item_keyword);
                    SyncQsYbContent = $"[ {keyWord.yb} ]";
                    SyncQsZhContent = keyWord.desc;
                }
                catch (Exception ex)
                {
                    Log4NetHelper.Error($"单词 KeyWord 绑定异常:{PaperItems[_itemIndex].items[0].item_keyword}", ex);
                }

                if (!string.IsNullOrEmpty(PaperItems[_itemIndex].items[0].img_source_content) &&
                    MediaPic.Contains(PaperItems[_itemIndex].items[0].img_source_content.ToUpper().Split('.').LastOrDefault()))
                {
                    string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperItems[_itemIndex].items[0].img_source_content}");
                    QsInfoImage = new BitmapImage(new Uri(url));
                }

                //初始化
                PlayTime          = 0;
                TotalTime         = 0;
                _audioPlayTimes   = 0;
                _item_repet_times = 1;
                _Recording        = RecordState.UnRecord;

                BeginExam(_NextFlowType);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo(string item_id = null)
        {
            if (_itemIndex >= PaperItems.Count)
            {
                _dTimer.Stop();
                _dTimer = null;
                //进入 下一道大题
                NextQsView();
            }
            else
            {
                //默认取第一题
                //PaperItems
                //QsItemContent = PaperItems[0].items[_itemIndex].item_content;

                infoList.AddRange(PaperItems[0].info_content.FromJsonTo <List <info_content> >());

                infoList.AddRange(PaperItems[1].info_content.FromJsonTo <List <info_content> >());

                QsTitleContent = infoList[0].text;


                if (!string.IsNullOrEmpty(PaperItems[0].info_content_img) &&
                    MediaPic.Contains(PaperItems[0].info_content_img.ToUpper().Split('.').LastOrDefault()))
                {
                    string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperItems[0].info_content_img}");
                    QsInfoImage = new BitmapImage(new Uri(url));
                }

                //初始化
                PlayTime          = 0;
                TotalTime         = 0;
                _audioPlayTimes   = 0;
                _item_repet_times = 1;
                _Recording        = RecordState.UnRecord;

                BeginExam(_NextFlowType);
            }
        }
Ejemplo n.º 8
0
        public void PlayAudio1(string audioFile, bool isSend = true)
        {
            GlobalUser.WavePlayer?.Stop();
            string reueUrl = "";

            try
            {
                GlobalUser.WavePlayer = CreateWavePlayer();

                string pfile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GlobalUser.DATAFOLDER, SecurityHelper
                                            .HmacMd5Encrypt(GlobalUser.SelectPaperName + GlobalUser.SelectPaperNumber,
                                                            GlobalUser.FILEPWD, Encoding.UTF8).ToUpper(),
                                            SecurityHelper.HmacMd5Encrypt(Path.GetFileNameWithoutExtension(audioFile), GlobalUser.FILEPWD,
                                                                          Encoding.UTF8).ToLower() + ".qf");

                if (!File.Exists(pfile))
                {
                    throw new Exception("无效的本地内容文件");
                }

                var sfile = FileSecretHelper.DecryptFile0(pfile);

                //if (!audioFile.ToLower().Contains(".mp3"))
                //    reueUrl = $"{audioFile}.mp3";
                Mp3FileReader mfr = new Mp3FileReader(sfile);
                //reueUrl = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{audioFile}");

                //if (!audioFile.ToLower().Contains(".mp3"))
                //    reueUrl = $"{audioFile}.mp3";

                //AudioFileReader afr =
                //    new AudioFileReader(Path.Combine(GlobalUser.AUDIODATAFOLDER, Path.GetFileName(audioFile)));
                GlobalUser.WavePlayer.Init(mfr);//存入 网络音频地址
                GlobalUser.WavePlayer.PlaybackStopped += OnPlaybackStopped1;

                //TotalTime = Convert.ToInt32(mfr.TotalTime.Minutes * 60 + mfr.TotalTime.Seconds);
                //PlayTime = 0;

                if (isSend)
                {
                    SendProgress();
                }

                GlobalUser.WavePlayer.Play();
            }
            catch (Exception)
            {
                try
                {
                    GlobalUser.WavePlayer?.Stop();
                    GlobalUser.WavePlayer?.Dispose();

                    GlobalUser.WavePlayer = CreateWavePlayer();
                    if (audioFile.ToLower().Contains("records."))
                    {
                        reueUrl = $"http://{audioFile}.mp3";
                    }
                    else
                    {
                        reueUrl = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{audioFile}");
                    }

                    MediaFoundationReader mfr = new MediaFoundationReader(reueUrl);
                    GlobalUser.WavePlayer.Init(mfr);//存入 网络音频地址
                    GlobalUser.WavePlayer.PlaybackStopped += OnPlaybackStopped1;

                    TotalTime = Convert.ToInt32(mfr.TotalTime.Minutes * 60 + mfr.TotalTime.Seconds);
                    PlayTime  = 0;

                    SendProgress();

                    GlobalUser.WavePlayer.Play();
                }
                catch (Exception e)
                {
                    Log4NetHelper.Error(
                        $"Play Audio Error ---- {e.Message} ----  {e.StackTrace} \r\n-------- url: {WebApiProxy.MEDIAURL}{audioFile} \r\n-------- True Url:{reueUrl}");

                    BeginExam(_NextFlowType);
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo(int item_id = 0)
        {
            if (_infoIndex == 0 || _infoIndex == 1)
            {
                if (_itemIndex >= PaperItems[1].items.Count())
                {
                    _itemIndex = 0;
                    _infoIndex = 2;
                }
            }
            else
            {
                if (_itemIndex >= PaperItems[_infoIndex].items.Count())
                {
                    _itemIndex = 0;
                    _infoIndex++;
                }
            }


            if (_infoIndex >= PaperItems.Count)
            {
                _dTimer.Stop();
                _dTimer = null;
                //进入 下一道大题
                NextQsView();
            }
            else
            {
                //默认取第一题
                //PaperItems
                if (_infoIndex == 2)
                {
                    QsTitleContent = PaperItems[_infoIndex].info_content;
                    QsItemContent  = "";
                    QsItemContent1 = PaperItems[_infoIndex].items[_itemIndex].item_content;
                    QsInfoImage    = null;
                }
                else
                {
                    QsItemContent = PaperItems[_infoIndex].info_content;

                    if (!string.IsNullOrEmpty(PaperItems[0].info_content_img) &&
                        MediaPic.Contains(PaperItems[0].info_content_img.ToUpper().Split('.').LastOrDefault()))
                    {
                        string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperItems[0].info_content_img}");
                        QsInfoImage = new BitmapImage(new Uri(url));
                    }
                }



                //初始化
                PlayTime          = 0;
                TotalTime         = 0;
                _audioPlayTimes   = 0;
                _item_repet_times = 1;
                _info_repet_times = 1;
                _Recording        = RecordState.UnRecord;

                BeginExam(_NextFlowType);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 加载题目
        /// </summary>
        /// <param name="item_id"></param>
        private void BindQsItemInfo(string item_id = null)
        {
            if (_itemIndex >= PaperItems.Count)
            {
                //进入 下一道大题
                NextQsView();
            }
            else
            {
                TitleTwo = PaperItems[_itemIndex].info_content;

                if (_itemIndex > 0)
                {
                    _showIndexNum = _showIndexNum + PaperItems[0].items.Count;
                }

                if (!string.IsNullOrEmpty(PaperItems[_itemIndex].info_content_img))
                {
                    string url = WebApiProxy.GetRedirectUrl($"{WebApiProxy.MEDIAURL}{PaperItems[_itemIndex].info_content_img}");
                    QsInfoImage = new BitmapImage(new Uri(url));
                }
                else
                {
                    QsInfoImage = null;
                }

                _subChoiceQsContent.Children.Clear();

                //if (PaperItems[_itemIndex].items.Count > 0)
                //{
                //    var subChoiceView = new SubTextChoiceView();
                //    subChoiceView.DataContext =
                //        new SubTextChoiceViewModel(PaperItems[_itemIndex].items[0], 0, (_showIndexNum + 1));

                //    _subChoiceQsContent.Children.Add(subChoiceView);
                //}
                //if (PaperItems[_itemIndex].items.Count > 1)
                //{
                //    var subChoiceView = new SubTextChoiceView();
                //    subChoiceView.DataContext = new SubTextChoiceViewModel(PaperItems[_itemIndex].items[1], 1, (_showIndexNum + 2));

                //    _subChoiceQsContent.Children.Add(subChoiceView);
                //}
                //if (PaperItems[_itemIndex].items.Count > 2)
                //{
                //    var subChoiceView = new SubTextChoiceView();
                //    subChoiceView.DataContext = new SubTextChoiceViewModel(PaperItems[_itemIndex].items[2], 2, (_showIndexNum + 3));

                //    _subChoiceQsContent.Children.Add(subChoiceView);
                //}



                for (int i = 0; i < PaperItems[_itemIndex].items.Count; i++)
                {
                    var subChoiceView = new SubTextChoiceView();
                    subChoiceView.DataContext =
                        new SubTextChoiceViewModel(PaperItems[_itemIndex].items[i], i, (_showIndexNum + i + 1));

                    _subChoiceQsContent.Children.Add(subChoiceView);
                }


                //初始化
                PlayTime          = 0;
                TotalTime         = 0;
                _audioPlayTimes   = 0;
                _prepareTime      = 0;
                _answerTime       = 0;
                _item_repet_times = 1;

                BeginExam(_NextFlowType);
            }
        }