Morozov_Pibd-32_KOP/VisEl/TestForm/Lab2.cs
2023-10-13 17:33:04 +03:00

111 lines
3.8 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 UnvisableComponents;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace TestForm
{
public partial class Lab2 : Form
{
ImageInfo info;
List<string> files;
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" };
List<Sportsmen> sportsmens = new List<Sportsmen>();
public Lab2()
{
InitializeComponent();
info = new ImageInfo();
files = new List<string>();
}
private void buttonOne_Click(object sender, EventArgs e)
{
info.Files = files;
imageExcel1.Load(info);
}
private void buttonTakePath_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog() == DialogResult.Cancel)
return;
string filename = saveFileDialog1.FileName;
labelPath.Text = filename;
info.Path = filename;
MessageBox.Show("Файл открыт");
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
info.Title = textBoxTitle.Text;
}
private void buttonTakeImage_Click(object sender, EventArgs e)
{
if (openFileDialogPath.ShowDialog() == DialogResult.Cancel)
return;
string filename = openFileDialogPath.FileName;
files.Add(filename);
labelTakenImages.Text +=" " + openFileDialogPath.FileName;
MessageBox.Show("Файл открыт");
}
private void buttonHead_Click(object sender, EventArgs e)
{
string path = @"C:\Users\Вова\Documents\WriteToExcel2.xlsx";
string title = "title";
ExcelInfo<Sportsmen> ei = new ExcelInfo<Sportsmen>();
ei.Title = title;
ei.Path = path;
ei.Dates = new List<Sportsmen>();
Dictionary<string, int> aloneFields = new Dictionary<string, int>();
ei.addDictionary("Personal", "name", 10);
ei.addDictionaryAlone("awards", 15);
ei.addDictionary("Personal", "city", 20);
ei.addDictionary("Proffesion", "Region", 30);
ei.addDictionary("Proffesion", "sport", 70);
sportsmens.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);
}
ei.Dates = sportsmens;
excelHead1.Load(ei);
}
private void buttonPaint_Click(object sender, EventArgs e)
{
string path = @"C:\Users\Вова\Documents\WriteToExcel2.xlsx";
string title = "title";
ChartInfo ci = new ChartInfo();
ci.Title = title;
ci.Path = path;
List<(string, int)> dates = new List<(string,int)>();
ci.DiagrammTitle = "CHARTTOP";
Random rn = new Random();
for (int i = 0; i < 5; i++)
{
dates.Add((names[rn.Next(0, 4)],rn.Next(1,10)));
}
ci.Dates = dates;
excelChart1.Load(ci);
}
}
}