using AbazovViewComponents.Components; using AbazovViewComponents.Exceptions; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace AbazovAppView { public partial class FormTest : Form { public FormTest() { InitializeComponent(); } private void buttonAdd_Click(object sender, EventArgs e) { Random random = new Random(); List items = new List(); for (int i = 0; i < 3; i++) { items.Add("item" + random.Next(0, 10000)); } abazovCheckedListBox.addItems(items); abazovCheckedListBox.selectedItem = items[1]; } private void abazovCheckedListBox_SelectedItemChange(string obj) { MessageBox.Show(obj, "Select event"); } private void buttonClear_Click(object sender, EventArgs e) { abazovCheckedListBox.clear(); } private void buttonSelected_Click(object sender, EventArgs e) { MessageBox.Show(abazovCheckedListBox.selectedItem ?? "null", "By getter"); } private void buttonBoundries_Click(object sender, EventArgs e) { abazovDatePicker.dateFrom = new DateTime(1970, 01, 01); abazovDatePicker.dateTo = new DateTime(2010, 01, 01); } private void buttonSetDate_Click(object sender, EventArgs e) { var result = MessageBox.Show("Установить значение в границах?", "Выбор", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { abazovDatePicker.Value = new DateTime(2000, 01, 01); } else { abazovDatePicker.Value = new DateTime(1900, 01, 01); } } private void abazovDatePicker_DateChange(object sender, EventArgs e) { MessageBox.Show("ok"); } private void abazovDatePicker_DateChange(DateTime obj) { MessageBox.Show(obj.ToShortDateString(), "Date change event"); } private void buttonGetDate_Click(object sender, EventArgs e) { try { DateTime date = abazovDatePicker.Value; MessageBox.Show(date.ToString(), "Через свойство"); } catch (DateBoundsNotSetException ex) { MessageBox.Show(ex.Message); } catch (DateOutOfBoundsException ex) { MessageBox.Show(ex.Message); } } private void buttonSetHierarchy_Click(object sender, EventArgs e) { abazovTreeView.setHierarchy(new List<(string, bool)>() { ("department", false), ("groupNumber", false), ("name", true) }); } private void buttonAddWorkers_Click(object sender, EventArgs e) { List workers = new List(); workers.Add(new Worker("Отдел 1", 1, "Иванов")); workers.Add(new Worker("Отдел 1", 1, "Петров")); workers.Add(new Worker("Отдел 1", 1, "Иванов")); workers.Add(new Worker("Отдел 1", 2, "Иванов")); workers.Add(new Worker("Отдел 2", 1, "Иванов")); workers.Add(new Worker("Отдел 2", 1, "Иванов")); workers.Add(new Worker("Отдел 2", 1, "Петров")); workers.Add(new Worker("Отдел 2", 2, "Иванов")); abazovTreeView.addItems(workers); } private void buttonGetValue_Click(object sender, EventArgs e) { Worker? worker = abazovTreeView.getSelecetedNodeValue(); if (worker == null) return; MessageBox.Show(worker.department + ", номер группы: " + worker.groupNumber + ", " + worker.name); } private void buttonGetIndex_Click(object sender, EventArgs e) { MessageBox.Show(abazovTreeView.SelectedNodeIndex.ToString()); } private void buttonSetIndex_Click(object sender, EventArgs e) { abazovTreeView.SelectedNodeIndex = 0; } } }