コード例 #1
0
ファイル: Single.cs プロジェクト: zw921005/beitimu
        private void Single_Load(object sender, EventArgs e)
        {
            int count = 0;

            try
            {
                string fileName;
                if (IsSingle)
                {
                    this.Text = "单选题";
                    fileName  = "data";
                }
                else
                {
                    this.Text = "多选题";
                    fileName  = "data1";
                }
                foreach (string line in System.IO.File.ReadLines(@"data\" + fileName, System.Text.Encoding.UTF8))
                {
                    SelectQuestion sq = new SelectQuestion(line, randomAnswer);
                    sqs.Add(sq);
                    count++;
                }
                if (randomQuestion)
                {
                    Random rd = new Random();
                    for (int i = 0; i < sqs.Count(); i++)
                    {
                        int            index = rd.Next(sqs.Count());
                        SelectQuestion temp  = sqs[i];
                        sqs[i]     = sqs[index];
                        sqs[index] = temp;
                    }
                }
                lblresult.Text   = "";
                totalQuestion    = sqs.Count();
                lblPageSize.Text = totalQuestion.ToString();
                show(sqs[0]);
            }
            catch (Exception ex)
            {
                this.Close();
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
ファイル: Single.cs プロジェクト: zw921005/beitimu
        public void show(SelectQuestion sq)
        {
            if (showID)
            {
                lblquestion.Text = sq.id.ToString() + "." + sq.question;
            }
            else
            {
                lblquestion.Text = sq.question;
            }
            for (int i = 0; i < answer.Length; i++)
            {
                answer[i] = false;
            }
            lblanswer.Text  = "";
            lblanswerA.Text = "";
            lblanswerB.Text = "";
            lblanswerC.Text = "";
            lblanswerD.Text = "";
            lblanswerE.Text = "";
            lblanswerF.Text = "";
            lblanswerA.Text = sq.answers[0];
            lblanswerB.Text = sq.answers[1];
            lblanswerC.Text = sq.answers[2];
            if (sq.answers.Length > 3)
            {
                lblanswerD.Text    = sq.answers[3];
                lblanswerD.Visible = true;
                btnD.Visible       = true;
            }
            else
            {
                lblanswerD.Visible = false;
                btnD.Visible       = false;
            }

            if (sq.answers.Length > 4)
            {
                lblanswerE.Text    = sq.answers[4];
                lblanswerE.Visible = true;
                btnE.Visible       = true;
            }
            else
            {
                lblanswerE.Visible = false;
                btnE.Visible       = false;
            }
            if (sq.answers.Length > 5)
            {
                lblanswerF.Text    = sq.answers[5];
                lblanswerF.Visible = true;
                btnF.Visible       = true;
            }
            else
            {
                lblanswerF.Visible = false;
                btnF.Visible       = false;
            }
            lblPageIndex.Text = (currentQuestion + 1).ToString();
            if (review)
            {
                lblanswer.Text = sqs[currentQuestion].getcorrectAnswersString(sqs[currentQuestion].correctAnswers);
            }
        }