コード例 #1
0
        private void Open_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Тестовые файлы|*.xml";

            if (ofd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            using (FileStream fs = new FileStream(ofd.FileName, FileMode.Open))
            {
                test = (QuestionsList)formatter.Deserialize(fs);
            }

            label1.Text = test.name;
            minutes     = test.minutes - 1;
            seconds     = 60;

            if (MessageBox.Show("Запустить тест?", "", MessageBoxButtons.OK) == DialogResult.OK)
            {
                testEnded = false;
                PlaceAnswers();
                buttonAnswer.Enabled = true;
                timer1.Start();
                labelProgress.Text = String.Format("0/{0}", test.Count());
            }
        }
コード例 #2
0
        public Result(QuestionsList test)
        {
            InitializeComponent();

            foreach (Question qu in test.questions)
            {
                dataGridView1.Rows.Add(String.Format("{0}. {1}", globalIndex, qu.question), qu.isCorrectly());
                globalIndex++;
            }

            questions     = test.Count();
            rightAnswered = test.questions.Where((a) => a.answered)
                            .Where((a) => a.answeredString.Equals(a.rightAnswer)).Count();

            myTest = test;
            dataGridView1.ReadOnly = true;
        }