示例#1
0
 public void Initialize(FormHello form)
 {
     try
     {
         var loader = new TestLoader();
         var tests  = loader.LoadTestsFromFolder(new DynamicParams().GetPath());
         VzvodAndLs.Set(tests.PlatoonList);
         Courses.Set(tests.CourseList);
     }
     catch (Exception) { }
 }
示例#2
0
        public FormHello()
        {
            InitializeComponent();

            new TestInizializator().Initialize(this);

            if (!Courses.Get().Contains("<Без предмета>"))
            {
                Courses.Get().Add("<Без предмета>");
            }

            comboBoxCourseFilter.Items.AddRange(Courses.Get().ToArray());

            ListPanelsTestsOnPanel = new List <Panel>();

            try
            {
                //Подгрузка тестов
                var testLoader = new TestLoader();

                var listOfLoadTests = testLoader.LoadTestsFromFolder(new DynamicParams().GetPath());

                foreach (Wrappers.Test test in listOfLoadTests.TestList)
                {
                    ListTestsRef.Add(test);

                    TestOperations = new Panel();

                    _linkLabelTestNew      = new Label();
                    _buttonTestDeleteNew   = new Button();
                    _buttonTestOpenNew     = new Button();
                    _buttonTestMarksNew    = new Button();
                    _buttonTestDownloadDoc = new Button();

                    TestOperations.BackColor = SystemColors.ControlLight;
                    TestOperations.Controls.Add(_linkLabelTestNew);
                    TestOperations.Controls.Add(_buttonTestOpenNew);
                    TestOperations.Controls.Add(_buttonTestMarksNew);
                    TestOperations.Controls.Add(_buttonTestDownloadDoc);
                    TestOperations.Controls.Add(_buttonTestDeleteNew);
                    TestOperations.Name = "panelTestInTestsList" + ListTestsRef.Count;
                    TestOperations.Size = new Size(1100, 51);
                    TestOperations.Tag  = "panelTestInTests";


                    FormChooseTestName formChooseTestName =
                        new FormChooseTestName(this, ListPanelsTestsOnPanel.Count)
                    {
                        startName = test.Name
                    };
                    formChooseTestName.Controls.Find("textBoxUserChooseTestName", true)[0].Text = test.Name;
                    formChooseTestName.Controls.Find("comboBoxCourse", true)[0].Text            = test.Course;
                    formChooseTestName.Controls.Find("textBoxMark5", true)[0].Text = test.Marks.Excellent.ToString();
                    formChooseTestName.Controls.Find("textBoxMark4", true)[0].Text = test.Marks.Good.ToString();
                    formChooseTestName.Controls.Find("textBoxMark3", true)[0].Text = test.Marks.Satisfactory.ToString();
                    formChooseTestName.Tag           = ListPanelsTestsOnPanel.Count;
                    ListMarksAndName[TestOperations] = formChooseTestName;

                    _linkLabelTestNew.AutoSize  = true;
                    _linkLabelTestNew.Font      = new Font("Century Gothic", 11.25F);
                    _linkLabelTestNew.Location  = new Point(3, 15);
                    _linkLabelTestNew.Name      = "linkLabelTest" + ListPanelsTestsOnPanel.Count;
                    _linkLabelTestNew.Size      = new Size(146, 20);
                    _linkLabelTestNew.Text      = test.Name;
                    _linkLabelTestNew.TabStop   = true;
                    _linkLabelTestNew.Tag       = ListPanelsTestsOnPanel.Count;
                    _linkLabelTestNew.TextAlign = ContentAlignment.MiddleCenter;

                    _buttonTestOpenNew.FlatStyle = FlatStyle.Flat;
                    _buttonTestOpenNew.Font      = new Font("Century Gothic", 11.25F);
                    _buttonTestOpenNew.Location  = new Point(485, 5);
                    _buttonTestOpenNew.Name      = "buttonTestOpen" + ListPanelsTestsOnPanel.Count;
                    _buttonTestOpenNew.Size      = new Size(150, 40);
                    _buttonTestOpenNew.Text      = "Открыть тест";
                    _buttonTestOpenNew.UseVisualStyleBackColor = true;
                    _buttonTestOpenNew.Tag       = ListPanelsTestsOnPanel.Count;
                    _buttonTestOpenNew.TextAlign = ContentAlignment.MiddleCenter;

                    _buttonTestMarksNew.FlatStyle = FlatStyle.Flat;
                    _buttonTestMarksNew.Font      = new Font("Century Gothic", 11.25F);
                    _buttonTestMarksNew.Location  = new Point(640, 5);
                    _buttonTestMarksNew.Name      = "buttonTestMarks" + ListPanelsTestsOnPanel.Count;
                    _buttonTestMarksNew.Size      = new Size(140, 40);
                    _buttonTestMarksNew.Text      = "Параметры";
                    _buttonTestMarksNew.UseVisualStyleBackColor = true;
                    _buttonTestMarksNew.Tag       = ListPanelsTestsOnPanel.Count;
                    _buttonTestMarksNew.TextAlign = ContentAlignment.MiddleCenter;

                    _buttonTestDownloadDoc.FlatStyle = FlatStyle.Flat;
                    _buttonTestDownloadDoc.Font      = new Font("Century Gothic", 11.25F);
                    _buttonTestDownloadDoc.Location  = new Point(785, 5);
                    _buttonTestDownloadDoc.Name      = "buttonTestDownloadDoc" + ListPanelsTestsOnPanel.Count;
                    _buttonTestDownloadDoc.Size      = new Size(150, 40);
                    _buttonTestDownloadDoc.Text      = "Скачать в Word";
                    _buttonTestDownloadDoc.UseVisualStyleBackColor = true;
                    _buttonTestDownloadDoc.Enabled   = true;
                    _buttonTestDownloadDoc.Tag       = ListPanelsTestsOnPanel.Count;
                    _buttonTestDownloadDoc.TextAlign = ContentAlignment.MiddleCenter;

                    _buttonTestDeleteNew.FlatStyle = FlatStyle.Flat;
                    _buttonTestDeleteNew.Font      = new Font("Century Gothic", 11.25F);
                    _buttonTestDeleteNew.Location  = new Point(940, 5);
                    _buttonTestDeleteNew.Name      = "buttonTestDelete" + ListPanelsTestsOnPanel.Count;
                    _buttonTestDeleteNew.Size      = new Size(150, 40);
                    _buttonTestDeleteNew.Text      = "Удалить";
                    _buttonTestDeleteNew.UseVisualStyleBackColor = true;
                    _buttonTestDeleteNew.Enabled = true;
                    _buttonTestDeleteNew.Tag     = ListPanelsTestsOnPanel.Count;


                    TestNameAndMarks.Add(test.Name,
                                         new List <int> {
                        test.Marks.Excellent, test.Marks.Good, test.Marks.Satisfactory
                    });

                    var peremTest = new Test(this, test.Name, TestNameAndMarks[test.Name], test.Course);
                    ListTests[TestOperations] = peremTest;


                    ListPanelsTestsOnPanel.Add(TestOperations);
                    panelMain.Controls.Add(TestOperations);


                    _buttonTestOpenNew.Click     += OpenCurrentTest;
                    _buttonTestMarksNew.Click    += TestCurrentMarks;
                    _buttonTestDownloadDoc.Click += TestCurrentDownloadDoc;
                    _buttonTestDeleteNew.Click   += TestCurrentDelete;

                    if (ListPanelsTestsOnPanel.Count > 0)
                    {
                        ListTests[TestOperations].Controls.Find("panelMiddle", true)[0].Controls
                        .Remove(
                            ListTests[TestOperations].Controls.Find("Задание №1", true)[0]);
                    }
                    //Добавление элементов в тест
                    InitTest(ListTestsRef[ListPanelsTestsOnPanel.Count - 1],
                             ListTests[TestOperations]);
                }
                Redistribution(ListPanelsTestsOnPanel);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            _formChooseVzvod = new FormChooseVzvod(this);
            _formSettings    = new FormSettings();


            MinimumSize = Size;
            MaximumSize = Size;
        }