142 lines
5.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 WinFormsLibrary.SupportClasses.Enums;
using WinFormsLibrary.SupportClasses;
using WinFormsLibrary;
namespace WinFormsProject
{
public partial class Form2 : Form
{
private List<string> testArray;
DocumentWithImage documentWithImage;
Table2column table2column;
CircleDiagram circleDiagram;
public Form2()
{
InitializeComponent();
documentWithImage = new DocumentWithImage();
table2column = new Table2column();
circleDiagram = new CircleDiagram();
}
private void button1_Click(object sender, EventArgs e)
{
testArray = new List<string>() {
"C:\\Users\\aleyc\\OneDrive\\Рабочий стол\\Images For Tets\\image_1.jpg",
"C:\\Users\\aleyc\\OneDrive\\Рабочий стол\\Images For Tets\\image_2.png",
};
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
ImageClass imageClass = new(dialog.FileName, "Любой заголовок", testArray);
documentWithImage.CreateDocument(imageClass);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button2_Click(object sender, EventArgs e)
{
List<int[]> mergedColumns = new()
{
new int[] { 0, 1, 2 }
};
List<ColumnDefinition> columnDefinitions = new List<ColumnDefinition>
{
new ColumnDefinition { Header = "Образование", PropertyName = "Eduction", Weight = 35 },
new ColumnDefinition { Header = "", PropertyName = "Education1", Weight = 35 },
new ColumnDefinition { Header = "", PropertyName = "Education2", Weight = 10 },
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
};
List<ColumnDefinition> columnDefinitions2 = new List<ColumnDefinition>
{
new ColumnDefinition { Header = "Группа", PropertyName = "Group", Weight = 35 },
new ColumnDefinition { Header = "Факультатив", PropertyName = "Faculty", Weight = 35 },
new ColumnDefinition { Header = "Курс", PropertyName = "Course", Weight = 10 },
new ColumnDefinition { Header = "Фамилия", PropertyName = "Name", Weight = 20 }
};
List<Student> data = new List<Student>
{
new Student { Group = "ПИбд-32", Faculty = "ФИСТ", Course = 3, Name = "Васильев" },
new Student { Group = "РТбд-11", Faculty = "РТФ", Course = 1, Name = "Иванов" },
new Student { Group = "ЛМККбд-41", Faculty = "ГФ", Course = 4, Name = "Смирнова" }
};
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
BigTable<Student> bigTable = new(dialog.FileName, "Задание 2", columnDefinitions, columnDefinitions2, data, mergedColumns);
table2column.CreateTable(bigTable);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void button3_Click(object sender, EventArgs e)
{
//фильтрация файлов для диалогового окна
using var dialog = new SaveFileDialog
{
Filter = "docx|*.docx"
};
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
string[] month = { "Январь", "Февраль", "Март" };
double[] profit1 = { 300, 440, 270 };
double[] profit2 = { 500, 620, 310 };
double[] profit3 = { 420, 189, 430 };
SimpleCircleDiagram simpleCircleDiagram = new(dialog.FileName, "Третье задание", "График прибыли", EnumAreaLegend.Right, new List<DataCircleDiagram> {
new DataCircleDiagram("Компания 1", month, profit1), new DataCircleDiagram("Компания 2", month, profit2), new DataCircleDiagram("Компания 3", month, profit3),
});
circleDiagram.AddCircleDiagram(simpleCircleDiagram);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}