コード例 #1
0
        public void GetQuestion()
        {
            if (QNum == 11)
            {
                GameDone = true;
                Timer.Stop();
                if (GID.Length > 3)
                {
                    GID = GID.Substring(1);
                }
                if (PID == 49)
                {
                    PID = 1;
                }
                else if (PID == 50)
                {
                    PID = 2;
                }
                if (GameDone)
                {
                    W.SendResults(Username, Cor, GID, Date, PID);
                    GetResults G = new GetResults(1, Cor, GID, PID);
                    G.Show();
                    Visible = false;
                }
            }

            string Question = W.GetQ(QNum);

            string[] Qs  = Question.Split(',');
            string   Q   = Qs[0];
            string   A   = Qs[1];
            string   B   = Qs[2];
            string   C   = Qs[3];
            string   D   = Qs[4];
            Random   Ran = new Random();

            LblQNum.Text = "Question " + QNum.ToString();
            QNum++;

            List <Point> ButtonList = new List <Point> {
                Rb1.Location, Rb2.Location, Rb3.Location, Rb4.Location
            };                                                                               //Defining Our Buttons
            var RadioButtons = new[] { Rb1, Rb2, Rb3, Rb4 };                                 //Defining Our Buttons
            var Location     = ButtonList.OrderBy(x => Ran.Next(ButtonList.Count)).ToList(); //Shuffle Where The Buttons Are

            for (int i = 0; i < RadioButtons.Length; i++)                                    //Change The Number Where The Buttons Are Displayed
            {
                RadioButtons[i].Location = Location[i];
            }

            LblQuestion.Text = Q;
            Rb1.Text         = A;
            Rb2.Text         = B;
            Rb3.Text         = C;
            Rb4.Text         = D;
        }
コード例 #2
0
ファイル: Offline.cs プロジェクト: HitikG/repo.hitikg.devAQA
        public void GetQuestion()
        {
            if (QNum == 11)
            {
                GameDone = true;
                Timer.Stop();

                if (GameDone)
                {
                    W.SendResults(Username, Cor, "1111", Date, 1111);
                    GetResults G = new GetResults(2, Cor, "0", 0);
                    G.Show();
                    Visible = false;
                }
            }

            string Question = W.GetQ(QNum);

            string[] Qs  = Question.Split(',');
            string   Q   = Qs[0];
            string   A   = Qs[1];
            string   B   = Qs[2];
            string   C   = Qs[3];
            string   D   = Qs[4];
            Random   Ran = new Random();

            LblQn.Text = "Question " + QNum.ToString();
            QNum++;

            List <Point> ButtonList = new List <Point> {
                rBtn1.Location, rBtn2.Location, rBtn3.Location, rBtn4.Location
            };                                                                               //Defining Our Buttons
            var RadioButtons = new[] { rBtn1, rBtn2, rBtn3, rBtn4 };                         //Defining Our Buttons
            var Location     = ButtonList.OrderBy(x => Ran.Next(ButtonList.Count)).ToList(); //Shuffle Where The Buttons Are

            for (int i = 0; i < RadioButtons.Length; i++)                                    //Change The Number Where The Buttons Are Displayed
            {
                RadioButtons[i].Location = Location[i];
            }

            LblQ.Text  = Q;
            rBtn1.Text = A;
            rBtn2.Text = B;
            rBtn3.Text = C;
            rBtn4.Text = D;
        }