using CustomComponents.Helpers; using WinFormForTest.TestClasses; namespace WinFormForTest { public partial class Form1 : Form { List plants = new List(); public Form1() { InitializeComponent(); customListBox1.AddToList("Элемент 1"); customListBox1.AddToList("Элемент 2"); customListBox1.AddToList("Элемент 3"); Plant pl1 = new Plant("овощь", "помидор", "красный"); Plant pl2 = new Plant("овощь", "помидор", "жёлтый"); Plant pl3 = new Plant("овощь", "огурец", "зелёный"); Plant pl4 = new Plant("фрукт", "яблоко", "зелёный"); Plant pl5 = new Plant("фрукт", "апельсин", "оранжевый"); Plant pl6 = new Plant("фрукт", "апельсин", "красный"); plants.Add(pl1); plants.Add(pl2); plants.Add(pl3); plants.Add(pl4); plants.Add(pl5); plants.Add(pl6); LoadTree(); } public void LoadTree() { customTree1.Hierarcy = new List { "Type", "Name", "Color" }; foreach (Plant plant in plants) { customTree1.AddNode(plant); } } private void buttonClear_Click(object sender, EventArgs e) { customListBox1.Clear(); } private void buttonCheck_Click(object sender, EventArgs e) { try { if (customComboBox1.TextBoxValue != null) { checkBoxValid.Text = "подходит"; checkBoxValid.Checked = true; checkBoxValid.BackColor = Color.Green; } } catch (Exception ex) { checkBoxValid.Text = "не подходит"; checkBoxValid.Checked = false; checkBoxValid.BackColor = Color.Red; MessageBox.Show(ex.Message); } } private void buttonEnter_Click(object sender, EventArgs e) { customListBox1.AddToList("Элемент 4"); customListBox1.AddToList("Элемент 5"); customListBox1.AddToList("Элемент 6"); } private void buttonGet_Click(object sender, EventArgs e) { labelItem.Text = customListBox1.SelectedElement; } private void buttonPdfImage_Click(object sender, EventArgs e) { var res = openFileDialog1.ShowDialog(this); if (res != DialogResult.OK) return; var files = openFileDialog1.FileNames; openFileDialog1.Dispose(); string path = "C:\\Users\\annal\\Desktop\\test_cop_lab2\\testImage.pdf"; MessageBox.Show(path); if (pdfImage1.CreatePdfDoc(new DataForImage(path, "Картинки", files))) MessageBox.Show("Success!"); else MessageBox.Show("Error"); } private void buttonPdfTable_Click(object sender, EventArgs e) { List films = new List() { new Film("Маска", "комедия, криминал, фэнтези", "1ч. 36мин.", "12+"), new Film("Звёздная пыль", "мелодрама, приключения, фэнтези", "2ч. 7мин.", "18+"), new Film("Аватар", "приключения, фантастика, боевик, драма", "2ч. 58мин.", "18+"), new Film("Константин", "фэнтези, ужасы, боевик, детектив", "2ч. 1мин.", "18+") }; List<(int, int)> merges = new List<(int, int)>(); merges.Add((1, 2)); List heights = new List { 10, 80, 30, 50, 25, 25 }; string path = "C:\\Users\\annal\\Desktop\\test_cop_lab2\\testTable.pdf"; List<(string, string)> headers = new List<(string, string)> { ("id", "Id"), ("", "Фильм"), ("Name", "Название"), ("Ganre", "Жанр"), ("Duration", "Продолжительность"), ("AgeRange", "Возрастное ограничение") }; if (pdfTable1.createTable(new DataForTable(path, "Таблица фильмов", heights, merges, headers, films))) { MessageBox.Show("Success!"); } } private void buttonPdfChart_Click(object sender, EventArgs e) { string path = "C:\\Users\\annal\\Desktop\\test_cop_lab2\\testPieChart.pdf"; List<(double, string)> elements = new List<(double, string)> { (20, "Коля"), (37, "Даша"), (10, "Егор"), (15, "Таня"), (18, "Валера") }; if (pdfPieChart1.CreatePieChart(new DataForPieChart(path, "Круговая диаграмма", "Успех просмотра 100 фильмов", DiagramLegendEnum.Bottom, "Просмотрено", elements))) { MessageBox.Show("Success!"); } } } }