private void q_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "IsCorrect")
            {
                if (!MathSetting.Instance.VoiceTip)
                {
                    return;
                }

                Question_a_b_c question = sender as Question_a_b_c;
                if (question != null)
                {
                    if (question.IsCorrect != null)
                    {
                        if (!question.IsCorrect.Value)
                        {
                            this.PlayMusic(this.failMp3);
                        }
                        else
                        {
                            this.PlayMusic(this.okMp3);
                        }
                    }
                    else
                    {
                    }
                }
            }
        }
        private void SafeGeneratedQuestionCompleted(int index)
        {
            this.CreateQuestionControl();

            this.questionData.AutoSave();

            this.ShowGeneratingInfo(false);

            this.timeControl              = new TimeControlEngine();
            this.timeControl.TimeElapsed += new EventHandler(timeControl_TimeElapsed);

            this.timerPanel.Visibility = System.Windows.Visibility.Visible;

            this.timeControl.Start();

            int i = 0;

            foreach (Question_a_b_c_Control ctrl in this.questionGrid.Children)
            {
                if (ctrl == null)
                {
                    continue;
                }

                if (ctrl.DataContext is Question_a_b_c)
                {
                    Question_a_b_c oldQ = ctrl.DataContext as Question_a_b_c;
                    oldQ.PropertyChanged -= q_PropertyChanged;
                }

                Question_a_b_c q = this.questionData.Items[i++] as Question_a_b_c;
                ctrl.DataContext   = q;
                q.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(q_PropertyChanged);
                if (i == this.questionData.Items.Count)
                {
                    break;
                }

                ctrl.SelectedChanged   += OnQuestonCtrlSelectedChanged;
                ctrl.QuestionValidated += OnQuestionValidated;
            }

            this.ActiveQuestionControl = (Question_a_b_c_Control)this.questionGrid.Children[0];
            if (this.ActiveQuestionControl != null)
            {
                this.ActiveQuestionControl.Select();
            }

            this.currentPage = 0;
            this.totalPage   = this.questionData.Items.Count / MathSetting.Instance.QuestionCountPerPage;
            if (this.questionData.Items.Count % MathSetting.Instance.QuestionCountPerPage != 0)
            {
                this.totalPage++;
            }

            //   this.countPerPageLabel.Content = string.Format(SoonLearning.Math.Fast.Properties.Resources.questionCountPerPage, MathSetting.Instance.QuestionCountPerPage);
            //this.Total = this.totalPage;
            this.UpdatePageInfo();
        }
        internal void ValidResult()
        {
            Question_a_b_c question = this.DataContext as Question_a_b_c;

            if (question != null)
            {
                BindingExpression be = this.resultTextBox.GetBindingExpression(TextBox.TextProperty);
                be.UpdateSource();
            }
        }
 internal void RetryQuiz()
 {
     this.questionData = MathSetting.Instance.CurrentQuestionData;
     foreach (Question q in this.questionData.Items)
     {
         if (q is Question_a_b_c)
         {
             Question_a_b_c abc = q as Question_a_b_c;
             abc.Result = null;
         }
     }
     this.totalTime = MathSetting.Instance.ExamTime * 60;
     this.isRetry   = true;
 }
        private void nextOpacityAnimate_Completed(object sender, EventArgs e)
        {
            this.questionGrid.Opacity = 0.0f;

            this.currentPage++;

            int count = 0;
            int index = this.currentPage * MathSetting.Instance.QuestionCountPerPage;

            foreach (Question_a_b_c_Control ctrl in this.questionGrid.Children)
            {
                if (ctrl == null)
                {
                    continue;
                }

                if (index == this.questionData.Items.Count)
                {
                    ctrl.Visibility = System.Windows.Visibility.Hidden;
                    continue;
                }
                else
                {
                    ctrl.Visibility = System.Windows.Visibility.Visible;
                }

                if (ctrl.DataContext is Question_a_b_c)
                {
                    Question_a_b_c oldQ = ctrl.DataContext as Question_a_b_c;
                    oldQ.PropertyChanged -= q_PropertyChanged;
                }

                Question_a_b_c q = this.questionData.Items[index++] as Question_a_b_c;
                ctrl.DataContext   = q;
                q.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(q_PropertyChanged);
                count++;
                if (count == MathSetting.Instance.QuestionCountPerPage)
                {
                    break;
                }
            }

            this.OpacityShowQuestionPage(1.0f, EndSwtichPage);

            this.UpdatePageInfo();
        }