Inheritance: System.Windows.Forms.UserControl
Exemplo n.º 1
0
        //Show question by id question
        public bool ShowQuestionByIDPhase_1()
        {
            //declare
            List<Phase> ListPhase;
            List<Question> ListQuestion;
            List<Answer> ListAnswer;
            Phase.IDContest = iDContest;
            int idquestion = 0;
            int a = 65;

            ListPhase = PhaseQuestionBl.getquestionRunGame_1(Phase);
            try
            {
                idquestion = ListPhase.ElementAt(0).IDQuestion;
                IDQuestion_Sub = idquestion;
                Phase.IDPhase = ListPhase.ElementAt(0).IDPhase;

                //show question in phase
                Question.IDQuestion = idquestion;
                ListQuestion = QuestionBL.GetQuestionByID(Question);
                ListAnswer = QuestionBL.GetAnswerByQuestionID(Question);
                //////show question on audience screen
                if (ListQuestion != null)
                {
                    /////display question on audience screen
                    audience.lbl_QuestionContent.Text = ListQuestion.ElementAt(0).NameQuestion;

                    typequestion = ListQuestion.ElementAt(0).TypeQuestion.ToLower();

                    /////question is onechoice type
                    if (ListQuestion.ElementAt(0).TypeQuestion.ToLower() == "onechoice")
                    {
                        //fix
                        if (ListAnswer.Count==2)
                        {
                            for (int h = 0; h < ListAnswer.Count; h++)
                            {
                                ShowAnswer ShowAnswer = new ShowAnswer();
                                ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / 2 - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count)) - 10);
                                ShowAnswer.rdb1.Text = Convert.ToChar(a + h).ToString();
                                ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                            }
                        }
                        else
                        {
                            for (int h = 0; h < ListAnswer.Count; h++)
                            {
                                ShowAnswer ShowAnswer = new ShowAnswer();
                                ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / 2 - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count / 2)) - 10);
                                ShowAnswer.rdb1.Text = Convert.ToChar(a + h).ToString();
                                ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                            }
                        }

                    }
                    else
                    {   //question is multichoice type
                        if (ListQuestion.ElementAt(0).TypeQuestion.ToLower() == "multichoice")
                        {
                            //fix
                            if (ListAnswer.Count == 2)
                            {
                                for (int h = 0; h < ListAnswer.Count; h++)
                                {
                                    ShowAnswer ShowAnswer = new ShowAnswer();
                                    ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / (2) - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count)) - 10);
                                    ShowAnswer.chk1.Text = Convert.ToChar(a + h).ToString();
                                    ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                    ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                    ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                    audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                                }
                            }
                            else
                            {
                                for (int h = 0; h < ListAnswer.Count; h++)
                                {
                                    ShowAnswer ShowAnswer = new ShowAnswer();
                                    ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / (2) - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count / 2)) - 10);
                                    ShowAnswer.chk1.Text = Convert.ToChar(a + h).ToString();
                                    ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                    ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                    ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                    audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                                }
                            }

                        }
                        else
                        {
                            //question is short answer type
                            audience.flp_AnswerQuiz.BackColor = Color.Transparent;
                            CorrectShortAnswer_1 = ListAnswer.ElementAt(0).ContentAnswer;
                        }
                    }
                    FixSizeText();
                    //update
                    Phase.IDContest = iDContest;
                    Phase.IDQuestion = idquestion;
                    //Check question have been showed
                    PhaseQuestionBl.EditQuestionStatus_1(Phase);
                }
                //Show answer for multi team
                TableAnswerMultiTeam_1(ListQuestion, ListAnswer);

                ListPhase = PhaseBL.GetPhaseByIDPhase(Phase);

                //show countdown time on game controller screen
                lbl_Time.Text = (ListPhase.ElementAt(0).TimePhase).ToString();
                timer1.Start();

                //show time conut down on audience screen
                audience.lbl_TimeShowQuestion.Text = (ListPhase.ElementAt(0).TimePhase).ToString();
                audience.progressBarControl1.Max = Convert.ToInt32(audience.lbl_TimeShowQuestion.Text) * 900;
                audience.progressBarControl1.Value = Convert.ToInt32(audience.lbl_TimeShowQuestion.Text) * 900;

                time = Convert.ToInt32(audience.lbl_TimeShowQuestion.Text);

                audience.timer1.Start();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Exemplo n.º 2
