PIbd-31_Malafeev.L.S._COP_25/Cop_25/Forms/FormMain.cs

76 lines
2.8 KiB
C#
Raw Normal View History

2024-09-06 00:43:56 +04:00
using Controls;
using Controls.Exceptions;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Forms
{
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
customComboBox.ComboBoxItems.Add("aboba1");
customComboBox.ComboBoxItems.Add("aboba2");
customComboBox.SelectedItem = "aboba1";
2024-09-06 00:43:56 +04:00
customTextBoxNumber.NumPattern = @"^\+7\d{10}$";
customListBox.SetTemplateString("Имя: {FirstName}, Фамилия: {LastName}, Возраст: {Age}", "{", "}");
Person person1 = new Person { FirstName = "{Лена}", LastName = "{Пряникова}", Age = "{18}" };
Person person2 = new Person { FirstName = "{Сергей}", LastName = "{Конфеткович}", Age = "{20}" };
2024-09-06 00:43:56 +04:00
customListBox.FillProperty(person1, 0, "FirstName");
customListBox.FillProperty(person1, 0, "LastName");
customListBox.FillProperty(person1, 0, "Age");
customListBox.FillProperty(person2, 1, "FirstName");
customListBox.FillProperty(person2, 1, "LastName");
customListBox.FillProperty(person2, 1, "Age");
}
private void buttonValidate_Click(object sender, EventArgs e)
{
try
{
string phoneNumber = customTextBoxNumber.TextBoxNumber;
MessageBox.Show($"Введенный номер: {phoneNumber}");
}
catch (CustomNumberException ex)
{
MessageBox.Show($"Ошибка: {ex.Message}");
}
}
private void buttonGetObject_Click(object sender, EventArgs e)
{
try
{
Person selectedPerson = customListBox.GetObjectFromStr<Person>();
MessageBox.Show($"Ваш друг. Имя: {selectedPerson.FirstName}, Фамилия: {selectedPerson.LastName}, Возраст: {selectedPerson.Age}");
2024-09-06 00:43:56 +04:00
}
catch (Exception ex)
{
MessageBox.Show($"Ошибка: {ex.Message}");
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
customComboBox.ComboBoxItems.Add("abobaSECRET");
}
2024-10-06 17:39:02 +04:00
private void buttonLargeText_CLick(object sender, EventArgs e)
{
string[] strings = new string[] { "aboba", "not aboba" , "best aboba"};
LargeTextComponent largeText = new LargeTextComponent();
largeText.CreateDocument("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\text.pdf", "OMEGA LABA 2", strings);
}
2024-09-06 00:43:56 +04:00
}
}