Приняты 1+2

This commit is contained in:
Andrey 2024-09-20 10:29:21 +03:00
parent 9ee931a747
commit 361c46c4b6
18 changed files with 717 additions and 33 deletions

View File

@ -7,4 +7,9 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PDFsharp-MigraDoc" Version="6.1.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.Components.NonVisualComponents.HelperModels
{
public class DataForImage
{
public DataForImage(string filepath, string header, string[] imagepaths)
{
this.filepath = filepath;
this.header = header;
this.imagepaths = imagepaths;
}
public string filepath;
public string header;
public string[] imagepaths;
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.Components.NonVisualComponents.HelperModels
{
public class DataForPieChart
{
public string FilePath = string.Empty;
public string DocumentTitle = string.Empty;//заголовок документа
public string ChartTitle = string.Empty;//заголовок диаграммы
public DiagramLegendEnum diagLegend;
public string LegendName = string.Empty;
public List<(double, string)> Items;
public DataForPieChart(string filePath, string documentTitle, string charttitle, DiagramLegendEnum diagLegend, string legendName, List<(double, string)> items)
{
FilePath = filePath;
DocumentTitle = documentTitle;
ChartTitle = charttitle;
this.diagLegend = diagLegend;
LegendName = legendName;
Items = items;
}
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.Components.NonVisualComponents.HelperModels
{
public class DataForTable<T>
{
public string FilePath = string.Empty;
public string DocumentTitle = string.Empty; //заголовок документа
public List<int> Heights; // высота строк
public List<(int, int)> Merges; // информаци о объединении ячеек
public List<(string props, string heads)> Headers; //заголовки шапки таблицы
public List<T> Data;
public DataForTable(string filePath, string documentTitle, List<int> heights, List<(int, int)> merges, List<(string, string)> headers, List<T> data)
{
FilePath = filePath;
DocumentTitle = documentTitle;
Heights = heights;
Merges = merges;
Headers = headers;
Data = data;
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.Components.NonVisualComponents.HelperModels
{
public enum DiagramLegendEnum
{
Top = 0,
Bottom = 1,
Right = 2,
Left = 3,
}
}

View File

@ -0,0 +1,36 @@
namespace Components.Components.NonVisualComponents
{
partial class PdfImage
{
/// <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
}
}

View File

@ -0,0 +1,75 @@
using Components.Components.NonVisualComponents.HelperModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace Components.Components.NonVisualComponents
{
public partial class PdfImage : Component
{
public PdfImage()
{
InitializeComponent();
}
public PdfImage(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public bool CreatePdfDoc(DataForImage dataForImage)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
CheckFileExsists(dataForImage);
// создание документа
Document _document = new Document();
var style = _document.Styles["Normal"];
style.Font.Name = "Arial";
style.Font.Size = 25;
style = _document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Bold = true;
//добавление заголовка
var section = _document.AddSection();
var paragraph = section.AddParagraph(dataForImage.header);
paragraph.Format.Alignment = ParagraphAlignment.Center;
paragraph.Format.SpaceAfter = "2cm";
//добавление изображений
foreach (string path in dataForImage.imagepaths)
if (File.Exists(path)) section.AddImage(path);
//сохранение документа
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(dataForImage.filepath);
return true;
}
private void CheckFileExsists(DataForImage dataForImage)
{
if (string.IsNullOrEmpty(dataForImage.filepath) || string.IsNullOrEmpty(dataForImage.header) || dataForImage.imagepaths.Length == 0)
{
throw new ArgumentNullException();
}
if (!File.Exists(dataForImage.filepath))
{
throw new FileNotFoundException(dataForImage.filepath);
}
}
}
}

View File

@ -0,0 +1,36 @@
namespace Components.Components.NonVisualComponents
{
partial class PdfPieChart
{
/// <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
}
}

View File

@ -0,0 +1,86 @@
using Components.Components.NonVisualComponents.HelperModels;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes.Charts;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.Components.NonVisualComponents
{
public partial class PdfPieChart : Component
{
public PdfPieChart()
{
InitializeComponent();
}
public PdfPieChart(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public bool CreatePieChart(DataForPieChart dataForPDFPie)
{
// проверки
if (string.IsNullOrEmpty(dataForPDFPie.FilePath) || string.IsNullOrEmpty(dataForPDFPie.DocumentTitle) || string.IsNullOrEmpty(dataForPDFPie.ChartTitle)
|| string.IsNullOrEmpty(dataForPDFPie.LegendName)
|| dataForPDFPie.Items.Count == 0) throw new ArgumentException("Недостаточно данных");
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Document _document = new Document();
var section = _document.AddSection();
var paragraph = section.AddParagraph(dataForPDFPie.DocumentTitle);
paragraph.Format.Alignment = ParagraphAlignment.Center;
paragraph.Format.SpaceAfter = "2cm";
Chart chart = section.AddChart(ChartType.Pie2D);
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
chart.HeaderArea.AddParagraph(dataForPDFPie.ChartTitle); // заголовок диаграммы
Series series = chart.SeriesCollection.AddSeries();
series.Name = dataForPDFPie.LegendName; // название сериии
XSeries xseries = chart.XValues.AddXSeries();
foreach ((double, string) el in dataForPDFPie.Items) // заполнение серии
{
series.Add(el.Item1);
xseries.Add(el.Item2);
}
switch (dataForPDFPie.diagLegend) // позиция легенды
{
case DiagramLegendEnum.Top:
chart.TopArea.AddLegend();
break;
case DiagramLegendEnum.Bottom:
chart.BottomArea.AddLegend();
break;
case DiagramLegendEnum.Right:
chart.RightArea.AddLegend();
break;
case DiagramLegendEnum.Left:
chart.LeftArea.AddLegend();
break;
}
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(dataForPDFPie.FilePath);
return true;
}
}
}

View File

@ -0,0 +1,36 @@
namespace Components.Components.NonVisualComponents
{
partial class PdfTable
{
/// <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
}
}

View File

@ -0,0 +1,178 @@
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.DocumentObjectModel;
using MigraDoc.Rendering;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Components.Components.NonVisualComponents.HelperModels;
namespace Components.Components.NonVisualComponents
{
public partial class PdfTable : Component
{
public PdfTable()
{
InitializeComponent();
}
public PdfTable(IContainer container)
{
container.Add(this);
InitializeComponent();
}
public bool createTable<T>(DataForTable<T> dataForPDF)
{
//проверки
if (dataForPDF.Merges.Count == 0 || dataForPDF.Heights.Count == 0 || dataForPDF.Headers.Count == 0
|| dataForPDF.Data.Count == 0 || string.IsNullOrEmpty(dataForPDF.FilePath)
|| string.IsNullOrEmpty(dataForPDF.DocumentTitle)) throw new ArgumentException("Недостаточно данных");
int[] cellsArray = new int[dataForPDF.Heights.Count];
foreach (var merge in dataForPDF.Merges)
{
if (merge.Item1 >= merge.Item2) throw new ArgumentException("Неправильно заполнены объединения строк");
for (int i = merge.Item1; i < merge.Item2; i++)
{
cellsArray[i]++;
}
}
foreach (int cell in cellsArray)
{
if (cell > 1) throw new ArgumentException("Объединения заходят друг на друга");
}
foreach ((string, string) el in dataForPDF.Headers)
if (string.IsNullOrEmpty(el.Item2)) throw new ArgumentException("Элементы шапки не могут быть пустыми");
//создание документа
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Document _document = new Document();
var style = _document.Styles["Normal"];
style = _document.Styles.AddStyle("NormalTitle", "Normal");
style.Font.Name = "Arial";
style.Font.Size = 25;
style.Font.Bold = true;
style = _document.Styles.AddStyle("Table", "Normal");
style.Font.Name = "Times New Roman";
style.Font.Size = 12;
//добавление заголовка
var section = _document.AddSection();
var paragraph = section.AddParagraph(dataForPDF.DocumentTitle);
paragraph.Format.Alignment = ParagraphAlignment.Center;
paragraph.Format.SpaceAfter = "2cm";
paragraph.Style = "NormalTitle";
//добавление таблицы
Table table = section.AddTable();
table.Style = "Table";
table.Borders.Width = 0.25;
Column column;
for (int i = 0; i < dataForPDF.Data.Count + 2; i++)
{
column = table.AddColumn();
column.Format.Alignment = ParagraphAlignment.Center;
}
// создание шапки и заполнение контентом
int mergeRange = 0; //размерность слияния
int mergeIndex = 0; //стартовый индекс начала слияния
Row row;
for (int i = 0; i < dataForPDF.Headers.Count; i++)
{
//если элемент шапки группируются по строкам
if (dataForPDF.Merges.Select(x => x.Item1).Contains(mergeIndex))
{
mergeRange = dataForPDF.Merges.Find(x => x.Item1 == mergeIndex).Item2 - mergeIndex;
mergeIndex = dataForPDF.Merges.Find(x => x.Item1 == mergeIndex).Item2 + 1;
//стилизация ячейки. в этом блоке кода (до цикла) создаётся объединяющая ячейка
row = table.AddRow();
row.Height = dataForPDF.Heights[i];
row.Format.Alignment = ParagraphAlignment.Center;
row.Format.Font.Bold = true;
row.Cells[0].AddParagraph(dataForPDF.Headers[i].Item2);
row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
row.Cells[0].MergeDown = mergeRange;
//с этого места создаются дочерние ячейки
for (int k = 0; k < mergeRange; k++)
{
i++;
row.Cells[1].AddParagraph(dataForPDF.Headers[i].Item2);
AddTheContent<T>(dataForPDF.Data, table, dataForPDF.Headers[i].Item1, row.Index, 2);
row.Cells[1].VerticalAlignment = VerticalAlignment.Center;
row = table.AddRow();
row.Height = dataForPDF.Heights[i];
row.Format.Font.Bold = true;
row.Format.Alignment = ParagraphAlignment.Center;
}
i++;
row.Cells[1].AddParagraph(dataForPDF.Headers[i].Item2);
AddTheContent<T>(dataForPDF.Data, table, dataForPDF.Headers[i].Item1, row.Index, 2);
row.Cells[1].VerticalAlignment = VerticalAlignment.Center;
}
else //если элемент шапки не группируется по строкам
{
//стилизация ячейки
row = table.AddRow();
row.Height = dataForPDF.Heights[i];
row.Format.Font.Bold = true;
row.Format.Alignment = ParagraphAlignment.Center;
row.Cells[0].AddParagraph(dataForPDF.Headers[i].Item2);
row.Cells[0].VerticalAlignment = VerticalAlignment.Center;
row.Cells[0].MergeRight = 1;
AddTheContent<T>(dataForPDF.Data, table, dataForPDF.Headers[i].Item1, row.Index, 2);
mergeIndex++;
}
}
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
renderer.Document = _document;
renderer.RenderDocument();
renderer.PdfDocument.Save(dataForPDF.FilePath);
return true;
}
//метод заполнения таблицы контентом, заполнение происходит построчно.
public void AddTheContent<T>(List<T> items, Table table, string header, int row_index, int cell_index)
{
foreach (Row r in table.Rows)
{
for (int i = 0; i < items.Count; i++)
{
if (r.Index == row_index && row_index == 0) r.Cells[cell_index + i].AddParagraph((i + 1).ToString());
else if (row_index != 0 && r.Index == row_index)
{
T item = items[i];
var type = typeof(T);
var fields = type.GetFields();
var field = fields.FirstOrDefault(x => x.Name.Equals(header));
r.Cells[cell_index + i].AddParagraph(field.GetValue(item).ToString());
r.Cells[cell_index + i].VerticalAlignment = VerticalAlignment.Center;
}
}
}
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Components.Components.VisualComponents.Classes
{
public class CharacterInfo
{
public string Age;
public string Name;
public string AKA;
public string Height;
public string Weight;
public CharacterInfo(string age, string name, string aka, string height, string weight)
{
Age = age;
Name = name;
AKA = aka;
Height = height;
Weight = weight;
}
}
}

View File

@ -63,15 +63,8 @@ namespace Components
{
get
{
if (checkedListBox.Items.Count == 0)
{
return "";
}
if (checkedListBox.Items.Count == null)
{
return "";
}
return checkedListBox.SelectedItem.ToString()!;
return checkedListBox.SelectedItem?.ToString() ?? string.Empty;
}
set
{

View File

@ -52,14 +52,8 @@ namespace Components.Components.VisualComponents
}
}
/*
private void textBox_Enter(object sender, EventArgs e)
{
ToolTip tt = new ToolTip();
tt.Show(examp, textBox, 30, -20, 2000);
}*/
public string? TextBoxValue
public string TextBoxValue
{
get
{
@ -81,7 +75,6 @@ namespace Components.Components.VisualComponents
if (value.Length >= MinValue && value.Length <= MaxValue)
{
textBox.Text = value;
_changeEvent?.Invoke(this, EventArgs.Empty);
}
}
}

View File

@ -14,42 +14,34 @@ namespace Components.Components.VisualComponents
public partial class UserTreeView : UserControl
{
private List<string> hierarchy;
private Dictionary<string, bool> forcedNewBranch;
public UserTreeView()
{
InitializeComponent();
hierarchy = new List<string>();
forcedNewBranch = new Dictionary<string, bool>();
}
public void SetHierarchy(List<string> hierarchy, Dictionary<string, bool> forcedNewBranch)
public void SetHierarchy(List<string> hierarchy)
{
this.hierarchy = hierarchy;
this.forcedNewBranch = forcedNewBranch;
}
public void AddObjectToTree<T>(T obj, string stopAtProperty)
public void AddObjectToTree<T>(T obj)
{
TreeNode currentNode = treeView.Nodes.Count > 0 ? treeView.Nodes[0] : treeView.Nodes.Add("");
foreach (var property in hierarchy)
{
var value = obj.GetType().GetProperty(property).GetValue(obj, null).ToString();
bool createNewBranch = forcedNewBranch.ContainsKey(property) && forcedNewBranch[property];
var childNode = currentNode.Nodes.Cast<TreeNode>().FirstOrDefault(n => n.Text == value);
if (childNode == null || createNewBranch)
if (childNode == null)
{
childNode = currentNode.Nodes.Add(value);
}
currentNode = childNode;
if (property == stopAtProperty)
{
break;
}
}
}

View File

@ -28,9 +28,17 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
userCheckedListBox1 = new Components.UserCheckedListBox();
userTextBox1 = new Components.Components.VisualComponents.UserTextBox();
userTreeView1 = new Components.Components.VisualComponents.UserTreeView();
pdfTable1 = new Components.Components.NonVisualComponents.PdfTable(components);
pdfPieChart1 = new Components.Components.NonVisualComponents.PdfPieChart(components);
pdfImage1 = new Components.Components.NonVisualComponents.PdfImage(components);
PdfImage = new Button();
PdfTable = new Button();
PdfChart = new Button();
openFileDialog1 = new OpenFileDialog();
SuspendLayout();
//
// userCheckedListBox1
@ -49,20 +57,58 @@
userTextBox1.Name = "userTextBox1";
userTextBox1.Size = new Size(396, 76);
userTextBox1.TabIndex = 1;
userTextBox1.TextBoxValue = null;
//
// userTreeView1
//
userTreeView1.Location = new Point(225, 84);
userTreeView1.Name = "userTreeView1";
userTreeView1.SelectedNodeIndex = -1;
userTreeView1.Size = new Size(550, 329);
userTreeView1.TabIndex = 2;
//
// PdfImage
//
PdfImage.Location = new Point(31, 453);
PdfImage.Name = "PdfImage";
PdfImage.Size = new Size(201, 29);
PdfImage.TabIndex = 3;
PdfImage.Text = "Create PdfImage";
PdfImage.UseVisualStyleBackColor = true;
PdfImage.Click += PdfImage_Click;
//
// PdfTable
//
PdfTable.Location = new Point(263, 453);
PdfTable.Name = "PdfTable";
PdfTable.Size = new Size(201, 29);
PdfTable.TabIndex = 4;
PdfTable.Text = "Create PdfTable";
PdfTable.UseVisualStyleBackColor = true;
PdfTable.Click += PdfTable_Click;
//
// PdfChart
//
PdfChart.Location = new Point(501, 453);
PdfChart.Name = "PdfChart";
PdfChart.Size = new Size(180, 29);
PdfChart.TabIndex = 5;
PdfChart.Text = "Create PdfChart";
PdfChart.UseVisualStyleBackColor = true;
PdfChart.Click += PdfChart_Click;
//
// openFileDialog1
//
openFileDialog1.FileName = "openFileDialog1";
openFileDialog1.Multiselect = true;
//
// Form1
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(1005, 490);
Controls.Add(PdfChart);
Controls.Add(PdfTable);
Controls.Add(PdfImage);
Controls.Add(userTreeView1);
Controls.Add(userTextBox1);
Controls.Add(userCheckedListBox1);
@ -76,5 +122,12 @@
private Components.UserCheckedListBox userCheckedListBox1;
private Components.Components.VisualComponents.UserTextBox userTextBox1;
private Components.Components.VisualComponents.UserTreeView userTreeView1;
private Components.Components.NonVisualComponents.PdfTable pdfTable1;
private Components.Components.NonVisualComponents.PdfPieChart pdfPieChart1;
private Components.Components.NonVisualComponents.PdfImage pdfImage1;
private Button PdfImage;
private Button PdfTable;
private Button PdfChart;
private OpenFileDialog openFileDialog1;
}
}

View File

@ -1,4 +1,7 @@
using Components.Components.NonVisualComponents.HelperModels;
using Components.Components.VisualComponents.Classes;
using System.Windows.Forms;
using static System.Reflection.Metadata.BlobBuilder;
namespace TestForm
{
@ -16,8 +19,7 @@ namespace TestForm
userTextBox1.MaxValue = 15;
var hierarchy = new List<string> { "Race", "Class", "FullName" };
var forcedNewBranch = new Dictionary<string, bool> { { "FullName", true } };
userTreeView1.SetHierarchy(hierarchy, forcedNewBranch);
userTreeView1.SetHierarchy(hierarchy);
var characters = new List<Character>() {
new Character { Race = "Dwarf", Class = "Warrior", FullName = "Gimli" },
@ -28,7 +30,71 @@ namespace TestForm
foreach (var character in characters)
{
userTreeView1.AddObjectToTree(character, hierarchy.Last());
userTreeView1.AddObjectToTree(character);
}
}
private void PdfImage_Click(object sender, EventArgs e)
{
var res = openFileDialog1.ShowDialog(this);
if (res != DialogResult.OK) return;
var files = openFileDialog1.FileNames;
openFileDialog1.Dispose();
string path = "C:\\testImage.pdf";
MessageBox.Show(path);
if (pdfImage1.CreatePdfDoc(new DataForImage(path, "Images", files))) MessageBox.Show("Success!");
else MessageBox.Show("Error");
}
private void PdfTable_Click(object sender, EventArgs e)
{
List<CharacterInfo> charactersinfo = new List<CharacterInfo>()
{
new CharacterInfo("139", "Gimli", "Elf-friend", "4'9", "196 lbs"),
new CharacterInfo("2931", "Legolas", "Greenleaf", "6'0", "150 lbs"),
new CharacterInfo("87", "Aragorn", "Strider", "6'6", "210 lbs"),
new CharacterInfo("41", "Boromir", "Captain of Gondor", "6'4", "225 lbs")
};
List<(int, int)> merges = new List<(int, int)>();
merges.Add((2, 3));
List<int> heights = new List<int> { 10, 40, 60, 20, 25, 15, 20 };
string path = "C:\\testTable.pdf";
List<(string, string)> headers = new List<(string, string)>
{
("id", "Id"),
("Age", "Age"),
("", "Heroes of Middle-earth"),
("Name", "Name"),
("AKA", "AKA"),
("Height", "Height"),
("Weight", "Weight")
};
if (pdfTable1.createTable(new DataForTable<CharacterInfo>(path, "Table", heights, merges, headers, charactersinfo)))
{
MessageBox.Show("Success");
}
}
private void PdfChart_Click(object sender, EventArgs e)
{
string path = "C:\\testChart.pdf";
List<(double, string)> elements = new List<(double, string)>
{
(42, "Gimli"),
(41, "Legolas"),
(214, "Aragorn"),
(1, "Boromir")
};
if (pdfPieChart1.CreatePieChart(new DataForPieChart(path, "Title", "Pie chart", DiagramLegendEnum.Top, "Orcs killed", elements)))
{
MessageBox.Show("Success");
}
}
}

View File

@ -117,4 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="pdfTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="pdfPieChart1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>139, 17</value>
</metadata>
<metadata name="pdfImage1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>281, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>410, 17</value>
</metadata>
</root>