コード例 #1
0
ファイル: FormHello.cs プロジェクト: Voenkaff/Test
        private void testCurrentDelete(object sender, EventArgs e)
        {
            var rz = MessageBox.Show("Удалить тест?", "Удаление", MessageBoxButtons.YesNo);

            if (rz == DialogResult.Yes)
            {
                Panel parentPanel = (Panel)((Button)sender).Parent;
                foreach (var panel in ListPanelsTestsOnPanel)
                {
                    foreach (Control control in panel.Controls)
                    {
                        if (control.Name == ((Control)sender).Name)
                        {
                            panelMain.Controls.Remove(panel);
                            ListPanelsTestsOnPanel.Remove(panel);
                            TestNameAndMarks.Remove(ListTests[parentPanel].Text);
                            ListTests.Remove(parentPanel);

                            if (comboBoxCourseFilter.SelectedItem != null)
                            {
                                listPanelWithFilter.Remove(panel);
                                Redistribution(listPanelWithFilter);
                            }
                            else
                            {
                                Redistribution(ListPanelsTestsOnPanel);
                            }

                            File.Delete(new DynamicParams().GetPath() + "\\" + panel.Controls[0].Text + ".test");
                            return;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: FormHello.cs プロジェクト: W1nterFox/Voenkaff
        private void buttonCreateTest_Click(object sender, EventArgs e)
        {
            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" + ListPanelsTestsOnPanel.Count;
            TestOperations.Size = new Size(1100, 51);
            TestOperations.Tag  = "panelTestInTests";

            FormChooseTestName formChooseTestName =
                new FormChooseTestName(this, ListPanelsTestsOnPanel.Count)
            {
                startName = ""
            };

            Visible = false;
            formChooseTestName.Visible                   = true;
            ListMarksAndName[TestOperations]             = formChooseTestName;
            ListMarksAndName[TestOperations].parentPanel = TestOperations;
            formChooseTestName.Tag = ListPanelsTestsOnPanel.Count;

            _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.TabIndex  = 1;
            _linkLabelTestNew.TabStop   = true;
            _linkLabelTestNew.Tag       = ListPanelsTestsOnPanel.Count;
            _linkLabelTestNew.TextAlign = ContentAlignment.MiddleCenter;

            _buttonTestDownloadDoc.FlatStyle = FlatStyle.Flat;
            _buttonTestDownloadDoc.Font      = new Font("Century Gothic", 11.25F);
            _buttonTestDownloadDoc.Location  = new Point(785, 5);
            _buttonTestDownloadDoc.Name      = "buttonTestDelete" + ListPanelsTestsOnPanel.Count;
            _buttonTestDownloadDoc.Size      = new Size(150, 40);
            _buttonTestDownloadDoc.TabIndex  = 6;
            _buttonTestDownloadDoc.Text      = "Скачать в Word";
            _buttonTestDownloadDoc.UseVisualStyleBackColor = true;
            _buttonTestDownloadDoc.Enabled   = true;
            _buttonTestDownloadDoc.Tag       = ListPanelsTestsOnPanel.Count;
            _buttonTestDownloadDoc.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.TabIndex  = 2;
            _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.TabIndex  = 4;
            _buttonTestMarksNew.Text      = "Параметры";
            _buttonTestMarksNew.UseVisualStyleBackColor = true;
            _buttonTestMarksNew.Tag       = ListPanelsTestsOnPanel.Count;
            _buttonTestMarksNew.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;

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


            _buttonTestOpenNew.Click  += OpenCurrentTest;
            _buttonTestMarksNew.Click += TestCurrentMarks;
            //_buttonTestDownloadNew.Click += testCurrentDownload;
            _buttonTestDownloadDoc.Click += TestCurrentDownloadDoc;
            _buttonTestDeleteNew.Click   += TestCurrentDelete;
            Redistribution(ListPanelsTestsOnPanel);
        }