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

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

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