PIbd-31_PotapovNS_COP_20/WinFormSolution/WinFormsApp/FormVisual.cs

92 lines
3.4 KiB
C#

using Components.Exceptions;
namespace WinFormsApp
{
public partial class FormVisual : Form
{
public FormVisual()
{
InitializeComponent();
}
private void buttonFillCheckedList_Click(object sender, EventArgs e)
{
List<string> list = new List<string>();
list.Add("Êàæäûé");
list.Add("Ïðîãðàììèñò");
list.Add("Æåëàåò");
list.Add("Çíàòü");
list.Add("C#");
userControlCheckedList.SetCheckedListBoxValues(list);
userControlCheckedList.CheckedItem = list[3];
}
private void buttonClearList_Click(object sender, EventArgs e)
{
userControlCheckedList.ClearCheckedListBoxValues();
}
private void buttonFillTreeView_Click(object sender, EventArgs e)
{
List<Employee> employees = new List<Employee>();
employees.Add(new Employee("Îòäåë ïðîäàæ", "Ìåíåäæåð", "Èâàíîâ", "Ñåìåí"));
employees.Add(new Employee("Îòäåë ìàðêåòèíãà", "Ìàðêåòîëîã", "Êàþìîâà", "Ñâåòëàíà"));
employees.Add(new Employee("Îòäåë ôèíàíñîâ", "Áóõãàëòåð", "Ðàõèìîâà", "Ýëüâèðà"));
employees.Add(new Employee("Îòäåë çàêóïîê", "Ìåíåäæåð", "Ñåìåíîâ", "Ïåòð"));
employees.Add(new Employee("Îòäåë ïðîäàæ", "Ìåíåäæåð", "Èâàíîâ", "Ïàâåë"));
employees.Add(new Employee("Îòäåë ìàðêåòèíãà", "Ìàðêåòîëîã", "Êàðàìûøåâà", "Òàòüÿíà"));
employees.Add(new Employee("Îòäåë ôèíàíñîâ", "Ôèíàíñèñò", "Àáàëîâ", "Àëüáåðò"));
employees.Add(new Employee("Îòäåë çàêóïîê", "Ãëàâíûé ìåíåäæåð", "Ìî÷àëîâ", "Àëåêñåé"));
employees.Add(new Employee("Îòäåë ïðîäàæ", "Ãëàâíûé ìåíåäæåð", "Êóçíåöîâà", "Ìàðèÿ"));
employees.Add(new Employee("Îòäåë ìàðêåòèíãà", "PR-ñïåöèàëèñò", "Êóòÿêîâ", "Ìèõàèë"));
employees.Add(new Employee("Îòäåë ôèíàíñîâ", "Àíàëèòèê", "Àñòàôüåâ", "Ïàâåë"));
employees.Add(new Employee("Îòäåë çàêóïîê", "Àíàëèòèê", "Ñìèðíîâà", "Àíàñòàñèÿ"));
List<(string PropertyName, bool AlwaysCreateBranch)> hierarchy =
[
("Departament", false),
("Position", false),
("Surname", false),
("Name", false),
];
userControlTreeView.SetHierarchy(hierarchy);
userControlTreeView.SetTreeObjects(employees);
}
private void buttonClearTreeView_Click(object sender, EventArgs e)
{
userControlTreeView.ClearTreeView();
}
private void buttonShowTreeViewNode_Click(object sender, EventArgs e)
{
Employee employee;
try
{
employee = userControlTreeView.GetObjectSelectedNode<Employee>();
textBoxTreeViewSelectedObject.Text = employee.ToString();
}
catch (PropertyNotDeclaratedException ex)
{
MessageBox.Show(ex.Message);
textBoxTreeViewSelectedObject.Text = string.Empty;
}
catch (PropertyNullException ex)
{
MessageBox.Show(ex.Message);
textBoxTreeViewSelectedObject.Text = string.Empty;
}
catch (NotSelectedNodeException ex)
{
MessageBox.Show(ex.Message);
textBoxTreeViewSelectedObject.Text = string.Empty;
}
}
}
}