Create PDF doc

This commit is contained in:
abazov73 2023-11-30 00:51:17 +04:00
parent 93ffc24a90
commit 105c89cda0
4 changed files with 32 additions and 1 deletions

View File

@ -16,6 +16,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NevaevaLibrary" Version="1.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -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;
}
}

View File

@ -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<string, List<(int, double)>> data = new Dictionary<string, List<(int, double)>>();
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("Успех");
}
}
}

View File

@ -63,7 +63,10 @@
<metadata name="excelImagesComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 0</value>
</metadata>
<metadata name="componentDocumentWithChartBarPdf.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>152, 17</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
<value>54</value>
</metadata>
</root>