using COP_1; using System; namespace COP_1Test { public partial class Form1 : Form { List list = new List(); public Form1() { InitializeComponent(); this.BackColor = GetRandomPastelColor(); list = new List(); list.AddRange(new string[] { "Значение 1", "Значение 2", "Значение 3", "Значение 4", "Значение 5", "Значение 6" }); Album album1 = new Album("Meds", "Placebo", "Alternative", "2006"); Album album2 = new Album("Iowa", "Slipknot", "Nu-Metal", "2001"); Album album3 = new Album("Showbiz", "Muse", "Alternative", "1999"); Album album4 = new Album("Chocolate Starfish and the Hot Dog Flavored Water", "Limp Bizkit", "Nu-metal", "2011"); valuesList.SetLayoutInfo("Название: {Title} Исполнитель: {Performer} Жанр: {Genre} Год: {Year}", "{", "}"); valuesList.AddInListBox(album1, 0); valuesList.AddInListBox(album2, 1); valuesList.AddInListBox(album3, 2); valuesList.AddInListBox(album4, 3); emailBox.Pattern = @"^[^@\s]+@[^@\s]+\.[^@\s]+$"; dropDownList.AddingToList(new List() { "Placebo", "Slipknot", "Blue October", "The Used", "Muse", "The Cure" }); dropDownList.ExplicitEvent += Event_Handler; emailBox.ExplicitEvent += Event_Handler; emailBox.SetExample("eeee@mail.ru"); } private Color GetRandomPastelColor() { Random random = new Random(); int red = random.Next(128, 256); int green = random.Next(128, 256); int blue = random.Next(128, 256); return Color.FromArgb(red, green, blue); } private void Event_Handler(object sender, EventArgs e) { this.BackColor = GetRandomPastelColor(); } private void buttonGet_Click(object sender, EventArgs e) { string str = valuesList.GetObjectFromStr().Title + " " + valuesList.GetObjectFromStr().Performer + " " + valuesList.GetObjectFromStr().Genre + " " + valuesList.GetObjectFromStr().Year; textBoxShowItem.Text = str; } private void buttonCheck_Click(object sender, EventArgs e) { try { if (emailBox.TextBoxValue != null) { label1.Visible = true; label1.Text = "true"; label1.ForeColor = Color.Green; } else { label1.Visible = true; label1.Text = "false"; label1.ForeColor = Color.Red; } } catch (Exception ex) { MessageBox.Show(ex.Message); } } private void buttonClear_Click(object sender, EventArgs e) { dropDownList.Clear(); } private void buttonGetDown_Click(object sender, EventArgs e) { textBoxResult.Text = dropDownList.Selected; } } }