0
        //show question by id question
        public bool ShowQuestionByIDPhase(int id)
        {
            //declare
            List<Phase> ListPhase;
            List<Question> ListQuestion;
            List<Answer> ListAnswer;
            int idquestion = 0;
            int a = 65;
            Phase.IDPhase = id;

            ListPhase = PhaseQuestionBl.getquestionRunGame(Phase);
            //if (ListPhase != null)
            //{
            try
            {
                idquestion = ListPhase.ElementAt(0).IDQuestion;
                IDQuestion_Sub = idquestion;

                //show question in phase
                Question.IDQuestion = idquestion;
                ListQuestion = QuestionBL.GetQuestionByID(Question);
                ListAnswer = QuestionBL.GetAnswerByQuestionID(Question);
                //////show question on audience screen
                if (ListQuestion != null)
                {
                    /////display question on audience screen
                    audience.lbl_QuestionContent.Text = ListQuestion.ElementAt(0).NameQuestion;

                    //audience.lbl_QuestionContent.Size = new System.Drawing.Size(audience.pnl_QuestionFrame.Width * 66 / 100, audience.lbl_QuestionContent.Height);
                    //audience.lbl_QuestionContent.Location = new Point(audience.lbl_QuestionContent.Location.X - audience.lbl_QuestionContent.Location.X + (audience.pnl_QuestionFrame.Width / 2) * 35 / 100, audience.lbl_QuestionContent.Location.Y);
                    audience.lbl_Phase.Text = NameofPhase(id) + "(" + (ListPhase.Count - 1) + ")";
                    audience.lbl_Point.Text = "Point: " + BonusScoreofPhase(id).ToString();
                    //get score
                    _BonusPhase = BonusScoreofPhase(id);
                    _MinusPhase = MinusScoreofPhase(id);
                    typequestion = ListQuestion.ElementAt(0).TypeQuestion.ToLower();
                    if (typequestion == "multichoice")
                    {
                        audience.lbl_typeQ.Text = "Type: Choose one answer";
                    }
                    else
                    {
                        if (typequestion == "onechoice")
                        {
                            audience.lbl_typeQ.Text = "Type: Choose multi answer";
                        }
                        else
                        {
                            audience.lbl_typeQ.Text = "Type: Fill short answer";
                        }
                    }

                    /////question is onechoice type
                    if (ListQuestion.ElementAt(0).TypeQuestion.ToLower() == "onechoice")
                    {
                        //fix
                        if (ListAnswer.Count== 2)
                        {
                            for (int h = 0; h < ListAnswer.Count; h++)
                            {
                                ShowAnswer ShowAnswer = new ShowAnswer();
                                ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / 2 - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count)) - 10);
                                ShowAnswer.rdb1.Text = Convert.ToChar(a + h).ToString();
                                ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                            }
                        }
                        else
                        {
                            for (int h = 0; h < ListAnswer.Count; h++)
                            {
                                ShowAnswer ShowAnswer = new ShowAnswer();
                                ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / 2 - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count / 2)) - 10);
                                ShowAnswer.rdb1.Text = Convert.ToChar(a + h).ToString();
                                ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                            }
                        }

                    }
                    else
                    {   //question is multichoice type
                        if (ListQuestion.ElementAt(0).TypeQuestion.ToLower() == "multichoice")
                        {
                            //fix
                            if (ListAnswer.Count==2)
                            {
                                for (int h = 0; h < ListAnswer.Count; h++)
                                {
                                    ShowAnswer ShowAnswer = new ShowAnswer();
                                    ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / (2) - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count)) - 10);
                                    ShowAnswer.chk1.Text = Convert.ToChar(a + h).ToString();
                                    ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                    ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                    ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                    audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                                }
                            }
                            else
                            {
                                for (int h = 0; h < ListAnswer.Count; h++)
                                {
                                    ShowAnswer ShowAnswer = new ShowAnswer();
                                    ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width / (2) - 10, audience.flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)ListAnswer.Count / 2)) - 10);
                                    ShowAnswer.chk1.Text = Convert.ToChar(a + h).ToString();
                                    ShowAnswer.lbl_labelAnswer.Text = Convert.ToChar(a + h).ToString() + ".";
                                    ShowAnswer.rtxt_Answer.Text = ListAnswer.ElementAt(h).ContentAnswer;
                                    ShowAnswer.lbl_Correct.Text = ListAnswer.ElementAt(h).IsCorrect.ToString();
                                    audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
                                }
                            }

                        }
                        else
                        {
                            //question is short answer type
                            audience.flp_AnswerQuiz.BackColor = Color.Transparent;
                            CorrectShortAnswer = ListAnswer.ElementAt(0).ContentAnswer;
                        }
                    }
                    FixSizeText();
                    //update
                    Phase.IDQuestion = idquestion;
                    //Check question have been showed
                    PhaseQuestionBl.EditQuestionStatus(Phase);
                }

                if (CheckChallengeChoice == true)
                {
                    TableAnswerMultiTeam(ListQuestion, ListAnswer);
                }
                else
                {
                    TableAnswerOneTeam(ListQuestion, ListAnswer);
                }

                ListPhase = PhaseBL.GetPhaseByIDPhase(Phase);
                //show countdown time on game controller screen
                lbl_Time.Text = (ListPhase.ElementAt(0).TimePhase).ToString();
                timer1.Start();
                //show time conut down on audience screen
                audience.lbl_TimeShowQuestion.Text = (ListPhase.ElementAt(0).TimePhase).ToString();
                audience.progressBarControl1.Max = Convert.ToInt32(audience.lbl_TimeShowQuestion.Text)*900;
                audience.progressBarControl1.Value = Convert.ToInt32(audience.lbl_TimeShowQuestion.Text)*900;
                //audience.progressBarControl1.Max = ListPhase.ElementAt(0).TimePhase * 900;
                //audience.progressBarControl1.Value = ListPhase.ElementAt(0).TimePhase * 900;
                time = Convert.ToInt32(audience.lbl_TimeShowQuestion.Text) ;
                //time = ListPhase.ElementAt(0).TimePhase;
                audience.timer1.Start();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
            //}
        }
