PIbd-32.-Gerimovich-I.M.-COP/WinFormsAppTest/Form1.cs
platoff aeeee 4def6e88ff done
2024-10-01 10:20:10 +04:00

109 lines
3.1 KiB
C#

using Library15Gerimovich;
using Library15Gerimovich.Exceptions;
namespace WinFormsAppTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeDefaultList();
InitializeInputRealNumber();
InitializeOutputTableResults();
}
//private void CreateImage()
//{
// Bitmap bmp = new(userControl11.Width - 10,
// userControl11.Height - 10);
// Graphics gr = Graphics.FromImage(bmp);
// gr.DrawEllipse(new Pen(Color.Red), 10, 10, 20, 20);
// userControl11.Avatar = bmp;
//}
//private void userControl11_AvatarChanged(object sender, EventArgs e)
//{
// var width = userControl11.Avatar.Width;
// MessageBox.Show($"Change avatar, width={width}");
//}
private void InitializeDefaultList()
{
defaultList.SetItems("RITG, SimbirSOft, Mediasoft");
}
private void InitializeInputRealNumber()
{
inputRealNumber.DoubleValue = 1500;
}
private void InitializeOutputTableResults()
{
outputTableResults.ConfigureColumns(new List<ColumnInfo>
{
new ColumnInfo("", 0, false, "Id"),
new ColumnInfo("Surname", 150, true, "Surname"),
new ColumnInfo("Name", 150, true, "Name"),
new ColumnInfo("Age", 50, true, "Age"),
});
TestObject TestOB = new TestObject(1, "Ôàìèëèÿ", "èìÿ", 10);
TestObject TestOB2 = new TestObject(1, "Èâàíîâ", "Èâàí", 29);
outputTableResults.InsertValue(TestOB);
outputTableResults.InsertValue(TestOB2);
}
private void defaultList_ItemSelected(object sender, EventArgs e)
{
MessageBox.Show(defaultList.SelectedItem);
}
private void InputComponent_ValueChanged(object sender, EventArgs e)
{
}
private void ClearListButton_Click(object sender, EventArgs e)
{
defaultList.ClearList();
}
private void PrintObjectButton_Click(object sender, EventArgs e)
{
var Test = outputTableResults.GetSelectedObject<TestObject>();
MessageBox.Show(Test.ToString());
}
private void CheckRealButton_Click_1(object sender, EventArgs e)
{
try
{
double? Value = inputRealNumber.DoubleValue;
if (Value != null)
{
MessageBox.Show($"Ââåäåíî âåùåñòâåííîå ÷èñëî: {Value}");
}
else
{
MessageBox.Show("Çíà÷åíèå - null");
}
}
catch (MalformedRealException ex)
{
MessageBox.Show(ex.Message);
}
catch (EmptyValueException ex)
{
MessageBox.Show(ex.Message);
}
}
private void ClearDatagridButton_Click(object sender, EventArgs e)
{
outputTableResults.ClearGrid();
}
}
}