KOP_Library_v5/TestView/Form1.cs

107 lines
2.6 KiB
C#

using ViewComponents.Exeption;
namespace TestView
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
string str = "ïåðâûé âòîðîé òðåòèé ÷åòâ¸ðòûé";
list_with_choice.Fill_List(str);
list_with_choice.Element = "ïåðâûé";
}
private void buttonClear_Click(object sender, EventArgs e)
{
list_with_choice.Clean_List();
}
private void buttonSelect_Click(object sender, EventArgs e)
{
MessageBox.Show(list_with_choice.Element ?? "null", "Âûáðàííûé ýëåìåíò");
}
private void list_with_choice_SelectedItemChange(string obj)
{
MessageBox.Show(obj, "Ñîáûòèå âûáîðà ýëåìåíòà");
}
private void buttonDip_Click(object sender, EventArgs e)
{
input_text.MinLen = 5;
input_text.MaxLen = 25;
MessageBox.Show($"Min: {input_text.minlen}; Max: {input_text.maxlen}");
}
private void buttonVal_Click(object sender, EventArgs e)
{
input_text.Element = "Ïðîâåðêà";
}
private void input_text_ItemChange(string obj)
{
MessageBox.Show(obj, "Ñîáûòèå èçìåíåíèÿ òåêñòà");
}
private void buttonCheck_Click(object sender, EventArgs e)
{
try
{
string val = input_text.Element;
MessageBox.Show(val, "×åðåç ñâîéñòâî");
}
catch (TextBoundsNotSetExeption ex)
{
MessageBox.Show(ex.Message);
}
catch (TextOutOfBoundsExeption ex)
{
MessageBox.Show(ex.Message);
}
}
private void buttonIerarhy_Click(object sender, EventArgs e)
{
myTreeView.setHierarchy(new List<(string, bool)> { ("Genre", false), ("Author", false), ("Title", true) });
MessageBox.Show("Èåðàðõèÿ çàäàíà");
}
private void buttonAddBook_Click(object sender, EventArgs e)
{
myTreeView.addItem(new Book("Ðîìàí", "Ãîãîëü Í.Â.", "̸ðòâûå äóøè"));
myTreeView.addItem(new Book("Ðîìàí", "Òóðãåíåâ È.Ñ.", "Îòöû è äåòè"));
myTreeView.addItem(new Book("Ôàíòàñòèêà", "Äæîðäæ Îðóýëë", "1984"));
myTreeView.addItem(new Book("Ôàíòàñòèêà", "Ðîóëèíã", "Ãàððè Ïîòòåð"));
}
private void buttonGetValue_Click(object sender, EventArgs e)
{
Book? book = myTreeView.getSelecetedNodeValue<Book>();
if (book == null) return;
MessageBox.Show("Æàíð: " + book.Genre + ", Àâòîð: " + book.Author + ", Íàçâàíèå: " + book.Title);
}
private void buttonGetIndex_Click(object sender, EventArgs e)
{
MessageBox.Show(myTreeView.SelectedNodeIndex.ToString());
}
private void buttonSetIndex_Click(object sender, EventArgs e)
{
myTreeView.SelectedNodeIndex = 1;û
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}