using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Test
{
    public partial class Form2 : Form
    {
        // Разбивает строку в массив слов
        private string[] arrayWord(string line)
        {
            string[] wordArray = line.Split(new char[] { ' ' });

            return wordArray;
        }
        
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            global.mode1 = new Form3();
            global.mode1.Show();
            global.modes.Hide();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            global.mode2 = new Form4();
            global.mode2.Show();
            global.modes.Hide();
        }

        private void Form2_Load(object sender, EventArgs e)
        {
            int i = 1;
            Random r = new Random();
            string dir = System.IO.Directory.GetCurrentDirectory() + @"\tests\Режим1";
            string dir2 = System.IO.Directory.GetCurrentDirectory() + @"\tests\Режим2";

            while (System.IO.Directory.GetFiles(dir, "f" + i.ToString() + "*.html", System.IO.SearchOption.TopDirectoryOnly).Count() != 0)
            {
                global.l++;
                i++;
            }

            while (System.IO.Directory.GetFiles(dir2, "f" + i.ToString() + "*.html", System.IO.SearchOption.TopDirectoryOnly).Count() != 0)
            {
                global.l++;
                i++;
            }
            global.k = System.IO.Directory.GetFiles(dir, "f*.html", System.IO.SearchOption.TopDirectoryOnly).Count();
            global.k = System.IO.Directory.GetFiles(dir2, "f*.html", System.IO.SearchOption.TopDirectoryOnly).Count();
            string path, line;
            string[] answerCatCount = new string[global.l];
            int n = 0;
            // Обьявляем файл
            path = System.IO.Directory.GetCurrentDirectory() + @"\tests\Режим1\conf.txt";
            path = System.IO.Directory.GetCurrentDirectory() + @"\tests\Режим2\conf.txt";
            System.IO.StreamReader filee = new System.IO.StreamReader(path);
            line = filee.ReadLine();
            // Массив для количества вопросов
            answerCatCount = arrayWord(line);
            for (int j = 0; j < answerCatCount.Count(); j++)
            {
                n += Convert.ToInt32(answerCatCount[j]);
            }
            global.n = n;
        }
    }
}
