78 lines
2.4 KiB
C#
78 lines
2.4 KiB
C#
using WinFormForTest.TestClasses;
|
|
|
|
namespace WinFormForTest
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
List<Plant> plants = new List<Plant>();
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
customListBox1.AddToList("Ýëåìåíò 1");
|
|
customListBox1.AddToList("Ýëåìåíò 2");
|
|
customListBox1.AddToList("Ýëåìåíò 3");
|
|
Plant pl1 = new Plant("îâîùü", "ïîìèäîð", "êðàñíûé");
|
|
Plant pl2 = new Plant("îâîùü", "ïîìèäîð", "æ¸ëòûé");
|
|
Plant pl3 = new Plant("îâîùü", "îãóðåö", "çåë¸íûé");
|
|
Plant pl4 = new Plant("ôðóêò", "ÿáëîêî", "çåë¸íûé");
|
|
Plant pl5 = new Plant("ôðóêò", "àïåëüñèí", "îðàíæåâûé");
|
|
Plant pl6 = new Plant("ôðóêò", "àïåëüñèí", "êðàñíûé");
|
|
plants.Add(pl1);
|
|
plants.Add(pl2);
|
|
plants.Add(pl3);
|
|
plants.Add(pl4);
|
|
plants.Add(pl5);
|
|
plants.Add(pl6);
|
|
LoadTree();
|
|
}
|
|
|
|
public void LoadTree()
|
|
{
|
|
var hierarcy= new List<string> { "Type", "Name", "Color" };
|
|
customTree1.SetHierarcy(hierarcy);
|
|
foreach (Plant plant in plants)
|
|
{
|
|
customTree1.AddObjectToTree(plant);
|
|
}
|
|
}
|
|
private void buttonClear_Click(object sender, EventArgs e)
|
|
{
|
|
customListBox1.Clear();
|
|
}
|
|
|
|
private void buttonCheck_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (customComboBox1.TextBoxValue != null)
|
|
{
|
|
checkBoxValid.Text = "ïîäõîäèò";
|
|
checkBoxValid.Checked = true;
|
|
checkBoxValid.BackColor = Color.Green;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
checkBoxValid.Text = "íå ïîäõîäèò";
|
|
checkBoxValid.Checked = false;
|
|
checkBoxValid.BackColor = Color.Red;
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void buttonEnter_Click(object sender, EventArgs e)
|
|
{
|
|
customListBox1.AddToList("Ýëåìåíò 4");
|
|
customListBox1.AddToList("Ýëåìåíò 5");
|
|
customListBox1.AddToList("Ýëåìåíò 6");
|
|
}
|
|
|
|
private void buttonGet_Click(object sender, EventArgs e)
|
|
{
|
|
labelItem.Text = customListBox1.SelectedElement;
|
|
}
|
|
|
|
}
|
|
}
|