PIbd-33_Nevaeva_KA_COP_28/NevaevaLibrary/TestApp/FormTest.cs

117 lines
5.8 KiB
C#
Raw Permalink Normal View History

2023-11-02 19:56:58 +04:00
using NevaevaLibrary.LogicalComponents;
using System;
2023-10-20 09:23:18 +04:00
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TestApp
{
public partial class FormTest : Form
{
public FormTest()
{
InitializeComponent();
}
private void buttonInsert_Click(object sender, EventArgs e)
{
List<string> testStrings = new List<string>() { "str1", "str2", "str3" };
comboBoxControl.addItems(testStrings);
}
private void buttonClear_Click(object sender, EventArgs e)
{
comboBoxControl.clear();
}
private void buttonGetSelected_Click(object sender, EventArgs e)
{
MessageBox.Show(comboBoxControl.SelectedValue, "Полученное значение");
}
private void buttonSetSelected_Click(object sender, EventArgs e)
{
comboBoxControl.SelectedValue = "str2";
}
private void comboBoxControl_SelectedValueChange(string obj)
{
MessageBox.Show(obj, "event");
}
private void buttonAddTemplate_Click(object sender, EventArgs e)
{
mailControl.validateEmailRegex = new Regex("^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$");
mailControl.setTooltipText("qwerty@gmail.com");
}
private void buttonInsertList_Click(object sender, EventArgs e)
{
listBoxControl.setParams("{name} works in {department} for {workYears} year(s)", '{', '}');
Worker w1 = new Worker("Vasya", "Management", 5);
Worker w2 = new Worker("Vasya Utkin", "Tech department cool stuff", 1);
Worker w3 = new Worker("Ivan", "Management", 2);
List <Worker> workers = new List<Worker> { w1, w2, w3 };
listBoxControl.setItems(workers);
}
private void buttonGetSelectedList_Click(object sender, EventArgs e)
{
Worker? worker = listBoxControl.getSelectedItem<Worker>();
if (worker is not null) MessageBox.Show(worker.ToString() + $"\n{worker.name}, {worker.department}, {worker.workYears}");
}
2023-11-02 19:56:58 +04:00
private void buttonWordText_Click(object sender, EventArgs e)
{
string[] paragraphs = { "test1", "Составлен в соответствии с учебным планом направления 09.03.04. Цель данного практикума ориентировать студентов на содержание и порядок выполнения лабораторных задач во время прохождения ими курсов «Методы искусственного интеллекта» и «Машинное обучение». Даются задания на лабораторные работы. ",
"Работа подготовлена на кафедре «Информационные системы»." };
openFileDialog.Dispose();
string path = AppDomain.CurrentDomain.BaseDirectory + "test.docx";
wordLongTextComponent.createWithLongText(new WordLongTextInfo(path, "Header", paragraphs));
MessageBox.Show("Готово!");
}
2023-11-02 22:28:58 +04:00
private void buttonTable_Click(object sender, EventArgs e)
{
List<OfficeWorker> workers = new List<OfficeWorker>();
workers.Add(new OfficeWorker(1, "Иванов", "Иван", 20, "Отдел продаж", "Бухгалтер", 25, "+7(834)234-03-49"));
workers.Add(new OfficeWorker(2, "Петров", "Петр", 25, "Отдел продаж", "Менеджер", 20, "+7(834)123-03-49"));
workers.Add(new OfficeWorker(3, "Сидоров", "Сергей", 27, "Отдел кадров", "HR", 2, "+7(834)593-03-49", true));
string path = AppDomain.CurrentDomain.BaseDirectory + "test2.docx";
List<(int, int)> merges = new List<(int, int)>();
merges.Add((1, 3));
merges.Add((4, 6));
List<int> widths = Enumerable.Repeat(70, 8).ToList();
List<(string, string)> headers = new List<(string, string)> { ("id", "id"), ("", "Личные данные"),
("lastName", "Фамилия"), ("firstName", "Имя"),
("age", "Возраст"), ("", "Работа"),
("department", "Отдел"), ("position", "Должность"),
("boxNumber", "Номер бокса"), ("phoneNumber", "Телефон")};
wordTableComponent.createWithTable(path, "header", merges, widths, headers, workers);
MessageBox.Show("Готово!");
}
2023-11-02 23:55:44 +04:00
private void buttonDiagram_Click(object sender, EventArgs e)
{
List<Department> departments = new List<Department>();
departments.Add(new Department("Dep 1", new List<int> { 330, 220, 400, 500 }));
departments.Add(new Department("Dep 2", new List<int> { 400, 300, 302 }));
departments.Add(new Department("Dep 3", new List<int> { 200, 220, 270 }));
string path = AppDomain.CurrentDomain.BaseDirectory + "test3.docx";
wordDiagramComponent.createWithDiagram(path, "test3", "Продажи", DiagramLegendEnum.TopRight, departments, "name", "sells");
MessageBox.Show("Готово!");
}
2023-10-20 09:23:18 +04:00
}
}