Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a0c55f7b5 | ||
| 5489c642f0 | |||
| 103dc552e0 | |||
| 53a4567a0d | |||
|
|
f098199010 | ||
|
|
ce79918c9b | ||
|
|
7fa0fee8f2 |
@@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.9.34723.18
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentsLibrary", "ComponentsLibrary\ComponentsLibrary.csproj", "{405DC0B1-6F7C-462D-A8F0-435EE9A1983B}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentsView", "ComponentsView\ComponentsView.csproj", "{92F249DD-167B-42EB-98A1-9B4B71D69B61}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{405DC0B1-6F7C-462D-A8F0-435EE9A1983B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{405DC0B1-6F7C-462D-A8F0-435EE9A1983B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{405DC0B1-6F7C-462D-A8F0-435EE9A1983B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{405DC0B1-6F7C-462D-A8F0-435EE9A1983B}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{92F249DD-167B-42EB-98A1-9B4B71D69B61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{92F249DD-167B-42EB-98A1-9B4B71D69B61}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{92F249DD-167B-42EB-98A1-9B4B71D69B61}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{92F249DD-167B-42EB-98A1-9B4B71D69B61}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {6D17BCB4-04C0-4B95-B46C-535B01552FDD}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
36
ComponentsLibrary/ComponentBigText.Designer.cs
generated
36
ComponentsLibrary/ComponentBigText.Designer.cs
generated
@@ -1,36 +0,0 @@
|
|||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
partial class ComponentBigText
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Обязательная переменная конструктора.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Освободить все используемые ресурсы.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Код, автоматически созданный конструктором компонентов
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
|
||||||
/// содержимое этого метода с помощью редактора кода.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
components = new System.ComponentModel.Container();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
using ComponentsLibrary.entities;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
|
|
||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
public partial class ComponentBigText : Component
|
|
||||||
{
|
|
||||||
public ComponentBigText()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentBigText(IContainer container)
|
|
||||||
{
|
|
||||||
container.Add(this);
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateWordText(DocumentSymple docInfo)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(docInfo.FileUrl) || string.IsNullOrEmpty(docInfo.Title) || !CheckData(docInfo.Text))
|
|
||||||
{
|
|
||||||
throw new Exception("Не все данные заполнены");
|
|
||||||
}
|
|
||||||
|
|
||||||
using (WordprocessingDocument wordDocument = WordprocessingDocument.Create(docInfo.FileUrl, WordprocessingDocumentType.Document))
|
|
||||||
{
|
|
||||||
// Добавляем главную часть документа
|
|
||||||
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
|
|
||||||
mainPart.Document = new Document();
|
|
||||||
Body body = mainPart.Document.AppendChild(new Body());
|
|
||||||
|
|
||||||
// Создаем параграф для заголовка
|
|
||||||
Paragraph titleParagraph = new Paragraph();
|
|
||||||
|
|
||||||
// Задаем свойства параграфа (центровка и отступ)
|
|
||||||
ParagraphProperties paragraphProperties = new ParagraphProperties();
|
|
||||||
paragraphProperties.AppendChild(new Justification() { Val = JustificationValues.Center });
|
|
||||||
|
|
||||||
// Применяем свойства параграфа к заголовку
|
|
||||||
titleParagraph.AppendChild(paragraphProperties);
|
|
||||||
|
|
||||||
// Создаем "бегунок" текста
|
|
||||||
Run titleRun = new Run();
|
|
||||||
|
|
||||||
// Устанавливаем свойства "бегунка" (шрифт, размер, жирный шрифт)
|
|
||||||
RunProperties runProperties = new RunProperties();
|
|
||||||
runProperties.AppendChild(new Bold());
|
|
||||||
runProperties.AppendChild(new FontSize() { Val = "48" }); // Размер шрифта, 24pt
|
|
||||||
|
|
||||||
// Применяем свойства к тексту
|
|
||||||
titleRun.AppendChild(runProperties);
|
|
||||||
|
|
||||||
// Добавляем текст заголовка
|
|
||||||
titleRun.AppendChild(new Text(docInfo.Title));
|
|
||||||
|
|
||||||
// Добавляем "бегунок" с текстом в параграф
|
|
||||||
titleParagraph.AppendChild(titleRun);
|
|
||||||
|
|
||||||
// Добавляем параграф в тело документа
|
|
||||||
body.AppendChild(titleParagraph);
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var line in docInfo.Text)
|
|
||||||
{
|
|
||||||
Paragraph paragraph = new Paragraph(new Run(new Text(line)));
|
|
||||||
body.Append(paragraph);
|
|
||||||
}
|
|
||||||
mainPart.Document.Save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckData(string[] data)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < data.Length; i++)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(data[i])) return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
36
ComponentsLibrary/ComponentDiagram.Designer.cs
generated
36
ComponentsLibrary/ComponentDiagram.Designer.cs
generated
@@ -1,36 +0,0 @@
|
|||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
partial class ComponentDiagram
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Обязательная переменная конструктора.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Освободить все используемые ресурсы.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Код, автоматически созданный конструктором компонентов
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
|
||||||
/// содержимое этого метода с помощью редактора кода.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
components = new System.ComponentModel.Container();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,100 +0,0 @@
|
|||||||
using Aspose.Words;
|
|
||||||
using Aspose.Words.Drawing;
|
|
||||||
using Aspose.Words.Drawing.Charts;
|
|
||||||
using ComponentsLibrary.entities;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
public partial class ComponentDiagram : Component
|
|
||||||
{
|
|
||||||
public ComponentDiagram()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentDiagram(IContainer container)
|
|
||||||
{
|
|
||||||
container.Add(this);
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
public void AddDiagram(DocumentDiagram diagramInfo)
|
|
||||||
{
|
|
||||||
if (!CheckData(diagramInfo.DataList))
|
|
||||||
{
|
|
||||||
throw new Exception("Не заполнены данные");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Создание документа и настройка шрифта
|
|
||||||
Document doc = new Document();
|
|
||||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
|
||||||
Aspose.Words.Font font = builder.Font;
|
|
||||||
font.Size = 24;
|
|
||||||
font.Bold = true;
|
|
||||||
font.Color = Color.Black;
|
|
||||||
font.Name = "Calibri";
|
|
||||||
|
|
||||||
//Настройка форматирования параграфа
|
|
||||||
ParagraphFormat paragraphFormat = builder.ParagraphFormat;
|
|
||||||
paragraphFormat.FirstLineIndent = 8;
|
|
||||||
paragraphFormat.SpaceAfter = 24;
|
|
||||||
paragraphFormat.Alignment = ParagraphAlignment.Center;
|
|
||||||
paragraphFormat.KeepTogether = true;
|
|
||||||
|
|
||||||
//Добавление заголовка
|
|
||||||
builder.Writeln(diagramInfo.FileHeader);
|
|
||||||
|
|
||||||
//Создание диаграммы
|
|
||||||
Shape shape = builder.InsertChart(ChartType.Line, 500, 270);
|
|
||||||
Chart chart = shape.Chart;
|
|
||||||
chart.Title.Text = diagramInfo.DiagramName; //Настройка заголовка диаграммы
|
|
||||||
ChartSeriesCollection seriesColl = chart.Series;
|
|
||||||
seriesColl.Clear();
|
|
||||||
|
|
||||||
string[] cats; //x - категории
|
|
||||||
double[] doubs; //y - данные
|
|
||||||
|
|
||||||
//Добавление серий данных
|
|
||||||
foreach (var data in diagramInfo.DataList)
|
|
||||||
{
|
|
||||||
cats = new string[diagramInfo.DataList.Count];
|
|
||||||
doubs = new double[diagramInfo.DataList.Count];
|
|
||||||
int i = 0;
|
|
||||||
foreach (var (name, value) in data.LineData)
|
|
||||||
{
|
|
||||||
cats[i] = name;
|
|
||||||
doubs[i] = value;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
seriesColl.Add(data.LineName, cats, doubs);
|
|
||||||
}
|
|
||||||
//Настройка легенды
|
|
||||||
ChartLegend legend = chart.Legend;
|
|
||||||
legend.Position = (LegendPosition)diagramInfo.AreaLegend;
|
|
||||||
legend.Overlay = true;
|
|
||||||
|
|
||||||
doc.Save(diagramInfo.FileUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool CheckData(List<DataLine> data)
|
|
||||||
{
|
|
||||||
string[] cats = new string[data.Count];
|
|
||||||
double[] doubs = new double[data.Count];
|
|
||||||
|
|
||||||
foreach (var _data in data)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
foreach (var (name, value) in _data.LineData)
|
|
||||||
{
|
|
||||||
cats[i] = name;
|
|
||||||
doubs[i] = value;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(_data.LineName) || cats.Length == 0 || doubs.Length == 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
36
ComponentsLibrary/ComponentTable.Designer.cs
generated
36
ComponentsLibrary/ComponentTable.Designer.cs
generated
@@ -1,36 +0,0 @@
|
|||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
partial class ComponentTable
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Обязательная переменная конструктора.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Освободить все используемые ресурсы.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Код, автоматически созданный конструктором компонентов
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
|
||||||
/// содержимое этого метода с помощью редактора кода.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
components = new System.ComponentModel.Container();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
using Aspose.Words;
|
|
||||||
using Aspose.Words.Tables;
|
|
||||||
using ComponentsLibrary.entities;
|
|
||||||
using System.ComponentModel;
|
|
||||||
|
|
||||||
|
|
||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
public partial class ComponentTable : Component
|
|
||||||
{
|
|
||||||
public ComponentTable()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ComponentTable(IContainer container)
|
|
||||||
{
|
|
||||||
container.Add(this);
|
|
||||||
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
public void CreateTable<T>(DocumentTable<T> tableWord) where T : class
|
|
||||||
{
|
|
||||||
// Проверка наличия данных и определений столбцов
|
|
||||||
if (tableWord.Items == null || tableWord.Items.Count == 0 || tableWord.ColumnParameters == null || tableWord.ColumnParameters.Count == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Не все данные заполнены");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Проверка, что все ячейки шапки заполнены и для каждого столбца определено свойство/поле класса
|
|
||||||
foreach (var columnParameters in tableWord.ColumnParameters)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(columnParameters.PropertyName))
|
|
||||||
{
|
|
||||||
throw new ArgumentException($"Incomplete column definition: {columnParameters.FirstRowHeader}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Создание документа
|
|
||||||
Document document = new Document();
|
|
||||||
DocumentBuilder builder = new DocumentBuilder(document);
|
|
||||||
|
|
||||||
// Установка стиля заголовка
|
|
||||||
Style titleStyle = builder.Document.Styles.Add(StyleType.Paragraph, "Title");
|
|
||||||
titleStyle.Font.Size = 16;
|
|
||||||
titleStyle.Font.Bold = true;
|
|
||||||
|
|
||||||
// Установка заголовка документа
|
|
||||||
builder.ParagraphFormat.Style = titleStyle;
|
|
||||||
builder.Writeln(tableWord.Title);
|
|
||||||
|
|
||||||
// Создание таблицы
|
|
||||||
Table table = builder.StartTable();
|
|
||||||
|
|
||||||
// Установка стиля для шапки таблицы
|
|
||||||
Style headerStyle = builder.Document.Styles.Add(StyleType.Paragraph, "HeaderStyle");
|
|
||||||
headerStyle.Font.Size = 14;
|
|
||||||
headerStyle.Font.Bold = true;
|
|
||||||
|
|
||||||
|
|
||||||
// Создание первой строки (шапка)
|
|
||||||
foreach (var columnParameters in tableWord.ColumnParameters)
|
|
||||||
{
|
|
||||||
builder.InsertCell();
|
|
||||||
builder.ParagraphFormat.Style = headerStyle;
|
|
||||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnParameters.Width);
|
|
||||||
builder.Write(columnParameters.FirstRowHeader);
|
|
||||||
}
|
|
||||||
builder.EndRow();
|
|
||||||
|
|
||||||
// Создание второй строки (шапка)
|
|
||||||
foreach (var columnParameters in tableWord.ColumnParameters)
|
|
||||||
{
|
|
||||||
builder.InsertCell();
|
|
||||||
builder.ParagraphFormat.Style = headerStyle;
|
|
||||||
builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(columnParameters.Width);
|
|
||||||
builder.Write(columnParameters.SecondRowHeader);
|
|
||||||
}
|
|
||||||
builder.EndRow();
|
|
||||||
|
|
||||||
int startCellIndex = -1;
|
|
||||||
int endCellIndex = -1;
|
|
||||||
|
|
||||||
// Создаем набор для хранения индексов ячеек, которые уже объединены по горизонтали
|
|
||||||
HashSet<int> horizontallyMergedCells = new();
|
|
||||||
// Объединение ячеек в первой строке шапки таблицы (если необходимо)
|
|
||||||
foreach (var mergedColumn in tableWord.MergedColumns)
|
|
||||||
{
|
|
||||||
startCellIndex = mergedColumn[0];
|
|
||||||
endCellIndex = mergedColumn[^1];
|
|
||||||
|
|
||||||
for (int i = startCellIndex; i <= endCellIndex; i++)
|
|
||||||
{
|
|
||||||
// Устанавливаем горизонтальное объединение
|
|
||||||
table.Rows[0].Cells[i].CellFormat.HorizontalMerge = i == startCellIndex ? CellMerge.First : CellMerge.Previous;
|
|
||||||
horizontallyMergedCells.Add(i); // Сохраняем индекс ячейки, которая объединена по горизонтали
|
|
||||||
|
|
||||||
// Устанавливаем выравнивание по центру
|
|
||||||
if (i == startCellIndex)
|
|
||||||
{
|
|
||||||
// Центрируем текст внутри ячейки
|
|
||||||
table.Rows[0].Cells[i].Paragraphs[0].ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Установка вертикального объединения заголовков
|
|
||||||
for (int columnIndex = 0; columnIndex < tableWord.ColumnParameters.Count; columnIndex++)
|
|
||||||
{
|
|
||||||
// Пропускаем столбцы, которые уже объединены по горизонтали
|
|
||||||
if (horizontallyMergedCells.Contains(columnIndex))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
table.Rows[0].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.First;
|
|
||||||
table.Rows[1].Cells[columnIndex].CellFormat.VerticalMerge = CellMerge.Previous;
|
|
||||||
|
|
||||||
table.Rows[0].Cells[columnIndex].CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
|
||||||
table.Rows[1].Cells[columnIndex].CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Установка стиля для данных таблицы
|
|
||||||
Style dataStyle = builder.Document.Styles.Add(StyleType.Paragraph, "DataStyle");
|
|
||||||
dataStyle.Font.Size = 12;
|
|
||||||
dataStyle.Font.Bold = false;
|
|
||||||
|
|
||||||
// Вставка данных в таблицу
|
|
||||||
foreach (var item in tableWord.Items)
|
|
||||||
{
|
|
||||||
foreach (var сolumnParameters in tableWord.ColumnParameters)
|
|
||||||
{
|
|
||||||
builder.InsertCell();
|
|
||||||
builder.ParagraphFormat.Style = dataStyle;
|
|
||||||
// Получение значения свойства/поля объекта по заданному имени
|
|
||||||
var propertyValue = item.GetType().GetProperty(сolumnParameters.PropertyName)?.GetValue(item)?.ToString();
|
|
||||||
builder.Write(propertyValue ?? string.Empty);
|
|
||||||
}
|
|
||||||
builder.EndRow();
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.EndTable();
|
|
||||||
|
|
||||||
// Сохранение документа в файл
|
|
||||||
document.Save(tableWord.FileUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<TargetFramework>net6.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
||||||
@@ -8,8 +8,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Aspose.Words" Version="24.10.0" />
|
<PackageReference Include="System.Collections" Version="4.3.0" />
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
75
ComponentsLibrary/Email.Designer.cs
generated
Normal file
75
ComponentsLibrary/Email.Designer.cs
generated
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
namespace ComponentsLibrary
|
||||||
|
{
|
||||||
|
partial class Email
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
textBoxEmail = new TextBox();
|
||||||
|
labelEmail = new Label();
|
||||||
|
toolTipEmail = new ToolTip(components);
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxEmail
|
||||||
|
//
|
||||||
|
textBoxEmail.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
textBoxEmail.Location = new Point(62, 15);
|
||||||
|
textBoxEmail.Name = "textBoxEmail";
|
||||||
|
textBoxEmail.Size = new Size(139, 23);
|
||||||
|
textBoxEmail.TabIndex = 0;
|
||||||
|
textBoxEmail.TextChanged += textBoxEmail_TextChanged;
|
||||||
|
textBoxEmail.Enter += showToolTip;
|
||||||
|
//
|
||||||
|
// labelEmail
|
||||||
|
//
|
||||||
|
labelEmail.AutoSize = true;
|
||||||
|
labelEmail.Location = new Point(17, 18);
|
||||||
|
labelEmail.Name = "labelEmail";
|
||||||
|
labelEmail.Size = new Size(39, 15);
|
||||||
|
labelEmail.TabIndex = 1;
|
||||||
|
labelEmail.Text = "Email:";
|
||||||
|
//
|
||||||
|
// Email
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
Controls.Add(labelEmail);
|
||||||
|
Controls.Add(textBoxEmail);
|
||||||
|
Name = "Email";
|
||||||
|
Size = new Size(218, 54);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxEmail;
|
||||||
|
private Label labelEmail;
|
||||||
|
private ToolTip toolTipEmail;
|
||||||
|
}
|
||||||
|
}
|
||||||
97
ComponentsLibrary/Email.cs
Normal file
97
ComponentsLibrary/Email.cs
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace ComponentsLibrary
|
||||||
|
{
|
||||||
|
public partial class Email : UserControl
|
||||||
|
{
|
||||||
|
private EventHandler? _changeEmail;
|
||||||
|
private string emailPattern;
|
||||||
|
public Email()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
//Должна всплывать подсказка ToolTip с примером правильного ввода (пример должен заполняться через публичный метод).
|
||||||
|
public void SetToolTip(string example)
|
||||||
|
{
|
||||||
|
toolTipEmail.SetToolTip(textBoxEmail, example);
|
||||||
|
}
|
||||||
|
private void showToolTip(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
toolTipEmail.Active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Публичное свойство для установки и получения введенного значения (set, get):
|
||||||
|
public string EmailValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(emailPattern))
|
||||||
|
{
|
||||||
|
throw new EmailException("Шаблон электронной почты не задан.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsValidEmail(textBoxEmail.Text))
|
||||||
|
{
|
||||||
|
throw new EmailException("Введенный адрес электронной почты не соответствует шаблону.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return textBoxEmail.Text;
|
||||||
|
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (IsValidEmail(value))
|
||||||
|
{
|
||||||
|
textBoxEmail.Text = value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
textBoxEmail.Text = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Шаблон, по которому будет проверяться вводимое значение, должен заполняться через публичное свойство
|
||||||
|
public string EmailPattern
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return emailPattern;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
emailPattern = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//правильный ввод должен заполняться через публичный метод
|
||||||
|
private bool IsValidEmail(string email)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(emailPattern))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return Regex.IsMatch(email, emailPattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
//событие, вызываемое при смене значения
|
||||||
|
public event EventHandler ChangeEmail
|
||||||
|
{
|
||||||
|
add { _changeEmail += value; }
|
||||||
|
remove { _changeEmail -= value; }
|
||||||
|
}
|
||||||
|
private void textBoxEmail_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_changeEmail?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TextBox EmailTextBox
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return textBoxEmail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
123
ComponentsLibrary/Email.resx
Normal file
123
ComponentsLibrary/Email.resx
Normal file
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="toolTipEmail.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>114, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
10
ComponentsLibrary/EmailException.cs
Normal file
10
ComponentsLibrary/EmailException.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace ComponentsLibrary
|
||||||
|
{
|
||||||
|
public class EmailException : Exception
|
||||||
|
{
|
||||||
|
public EmailException(string message) : base(message)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
75
ComponentsLibrary/ImageLoad.Designer.cs
generated
Normal file
75
ComponentsLibrary/ImageLoad.Designer.cs
generated
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
namespace ComponentsLab
|
||||||
|
{
|
||||||
|
partial class ImageLoad
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
pictureBoxAvatar = new PictureBox();
|
||||||
|
buttonLoad = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// pictureBoxAvatar
|
||||||
|
//
|
||||||
|
pictureBoxAvatar.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
pictureBoxAvatar.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
pictureBoxAvatar.Location = new Point(3, 3);
|
||||||
|
pictureBoxAvatar.Name = "pictureBoxAvatar";
|
||||||
|
pictureBoxAvatar.Size = new Size(225, 194);
|
||||||
|
pictureBoxAvatar.TabIndex = 0;
|
||||||
|
pictureBoxAvatar.TabStop = false;
|
||||||
|
//
|
||||||
|
// buttonLoad
|
||||||
|
//
|
||||||
|
buttonLoad.Anchor = AnchorStyles.Bottom;
|
||||||
|
buttonLoad.Location = new Point(78, 203);
|
||||||
|
buttonLoad.Name = "buttonLoad";
|
||||||
|
buttonLoad.Size = new Size(74, 23);
|
||||||
|
buttonLoad.TabIndex = 1;
|
||||||
|
buttonLoad.Text = "Загрузить";
|
||||||
|
buttonLoad.UseVisualStyleBackColor = true;
|
||||||
|
buttonLoad.Click += buttonLoad_Click;
|
||||||
|
//
|
||||||
|
// ImageLoad
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
Controls.Add(buttonLoad);
|
||||||
|
Controls.Add(pictureBoxAvatar);
|
||||||
|
Name = "ImageLoad";
|
||||||
|
Size = new Size(232, 235);
|
||||||
|
((System.ComponentModel.ISupportInitialize)pictureBoxAvatar).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private PictureBox pictureBoxAvatar;
|
||||||
|
private Button buttonLoad;
|
||||||
|
}
|
||||||
|
}
|
||||||
56
ComponentsLibrary/ImageLoad.cs
Normal file
56
ComponentsLibrary/ImageLoad.cs
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
|
||||||
|
namespace ComponentsLab
|
||||||
|
{
|
||||||
|
|
||||||
|
public partial class ImageLoad : UserControl
|
||||||
|
{
|
||||||
|
private event EventHandler? _avatarChanged;
|
||||||
|
private event Action? _errorOccured;
|
||||||
|
public string Error { get; private set; }
|
||||||
|
public Image Avatar
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return pictureBoxAvatar.Image;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
pictureBoxAvatar.Image = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public event EventHandler AvatarChanged
|
||||||
|
{
|
||||||
|
add { _avatarChanged += value; }
|
||||||
|
remove { _avatarChanged -= value; }
|
||||||
|
}
|
||||||
|
public event Action AnErrorOccurred
|
||||||
|
{
|
||||||
|
add { _errorOccured += value; }
|
||||||
|
remove { _errorOccured -= value; }
|
||||||
|
}
|
||||||
|
public ImageLoad()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Error = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonLoad_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var ofd = new OpenFileDialog();
|
||||||
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pictureBoxAvatar.Image = Image.FromFile(ofd.FileName);
|
||||||
|
_avatarChanged?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Error = ex.Message;
|
||||||
|
_errorOccured?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace ComponentsLibrary
|
namespace ComponentsLibrary
|
||||||
{
|
{
|
||||||
partial class TestComponent
|
partial class ListBoxValues
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обязательная переменная конструктора.
|
/// Обязательная переменная конструктора.
|
||||||
@@ -28,9 +28,32 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
components = new System.ComponentModel.Container();
|
listBox = new ListBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// listBox
|
||||||
|
//
|
||||||
|
listBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
listBox.FormattingEnabled = true;
|
||||||
|
listBox.ItemHeight = 15;
|
||||||
|
listBox.Location = new Point(3, 3);
|
||||||
|
listBox.Name = "listBox";
|
||||||
|
listBox.Size = new Size(222, 124);
|
||||||
|
listBox.TabIndex = 0;
|
||||||
|
listBox.SelectedIndexChanged += listBox_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// ListBoxValues
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(listBox);
|
||||||
|
Name = "ListBoxValues";
|
||||||
|
Size = new Size(228, 132);
|
||||||
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private ListBox listBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
115
ComponentsLibrary/ListBoxValues.cs
Normal file
115
ComponentsLibrary/ListBoxValues.cs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
|
||||||
|
namespace ComponentsLibrary
|
||||||
|
{
|
||||||
|
public partial class ListBoxValues : UserControl
|
||||||
|
{
|
||||||
|
private string layoutString = string.Empty;
|
||||||
|
private char startSymbol = '{';
|
||||||
|
private char endSymbol = '}';
|
||||||
|
private List<object> items = new List<object>();
|
||||||
|
private EventHandler? _getObject;
|
||||||
|
public ListBoxValues()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
//событие, вызываемое при выборе строки
|
||||||
|
public event EventHandler GetObject
|
||||||
|
{
|
||||||
|
add { _getObject += value; }
|
||||||
|
remove { _getObject -= value; }
|
||||||
|
}
|
||||||
|
private void listBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_getObject?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Публичное свойство для установки и получения индекса выбранной строки (set, get).
|
||||||
|
public int SelectedIndex
|
||||||
|
{
|
||||||
|
get { return listBox.SelectedIndex; }
|
||||||
|
set { listBox.SelectedIndex = value; }
|
||||||
|
}
|
||||||
|
// Публичный метод для установки макетной строки и символов
|
||||||
|
public void SetLayout(string layout, char startChar, char endChar)
|
||||||
|
{
|
||||||
|
layoutString = layout;
|
||||||
|
startSymbol = startChar;
|
||||||
|
endSymbol = endChar;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Публичный метод для заполнения ListBox
|
||||||
|
public void FillListBox<T>(IEnumerable<T> itemList)
|
||||||
|
{
|
||||||
|
listBox.Items.Clear();
|
||||||
|
items.Clear();
|
||||||
|
foreach (var item in itemList)
|
||||||
|
{
|
||||||
|
if (item != null) {
|
||||||
|
items.Add(item);
|
||||||
|
string displayText = CreateDisplayText(item);
|
||||||
|
listBox.Items.Add(displayText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Метод для создания строки на основе макета
|
||||||
|
private string CreateDisplayText(object item)
|
||||||
|
{
|
||||||
|
string text = layoutString;
|
||||||
|
PropertyInfo[] properties = item.GetType().GetProperties();
|
||||||
|
|
||||||
|
foreach (var prop in properties)
|
||||||
|
{
|
||||||
|
string propertyValue = prop.GetValue(item)?.ToString() ?? string.Empty;
|
||||||
|
text = text.Replace($"{startSymbol}{prop.Name}{endSymbol}", propertyValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
|
||||||
|
}
|
||||||
|
// Публичный параметризованный метод для получения объекта из выбранной строки
|
||||||
|
public T GetSelectedItem<T>() where T : new()
|
||||||
|
{
|
||||||
|
var selectedItem = listBox.SelectedItem;
|
||||||
|
if (selectedItem == null)
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
string selectedString = selectedItem.ToString();
|
||||||
|
T obj = new T();
|
||||||
|
|
||||||
|
PropertyInfo[] properties = typeof(T).GetProperties();
|
||||||
|
|
||||||
|
string pattern = layoutString;
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < properties.Length; i++)
|
||||||
|
{
|
||||||
|
PropertyInfo prop = properties[i];
|
||||||
|
string propertyPattern = $"{startSymbol}{prop.Name}{endSymbol}";
|
||||||
|
if (i == properties.Length - 1)
|
||||||
|
{
|
||||||
|
pattern = pattern.Replace(propertyPattern, "(.*)");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pattern = pattern.Replace(propertyPattern, "(.*?)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Regex regex = new Regex(pattern);
|
||||||
|
Match match = regex.Match(selectedString);
|
||||||
|
|
||||||
|
for (int i = 0; i < properties.Length; i++)
|
||||||
|
{
|
||||||
|
string value = match.Groups[i + 1].Value;
|
||||||
|
object convertedValue = Convert.ChangeType(value, properties[i].PropertyType);
|
||||||
|
properties[i].SetValue(obj, convertedValue);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
120
ComponentsLibrary/ListBoxValues.resx
Normal file
120
ComponentsLibrary/ListBoxValues.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
using System.ComponentModel;
|
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
|
||||||
|
|
||||||
namespace ComponentsLibrary
|
|
||||||
{
|
|
||||||
public partial class TestComponent : Component
|
|
||||||
{
|
|
||||||
private string _fileName;
|
|
||||||
//DocumentEntry doc = new DocumentEntry("C:\\Users\\Natalia\\Desktop\\5semestr\\KOP\\KOP-PIbd-32-Katysheva-N-E", "doc.docx", text);
|
|
||||||
public string FileName
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!value.EndsWith(".txt"))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("No txt file");
|
|
||||||
}
|
|
||||||
_fileName = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public TestComponent()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_fileName = string.Empty;
|
|
||||||
}
|
|
||||||
public TestComponent(IContainer container)
|
|
||||||
{
|
|
||||||
container.Add(this);
|
|
||||||
InitializeComponent();
|
|
||||||
_fileName = string.Empty;
|
|
||||||
}
|
|
||||||
public bool SaveToFile(string[] texts)
|
|
||||||
{
|
|
||||||
CheckFileExsists();
|
|
||||||
using var writer = new StreamWriter(_fileName, true);
|
|
||||||
foreach (var text in texts)
|
|
||||||
{
|
|
||||||
writer.WriteLine(text);
|
|
||||||
}
|
|
||||||
writer.Flush();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private void CheckFileExsists()
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(_fileName))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(_fileName);
|
|
||||||
}
|
|
||||||
if (!File.Exists(_fileName))
|
|
||||||
{
|
|
||||||
File.Create(_fileName).Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
62
ComponentsLibrary/VisualSelectionComponent.Designer.cs
generated
Normal file
62
ComponentsLibrary/VisualSelectionComponent.Designer.cs
generated
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
namespace ComponentsLab
|
||||||
|
{
|
||||||
|
partial class VisualSelectionComponent
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обязательная переменная конструктора.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Освободить все используемые ресурсы.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Код, автоматически созданный конструктором компонентов
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||||
|
/// содержимое этого метода с помощью редактора кода.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
comboBoxComponent = new ComboBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxComponent
|
||||||
|
//
|
||||||
|
comboBoxComponent.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
comboBoxComponent.FormattingEnabled = true;
|
||||||
|
comboBoxComponent.Items.AddRange(new object[] { "Значение 1", "Значение 2", "Значение 3", "Значение 4", "Значение 5" });
|
||||||
|
comboBoxComponent.Location = new Point(17, 31);
|
||||||
|
comboBoxComponent.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
comboBoxComponent.Name = "comboBoxComponent";
|
||||||
|
comboBoxComponent.Size = new Size(138, 28);
|
||||||
|
comboBoxComponent.TabIndex = 0;
|
||||||
|
comboBoxComponent.SelectedIndexChanged += comboBoxComponent_SelectedIndexChanged;
|
||||||
|
//
|
||||||
|
// VisualSelectionComponent
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
Controls.Add(comboBoxComponent);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
|
Name = "VisualSelectionComponent";
|
||||||
|
Size = new Size(169, 87);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxComponent;
|
||||||
|
}
|
||||||
|
}
|
||||||
43
ComponentsLibrary/VisualSelectionComponent.cs
Normal file
43
ComponentsLibrary/VisualSelectionComponent.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
namespace ComponentsLab
|
||||||
|
{
|
||||||
|
public partial class VisualSelectionComponent : UserControl
|
||||||
|
{
|
||||||
|
private EventHandler? _changeComboBox;
|
||||||
|
public VisualSelectionComponent()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
//Публичное свойство (set, get) для установки и получения выбранного значения (возвращает пустую строку, если нет выбранного значения)
|
||||||
|
public string comboBoxSelectedValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return comboBoxComponent.SelectedItem?.ToString() ?? string.Empty;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxComponent.SelectedItem = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Событие, вызываемое при смене значения в ComboBox
|
||||||
|
public event EventHandler ChangeComboBox
|
||||||
|
{
|
||||||
|
add { _changeComboBox += value; }
|
||||||
|
remove { _changeComboBox -= value; }
|
||||||
|
}
|
||||||
|
private void comboBoxComponent_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_changeComboBox?.Invoke(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Отдельный публичный метод отчистки списка
|
||||||
|
public void clearList()
|
||||||
|
{
|
||||||
|
comboBoxComponent.Items.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
120
ComponentsLibrary/VisualSelectionComponent.resx
Normal file
120
ComponentsLibrary/VisualSelectionComponent.resx
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace ComponentsLibrary.entities
|
|
||||||
{
|
|
||||||
public class ColumnParams
|
|
||||||
{
|
|
||||||
public string FirstRowHeader { get; set; } = string.Empty;
|
|
||||||
public string SecondRowHeader { get; set; } = string.Empty;
|
|
||||||
public string PropertyName { get; set; } = string.Empty;
|
|
||||||
public double Width { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
namespace ComponentsLibrary.entities
|
|
||||||
{
|
|
||||||
public class DataLine
|
|
||||||
{
|
|
||||||
public string LineName { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
public (string, double)[] LineData { get; set; }
|
|
||||||
|
|
||||||
public DataLine(string nameSeries, (string, double)[] lineData)
|
|
||||||
{
|
|
||||||
LineName = nameSeries;
|
|
||||||
LineData = lineData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
using ComponentsLibrary.entities.enums;
|
|
||||||
using DocumentFormat.OpenXml.Drawing;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComponentsLibrary.entities
|
|
||||||
{
|
|
||||||
public class DocumentDiagram
|
|
||||||
{
|
|
||||||
public string FileUrl = string.Empty;
|
|
||||||
|
|
||||||
public string FileHeader = string.Empty;
|
|
||||||
|
|
||||||
public string DiagramName = string.Empty;
|
|
||||||
|
|
||||||
public EnumAreaLegend AreaLegend;
|
|
||||||
|
|
||||||
public List<DataLine> DataList = new();
|
|
||||||
|
|
||||||
public DocumentDiagram(string fileUrl, string fileHeader, string diagramName, EnumAreaLegend areaLegend, List<DataLine> dataList)
|
|
||||||
{
|
|
||||||
FileUrl = fileUrl;
|
|
||||||
FileHeader = fileHeader;
|
|
||||||
DiagramName = diagramName;
|
|
||||||
AreaLegend = areaLegend;
|
|
||||||
DataList = dataList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
namespace ComponentsLibrary.entities
|
|
||||||
{
|
|
||||||
public class DocumentSymple
|
|
||||||
{
|
|
||||||
public string FileUrl { get; set; } = string.Empty;
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
public string[] Text { get; set; }
|
|
||||||
|
|
||||||
public DocumentSymple(string fileUrl, string title, string[] text)
|
|
||||||
{
|
|
||||||
FileUrl = fileUrl;
|
|
||||||
Title = title;
|
|
||||||
Text = text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
namespace ComponentsLibrary.entities
|
|
||||||
{
|
|
||||||
public class DocumentTable<T>
|
|
||||||
{
|
|
||||||
//путь до файла
|
|
||||||
public string FileUrl { get; set; } = string.Empty;
|
|
||||||
//заголовок в документе
|
|
||||||
public string Title { get; set; } = string.Empty;
|
|
||||||
//параметры колонок (ширина и тд)
|
|
||||||
public List<ColumnParams> ColumnParameters { get; set; } = new();
|
|
||||||
|
|
||||||
//данные для таблицы
|
|
||||||
public List<T> Items { get; set; } = new();
|
|
||||||
|
|
||||||
//информация по объединению колонок
|
|
||||||
public List<int[]> MergedColumns { get; set; } = new();
|
|
||||||
|
|
||||||
public DocumentTable(string fileUrl, string title, List<ColumnParams> columnParameters, List<T> data, List<int[]> mergedColumns)
|
|
||||||
{
|
|
||||||
FileUrl = fileUrl;
|
|
||||||
Title = title;
|
|
||||||
ColumnParameters = columnParameters;
|
|
||||||
Items = data;
|
|
||||||
MergedColumns = mergedColumns;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
namespace ComponentsLibrary.entities
|
|
||||||
{
|
|
||||||
public class Employee
|
|
||||||
{
|
|
||||||
public string Status { get; set; }
|
|
||||||
public string Name { get; set; }
|
|
||||||
public string Surname { get; set; }
|
|
||||||
public string Age { get; set; }
|
|
||||||
public string Childrens { get; set; }
|
|
||||||
public string Car { get; set; }
|
|
||||||
public string Post { get; set; }
|
|
||||||
public string Experience { get; set; }
|
|
||||||
public string Prize { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
public Employee(string status, string name, string surname, string age,string childrens,string car,string post,string experience,string prize)
|
|
||||||
{
|
|
||||||
Status = status;
|
|
||||||
Name = name;
|
|
||||||
Surname = surname;
|
|
||||||
Age = age;
|
|
||||||
Childrens = childrens;
|
|
||||||
Car = car;
|
|
||||||
Post = post;
|
|
||||||
Experience = experience;
|
|
||||||
Prize = prize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Employee() { }
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
string temp = Status + ", " + Name + ", " + Surname + ", " + Age + ", " + Childrens + ", " + Car + ", " + Post + ", " + Experience + ", " + Prize;
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ComponentsLibrary.entities.enums
|
|
||||||
{
|
|
||||||
public enum EnumAreaLegend
|
|
||||||
{
|
|
||||||
None,
|
|
||||||
|
|
||||||
Left,
|
|
||||||
|
|
||||||
Top,
|
|
||||||
|
|
||||||
Right,
|
|
||||||
|
|
||||||
Bottom,
|
|
||||||
|
|
||||||
TopRight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
145
ComponentsView/FormComponents.Designer.cs
generated
145
ComponentsView/FormComponents.Designer.cs
generated
@@ -1,4 +1,4 @@
|
|||||||
namespace ComponentsView
|
namespace ComponentsLab
|
||||||
{
|
{
|
||||||
partial class FormComponents
|
partial class FormComponents
|
||||||
{
|
{
|
||||||
@@ -28,102 +28,93 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
components = new System.ComponentModel.Container();
|
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
|
||||||
testComponent = new ComponentsLibrary.TestComponent(components);
|
imageLoad = new ImageLoad();
|
||||||
richTextBoxTest = new RichTextBox();
|
visualSelectionComponent1 = new VisualSelectionComponent();
|
||||||
buttonSaveText = new Button();
|
emailComponent = new ComponentsLibrary.Email();
|
||||||
componentBigText = new ComponentsLibrary.ComponentBigText(components);
|
buttonCheckEmail = new Button();
|
||||||
richTextBoxWord = new RichTextBox();
|
listBoxValues = new ComponentsLibrary.ListBoxValues();
|
||||||
buttonSaveTextWord = new Button();
|
|
||||||
componentTable = new ComponentsLibrary.ComponentTable(components);
|
|
||||||
buttonSaveTable = new Button();
|
|
||||||
buttonSaveDiagram = new Button();
|
|
||||||
componentDiagram = new ComponentsLibrary.ComponentDiagram(components);
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// richTextBoxTest
|
// imageLoad
|
||||||
//
|
//
|
||||||
richTextBoxTest.Location = new Point(12, 12);
|
imageLoad.Avatar = null;
|
||||||
richTextBoxTest.Name = "richTextBoxTest";
|
imageLoad.BorderStyle = BorderStyle.FixedSingle;
|
||||||
richTextBoxTest.Size = new Size(175, 96);
|
imageLoad.Location = new Point(14, 16);
|
||||||
richTextBoxTest.TabIndex = 0;
|
imageLoad.Margin = new Padding(3, 5, 3, 5);
|
||||||
richTextBoxTest.Text = "";
|
imageLoad.Name = "imageLoad";
|
||||||
|
imageLoad.Size = new Size(168, 122);
|
||||||
|
imageLoad.TabIndex = 0;
|
||||||
|
imageLoad.AvatarChanged += ImageLoad_AvatarChanged;
|
||||||
//
|
//
|
||||||
// buttonSaveText
|
// visualSelectionComponent1
|
||||||
//
|
//
|
||||||
buttonSaveText.Location = new Point(12, 114);
|
visualSelectionComponent1.BorderStyle = BorderStyle.FixedSingle;
|
||||||
buttonSaveText.Name = "buttonSaveText";
|
visualSelectionComponent1.comboBoxSelectedValue = "";
|
||||||
buttonSaveText.Size = new Size(175, 23);
|
visualSelectionComponent1.Location = new Point(207, 16);
|
||||||
buttonSaveText.TabIndex = 1;
|
visualSelectionComponent1.Margin = new Padding(3, 5, 3, 5);
|
||||||
buttonSaveText.Text = "Загрузить в txt";
|
visualSelectionComponent1.Name = "visualSelectionComponent1";
|
||||||
buttonSaveText.UseVisualStyleBackColor = true;
|
visualSelectionComponent1.Size = new Size(178, 122);
|
||||||
buttonSaveText.Click += buttonSaveText_Click;
|
visualSelectionComponent1.TabIndex = 1;
|
||||||
|
visualSelectionComponent1.ChangeComboBox += visualSelectionComponent1_ChangeComboBox;
|
||||||
//
|
//
|
||||||
// richTextBoxWord
|
// emailComponent
|
||||||
//
|
//
|
||||||
richTextBoxWord.Location = new Point(193, 12);
|
emailComponent.BorderStyle = BorderStyle.FixedSingle;
|
||||||
richTextBoxWord.Name = "richTextBoxWord";
|
emailComponent.EmailPattern = null;
|
||||||
richTextBoxWord.Size = new Size(169, 96);
|
emailComponent.Location = new Point(407, 16);
|
||||||
richTextBoxWord.TabIndex = 2;
|
emailComponent.Margin = new Padding(3, 5, 3, 5);
|
||||||
richTextBoxWord.Text = "";
|
emailComponent.Name = "emailComponent";
|
||||||
|
emailComponent.Size = new Size(196, 122);
|
||||||
|
emailComponent.TabIndex = 2;
|
||||||
|
emailComponent.ChangeEmail += emailComponent_ChangeEmail;
|
||||||
//
|
//
|
||||||
// buttonSaveTextWord
|
// buttonCheckEmail
|
||||||
//
|
//
|
||||||
buttonSaveTextWord.Location = new Point(193, 114);
|
buttonCheckEmail.Location = new Point(427, 88);
|
||||||
buttonSaveTextWord.Name = "buttonSaveTextWord";
|
buttonCheckEmail.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonSaveTextWord.Size = new Size(169, 23);
|
buttonCheckEmail.Name = "buttonCheckEmail";
|
||||||
buttonSaveTextWord.TabIndex = 3;
|
buttonCheckEmail.Size = new Size(155, 31);
|
||||||
buttonSaveTextWord.Text = "Сохранить в word";
|
buttonCheckEmail.TabIndex = 3;
|
||||||
buttonSaveTextWord.UseVisualStyleBackColor = true;
|
buttonCheckEmail.Text = "Проверить email";
|
||||||
buttonSaveTextWord.Click += buttonSaveTextWord_Click;
|
buttonCheckEmail.UseVisualStyleBackColor = true;
|
||||||
|
buttonCheckEmail.Click += buttonCheckEmail_Click;
|
||||||
//
|
//
|
||||||
// buttonSaveTable
|
// listBoxValues
|
||||||
//
|
//
|
||||||
buttonSaveTable.Location = new Point(12, 143);
|
listBoxValues.BorderStyle = BorderStyle.FixedSingle;
|
||||||
buttonSaveTable.Name = "buttonSaveTable";
|
listBoxValues.Location = new Point(14, 147);
|
||||||
buttonSaveTable.Size = new Size(350, 41);
|
listBoxValues.Margin = new Padding(3, 5, 3, 5);
|
||||||
buttonSaveTable.TabIndex = 5;
|
listBoxValues.Name = "listBoxValues";
|
||||||
buttonSaveTable.Text = "Cоздать документ с таблицей";
|
listBoxValues.SelectedIndex = -1;
|
||||||
buttonSaveTable.UseVisualStyleBackColor = true;
|
listBoxValues.Size = new Size(589, 298);
|
||||||
buttonSaveTable.Click += buttonSaveTable_Click;
|
listBoxValues.TabIndex = 4;
|
||||||
//
|
listBoxValues.GetObject += listBoxValues_GetObject;
|
||||||
// buttonSaveDiagram
|
listBoxValues.Load += listBoxValues_Load;
|
||||||
//
|
|
||||||
buttonSaveDiagram.Location = new Point(12, 190);
|
|
||||||
buttonSaveDiagram.Name = "buttonSaveDiagram";
|
|
||||||
buttonSaveDiagram.Size = new Size(350, 41);
|
|
||||||
buttonSaveDiagram.TabIndex = 6;
|
|
||||||
buttonSaveDiagram.Text = "Cоздать документ с диаграмой";
|
|
||||||
buttonSaveDiagram.UseVisualStyleBackColor = true;
|
|
||||||
buttonSaveDiagram.Click += buttonSaveDiagram_Click;
|
|
||||||
//
|
//
|
||||||
// FormComponents
|
// FormComponents
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(373, 244);
|
ClientSize = new Size(630, 501);
|
||||||
Controls.Add(buttonSaveDiagram);
|
Controls.Add(listBoxValues);
|
||||||
Controls.Add(buttonSaveTable);
|
Controls.Add(buttonCheckEmail);
|
||||||
Controls.Add(buttonSaveTextWord);
|
Controls.Add(emailComponent);
|
||||||
Controls.Add(richTextBoxWord);
|
Controls.Add(visualSelectionComponent1);
|
||||||
Controls.Add(buttonSaveText);
|
Controls.Add(imageLoad);
|
||||||
Controls.Add(richTextBoxTest);
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormComponents";
|
Name = "FormComponents";
|
||||||
Text = "Form1";
|
Text = "FormComponents";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private ComponentsLibrary.TestComponent testComponent;
|
private System.ComponentModel.BackgroundWorker backgroundWorker1;
|
||||||
private RichTextBox richTextBoxTest;
|
private ComponentsLab.ImageLoad imageLoad;
|
||||||
private Button buttonSaveText;
|
private ComponentsLab.VisualSelectionComponent visualSelectionComponent1;
|
||||||
private ComponentsLibrary.ComponentBigText componentBigText;
|
private ComponentsLibrary.Email emailComponent;
|
||||||
private RichTextBox richTextBoxWord;
|
private Button buttonCheckEmail;
|
||||||
private Button buttonSaveTextWord;
|
private ComponentsLibrary.ListBoxValues listBoxValues;
|
||||||
private ComponentsLibrary.ComponentTable componentTable;
|
|
||||||
private Button buttonSaveTable;
|
|
||||||
private Button buttonSaveDiagram;
|
|
||||||
private ComponentsLibrary.ComponentDiagram componentDiagram;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,153 +1,95 @@
|
|||||||
using ComponentsLibrary.entities;
|
using ComponentsLibrary;
|
||||||
using ComponentsLibrary.entities.enums;
|
using ComponentsView;
|
||||||
using DocumentFormat.OpenXml.Drawing;
|
|
||||||
|
|
||||||
namespace ComponentsView
|
namespace ComponentsLab
|
||||||
{
|
{
|
||||||
public partial class FormComponents : Form
|
public partial class FormComponents : Form
|
||||||
{
|
{
|
||||||
|
private Random random = new Random();
|
||||||
public FormComponents()
|
public FormComponents()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
testComponent.FileName = "2.txt";
|
CreateImage();
|
||||||
|
EmailLoad();
|
||||||
|
}
|
||||||
|
private void CreateImage()
|
||||||
|
{
|
||||||
|
Bitmap bmp = new(imageLoad.Width - 10, imageLoad.Height - 10);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
gr.DrawEllipse(new Pen(Color.Red), 10, 10, 20, 20);
|
||||||
|
imageLoad.Avatar = bmp;
|
||||||
|
}
|
||||||
|
private void ImageLoad_AvatarChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var width = imageLoad.Avatar.Width;
|
||||||
|
MessageBox.Show($"Change avatar, width={width}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSaveText_Click(object sender, EventArgs e)
|
private void visualSelectionComponent1_ChangeComboBox(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var val = visualSelectionComponent1.comboBoxSelectedValue;
|
||||||
|
MessageBox.Show($"Change value, value={val}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EmailLoad()
|
||||||
|
{
|
||||||
|
emailComponent.EmailPattern = @"^[^@\s]+@[^@\s]+\.[^@\s]+$";
|
||||||
|
emailComponent.SetToolTip("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: example@domain.com");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonCheckEmail_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
testComponent.SaveToFile(richTextBoxTest.Lines);
|
var email = emailComponent.EmailValue;
|
||||||
MessageBox.Show("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
MessageBox.Show($"Email <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (EmailException ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. ", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void emailComponent_ChangeEmail(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int r = random.Next(256);
|
||||||
|
int g = random.Next(256);
|
||||||
|
int b = random.Next(256);
|
||||||
|
emailComponent.EmailTextBox.ForeColor = Color.FromArgb(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSaveTextWord_Click(object sender, EventArgs e)
|
private void listBoxValues_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using var dialog = new SaveFileDialog
|
listBoxValues.SetLayout("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [Temp], <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [Pressure]", '[', ']');
|
||||||
|
var objectList = new List<ObjectClass>
|
||||||
{
|
{
|
||||||
Filter = "docx|*.docx"
|
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", Pressure = "1008" },
|
||||||
|
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2", Pressure = "1008" },
|
||||||
|
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3", Pressure = 1010 },
|
||||||
|
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4", Pressure = 1011 },
|
||||||
|
new ObjectClass { Temp = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5", Pressure = 1009 },
|
||||||
};
|
};
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
listBoxValues.FillListBox(objectList);
|
||||||
|
}
|
||||||
|
private void listBoxValues_GetObject(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DocumentSymple doc = new(dialog.FileName, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", richTextBoxWord.Lines);
|
var selectedItem = listBoxValues.GetSelectedItem<ObjectClass>();
|
||||||
componentBigText.CreateWordText(doc);
|
checkParametrs();
|
||||||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
}
|
||||||
|
catch (EmailException ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
MessageBox.Show(ex.Message, $"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSaveTable_Click(object sender, EventArgs e)
|
private void checkParametrs()
|
||||||
{
|
{
|
||||||
List<int[]> mergedColumns = new()
|
ObjectClass obj = listBoxValues.GetSelectedItem<ObjectClass>();
|
||||||
{
|
object? T = obj?.Temp;
|
||||||
new int[] { 1, 5 },
|
object? P = obj?.Pressure;
|
||||||
new int[] { 6, 7 },
|
MessageBox.Show($"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {T}, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: {P}");
|
||||||
};
|
|
||||||
|
|
||||||
var columns = new List<ColumnParams>
|
|
||||||
{
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "", PropertyName = "Status", Width = 1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD>",PropertyName = "Name", Width = 1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Surname", Width = 1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Age", Width = 0.1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD>", PropertyName = "Childrens", Width = 0.1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Car", Width = 1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", PropertyName = "Post", Width = 1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "<22><><EFBFBD><EFBFBD>", PropertyName = "Experience", Width = 1 },
|
|
||||||
new() { FirstRowHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", SecondRowHeader = "", PropertyName = "Prize", Width = 1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
var employees = new List<Employee>
|
|
||||||
{
|
|
||||||
new() { Status = "Active", Name = "John", Surname = "Doe", Age = "35", Childrens = "2", Car = "Toyota", Post = "Manager", Experience = "10 years", Prize = "5000" },
|
|
||||||
new() { Status = "On Leave", Name = "Alice", Surname = "Smith", Age = "28", Childrens = "1", Car = "Honda", Post = "Developer", Experience = "5 years", Prize = "3000" },
|
|
||||||
new() { Status = "Active", Name = "Bob", Surname = "Brown", Age = "40", Childrens = "3", Car = "Ford", Post = "Team Lead", Experience = "15 years", Prize = "7000" },
|
|
||||||
new() { Status = "Retired", Name = "Carol", Surname = "Johnson", Age = "65", Childrens = "4", Car = "None", Post = "Accountant", Experience = "30 years", Prize = "10000" },
|
|
||||||
new() { Status = "Active", Name = "David", Surname = "Wilson", Age = "45", Childrens = "2", Car = "Chevrolet", Post = "Designer", Experience = "20 years", Prize = "4000" },
|
|
||||||
new() { Status = "Active", Name = "Eve", Surname = "Davis", Age = "32", Childrens = "0", Car = "Tesla", Post = "Data Scientist", Experience = "8 years", Prize = "6000" },
|
|
||||||
new() { Status = "On Leave", Name = "Frank", Surname = "Miller", Age = "38", Childrens = "2", Car = "BMW", Post = "Product Manager", Experience = "12 years", Prize = "5500" },
|
|
||||||
new() { Status = "Active", Name = "Grace", Surname = "Taylor", Age = "29", Childrens = "1", Car = "Mercedes", Post = "QA Engineer", Experience = "6 years", Prize = "3500" },
|
|
||||||
new() { Status = "Resigned", Name = "Henry", Surname = "Anderson", Age = "50", Childrens = "3", Car = "Audi", Post = "CTO", Experience = "25 years", Prize = "12000" },
|
|
||||||
new() { Status = "Active", Name = "Ivy", Surname = "Thomas", Age = "27", Childrens = "0", Car = "Volkswagen", Post = "Intern", Experience = "1 year", Prize = "1000" }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
using var dialog = new SaveFileDialog
|
|
||||||
{
|
|
||||||
Filter = "docx|*.docx"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
DocumentTable<Employee> info = new(dialog.FileName, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", columns, employees, mergedColumns);
|
|
||||||
componentTable.CreateTable(info);
|
|
||||||
|
|
||||||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buttonSaveDiagram_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
using var dialog = new SaveFileDialog
|
|
||||||
{
|
|
||||||
Filter = "docx|*.docx"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (dialog.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
(string, double)[] series1 = { ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1", 100), ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2", 300), ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3", 400) };
|
|
||||||
(string, double)[] series2 = { ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1", 400), ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2", 300), ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3", 100) };
|
|
||||||
(string, double)[] series3 = { ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1", 200), ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2", 500), ("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3", 900) };
|
|
||||||
|
|
||||||
string fileUrl = dialog.FileName;
|
|
||||||
string docHeader = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
||||||
string diagramName = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
||||||
List<DataLine> dataList = new List<DataLine> {
|
|
||||||
new DataLine("<22><><EFBFBD><EFBFBD><EFBFBD> 1", series1),
|
|
||||||
new DataLine("<22><><EFBFBD><EFBFBD><EFBFBD> 2", series2),
|
|
||||||
new DataLine("<22><><EFBFBD><EFBFBD><EFBFBD> 3", series3),
|
|
||||||
};
|
|
||||||
|
|
||||||
DocumentDiagram diagram = new(fileUrl, docHeader, diagramName, EnumAreaLegend.Right, dataList);
|
|
||||||
|
|
||||||
componentDiagram.AddDiagram(diagram);
|
|
||||||
|
|
||||||
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,16 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="testComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="backgroundWorker1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="componentBigText.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>154, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="componentTable.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>308, 17</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="componentDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>451, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
||||||
8
ComponentsView/ObjectClass.cs
Normal file
8
ComponentsView/ObjectClass.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace ComponentsView
|
||||||
|
{
|
||||||
|
public class ObjectClass
|
||||||
|
{
|
||||||
|
public object? Temp { get; set; }
|
||||||
|
public object? Pressure { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using DocumentFormat.OpenXml;
|
using System.Text.RegularExpressions;
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
namespace ComponentsLab
|
||||||
namespace ComponentsView
|
|
||||||
{
|
{
|
||||||
internal static class Program
|
internal static class Program
|
||||||
{
|
{
|
||||||
@@ -11,6 +10,7 @@ namespace ComponentsView
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
|
|||||||
Reference in New Issue
Block a user