131 lines
4.5 KiB
C#
131 lines
4.5 KiB
C#
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;
|
||
using VisableComponents;
|
||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||
|
||
namespace TestForm
|
||
{
|
||
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());
|
||
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)
|
||
{
|
||
MessageBox.Show("Данные поменялись");
|
||
}
|
||
private void CustomEvent_HandlerDate(object sender, EventArgs e)
|
||
{
|
||
labelDateChange.Text = "Ку-ку";
|
||
}
|
||
|
||
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)
|
||
{
|
||
labelChecked.Text = myTextBoxDate.Value.ToString();
|
||
}
|
||
|
||
private void buttonGiveTime_Click(object sender, EventArgs e)
|
||
{
|
||
myTextBoxDate.Value = dateTimePicker.Value;
|
||
}
|
||
|
||
private void buttonGO_Click(object sender, EventArgs e)
|
||
{
|
||
myTreeView1.addToHierarchy(stringToHierachy);
|
||
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)
|
||
{
|
||
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();
|
||
}
|
||
}
|
||
}
|