KOP-PIbd-32-Katysheva-N-E/ComponentsView/FormComponents.cs

96 lines
2.8 KiB
C#
Raw Permalink Normal View History

2024-09-16 20:52:42 +04:00
using ComponentsLibrary;
using ComponentsView;
namespace ComponentsLab
{
public partial class FormComponents : Form
{
private Random random = new Random();
public FormComponents()
{
InitializeComponent();
CreateImage();
EmailLoad();
}
private void CreateImage()
{
Bitmap bmp = new(imageLoad.Width - 10, imageLoad.Height - 10);
Graphics gr = Graphics.FromImage(bmp);
gr.DrawEllipse(new Pen(Color.Red), 10, 10, 20, 20);
imageLoad.Avatar = bmp;
}
private void ImageLoad_AvatarChanged(object sender, EventArgs e)
{
var width = imageLoad.Avatar.Width;
MessageBox.Show($"Change avatar, width={width}");
}
private void visualSelectionComponent1_ChangeComboBox(object sender, EventArgs e)
{
var val = visualSelectionComponent1.comboBoxSelectedValue;
MessageBox.Show($"Change value, value={val}");
}
private void EmailLoad()
{
emailComponent.EmailPattern = @"^[^@\s]+@[^@\s]+\.[^@\s]+$";
emailComponent.SetToolTip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: example@domain.com");
}
private void buttonCheckEmail_Click(object sender, EventArgs e)
{
try
{
var email = emailComponent.EmailValue;
MessageBox.Show($"Email <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
catch (EmailException ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. ", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void emailComponent_ChangeEmail(object sender, EventArgs e)
{
int r = random.Next(256);
int g = random.Next(256);
int b = random.Next(256);
emailComponent.EmailTextBox.ForeColor = Color.FromArgb(r, g, b);
}
private void listBoxValues_Load(object sender, EventArgs e)
{
2024-10-10 17:57:14 +04:00
listBoxValues.SetLayout("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [Temp], <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [Pressure]", '[', ']');
2024-09-16 20:52:42 +04:00
var objectList = new List<ObjectClass>
{
2024-10-10 17:57:14 +04:00
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", Pressure = "1008" },
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2", Pressure = "1008" },
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3", Pressure = 1010 },
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4", Pressure = 1011 },
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5", Pressure = 1009 },
2024-09-16 20:52:42 +04:00
};
listBoxValues.FillListBox(objectList);
}
2024-09-30 20:39:14 +04:00
private void listBoxValues_GetObject(object sender, EventArgs e)
{
try
{
var selectedItem = listBoxValues.GetSelectedItem<ObjectClass>();
2024-10-10 17:57:14 +04:00
checkParametrs();
2024-09-30 20:39:14 +04:00
}
catch (EmailException ex)
{
MessageBox.Show(ex.Message, $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
2024-10-01 15:35:05 +04:00
private void checkParametrs()
{
ObjectClass obj = listBoxValues.GetSelectedItem<ObjectClass>();
2024-10-10 17:57:14 +04:00
object? T = obj?.Temp;
object? P = obj?.Pressure;
2024-10-01 15:35:05 +04:00
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {T}, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {P}");
}
}
2024-09-16 20:52:42 +04:00
}