Exemplo n.º 3
0
        //--5 Show correct answer
        public void ShowCorrectAnswer()
        {
            //show correct answer with question type: onechoie or multichoice
            if (typequestion == "onechoice" || typequestion == "multichoice")
            {
                foreach (ShowAnswer answer in audience.flp_AnswerQuiz.Controls)
                {
                    if (answer.lbl_Correct.Text.ToLower() == "true")
                    {
                        answer.BackgroundImage = Properties.Resources.dung_2;
                        if (typequestion == "onechoice")
                        {
                            CorrectAnswerChallenge = answer.rdb1.Text;
                        }
                        else
                        {
                            CorrectAnswerChallenge += answer.chk1.Text;
                        }
                        CorrectAnswer++;
                    }
                    if (answer.chk1.Checked == true)
                    {
                        if (answer.lbl_Correct.Text.ToLower() == "true")
                        {
                            PlayerCheck++;
                        }
                        else
                        {
                            PlayerCheck--;
                        }
                    }
                    if (answer.rdb1.Checked == true)
                    {
                        if (answer.lbl_Correct.Text.ToLower() == "true")
                        {
                            PlayerCheck++;
                        }
                    }
                }
            }
            else
            {
                CorrectAnswerChallenge = CorrectShortAnswer;
                //show correct answer with short answer
                ShowAnswer ShowAnswer = new ShowAnswer();
                ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width - 10, audience.flp_AnswerQuiz.Height/2 - 10);
                ShowAnswer.lbl_labelAnswer.Visible = false;
                ShowAnswer.rtxt_Answer.Text = CorrectShortAnswer;
                ShowAnswer.rtxt_Answer.Font = new Font("Verdana", 24.0f, FontStyle.Bold);
                ShowAnswer.rtxt_Answer.TextAlign = ContentAlignment.MiddleCenter;
                ShowAnswer.BackgroundImage = Properties.Resources.dung_ShortAnswer;
                audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);

            }

            //check player correct or incorrect
            if (typequestion == "multichoice")
            {
                foreach (PlayerAnswer playerAnswer in audience.flp_PlayerAnswers.Controls)
                {
                    if (playerAnswer.lbl_TeamAnswer.Text.Trim().Replace(" ", "").ToLower() == CorrectAnswerChallenge.ToLower())
                    {
                        playerAnswer.lbl_Check.Text = "true";
                        playerAnswer.pb_Result.Image = Properties.Resources.Correct_ico;
                        CheckPlayerCorrect = true;

                        //Show Score team have receive
                        if (CheckChallengeChoice == false)
                        {
                            //Sound
                            try
                            {
                                axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\DapAnDung.wav";
                                axWindowsMediaPlayer1.Ctlcontrols.play();
                            }
                            catch (Exception)
                            {
                            }

                            if (_BonusPhase ==0)
                            {
                                playerAnswer.lbl_Score.Text = "" + _BonusPhase;
                            }
                            else
                            {
                                playerAnswer.lbl_Score.Text = "+" + _BonusPhase;
                            }
                            playerAnswer.lbl_Score.Visible = true;
                        }
                        else
                        {
                            ReceiveScoreChallenge();
                        }
                    }
                    else
                    {
                        playerAnswer.lbl_Check.Text = "false";
                        playerAnswer.pb_Result.Image = Properties.Resources.X_icon_vien;

                        //sound wrong answer
                        if (CheckChallengeChoice == false)
                        {
                            //Sound
                            try
                            {
                                axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\DapAnSai.wav";
                                axWindowsMediaPlayer1.Ctlcontrols.play();
                            }
                            catch (Exception)
                            {
                            }

                            if (_MinusPhase==0)
                            {
                                playerAnswer.lbl_Score.Text = "" + _MinusPhase;
                            }
                            else
                            {
                                playerAnswer.lbl_Score.Text = "-" + _MinusPhase;
                            }
                            playerAnswer.lbl_Score.Visible = true;
                        }
                        else
                        {
                            ReceiveScoreChallenge();
                        }
                    }
                }

            }
            else
            {
                if (typequestion == "onechoice")
                {
                    foreach (PlayerAnswer playerAnswer in audience.flp_PlayerAnswers.Controls)
                    {
                        if (playerAnswer.lbl_TeamAnswer.Text.ToLower() == CorrectAnswerChallenge.ToLower())
                        {
                            playerAnswer.lbl_Check.Text = "true";
                            playerAnswer.pb_Result.Image = Properties.Resources.Correct_ico;
                            CheckPlayerCorrect = true;

                            //Show Score team have receive
                            if (CheckChallengeChoice == false)
                            {
                                //Sound
                                try
                                {
                                    axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\DapAnDung.wav";
                                    axWindowsMediaPlayer1.Ctlcontrols.play();
                                }
                                catch (Exception)
                                {
                                }

                                if (_BonusPhase==0)
                                {
                                    playerAnswer.lbl_Score.Text = "" + _BonusPhase;
                                }
                                else
                                {
                                    playerAnswer.lbl_Score.Text = "+" + _BonusPhase;
                                }
                                playerAnswer.lbl_Score.Visible = true;
                            }
                            else
                            {
                                ReceiveScoreChallenge();
                            }
                        }
                        else
                        {
                            playerAnswer.lbl_Check.Text = "false";
                            playerAnswer.pb_Result.Image = Properties.Resources.X_icon_vien;

                            //sound wrong answer
                            if (CheckChallengeChoice == false)
                            {
                                //Sound
                                try
                                {
                                    axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\DapAnSai.wav";
                                    axWindowsMediaPlayer1.Ctlcontrols.play();
                                }
                                catch (Exception)
                                {
                                }

                                if (_MinusPhase == 0)
                                {
                                    playerAnswer.lbl_Score.Text = "" + _MinusPhase;
                                }
                                else
                                {
                                    playerAnswer.lbl_Score.Text = "-" + _MinusPhase;
                                }
                                playerAnswer.lbl_Score.Visible = true;
                            }
                            else
                            {
                                ReceiveScoreChallenge();
                            }
                        }
                    }
                }
                else
                {
                    foreach (PlayerAnswer playerAnswer in audience.flp_PlayerAnswers.Controls)
                    {
                        if (playerAnswer.lbl_TeamAnswer.Text.ToLower() == CorrectAnswerChallenge.ToLower())
                        {
                            playerAnswer.lbl_Check.Text = "true";
                            playerAnswer.pb_Result.Image = Properties.Resources.Correct_ico;
                            CheckPlayerCorrect = true;

                            //Show Score team have receive
                            if (CheckChallengeChoice == false)
                            {
                                //Sound
                                try
                                {
                                    axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\DapAnDung.wav";
                                    axWindowsMediaPlayer1.Ctlcontrols.play();
                                }
                                catch (Exception)
                                {
                                }

                                if (_BonusPhase == 0)
                                {
                                    playerAnswer.lbl_Score.Text = "" + _BonusPhase;
                                }
                                else
                                {
                                    playerAnswer.lbl_Score.Text = "+" + _BonusPhase;
                                }
                                playerAnswer.lbl_Score.Visible = true;
                            }
                            else
                            {
                                ReceiveScoreChallenge();
                            }
                        }
                        else
                        {
                            playerAnswer.lbl_Check.Text = "false";
                            playerAnswer.pb_Result.Image = Properties.Resources.X_icon_vien;

                            //sound wrong answer
                            if (CheckChallengeChoice == false)
                            {
                                //Sound
                                try
                                {
                                    axWindowsMediaPlayer1.URL = (Directory.GetCurrentDirectory()) + "\\Sound\\DapAnSai.wav";
                                    axWindowsMediaPlayer1.Ctlcontrols.play();
                                }
                                catch (Exception)
                                {
                                }

                                if (_MinusPhase == 0)
                                {
                                    playerAnswer.lbl_Score.Text = "" + _MinusPhase;
                                }
                                else
                                {
                                    playerAnswer.lbl_Score.Text = "-" + _MinusPhase;
                                }
                                playerAnswer.lbl_Score.Visible = true;
                            }
                            else
                            {
                                ReceiveScoreChallenge();
                            }
                        }
                    }
                }
            }

            //Show check correct
            foreach (Team teamCS in flp_Team.Controls)
            {
                if (Convert.ToInt32(teamCS.lbl_Sequence.Text) == sequenceplayer(records.ElementAt(team).IDPlayer) || teamCS.chk_Challenged.Checked == true)
                {
                    teamCS.chk_Correct.Visible = true;
                }
            }
            step++;
        }
