2023-11-03 09:59:23 +04:00
|
|
|
|
using DocumentFormat.OpenXml.Bibliography;
|
|
|
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
|
|
using KOP_Labs.Classes;
|
|
|
|
|
using Microsoft.VisualBasic.ApplicationServices;
|
|
|
|
|
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 WinForm
|
|
|
|
|
{
|
|
|
|
|
public partial class NonVisualForm : Form
|
|
|
|
|
{
|
|
|
|
|
public NonVisualForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
MyHistogramm histogram;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buttonWordSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-11-03 11:07:28 +04:00
|
|
|
|
using var dialog = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "docx|*.docx"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string title = "Заголовок";
|
|
|
|
|
string[,] row1 = {
|
2023-11-03 09:59:23 +04:00
|
|
|
|
{ "Стр1 Кол1", "Стр1 Кол2" }
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-03 11:07:28 +04:00
|
|
|
|
string[,] row2 = {
|
2023-11-03 09:59:23 +04:00
|
|
|
|
{ "Стр2 Кол1", "Стр2 Кол2" }
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-03 11:07:28 +04:00
|
|
|
|
string[,] row3 = {
|
2023-11-03 09:59:23 +04:00
|
|
|
|
{ "Стр3 Кол1", "Стр3 Кол3" }
|
|
|
|
|
};
|
2023-11-03 11:07:28 +04:00
|
|
|
|
MyTable table = new MyTable(dialog.FileName, title, new List<string[,]> { row1, row2, row3 });
|
|
|
|
|
wordTableComponent1.CreateDoc(table);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-11-03 09:59:23 +04:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSaveHist_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-11-03 11:07:28 +04:00
|
|
|
|
using var dialog = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "docx|*.docx"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
histogram = new(dialog.FileName, "Заголовок", "Гистограмма", EnumLegends.Right, new List<DataHistogramm> {
|
|
|
|
|
new DataHistogramm("Тихий дон", 170), new DataHistogramm("Мастер и Маргарита", 400),
|
|
|
|
|
new DataHistogramm("Сборник Пушкина", 240), new DataHistogramm("12 стульев", 200)
|
2023-11-03 09:59:23 +04:00
|
|
|
|
});
|
|
|
|
|
|
2023-11-03 11:07:28 +04:00
|
|
|
|
wordHistogramm1.CreateHistogramm(histogram);
|
|
|
|
|
|
2023-11-30 23:20:29 +04:00
|
|
|
|
|
2023-11-03 11:07:28 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 09:59:23 +04:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Book> books;
|
2023-11-30 23:20:29 +04:00
|
|
|
|
Book book1 = new Book("Pushkin", "fgsddsdf", "fdsds");
|
|
|
|
|
Book book2 = new Book("Pushkin", "aa", "fdads");
|
|
|
|
|
Book book3 = new Book("Pushkin", "fgdf", "ffsds");
|
|
|
|
|
Book book4 = new Book("Lermontov", "ffsssff", "asdss");
|
|
|
|
|
Book book5 = new Book("Lermontov", "ffdsff", "asdsss");
|
|
|
|
|
Book book6 = new Book("Pushkin", "fgdf", "ffsds");
|
2023-11-03 09:59:23 +04:00
|
|
|
|
|
|
|
|
|
Dictionary<int, ColumnParameters> colData;
|
|
|
|
|
private void buttonHead_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-11-03 11:07:28 +04:00
|
|
|
|
|
2023-11-03 09:59:23 +04:00
|
|
|
|
books = new()
|
|
|
|
|
{
|
2023-11-03 11:07:28 +04:00
|
|
|
|
book1, book2, book3, book4, book5, book6
|
2023-11-03 09:59:23 +04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
colData = new Dictionary<int, ColumnParameters>()
|
|
|
|
|
{
|
2023-11-03 11:07:28 +04:00
|
|
|
|
{ 0, new ColumnParameters("Автор", "Author") },
|
|
|
|
|
{ 1, new ColumnParameters("Id книги", "Id") },
|
|
|
|
|
{ 2, new ColumnParameters("Имя", "Name") },
|
|
|
|
|
{ 3, new ColumnParameters("Аннотация", "Annotation") }
|
2023-11-03 09:59:23 +04:00
|
|
|
|
|
|
|
|
|
};
|
2023-11-03 11:07:28 +04:00
|
|
|
|
using var dialog = new SaveFileDialog
|
|
|
|
|
{
|
|
|
|
|
Filter = "docx|*.docx"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MyTableWithHead<Book> myTable = new(dialog.FileName, "Заголовок", new List<double> { 50, 50 },
|
|
|
|
|
new List<double> { 2000, 2000, 1500, 1500 }, books.GroupBy(b => b.Author).SelectMany(a => a).ToList(), colData);
|
|
|
|
|
wordTableHeaderComponent1.CreateDoc(myTable);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-03 09:59:23 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|