コード例 #1
0
        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            if (this.questionPanel.Children[0] is MCQuestionUserControl)
            {
                MCQuestionUserControl mcQuestionCtrl = this.questionPanel.Children[0] as MCQuestionUserControl;
                if (!mcQuestionCtrl.IsCorrect)
                {
                    MessageWindow msgWin = new MessageWindow();
                    msgWin.ShowMessage("请检查答案或者察看解题方法!", MessageBoxButton.OK, null);
                    return;
                }
            }
            else if (this.questionPanel.Children[0] is TableQuestionUserControl)
            {
                TableQuestionUserControl tableQuestionCtrl = this.questionPanel.Children[0] as TableQuestionUserControl;
                if (!tableQuestionCtrl.IsCorrect)
                {
                    MessageWindow msgWin = new MessageWindow();
                    msgWin.ShowMessage("请检查答案或者察看解题方法!", MessageBoxButton.OK, null);
                    return;
                }
            }
            else if (this.questionPanel.Children[0] is FIBQuestionUserControl)
            {
                FIBQuestionUserControl fibQuestionCtrl = this.questionPanel.Children[0] as FIBQuestionUserControl;
                if (!fibQuestionCtrl.IsCorrect)
                {
                    MessageWindow msgWin = new MessageWindow();
                    msgWin.ShowMessage("请检查答案或者察看解题方法!", MessageBoxButton.OK, null);
                    return;
                }
            }

            this.ShowNextQuestion();
        }
コード例 #2
0
        private void ShowQuestion(Question question)
        {
            if (question == null)
            {
                return;
            }

            this.solutionWrapPanel.Children.Clear();

            this.sectionInfoLabel.Text = this.exercise.CurrentSection.Title + this.exercise.CurrentSection.Description;

            this.UpdateButtonState();

            this.questionPanel.Children.Clear();
            if (question is TableQuestion)
            {
                TableQuestionUserControl ctrl = new TableQuestionUserControl(question as TableQuestion,
                                                                             this.exercise.GetQuestionResponse(question.Id) as SelectableQuestionResponse);
                ctrl.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                ctrl.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                this.questionPanel.Children.Add(ctrl);
            }
            else if (question is SelectableQuestion)
            {
                MCQuestionUserControl ctrl = new MCQuestionUserControl(question as SelectableQuestion,
                                                                       this.exercise.GetQuestionResponse(question.Id) as SelectableQuestionResponse,
                                                                       this.exercise.QuestionIndex);
                ctrl.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                ctrl.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                this.questionPanel.Children.Add(ctrl);
            }
            else if (question is FIBQuestion)
            {
                FIBQuestionUserControl ctrl = new FIBQuestionUserControl(question as FIBQuestion,
                                                                         this.exercise.GetQuestionResponse(question.Id) as FIBQuestionResponse,
                                                                         this.exercise.QuestionIndex);
                ctrl.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                ctrl.VerticalAlignment   = System.Windows.VerticalAlignment.Center;
                this.questionPanel.Children.Add(ctrl);
            }
            else if (question is ESQuestion)
            {
                ESQuestionUserControl ctrl = new ESQuestionUserControl(question as ESQuestion,
                                                                       this.exercise.GetQuestionResponse(question.Id) as ESQuestionResponse,
                                                                       this.exercise.QuestionIndex);
                ctrl.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
                ctrl.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
                this.questionPanel.Children.Add(ctrl);
            }
        }