Exemplo n.º 4
0
        //Show Correct Answer
        public void ShowCorrectAnswer_1()
        {
            //show correct answer with question type: onechoie or multichoice
            if (typequestion == "onechoice" || typequestion == "multichoice")
            {
                foreach (ShowAnswer answer in audience.flp_AnswerQuiz.Controls)
                {
                    if (answer.lbl_Correct.Text.ToLower() == "true")
                    {
                        answer.BackgroundImage = Properties.Resources.dung_2;
                        if (typequestion == "onechoice")
                        {
                            CorrectAnswerChallenge_1 = answer.rdb1.Text;
                        }
                        else
                        {
                            CorrectAnswerChallenge_1 += answer.chk1.Text;
                        }
                        CorrectAnswer_1++;
                    }
                    if (answer.chk1.Checked == true)
                    {
                        if (answer.lbl_Correct.Text.ToLower() == "true")
                        {
                            PlayerCheck_1++;
                        }
                        else
                        {
                            PlayerCheck_1--;
                        }
                    }
                    if (answer.rdb1.Checked == true)
                    {
                        if (answer.lbl_Correct.Text.ToLower() == "true")
                        {
                            PlayerCheck_1++;
                        }
                    }
                }
            }
            else
            {
                CorrectAnswerChallenge_1 = CorrectShortAnswer_1;

                ShowAnswer ShowAnswer = new ShowAnswer();
                ShowAnswer.Size = new System.Drawing.Size(audience.flp_AnswerQuiz.Width - 10, audience.flp_AnswerQuiz.Height/2 - 10);
                ShowAnswer.lbl_labelAnswer.Visible = false;
                ShowAnswer.rtxt_Answer.Text = CorrectShortAnswer_1;
                ShowAnswer.rtxt_Answer.Font = new Font("Verdana", 24.0f, FontStyle.Bold);
                ShowAnswer.rtxt_Answer.TextAlign = ContentAlignment.MiddleCenter;
                ShowAnswer.BackgroundImage = Properties.Resources.dung_ShortAnswer;
                audience.flp_AnswerQuiz.Controls.Add(ShowAnswer);
            }

            //check player correct or incorrect
            if (typequestion == "multichoice")
            {
                foreach (PlayerAnswer playerAnswer in audience.flp_PlayerAnswers.Controls)
                {
                    if (playerAnswer.lbl_TeamAnswer.Text.Trim().Replace(" ", "").ToLower() == CorrectAnswerChallenge_1.ToLower())
                    {
                        playerAnswer.lbl_Check.Text = "true";
                        playerAnswer.pb_Result.Image = Properties.Resources.Correct_ico;
                        //CheckPlayerCorrect = true;
                    }
                    else
                    {
                        playerAnswer.lbl_Check.Text = "false";
                        playerAnswer.pb_Result.Image = Properties.Resources.X_icon_vien;
                    }
                }
            }
            else
            {
                if (typequestion == "onechoice")
                {
                    foreach (PlayerAnswer playerAnswer in audience.flp_PlayerAnswers.Controls)
                    {
                        if (playerAnswer.lbl_TeamAnswer.Text.ToLower() == CorrectAnswerChallenge_1.ToLower())
                        {
                            playerAnswer.lbl_Check.Text = "true";
                            playerAnswer.pb_Result.Image = Properties.Resources.Correct_ico;
                            //CheckPlayerCorrect = true;
                        }
                        else
                        {
                            playerAnswer.lbl_Check.Text = "false";
                            playerAnswer.pb_Result.Image = Properties.Resources.X_icon_vien;
                        }
                    }
                }
                else
                {
                    foreach (PlayerAnswer playerAnswer in audience.flp_PlayerAnswers.Controls)
                    {
                        if (playerAnswer.lbl_TeamAnswer.Text.ToLower() == CorrectAnswerChallenge_1.ToLower())
                        {
                            playerAnswer.lbl_Check.Text = "true";
                            playerAnswer.pb_Result.Image = Properties.Resources.Correct_ico;
                            //CheckPlayerCorrect = true;
                        }
                        else
                        {
                            playerAnswer.lbl_Check.Text = "false";
                            playerAnswer.pb_Result.Image = Properties.Resources.X_icon_vien;
                        }
                    }
                }
            }
            //Show check correct
            //foreach (Team teamCS in flp_Team.Controls)
            //{
            //    if (teamCS.chk_Challenged.Checked == true)
            //    {
            //        teamCS.chk_Correct.Visible = true;
            //    }
            //}
        }
