private void Generate_Click(object sender, EventArgs e)
        {
            if (directoryName != string.Empty)
            {
                GenerationKeyForTest key = null;
                try
                {
                    string strKey = keyBox.Text;
                    if (checkBox1.Checked)
                    {
                        string[] values = strKey.Split('.');
                        values[10] = "1";
                        strKey     = string.Join(".", values);
                    }
                    key = new GenerationKeyForTest(strKey);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }


                if (key != null)
                {
                    Test test = new Test(key);
                    test.CreateTestDirectory(directoryName);
                }
            }
            else
            {
                MessageBox.Show("Выберите папку в которую будут сохроняться файлы с вариантами", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #2
0
        private void GenerateBtn_Click(object sender, EventArgs e)
        {
            if (CheckСorrectnessInput())
            {
                if (directoryName == string.Empty)
                {
                    MessageBox.Show("Выберите папку в которую будут сохроняться файлы с вариантами", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    List <GenerationKey> keys = new List <GenerationKey>();

                    bool answersCheckBox = checkBoxAnswers.Checked;

                    int  seed               = rnd.Next(1, 1000000);
                    int  countOfRoots1      = int.Parse(CountOfRoots1.Text);
                    int  maxValueRoots1     = int.Parse(MaxValueRoots1.Text);
                    int  maxPolyPower1      = int.Parse(MaxPolyPower1.Text);
                    int  countOfTasks1      = int.Parse(CountOfTasks1.Text);
                    bool containsLog1       = checkBoxLog1.Checked;
                    bool containsRadical1   = checkBoxRadical1.Checked;
                    bool containsPowerFunc1 = checkBoxPowerFunc1.Checked;
                    bool containsRMT1       = checkBoxRMT1.Checked;
                    bool oneFrac1           = checkBoxOneFruc1.Checked;

                    Settings settingsForPart1 = new Settings(countOfRoots1, maxValueRoots1,
                                                             maxPolyPower1, oneFrac1, containsLog1,
                                                             containsRadical1, containsRMT1,
                                                             containsPowerFunc1, answersCheckBox);
                    keys.Add(new GenerationKey(countOfTasks1, seed, settingsForPart1));

                    if (CountOfRoots2.Enabled)
                    {
                        seed = (keys[0].Seed + 1) % 1000000;
                        int  countOfRoots2      = int.Parse(CountOfRoots2.Text);
                        int  maxValueRoots2     = int.Parse(MaxValueRoots2.Text);
                        int  maxPolyPower2      = int.Parse(MaxPolyPower2.Text);
                        int  countOfTasks2      = int.Parse(CountOfTasks2.Text);
                        bool containsLog2       = checkBoxLog2.Checked;
                        bool containsRadical2   = checkBoxRadical2.Checked;
                        bool containsPowerFunc2 = checkBoxPowerFunc2.Checked;
                        bool containsRMT2       = checkBoxRMT2.Checked;
                        bool oneFrac2           = checkBoxOneFruc2.Checked;

                        Settings settingsForPart2 = new Settings(countOfRoots2, maxValueRoots2,
                                                                 maxPolyPower2, oneFrac2, containsLog2,
                                                                 containsRadical2, containsRMT2,
                                                                 containsPowerFunc2, answersCheckBox);
                        keys.Add(new GenerationKey(countOfTasks2, seed, settingsForPart2));
                    }
                    else
                    {
                        seed = (keys[0].Seed + 1) % 1000000;
                        Settings settingsForPart2 = new Settings(1, 11, 1, false, false, false, false, false, answersCheckBox);
                        keys.Add(new GenerationKey(0, seed, settingsForPart2));
                    }

                    if (CountOfRoots3.Enabled)
                    {
                        seed = (keys[1].Seed + 1) % 1000000;
                        int  countOfRoots3      = int.Parse(CountOfRoots3.Text);
                        int  maxValueRoots3     = int.Parse(MaxValueRoots3.Text);
                        int  maxPolyPower3      = int.Parse(MaxPolyPower3.Text);
                        int  countOfTasks3      = int.Parse(CountOfTasks3.Text);
                        bool containsLog3       = checkBoxLog3.Checked;
                        bool containsRadical3   = checkBoxRadical3.Checked;
                        bool containsPowerFunc3 = checkBoxPowerFunc3.Checked;
                        bool containsRMT3       = checkBoxRMT3.Checked;
                        bool oneFrac3           = checkBoxOneFruc3.Checked;

                        Settings settingsForPart3 = new Settings(countOfRoots3, maxValueRoots3,
                                                                 maxPolyPower3, oneFrac3, containsLog3,
                                                                 containsRadical3, containsRMT3,
                                                                 containsPowerFunc3, answersCheckBox);
                        keys.Add(new GenerationKey(countOfTasks3, seed, settingsForPart3));
                    }
                    else
                    {
                        seed = (keys[1].Seed + 1) % 1000000;
                        Settings settingsForPart3 = new Settings(1, 11, 1, false, false, false, false, false, answersCheckBox);
                        keys.Add(new GenerationKey(0, seed, settingsForPart3));
                    }

                    if (CountOfRoots4.Enabled)
                    {
                        seed = (keys[2].Seed + 1) % 1000000;
                        int  countOfRoots4      = int.Parse(CountOfRoots4.Text);
                        int  maxValueRoots4     = int.Parse(MaxValueRoots4.Text);
                        int  maxPolyPower4      = int.Parse(MaxPolyPower4.Text);
                        int  countOfTasks4      = int.Parse(CountOfTasks4.Text);
                        bool containsLog4       = checkBoxLog4.Checked;
                        bool containsRadical4   = checkBoxRadical4.Checked;
                        bool containsPowerFunc4 = checkBoxPowerFunc4.Checked;
                        bool containsRMT4       = checkBoxRMT4.Checked;
                        bool oneFrac4           = checkBoxOneFruc4.Checked;

                        Settings settingsForPart4 = new Settings(countOfRoots4, maxValueRoots4,
                                                                 maxPolyPower4, oneFrac4, containsLog4,
                                                                 containsRadical4, containsRMT4,
                                                                 containsPowerFunc4, answersCheckBox);
                        keys.Add(new GenerationKey(countOfTasks4, seed, settingsForPart4));
                    }
                    else
                    {
                        seed = (keys[2].Seed + 1) % 1000000;
                        Settings settingsForPart4 = new Settings(1, 11, 1, false, false, false, false, false, answersCheckBox);
                        keys.Add(new GenerationKey(0, seed, settingsForPart4));
                    }

                    if (CountOfRoots5.Enabled)
                    {
                        seed = (keys[3].Seed + 1) % 1000000;
                        int  countOfRoots5      = int.Parse(CountOfRoots5.Text);
                        int  maxValueRoots5     = int.Parse(MaxValueRoots5.Text);
                        int  maxPolyPower5      = int.Parse(MaxPolyPower5.Text);
                        int  countOfTasks5      = int.Parse(CountOfTasks5.Text);
                        bool containsLog5       = checkBoxLog5.Checked;
                        bool containsRadical5   = checkBoxRadical5.Checked;
                        bool containsPowerFunc5 = checkBoxPowerFunc5.Checked;
                        bool containsRMT5       = checkBoxRMT5.Checked;
                        bool oneFrac5           = checkBoxOneFruc5.Checked;

                        Settings settingsForPart5 = new Settings(countOfRoots5, maxValueRoots5,
                                                                 maxPolyPower5, oneFrac5, containsLog5,
                                                                 containsRadical5, containsRMT5,
                                                                 containsPowerFunc5, answersCheckBox);
                        keys.Add(new GenerationKey(countOfTasks5, seed, settingsForPart5));
                    }
                    else
                    {
                        seed = (keys[3].Seed + 1) % 1000000;
                        Settings settingsForPart5 = new Settings(1, 11, 1, false, false, false, false, false, answersCheckBox);
                        keys.Add(new GenerationKey(0, seed, settingsForPart5));
                    }

                    int countOfTests = int.Parse(CountOfTests.Text);
                    GenerationKeyForTest keyForTest = new GenerationKeyForTest(keys, countOfTests);

                    Test test = new Test(keyForTest);
                    test.CreateTestDirectory(directoryName);
                    MessageTextBox.Text      = $"Генерация прошла успешно. Проверьте выбранную вами папку. Ключ Генерации: {keyForTest}";
                    MessageTextBox.ForeColor = Color.FromArgb(39, 174, 96);
                }
            }
        }