From 105c89cda02fb086b4b98f17f4af6f72fa723ae6 Mon Sep 17 00:00:00 2001 From: abazov73 <92822431+abazov73@users.noreply.github.com> Date: Thu, 30 Nov 2023 00:51:17 +0400 Subject: [PATCH] Create PDF doc --- AbazovApp/AccountsApp/AccountsApp.csproj | 1 + AbazovApp/AccountsApp/FormMain.Designer.cs | 3 +++ AbazovApp/AccountsApp/FormMain.cs | 24 ++++++++++++++++++++++ AbazovApp/AccountsApp/FormMain.resx | 5 ++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/AbazovApp/AccountsApp/AccountsApp.csproj b/AbazovApp/AccountsApp/AccountsApp.csproj index 935acdf..48b9f15 100644 --- a/AbazovApp/AccountsApp/AccountsApp.csproj +++ b/AbazovApp/AccountsApp/AccountsApp.csproj @@ -16,6 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/AbazovApp/AccountsApp/FormMain.Designer.cs b/AbazovApp/AccountsApp/FormMain.Designer.cs index 332cf77..ba49e36 100644 --- a/AbazovApp/AccountsApp/FormMain.Designer.cs +++ b/AbazovApp/AccountsApp/FormMain.Designer.cs @@ -41,6 +41,7 @@ this.интересыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.controlDataTable = new ControlsLibraryNet60.Data.ControlDataTableTable(); this.excelImagesComponent = new AbazovViewComponents.LogicalComponents.ExcelImagesComponent(this.components); + this.componentDocumentWithChartBarPdf = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf(this.components); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // @@ -122,6 +123,7 @@ this.документСДиаграммойToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); this.документСДиаграммойToolStripMenuItem.Size = new System.Drawing.Size(313, 26); this.документСДиаграммойToolStripMenuItem.Text = "Документ с диаграммой"; + this.документСДиаграммойToolStripMenuItem.Click += new System.EventHandler(this.документСДиаграммойToolStripMenuItem_Click); // // интересыToolStripMenuItem // @@ -171,5 +173,6 @@ private ToolStripMenuItem интересыToolStripMenuItem; private ControlsLibraryNet60.Data.ControlDataTableTable controlDataTable; private AbazovViewComponents.LogicalComponents.ExcelImagesComponent excelImagesComponent; + private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartBarPdf componentDocumentWithChartBarPdf; } } \ No newline at end of file diff --git a/AbazovApp/AccountsApp/FormMain.cs b/AbazovApp/AccountsApp/FormMain.cs index d7fd573..123055c 100644 --- a/AbazovApp/AccountsApp/FormMain.cs +++ b/AbazovApp/AccountsApp/FormMain.cs @@ -2,6 +2,7 @@ using AccountsContracts.BindingModels; using AccountsContracts.BusinessLogicContracts; using AccountsContracts.ViewModels; +using ComponentsLibraryNet60.Models; using ControlsLibraryNet60.Core; using ControlsLibraryNet60.Models; using System; @@ -30,6 +31,7 @@ namespace AccountsApp new DataTableColumnConfig { ColumnHeader = "Выбранный интерес", PropertyName = "InterestName", Visible = true, Width = 200}, new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200}, }); + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); } private void создатьToolStripMenuItem_Click(object sender, EventArgs e) @@ -102,5 +104,27 @@ namespace AccountsApp string path = AppDomain.CurrentDomain.BaseDirectory + "Аватары.xlsx"; if (excelImagesComponent.createWithImages(new ExcelImageInfo(path, "Аватары", avatars.ToArray()))) MessageBox.Show("Документ создан"); } + + private void документСДиаграммойToolStripMenuItem_Click(object sender, EventArgs e) + { + string path = AppDomain.CurrentDomain.BaseDirectory + "Интересы.pdf"; + Dictionary> data = new Dictionary>(); + + data = _logic + .ReadList(null) + .GroupBy(x => x.InterestName) + .ToDictionary(x => x.Key, x => new List<(int, double)> { (0, x.Count())}); + + componentDocumentWithChartBarPdf.CreateDoc(new ComponentDocumentWithChartConfig + { + Header = "Интересы", + FilePath = path, + ChartTitle = "Интересы", + LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom, + Data = data, + }); + + MessageBox.Show("Успех"); + } } } diff --git a/AbazovApp/AccountsApp/FormMain.resx b/AbazovApp/AccountsApp/FormMain.resx index e9680e0..f963f1f 100644 --- a/AbazovApp/AccountsApp/FormMain.resx +++ b/AbazovApp/AccountsApp/FormMain.resx @@ -63,7 +63,10 @@ 152, 0 + + 152, 17 + - 25 + 54 \ No newline at end of file