diff --git a/1.txt b/1.txt
new file mode 100644
index 0000000..e69de29
diff --git a/CheckedListBoxLibrary/Components/PdfImage/PdfImage.Designer.cs b/CheckedListBoxLibrary/Components/PdfImage/PdfImage.Designer.cs
new file mode 100644
index 0000000..b8c94aa
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/PdfImage/PdfImage.Designer.cs
@@ -0,0 +1,36 @@
+namespace MyUserControls.Components.PdfImage
+{
+ partial class PdfImage
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором компонентов
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/PdfImage/PdfImage.cs b/CheckedListBoxLibrary/Components/PdfImage/PdfImage.cs
new file mode 100644
index 0000000..6460f40
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/PdfImage/PdfImage.cs
@@ -0,0 +1,47 @@
+using MyUserControls.Components.office_package;
+using MyUserControls.Components.office_package.HelperEnums;
+using MyUserControls.Components.office_package.HelperModels;
+using MyUserControls.Components.office_package.Implements;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.PdfImage
+{
+ public partial class PdfImage : Component
+ {
+ ISaveToPdf SaveToPdf = new SaveToPdf();
+
+ public PdfImage()
+ {
+ InitializeComponent();
+ }
+
+ public PdfImage(IContainer container)
+ {
+ container.Add(this);
+ InitializeComponent();
+ }
+
+ public void CreatePdf(PdfImageInfo info)
+ {
+ info.CheckFields();
+ SaveToPdf.CreatePdf(info);
+ SaveToPdf.CreateParagraph(new PdfParagraph
+ {
+ Text = info.Title,
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ foreach (var image in info.Images)
+ {
+ SaveToPdf.CreateImage(image);
+ }
+ SaveToPdf.SavePdf(info);
+ }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/PdfImage/PdfImageInfo.cs b/CheckedListBoxLibrary/Components/PdfImage/PdfImageInfo.cs
new file mode 100644
index 0000000..0f3c7fc
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/PdfImage/PdfImageInfo.cs
@@ -0,0 +1,24 @@
+using MyUserControls.Components.office_package.HelperModels;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.PdfImage
+{
+ public class PdfImageInfo : IPdfInfo
+ {
+ public string FileName { get; set; } = string.Empty;
+ public string Title { get; set; } = string.Empty;
+ public List Images { get; set; } = new List();
+
+ public void CheckFields()
+ {
+ if (string.IsNullOrWhiteSpace(FileName) || string.IsNullOrWhiteSpace(Title) || Images == null || Images.Count == 0)
+ {
+ throw new ArgumentException("Все поля должны быть заполнены.");
+ }
+ }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/PdfTable/PdfTable.Designer.cs b/CheckedListBoxLibrary/Components/PdfTable/PdfTable.Designer.cs
new file mode 100644
index 0000000..404aabe
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/PdfTable/PdfTable.Designer.cs
@@ -0,0 +1,36 @@
+namespace MyUserControls.Components.PdfTable
+{
+ partial class PdfTable
+ {
+ ///
+ /// Обязательная переменная конструктора.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Освободить все используемые ресурсы.
+ ///
+ /// истинно, если управляемый ресурс должен быть удален; иначе ложно.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Код, автоматически созданный конструктором компонентов
+
+ ///
+ /// Требуемый метод для поддержки конструктора — не изменяйте
+ /// содержимое этого метода с помощью редактора кода.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/PdfTable/PdfTable.cs b/CheckedListBoxLibrary/Components/PdfTable/PdfTable.cs
new file mode 100644
index 0000000..66e832f
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/PdfTable/PdfTable.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.PdfTable
+{
+ public partial class PdfTable : Component
+ {
+ public PdfTable()
+ {
+ InitializeComponent();
+ }
+
+ public PdfTable(IContainer container)
+ {
+ container.Add(this);
+
+ InitializeComponent();
+ }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/PdfTable/PdfTableInfo.cs b/CheckedListBoxLibrary/Components/PdfTable/PdfTableInfo.cs
new file mode 100644
index 0000000..e03e737
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/PdfTable/PdfTableInfo.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.PdfTable
+{
+ internal class PdfTableInfo
+ {
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfCellsMergeDirections.cs b/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfCellsMergeDirections.cs
new file mode 100644
index 0000000..26bb861
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfCellsMergeDirections.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperEnums
+{
+ public enum PdfCellsMergeDirections
+ {
+ Down,
+ Right
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfDiagramLegendLocation.cs b/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfDiagramLegendLocation.cs
new file mode 100644
index 0000000..1616715
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfDiagramLegendLocation.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperEnums
+{
+ public enum PdfDiagramLegendLocation
+ {
+ Left,
+ Right,
+ Top,
+ Bottom,
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfParagraphAlignmentType.cs b/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfParagraphAlignmentType.cs
new file mode 100644
index 0000000..cf256b8
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperEnums/PdfParagraphAlignmentType.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperEnums
+{
+ public enum PdfParagraphAlignmentType
+ {
+ Center,
+ Left,
+ Right
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/IPdfInfo.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/IPdfInfo.cs
new file mode 100644
index 0000000..33bcb0a
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/IPdfInfo.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public interface IPdfInfo
+ {
+ public string FileName { get; }
+ public string Title { get; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/IPdfPieChartParameters.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/IPdfPieChartParameters.cs
new file mode 100644
index 0000000..857d284
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/IPdfPieChartParameters.cs
@@ -0,0 +1,16 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public interface IPdfPieChartParameters
+ {
+ public string ChartTitle { get; }
+ public PdfDiagramLegendLocation LegendLocation { get; }
+ public PdfDiagramSeries Series { get; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/ITableTextParameters.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/ITableTextParameters.cs
new file mode 100644
index 0000000..05468ef
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/ITableTextParameters.cs
@@ -0,0 +1,15 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public interface ITableTextParameters
+ {
+ public string Style { get; }
+ public PdfParagraphAlignmentType ParagraphAlignment { get; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfCellParameters.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfCellParameters.cs
new file mode 100644
index 0000000..fb434e6
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfCellParameters.cs
@@ -0,0 +1,16 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public class PdfCellParameters : ITableTextParameters
+ {
+ public string Text { get; set; } = string.Empty;
+ public string Style { get; set; } = string.Empty;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfCellsMergeParameters.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfCellsMergeParameters.cs
new file mode 100644
index 0000000..528ac26
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfCellsMergeParameters.cs
@@ -0,0 +1,17 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public class PdfCellsMergeParameters
+ {
+ public int RowIndex = 0;
+ public int ColumnIndex = 0;
+ public PdfCellsMergeDirections Direction;
+ public int CellNumber = 1;
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfColumnParameters.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfColumnParameters.cs
new file mode 100644
index 0000000..c0c2181
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfColumnParameters.cs
@@ -0,0 +1,17 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public class PdfColumnParameters : ITableTextParameters
+ {
+ public List Texts { get; set; } = new();
+ public string Style { get; set; } = string.Empty;
+ public int ColumnIndex = 0;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfDiagramSeries.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfDiagramSeries.cs
new file mode 100644
index 0000000..b99cf1c
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfDiagramSeries.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public class PdfDiagramSeries
+ {
+ public string SeriesName { get; set; } = string.Empty;
+ public Dictionary Data = new();
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfParagraph.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfParagraph.cs
new file mode 100644
index 0000000..ecfee1e
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfParagraph.cs
@@ -0,0 +1,16 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public class PdfParagraph
+ {
+ public string Text { get; set; } = string.Empty;
+ public string Style { get; set; } = string.Empty;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfRowParameters.cs b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfRowParameters.cs
new file mode 100644
index 0000000..6b62369
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/HelperModels/PdfRowParameters.cs
@@ -0,0 +1,16 @@
+using MyUserControls.Components.office_package.HelperEnums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package.HelperModels
+{
+ public class PdfRowParameters : ITableTextParameters
+ {
+ public List Texts { get; set; } = new();
+ public string Style { get; set; } = string.Empty;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/ISaveToPdf.cs b/CheckedListBoxLibrary/Components/office_package/ISaveToPdf.cs
new file mode 100644
index 0000000..c291f87
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/ISaveToPdf.cs
@@ -0,0 +1,66 @@
+using MyUserControls.Components.office_package.HelperModels;
+using MyUserControls.Components.PdfImage;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MyUserControls.Components.office_package
+{
+ public interface ISaveToPdf
+ {
+ ///
+ /// Создание doc-файла
+ ///
+ ///
+ void CreatePdf(IPdfInfo info);
+ ///
+ /// Создание параграфа с текстом
+ ///
+ void CreateParagraph(PdfParagraph paragraph);
+ ///
+ /// Создание изображения в pdf файле
+ ///
+ void CreateImage(byte[] image);
+ ///
+ /// Создание таблицы
+ /// определенной ширины
+ ///
+ void CreateTable();
+ ///
+ /// Создание таблицы с заданным количеством столбцов
+ /// определенной ширины
+ ///
+ void CreateTableWithColumns(List columns);
+ ///
+ /// Создание таблицы с заданным количеством столбцов
+ ///
+ void CreateTableWithColumns(int columnNumber);
+ ///
+ /// Создание и заполнение строки
+ ///
+ ///
+ void CreateRow(PdfRowParameters rowParameters);
+ ///
+ /// Создание и заполнение столбца
+ ///
+ void InsertTextIntoColumn(PdfColumnParameters columnParameters);
+ ///
+ /// Создание и заполнение ячейки
+ ///
+ void InsertTextIntoCell(int rowIndex, int columnIndex, PdfCellParameters cellParameters);
+ ///
+ /// Создание и заполнение ячейки
+ ///
+ void MergeCells(PdfCellsMergeParameters parameters);
+ ///
+ /// Создание и заполнение круговой диаграммы
+ ///
+ void CreatePieChart(IPdfPieChartParameters parameters);
+ ///
+ /// Сохранение файла
+ ///
+ void SavePdf(IPdfInfo info);
+ }
+}
diff --git a/CheckedListBoxLibrary/Components/office_package/Implements/SaveToPdf.cs b/CheckedListBoxLibrary/Components/office_package/Implements/SaveToPdf.cs
new file mode 100644
index 0000000..7703584
--- /dev/null
+++ b/CheckedListBoxLibrary/Components/office_package/Implements/SaveToPdf.cs
@@ -0,0 +1,256 @@
+using MigraDoc.DocumentObjectModel;
+using MigraDoc.Rendering;
+using MigraDoc.DocumentObjectModel.Tables;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Security.Cryptography;
+using System.Reflection;
+using System.Data.Common;
+using MigraDoc.DocumentObjectModel.Shapes;
+using MigraDoc.DocumentObjectModel.Shapes.Charts;
+using MyUserControls.Components.office_package.HelperEnums;
+using MyUserControls.Components.office_package.HelperModels;
+
+namespace MyUserControls.Components.office_package.Implements
+{
+ public class SaveToPdf : ISaveToPdf
+ {
+ private Document? _document;
+ private Section? _section;
+ private Table? _table;
+
+ private readonly Unit BORDER_WIDTH = 0.5;
+ private readonly Unit COLUMN_WIDTH = Unit.FromCentimeter(3.5);
+ private readonly Unit IMAGE_WIDTH = Unit.FromCentimeter(15);
+
+ public void CreatePdf(IPdfInfo info)
+ {
+ _document = new Document();
+ DefineStyles(_document);
+ _section = _document.AddSection();
+ }
+ public void SavePdf(IPdfInfo info)
+ {
+ if (string.IsNullOrWhiteSpace(info.FileName))
+ {
+ throw new ArgumentNullException("Имя файла не задано");
+ }
+
+ if (_document == null || _section == null)
+ {
+ throw new ArgumentNullException("Документ не сформирован, сохранять нечего");
+ }
+ var renderer = new PdfDocumentRenderer(true){
+ Document = _document
+ };
+ renderer.RenderDocument();
+ renderer.PdfDocument.Save(info.FileName);
+ }
+ private static ParagraphAlignment GetParagraphAlignment(
+ PdfParagraphAlignmentType type)
+ {
+ return type switch
+ {
+ PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
+ PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
+ PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
+ _ => ParagraphAlignment.Justify,
+ };
+ }
+
+ private static void DefineStyles(Document document)
+ {
+ var style = document.Styles["Normal"];
+ style.Font.Name = "Times New Roman";
+ style.Font.Size = 14;
+ style = document.Styles.AddStyle("NormalTitle", "Normal");
+ style.Font.Bold = true;
+ }
+
+ public void CreateParagraph(PdfParagraph pdfParagraph)
+ {
+ if (_document == null)
+ {
+ return;
+ }
+ if (_section == null)
+ {
+ _section = _document.AddSection();
+ }
+ var paragraph = _section.AddParagraph(pdfParagraph.Text);
+ paragraph.Format.SpaceAfter = "1cm";
+ paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
+ paragraph.Style = pdfParagraph.Style;
+ }
+ public void CreateImage(byte[] image)
+ {
+ if (image == null || image.Length == 0)
+ {
+ throw new ArgumentNullException("Картинка не загружена");
+ }
+ if (_document == null)
+ {
+ return;
+ }
+ if (_section == null)
+ {
+ _section = _document.AddSection();
+ }
+ var imageFileName = Path.GetTempFileName();
+ File.WriteAllBytes(imageFileName, image);
+ var img = _section.AddImage(imageFileName);
+ img.Width = IMAGE_WIDTH;
+ img.LockAspectRatio = true;
+ _section.AddParagraph();
+ }
+ public void CreateTable()
+ {
+ if (_document == null || _section == null)
+ {
+ return;
+ }
+ _table = _section.AddTable();
+ }
+
+ public void CreateTableWithColumns(List columns)
+ {
+ if (_document == null || _section == null)
+ {
+ return;
+ }
+ _table = _section.AddTable();
+ foreach (var elem in columns)
+ {
+ _table.AddColumn(elem);
+ }
+ }
+
+ public void CreateTableWithColumns(int columnNumber)
+ {
+ if (_document == null || _section == null)
+ {
+ return;
+ }
+ _table = _section.AddTable();
+ for (int i = 0; i < columnNumber; i++)
+ {
+ _table.AddColumn(COLUMN_WIDTH);
+ }
+ }
+
+ public void CreateRow(PdfRowParameters rowParameters)
+ {
+ if (_table == null)
+ {
+ return;
+ }
+ var row = _table.AddRow();
+ for (int i = 0; i < rowParameters.Texts.Count; ++i)
+ {
+ if (!string.IsNullOrWhiteSpace(rowParameters.Texts[i]))
+ InsertTextIntoCell(row.Index, i, rowParameters, rowParameters.Texts[i]);
+ }
+ }
+
+ public void InsertTextIntoColumn(PdfColumnParameters columnParameters)
+ {
+ if (_table == null)
+ {
+ return;
+ }
+ for (int i = 0; i < columnParameters.Texts.Count; ++i)
+ {
+ if (!string.IsNullOrWhiteSpace(columnParameters.Texts[i]))
+ InsertTextIntoCell(i, columnParameters.ColumnIndex, columnParameters, columnParameters.Texts[i]);
+ }
+ }
+
+ public void InsertTextIntoCell(int rowIndex, int columnIndex, PdfCellParameters cellParameters)
+ {
+ InsertTextIntoCell(rowIndex, columnIndex, cellParameters, cellParameters.Text);
+ }
+
+ private void InsertTextIntoCell(int rowIndex, int columnIndex, ITableTextParameters parameters, string text)
+ {
+ if (_table == null)
+ {
+ return;
+ }
+ Cell cell = _table.Rows[rowIndex].Cells[columnIndex];
+ cell.AddParagraph(text);
+ if (!string.IsNullOrEmpty(parameters.Style))
+ {
+ cell.Style = parameters.Style;
+ }
+ cell.Borders.Left.Width = BORDER_WIDTH;
+ cell.Borders.Right.Width = BORDER_WIDTH;
+ cell.Borders.Top.Width = BORDER_WIDTH;
+ cell.Borders.Bottom.Width = BORDER_WIDTH;
+ cell.Format.Alignment = GetParagraphAlignment(
+ parameters.ParagraphAlignment);
+ cell.VerticalAlignment = VerticalAlignment.Center;
+ }
+
+ public void MergeCells(PdfCellsMergeParameters parameters)
+ {
+ if (_table == null)
+ {
+ return;
+ }
+ Cell cell = _table.Rows[parameters.RowIndex].Cells[parameters.ColumnIndex];
+ switch (parameters.Direction)
+ {
+ case PdfCellsMergeDirections.Down:
+ cell.MergeDown = parameters.CellNumber;
+ break;
+ case PdfCellsMergeDirections.Right:
+ cell.MergeRight = parameters.CellNumber;
+ break;
+ }
+ }
+ public void CreatePieChart(IPdfPieChartParameters parameters)
+ {
+ if (_document == null || _section == null)
+ throw new ArgumentNullException(nameof(_document), "Document is not created.");
+ Chart chart = new Chart(ChartType.Pie2D);
+ Series series = chart.SeriesCollection.AddSeries();
+ series.Name = parameters.Series.SeriesName;
+ series.Add(parameters.Series.Data.Select(x => x.Value).ToArray());
+ chart.XValues.AddXSeries().Add(parameters.Series.Data.Select(x => x.Key).ToArray());
+ ConfigChart(parameters, chart);
+ _section.Add(chart);
+ }
+
+ private void ConfigChart(IPdfPieChartParameters parameters, Chart chart)
+ {
+ chart.DataLabel.Type = DataLabelType.Percent;
+ chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
+ chart.Width = Unit.FromCentimeter(16.0);
+ chart.Height = Unit.FromCentimeter(12.0);
+ chart.TopArea.AddParagraph(parameters.ChartTitle);
+ chart.XAxis.MajorTickMark = (TickMarkType)2;
+ chart.YAxis.MajorTickMark = (TickMarkType)2;
+ chart.YAxis.HasMajorGridlines = true;
+ chart.PlotArea.LineFormat.Width = new Unit(1);
+ chart.PlotArea.LineFormat.Visible = true;
+ switch (parameters.LegendLocation)
+ {
+ case PdfDiagramLegendLocation.Left:
+ chart.LeftArea.AddLegend();
+ break;
+ case PdfDiagramLegendLocation.Right:
+ chart.RightArea.AddLegend();
+ break;
+ case PdfDiagramLegendLocation.Top:
+ chart.TopArea.AddLegend();
+ break;
+ case PdfDiagramLegendLocation.Bottom:
+ chart.BottomArea.AddLegend();
+ break;
+ }
+ }
+ }
+}
diff --git a/CheckedListBoxLibrary/MyUserControls.csproj b/CheckedListBoxLibrary/MyUserControls.csproj
index 060aa1c..09a8f03 100644
--- a/CheckedListBoxLibrary/MyUserControls.csproj
+++ b/CheckedListBoxLibrary/MyUserControls.csproj
@@ -7,4 +7,12 @@
enable
+
+
+
+
+
+
+
+
diff --git a/WinFormsApp1/Documents/PdfWithImage.pdf b/WinFormsApp1/Documents/PdfWithImage.pdf
new file mode 100644
index 0000000..0910b02
Binary files /dev/null and b/WinFormsApp1/Documents/PdfWithImage.pdf differ
diff --git a/WinFormsApp1/Form1.Designer.cs b/WinFormsApp1/Form1.Designer.cs
index db87abe..21cdb4c 100644
--- a/WinFormsApp1/Form1.Designer.cs
+++ b/WinFormsApp1/Form1.Designer.cs
@@ -35,11 +35,15 @@
testComponent1 = new MyUserControls.Components.testComponent(components);
buttonSave = new Button();
richTextBoxText = new RichTextBox();
+ pdfImage = new MyUserControls.Components.PdfImage.PdfImage(components);
+ listBoxImages = new ListBox();
+ chooseImage = new Button();
+ createPdfImages = new Button();
SuspendLayout();
//
// smartCheckedListBox1
//
- smartCheckedListBox1.Location = new Point(37, 12);
+ smartCheckedListBox1.Location = new Point(12, 12);
smartCheckedListBox1.Name = "smartCheckedListBox1";
smartCheckedListBox1.SelectedValue = "";
smartCheckedListBox1.Size = new Size(241, 182);
@@ -47,23 +51,23 @@
//
// smartTextBox1
//
- smartTextBox1.Location = new Point(12, 318);
+ smartTextBox1.Location = new Point(0, 329);
smartTextBox1.MaxLength = 100;
smartTextBox1.MinLength = 0;
smartTextBox1.Name = "smartTextBox1";
- smartTextBox1.Size = new Size(312, 98);
+ smartTextBox1.Size = new Size(295, 98);
smartTextBox1.TabIndex = 2;
//
// hierarchicalTreeView
//
- hierarchicalTreeView.Location = new Point(12, 163);
+ hierarchicalTreeView.Location = new Point(0, 162);
hierarchicalTreeView.Name = "hierarchicalTreeView";
hierarchicalTreeView.Size = new Size(266, 174);
hierarchicalTreeView.TabIndex = 3;
//
// buttonSave
//
- buttonSave.Location = new Point(337, 162);
+ buttonSave.Location = new Point(337, 111);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(168, 32);
buttonSave.TabIndex = 4;
@@ -75,15 +79,47 @@
//
richTextBoxText.Location = new Point(337, 26);
richTextBoxText.Name = "richTextBoxText";
- richTextBoxText.Size = new Size(168, 130);
+ richTextBoxText.Size = new Size(168, 70);
richTextBoxText.TabIndex = 5;
richTextBoxText.Text = "";
//
+ // listBoxImages
+ //
+ listBoxImages.FormattingEnabled = true;
+ listBoxImages.ItemHeight = 20;
+ listBoxImages.Location = new Point(330, 162);
+ listBoxImages.Name = "listBoxImages";
+ listBoxImages.Size = new Size(184, 64);
+ listBoxImages.TabIndex = 6;
+ //
+ // chooseImage
+ //
+ chooseImage.Location = new Point(331, 232);
+ chooseImage.Name = "chooseImage";
+ chooseImage.Size = new Size(183, 27);
+ chooseImage.TabIndex = 7;
+ chooseImage.Text = "Добавить картинку";
+ chooseImage.UseVisualStyleBackColor = true;
+ chooseImage.Click += chooseImage_Click;
+ //
+ // createPdfImages
+ //
+ createPdfImages.Location = new Point(330, 265);
+ createPdfImages.Name = "createPdfImages";
+ createPdfImages.Size = new Size(184, 29);
+ createPdfImages.TabIndex = 8;
+ createPdfImages.Text = "Создать пдф";
+ createPdfImages.UseVisualStyleBackColor = true;
+ createPdfImages.Click += createPdfImages_Click;
+ //
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(1120, 450);
+ ClientSize = new Size(1120, 474);
+ Controls.Add(createPdfImages);
+ Controls.Add(chooseImage);
+ Controls.Add(listBoxImages);
Controls.Add(richTextBoxText);
Controls.Add(buttonSave);
Controls.Add(hierarchicalTreeView);
@@ -102,5 +138,9 @@
private MyUserControls.Components.testComponent testComponent1;
private Button buttonSave;
private RichTextBox richTextBoxText;
+ private MyUserControls.Components.PdfImage.PdfImage pdfImage;
+ private ListBox listBoxImages;
+ private Button chooseImage;
+ private Button createPdfImages;
}
}
diff --git a/WinFormsApp1/Form1.cs b/WinFormsApp1/Form1.cs
index dcb2610..6535228 100644
--- a/WinFormsApp1/Form1.cs
+++ b/WinFormsApp1/Form1.cs
@@ -1,10 +1,14 @@
using MyUserControls;
+using MyUserControls.Components.office_package.Implements;
+using MyUserControls.Components.PdfImage;
using System.ComponentModel;
+
namespace WinFormsApp1
{
public partial class Form1 : Form
{
+ private List selectedImages = new List();
public Form1()
{
InitializeComponent();
@@ -70,5 +74,62 @@ namespace WinFormsApp1
}
}
+
+ private void chooseImage_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ using OpenFileDialog openFileDialog = new OpenFileDialog
+ {
+ Multiselect = true,
+ Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp"
+ };
+ if (openFileDialog.ShowDialog() == DialogResult.OK)
+ {
+ selectedImages.Clear();
+ listBoxImages.Items.Clear();
+ foreach (string filePath in openFileDialog.FileNames)
+ {
+ selectedImages.Add(File.ReadAllBytes(filePath));
+ listBoxImages.Items.Add(Path.GetFileName(filePath));
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
+ private void createPdfImages_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ if (selectedImages.Count == 0)
+ {
+ MessageBox.Show(" ", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+
+ string currentDirectory = Directory.GetCurrentDirectory();
+
+ string filePath = Path.Combine(currentDirectory, @"..\..\..\Documents\PdfWithImage.pdf");
+
+ var info = new PdfImageInfo
+ {
+ FileName = filePath,
+ Title = "title",
+ Images = selectedImages
+ };
+ pdfImage.CreatePdf(info);
+ MessageBox.Show(" ", " ", MessageBoxButtons.OK, MessageBoxIcon.Information);
+
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ }
+
}
}
diff --git a/WinFormsApp1/Form1.resx b/WinFormsApp1/Form1.resx
index 29292b5..e213689 100644
--- a/WinFormsApp1/Form1.resx
+++ b/WinFormsApp1/Form1.resx
@@ -120,4 +120,7 @@
17, 17
+
+ 183, 17
+
\ No newline at end of file
diff --git a/WinFormsApp1/WinFormsApp1.csproj b/WinFormsApp1/WinFormsApp1.csproj
index f3803f8..87d28fe 100644
--- a/WinFormsApp1/WinFormsApp1.csproj
+++ b/WinFormsApp1/WinFormsApp1.csproj
@@ -12,4 +12,8 @@
+
+
+
+
\ No newline at end of file