CapDemo.Open_Game.ShowQuestionByIDPhase C# (CSharp) Метод

ShowQuestionByIDPhase() публичный Метод

public ShowQuestionByIDPhase ( int id ) : bool
id int
Результат bool
        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;
            }
            //}
        }