2023-09-15 15:21:51 +04:00
|
|
|
|
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;
|
|
|
|
|
using TestLib;
|
2023-10-13 18:33:04 +04:00
|
|
|
|
using VisableComponents;
|
2023-09-15 15:21:51 +04:00
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
|
|
2023-10-13 18:33:04 +04:00
|
|
|
|
namespace TestForm
|
2023-09-15 15:21:51 +04:00
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
List<string> ordersToAdd = new List<string>();
|
|
|
|
|
List<string> stringToHierachy = new List<string>();
|
|
|
|
|
List<Sportsmen> sportsmens = new List<Sportsmen>();
|
|
|
|
|
string[] names = {"Vova M","Sasha A","Dima D", "Danila L" };
|
|
|
|
|
string[] sports = { "Run", "Swim", "Cycle", "Race", "Box" };
|
|
|
|
|
string[] cities = { "Moskow", "Samara", "Piter", "Kazan", "Kyrsk" };
|
|
|
|
|
string[] countries = { "Russia", "Spain", "China", "India", "Brazil" };
|
|
|
|
|
string[] rewards = { "#1", "#2", "KMS", "Olymp", "MS" };
|
|
|
|
|
|
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
comboBox1.Items.AddRange(typeof(Sportsmen).GetFields().Select(x => x.Name).ToArray());
|
|
|
|
|
comboBox1.Items.AddRange(typeof(Sportsmen).GetProperties().Select(x => x.Name).ToArray());
|
2023-09-27 13:07:44 +04:00
|
|
|
|
myTextBoxDate.DateMax = new DateTime(2019, 12, 1);
|
|
|
|
|
myTextBoxDate.DateMin = new DateTime(2012, 12, 1);
|
|
|
|
|
|
|
|
|
|
newCheckList1.ValueChanged += CustomEvent_Handler;
|
|
|
|
|
myTextBoxDate.ValueChanged += CustomEvent_HandlerDate;
|
|
|
|
|
}
|
|
|
|
|
private void CustomEvent_Handler(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-10-13 18:33:04 +04:00
|
|
|
|
MessageBox.Show("Данные поменялись");
|
2023-09-27 13:07:44 +04:00
|
|
|
|
}
|
|
|
|
|
private void CustomEvent_HandlerDate(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
labelDateChange.Text = "Ку-ку";
|
2023-09-15 15:21:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (textBoxList.Text is null || textBoxList.Text.Length == 0) return;
|
|
|
|
|
ordersToAdd.Add(textBoxList.Text);
|
|
|
|
|
elemetsOfList.Text += textBoxList.Text + ", ";
|
|
|
|
|
textBoxList.Text = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadInBox_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
newCheckList1.LoadValues(ordersToAdd);
|
|
|
|
|
ordersToAdd.Clear();
|
|
|
|
|
elemetsOfList.Text = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonClear_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
newCheckList1.RemoveAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonTake_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
textBoxTakeValue.Text = newCheckList1.selectedValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonReplace_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
newCheckList1.selectedValue = textBoxTakeValue.Text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonTakeTime_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-09-27 13:07:44 +04:00
|
|
|
|
labelChecked.Text = myTextBoxDate.Value.ToString();
|
2023-09-15 15:21:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonGiveTime_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-09-27 13:07:44 +04:00
|
|
|
|
myTextBoxDate.Value = dateTimePicker.Value;
|
2023-09-15 15:21:51 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonGO_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-09-27 13:07:44 +04:00
|
|
|
|
myTreeView1.addToHierarchy(stringToHierachy);
|
2023-09-15 15:21:51 +04:00
|
|
|
|
myTreeView1.LoadTree(sportsmens);
|
|
|
|
|
labelHier.Text = "";
|
|
|
|
|
stringToHierachy.Clear();
|
|
|
|
|
sportsmens.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonAddHier_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if(stringToHierachy.Contains(comboBox1.SelectedItem))
|
|
|
|
|
return;
|
|
|
|
|
stringToHierachy.Add(comboBox1.SelectedItem.ToString());
|
|
|
|
|
labelHier.Text += " " + comboBox1.SelectedItem.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonGen_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
sportsmens.Clear();
|
|
|
|
|
listBox1.Items.Clear();
|
|
|
|
|
Random rn = new Random();
|
|
|
|
|
for(int i = 0; i < 10; i++)
|
|
|
|
|
{
|
|
|
|
|
Sportsmen sm = new Sportsmen(names[rn.Next(0, 4)], sports[rn.Next(0, 5)], cities[rn.Next(0, 5)], countries[rn.Next(0, 5)], rewards[rn.Next(0, 5)]);
|
|
|
|
|
sportsmens.Add(sm);
|
|
|
|
|
listBox1.Items.Add($"{sm.name} {sm.sport} {sm.country} {sm.city} {sm.awards}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonTakeNode_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-09-27 13:07:44 +04:00
|
|
|
|
var f = typeof(Sportsmen);
|
|
|
|
|
var res = myTreeView1.GetNode(typeof(Sportsmen));
|
|
|
|
|
labelNode.Text = res.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lab2ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Lab2 lab2 = new Lab2();
|
|
|
|
|
lab2.Show();
|
2023-09-15 15:21:51 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|