diff --git a/Components/Components.csproj b/Components/Components.csproj index 3b33f9a..d501559 100644 --- a/Components/Components.csproj +++ b/Components/Components.csproj @@ -8,7 +8,6 @@ - diff --git a/Components/Nonvisual/UserControlTableDocument.Designer.cs b/Components/Nonvisual/UserControlTableDocument.Designer.cs deleted file mode 100644 index 525ee88..0000000 --- a/Components/Nonvisual/UserControlTableDocument.Designer.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace Components -{ - partial class UserControlTableDocument - { - /// - /// Обязательная переменная конструктора. - /// - 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/Components/Nonvisual/UserControlTableDocument.cs b/Components/Nonvisual/UserControlTableDocument.cs deleted file mode 100644 index a1ce594..0000000 --- a/Components/Nonvisual/UserControlTableDocument.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Components -{ - public partial class UserControlTableDocument : Component - { - public UserControlTableDocument() - { - InitializeComponent(); - } - - public UserControlTableDocument(IContainer container) - { - container.Add(this); - - InitializeComponent(); - } - - public void SaveToDocument(string filePath, string header, List tables) - { - if (string.IsNullOrEmpty(filePath)) throw new ArgumentNullException("Empty string instead of path to file"); - if (string.IsNullOrEmpty(header)) throw new ArgumentNullException("Header string is empty"); - if (tables.Count == 0) throw new ArgumentNullException("Table list is empty"); - - SaveToPdf saver = new SaveToPdf(); - - saver.CreateDoc(filePath, header, tables); - } - } -} diff --git a/Components/SaveToPdf.cs b/Components/SaveToPdf.cs deleted file mode 100644 index 7ac3f44..0000000 --- a/Components/SaveToPdf.cs +++ /dev/null @@ -1,117 +0,0 @@ -using MigraDoc.DocumentObjectModel; -using MigraDoc.DocumentObjectModel.Tables; -using MigraDoc.Rendering; -using Components.SaveToPdfHelpers; - -namespace Components -{ - internal class SaveToPdf - { - private Document? _document; - private Section? _section; - private Table? _table; - public void CreateDoc(string title, string path, List tables) - { - _document = new Document(); - DefineStyles(_document); - _section = _document.AddSection(); - - CreateParagraph(new PdfParagraph - { - Text = title, - Style = "NormalTitle", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - - foreach (var table in tables) - { - if (table.Length == 0) continue; - - CreateTable(Enumerable.Repeat("3cm", table[0].Length).ToList()); - - foreach (var row in table) - { - CreateRow(new PdfRowParameters - { - Texts = row.ToList(), - Style = "Normal", - ParagraphAlignment = PdfParagraphAlignmentType.Left - }); - } - - CreateParagraph(new PdfParagraph()); - } - - var renderer = new PdfDocumentRenderer(true) - { - Document = _document - }; - renderer.RenderDocument(); - renderer.PdfDocument.Save(path); - } - 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; - } - protected void CreateParagraph(PdfParagraph pdfParagraph) - { - if (_section == null) - { - return; - } - var paragraph = _section.AddParagraph(pdfParagraph.Text); - paragraph.Format.SpaceAfter = "1cm"; - paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment); - paragraph.Style = pdfParagraph.Style; - } - protected void CreateTable(List columns) - { - if (_document == null) - { - return; - } - _table = _document.LastSection.AddTable(); - foreach (var elem in columns) - { - _table.AddColumn(elem); - } - } - protected void CreateRow(PdfRowParameters rowParameters) - { - if (_table == null) - { - return; - } - var row = _table.AddRow(); - for (int i = 0; i < rowParameters.Texts.Count; ++i) - { - row.Cells[i].AddParagraph(rowParameters.Texts[i]); - if (!string.IsNullOrEmpty(rowParameters.Style)) - { - row.Cells[i].Style = rowParameters.Style; - } - Unit borderWidth = 0.5; - row.Cells[i].Borders.Left.Width = borderWidth; - row.Cells[i].Borders.Right.Width = borderWidth; - row.Cells[i].Borders.Top.Width = borderWidth; - row.Cells[i].Borders.Bottom.Width = borderWidth; - row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment); - row.Cells[i].VerticalAlignment = VerticalAlignment.Center; - } - } - } -} diff --git a/Components/SaveToPdfHelpers/PdfParagraph.cs b/Components/SaveToPdfHelpers/PdfParagraph.cs deleted file mode 100644 index ac1f2ab..0000000 --- a/Components/SaveToPdfHelpers/PdfParagraph.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Components.SaveToPdfHelpers -{ - 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/Components/SaveToPdfHelpers/PdfParagraphAlignmentType.cs b/Components/SaveToPdfHelpers/PdfParagraphAlignmentType.cs deleted file mode 100644 index bde3c13..0000000 --- a/Components/SaveToPdfHelpers/PdfParagraphAlignmentType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Components.SaveToPdfHelpers -{ - public enum PdfParagraphAlignmentType - { - Center, - Left, - Right - } -} diff --git a/Components/SaveToPdfHelpers/PdfRowParameters.cs b/Components/SaveToPdfHelpers/PdfRowParameters.cs deleted file mode 100644 index 76435a6..0000000 --- a/Components/SaveToPdfHelpers/PdfRowParameters.cs +++ /dev/null @@ -1,10 +0,0 @@ - -namespace Components.SaveToPdfHelpers -{ - public class PdfRowParameters - { - public List Texts { get; set; } = new(); - public string Style { get; set; } = string.Empty; - public PdfParagraphAlignmentType ParagraphAlignment { get; set; } - } -} diff --git a/ComponentsProgramming.sln b/ComponentsProgramming.sln index af87b6f..b8d9e2a 100644 --- a/ComponentsProgramming.sln +++ b/ComponentsProgramming.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 17.9.34728.123 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Components", "Components\Components.csproj", "{260D3E8C-3599-49F1-BF42-64A92DD0FB62}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestingForm", "TestingForm\TestingForm.csproj", "{4F4882A1-4DF1-4BC3-B022-9935E70E5552}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -17,10 +15,6 @@ Global {260D3E8C-3599-49F1-BF42-64A92DD0FB62}.Debug|Any CPU.Build.0 = Debug|Any CPU {260D3E8C-3599-49F1-BF42-64A92DD0FB62}.Release|Any CPU.ActiveCfg = Release|Any CPU {260D3E8C-3599-49F1-BF42-64A92DD0FB62}.Release|Any CPU.Build.0 = Release|Any CPU - {4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4F4882A1-4DF1-4BC3-B022-9935E70E5552}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/TestingForm/FormMain.Designer.cs b/TestingForm/FormMain.Designer.cs deleted file mode 100644 index 05ec2ff..0000000 --- a/TestingForm/FormMain.Designer.cs +++ /dev/null @@ -1,45 +0,0 @@ -namespace TestingForm -{ - partial class FormMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - SuspendLayout(); - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Name = "FormMain"; - Text = "cB"; - ResumeLayout(false); - } - - #endregion - } -} diff --git a/TestingForm/FormMain.cs b/TestingForm/FormMain.cs deleted file mode 100644 index 80839c4..0000000 --- a/TestingForm/FormMain.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TestingForm -{ - public partial class FormMain : Form - { - public FormMain() - { - InitializeComponent(); - } - } -} diff --git a/TestingForm/FormMain.resx b/TestingForm/FormMain.resx deleted file mode 100644 index af32865..0000000 --- a/TestingForm/FormMain.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/TestingForm/Program.cs b/TestingForm/Program.cs deleted file mode 100644 index 47a2336..0000000 --- a/TestingForm/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace TestingForm -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. - ApplicationConfiguration.Initialize(); - Application.Run(new FormMain()); - } - } -} \ No newline at end of file diff --git a/TestingForm/TestingForm.csproj b/TestingForm/TestingForm.csproj deleted file mode 100644 index 5a248b2..0000000 --- a/TestingForm/TestingForm.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - WinExe - net7.0-windows - enable - true - enable - - - - - - - \ No newline at end of file