119 lines
2.9 KiB
C#
119 lines
2.9 KiB
C#
|
using CustomComponents.Objects;
|
|||
|
using ExcelComponents.Models;
|
|||
|
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 TestForms
|
|||
|
{
|
|||
|
public partial class TestForm : Form
|
|||
|
{
|
|||
|
public TestForm()
|
|||
|
{
|
|||
|
|
|||
|
InitializeComponent();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void ButtonBigText_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(textBoxTitle.Text))
|
|||
|
{
|
|||
|
bigTextExcel.BigTextGen(new BigTextConfig()
|
|||
|
{
|
|||
|
FilePath = saveFileDialog.FileName,
|
|||
|
Title = textBoxTitle.Text,
|
|||
|
Text = richTextBox.Lines
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ButtonTable_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(textBoxTitle.Text))
|
|||
|
{
|
|||
|
string[] headers = new[]
|
|||
|
{
|
|||
|
"Идент", "Статус", "Личные данные",
|
|||
|
"Имя", "Фамилия", "Возраст",
|
|||
|
"Дети", "Машина", "Работа",
|
|||
|
"Подразделение", "Должность", "Премия"
|
|||
|
};
|
|||
|
double[] colWidth = new double[] { 10, 10, 15, 15, 15, 10, 10, 15, 15, 10 };
|
|||
|
Dictionary<int, int> merge = new() { [7] = 2, [2] = 3 };
|
|||
|
Employee[] data = new Employee[]
|
|||
|
{
|
|||
|
new Employee()
|
|||
|
{
|
|||
|
Id = 1,
|
|||
|
Status = false,
|
|||
|
FirstName = "First name 1",
|
|||
|
LastName = "Last name 1",
|
|||
|
Age = 20,
|
|||
|
Children = true,
|
|||
|
Car = false,
|
|||
|
Subdivision = "Subdivision 1",
|
|||
|
Post = "Post 1",
|
|||
|
Bonus = 0.0
|
|||
|
},
|
|||
|
new Employee()
|
|||
|
{
|
|||
|
Id = 2,
|
|||
|
Status = false,
|
|||
|
FirstName = "First name 2",
|
|||
|
LastName = "Last name 2",
|
|||
|
Age = 21,
|
|||
|
Children = false,
|
|||
|
Car = true,
|
|||
|
Subdivision = "Subdivision 2",
|
|||
|
Post = "Post 2",
|
|||
|
Bonus = 2.0
|
|||
|
},
|
|||
|
};
|
|||
|
string[] props = new string[]
|
|||
|
{
|
|||
|
"Id", "Status", "FirstName",
|
|||
|
"LastName", "Age", "Children",
|
|||
|
"Car", "Subdivision", "Post", "Bonus"
|
|||
|
};
|
|||
|
excelTable.GenTable(new TableConfig<Employee>()
|
|||
|
{
|
|||
|
Title = textBoxTitle.Text,
|
|||
|
FilePath = saveFileDialog.FileName,
|
|||
|
ColWidth = colWidth,
|
|||
|
Headers = headers,
|
|||
|
Data = data,
|
|||
|
Props = props,
|
|||
|
Merge = merge
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void ButtonChart_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (saveFileDialog.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(textBoxTitle.Text) && !string.IsNullOrEmpty(textBoxChartTitle.Text))
|
|||
|
{
|
|||
|
excelLinearChart.GenChart(new LinearChartConfig()
|
|||
|
{
|
|||
|
Title = textBoxTitle.Text,
|
|||
|
FilePath = saveFileDialog.FileName,
|
|||
|
ChartTitle = textBoxChartTitle.Text,
|
|||
|
Data = new List<(string, double[])>
|
|||
|
{
|
|||
|
("header1", new double[] { 5.5, 4, 3, 2.7, 1 }),
|
|||
|
("header2", new double[] { 1.2, 2.1, 3.2, 4, 5 })
|
|||
|
},
|
|||
|
Labels = new[] { "pepsi", "cola", "fanta", "idk", "pchel" },
|
|||
|
LegendPosition = ChartLegendPosition.Bottom
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|