Exemplo n.º 5
0
        private void PreviewQuestion_Load(object sender, EventArgs e)
        {
            lbl_QuestionContent.Text = questionPreview;
            if (answerPreview.Count == 2)
            {
                for (int i = 0; i < answerPreview.Count; i++)
                {
                    ShowAnswer showanswer = new ShowAnswer();
                    showanswer.rtxt_Answer.Text = answerPreview.ElementAt(i).ToString();
                    showanswer.Size = new System.Drawing.Size(flp_AnswerQuiz.Width / 2 - 10, flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)answerPreview.Count)) - 10);
                    showanswer.lbl_labelAnswer.Text = Convert.ToChar(65 + i).ToString() + ".";
                    flp_AnswerQuiz.Controls.Add(showanswer);
                }
            }
            else
            {
                for (int i = 0; i < answerPreview.Count; i++)
                {
                    ShowAnswer showanswer = new ShowAnswer();
                    showanswer.rtxt_Answer.Text = answerPreview.ElementAt(i).ToString();
                    showanswer.Size = new System.Drawing.Size(flp_AnswerQuiz.Width / 2 - 10, flp_AnswerQuiz.Height / (int)(Math.Ceiling((double)answerPreview.Count / 2)) - 10);
                    showanswer.lbl_labelAnswer.Text = Convert.ToChar(65 + i).ToString() + ".";
                    flp_AnswerQuiz.Controls.Add(showanswer);
                }
            }

            PlayerAnswer PlayerAnswer = new PlayerAnswer();
            PlayerAnswer.lbl_TeamName.Text = "GSC Team";
            PlayerAnswer.lbl_TeamAnswer.Text = "A";
            PlayerAnswer.lbl_Score.Text = "+20";
            PlayerAnswer.lbl_Score.Visible = true;
            PlayerAnswer.Location = new Point(PlayerAnswer.Location.X + flp_PlayerAnswers.Width/2 - PlayerAnswer.Width/2,PlayerAnswer.Location.Y+0);
            flp_PlayerAnswers.Controls.Add(PlayerAnswer);

            FixSizeText();
        }