107 lines
2.5 KiB
C#
107 lines
2.5 KiB
C#
using System.Windows.Forms;
|
|
using YunusovComponentsLibrary;
|
|
using YunusovComponentsLibrary.Exceptions;
|
|
|
|
namespace Form1
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
|
|
|
|
InitializeSelectComponent();
|
|
InitializeInputComponent();
|
|
|
|
}
|
|
private void InitializeSelectComponent()
|
|
{
|
|
selectComponent.Input("Çíà÷åíèå 1");
|
|
selectComponent.Input("Çíà÷åíèå 2");
|
|
selectComponent.Input("Çíà÷åíèå 3");
|
|
selectComponent.Input("Çíà÷åíèå 4");
|
|
selectComponent.Input("Çíà÷åíèå 5");
|
|
}
|
|
private void SelectComponent_ItemSelected(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(selectComponent.SelectedItem);
|
|
}
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
if (textBox.Text != "")
|
|
selectComponent.Input(textBox.Text);
|
|
}
|
|
private void buttonClearList_Click(object sender, EventArgs e)
|
|
{
|
|
selectComponent.ClearList();
|
|
}
|
|
private void InitializeInputComponent()
|
|
{
|
|
inputComponent.FloatValue = 12.3f;
|
|
}
|
|
private void buttonShowFloat_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
float? Value = inputComponent.FloatValue;
|
|
if (Value != null)
|
|
{
|
|
MessageBox.Show($"Ââåäåííîå ÷èñëî: {Value}");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Çíà÷åíèå - null");
|
|
}
|
|
}
|
|
catch (NotFloatException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
catch (EmptyValueException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
private void InitializeDataGridViewComponent()
|
|
{
|
|
listOutputComponent.ConfigColumn(new()
|
|
{
|
|
ColumnsCount = 4,
|
|
Header = new string[] { "ID", "Èìÿ", "Ôàìèëèÿ", "Âîçðàñò" },
|
|
Width = new int[] { 10, 150, 150, 100 },
|
|
IsVisible = new bool[] { false, true, true, true },
|
|
PropertiesName = new string[] { "Id", "Name", "Yourname", "Age" }
|
|
});
|
|
List<TestPerson> Persons = new()
|
|
{
|
|
new TestPerson(1, "Âÿ÷åñëàâ", "Èâàíîâ", 20),
|
|
new TestPerson(2, "Ðîñòèñëàâ", "Çàõàðîâ", 20),
|
|
new TestPerson(3, "Ñåðãåé", "Ñåðãååâ", 59),
|
|
new TestPerson(4, "Àðò¸ì", "ßøèí", 25),
|
|
new TestPerson(5, "Ëåâ", "ßøèí", 89),
|
|
};
|
|
|
|
foreach (TestPerson person in Persons)
|
|
{
|
|
listOutputComponent.AddItem(person);
|
|
}
|
|
}
|
|
|
|
private void buttonAddListOutput_Click(object sender, EventArgs e)
|
|
{
|
|
InitializeDataGridViewComponent();
|
|
}
|
|
|
|
private void buttonClearListOutput_Click(object sender, EventArgs e)
|
|
{
|
|
listOutputComponent.ClearDataGridView();
|
|
}
|
|
|
|
private void buttonGetListOutput_Click(object sender, EventArgs e)
|
|
{
|
|
var Test = listOutputComponent.GetSelectedObject<TestPerson>();
|
|
MessageBox.Show(Test.ToString());
|
|
}
|
|
}
|
|
} |