76 lines
2.0 KiB
C#
76 lines
2.0 KiB
C#
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("Ïðèìåð: example@domain.com");
|
|
}
|
|
|
|
private void buttonCheckEmail_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var email = emailComponent.EmailValue;
|
|
MessageBox.Show($"Email ñîîòâåòñòâóåò øàáëîíó");
|
|
}
|
|
catch (EmailException ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Îøèáêà. Âåäåííûé àäðåñ ýëåêòðîííîé ïî÷òû íå ñîîòâåòñòâóåò øàáëîíó. ", 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)
|
|
{
|
|
listBoxValues.SetLayout("Òåìïåðàòóðà âîçäóõà {T}, äàâëåíèå {P}", '{', '}');
|
|
var objectList = new List<ObjectClass>
|
|
{
|
|
new ObjectClass { T = 20.5, P = 1012 },
|
|
new ObjectClass { T = 18.3, P = 1008 },
|
|
new ObjectClass { T = 50.1, P = 1010 },
|
|
new ObjectClass { T = 30.0, P = 1011 },
|
|
new ObjectClass { T = 18.9, P = 1009 },
|
|
};
|
|
listBoxValues.FillListBox(objectList);
|
|
}
|
|
}
|
|
}
|