Compare commits
No commits in common. "914e8a830c78dd678715281a223c12440a54cdc2" and "bbaf9cd3fb1f0ce0536fb23f52d0397099a31e5c" have entirely different histories.
914e8a830c
...
bbaf9cd3fb
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.Nonvisual
|
||||
{
|
||||
public enum LegendAlignment
|
||||
{
|
||||
Top,
|
||||
Bottom,
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
namespace Components.Nonvisual
|
||||
{
|
||||
partial class UserControlConfigurableTableDocument
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.Nonvisual
|
||||
{
|
||||
public partial class UserControlConfigurableTableDocument : Component
|
||||
{
|
||||
public UserControlConfigurableTableDocument()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public UserControlConfigurableTableDocument(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void SaveToDocument<T>(string filePath, string title,
|
||||
List<(double width, string header, string propName)> columns,
|
||||
double headerRowHeight, double rowHeight, List<T> data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath)) throw new ArgumentNullException("Empty string instead of path to file");
|
||||
if (string.IsNullOrEmpty(title)) throw new ArgumentNullException("Title string is empty");
|
||||
if (data.Count == 0) throw new ArgumentNullException("Data list is empty");
|
||||
if (columns.Count == 0) throw new ArgumentNullException("Column info list is empty");
|
||||
if (rowHeight == 0D || headerRowHeight == 0D) throw new ArgumentNullException("Row height is empty");
|
||||
|
||||
SaveToPdf saver = new SaveToPdf();
|
||||
|
||||
saver.CreateConfigurableTableDocument(filePath, title, columns, headerRowHeight, rowHeight, data);
|
||||
}
|
||||
}
|
||||
}
|
36
Components/Nonvisual/UserControlHist.Designer.cs
generated
36
Components/Nonvisual/UserControlHist.Designer.cs
generated
@ -1,36 +0,0 @@
|
||||
namespace Components.Nonvisual
|
||||
{
|
||||
partial class UserControlHist
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace Components.Nonvisual
|
||||
{
|
||||
public partial class UserControlHist : Component
|
||||
{
|
||||
public UserControlHist()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public UserControlHist(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateHist(string filePath, string title, string histTitle,
|
||||
LegendAlignment alignment, Dictionary<string, int[]> data)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
throw new ArgumentException("Filename cannot be empty");
|
||||
if (string.IsNullOrEmpty(title))
|
||||
throw new ArgumentException("Title cannot be empty");
|
||||
if (string.IsNullOrEmpty(histTitle))
|
||||
throw new ArgumentException("Hist title cannot be empty");
|
||||
if (data.Count == 0)
|
||||
throw new ArgumentException("Data cannot be empty");
|
||||
|
||||
SaveToPdf saver = new SaveToPdf();
|
||||
saver.CreateHist(filePath, title, histTitle, alignment, data);
|
||||
}
|
||||
}
|
||||
}
|
@ -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<string[][]> 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.CreateTableDocumentWithContext(filePath, header, tables);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,284 +0,0 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
using Components.SaveToPdfHelpers;
|
||||
using System.Text;
|
||||
using System.Security.Cryptography;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using Components.Nonvisual;
|
||||
using System.IO;
|
||||
|
||||
namespace Components
|
||||
{
|
||||
internal class SaveToPdf
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
public void CreateTableDocumentWithContext(string title, string path, List<string[][]> tables)
|
||||
{
|
||||
_document = new Document();
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
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);
|
||||
}
|
||||
|
||||
public void CreateConfigurableTableDocument<T>(string path, string title,
|
||||
List<(double width, string header, string propName)> columns, double headerRowHeight,
|
||||
double rowHeight, List<T> data)
|
||||
{
|
||||
_document = new Document();
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
|
||||
CreateTable(columns.Select(c => c.width).ToList());
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = columns.Select(c => c.header).ToList(),
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center,
|
||||
RowHeight = headerRowHeight,
|
||||
});
|
||||
|
||||
foreach (var obj in data)
|
||||
{
|
||||
List<string> cells = new List<string>();
|
||||
|
||||
for (int i = 0; i < columns.Count; i++)
|
||||
{
|
||||
var propName = columns[i].propName;
|
||||
var prop = typeof(T).GetProperty(propName);
|
||||
if (prop is null)
|
||||
{
|
||||
throw new ArgumentException($"Failed to find property {prop} in provided objects class");
|
||||
}
|
||||
var propVal = prop.GetValue(obj)?.ToString();
|
||||
if (propVal is not null)
|
||||
{
|
||||
cells.Add(propVal);
|
||||
}
|
||||
}
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = cells,
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left,
|
||||
FirstCellStyle = "NormalTitle",
|
||||
FirstCellParagraphAlignment = PdfParagraphAlignmentType.Center,
|
||||
RowHeight = rowHeight,
|
||||
});
|
||||
}
|
||||
|
||||
CreateParagraph(new PdfParagraph());
|
||||
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(path);
|
||||
}
|
||||
|
||||
public void CreateHist(string filePath, string title, string histTitle,
|
||||
LegendAlignment alignment, Dictionary<string, int[]> data)
|
||||
{
|
||||
_document = new Document();
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
DefineStyles(_document);
|
||||
_section = _document.AddSection();
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
|
||||
CreateChart(new PdfChartParameters
|
||||
{
|
||||
Data = data,
|
||||
Title = histTitle,
|
||||
LegendAlignment = alignment,
|
||||
});
|
||||
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(filePath);
|
||||
}
|
||||
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<string> columns)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columns)
|
||||
{
|
||||
_table.AddColumn(elem);
|
||||
}
|
||||
}
|
||||
|
||||
protected void CreateTable(List<double> columnWidths)
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_table = _document.LastSection.AddTable();
|
||||
foreach (var elem in columnWidths)
|
||||
{
|
||||
_table.AddColumn(Unit.FromCentimeter(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 (i == 0 && !string.IsNullOrEmpty(rowParameters.FirstCellStyle))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.FirstCellStyle;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(rowParameters.Style))
|
||||
{
|
||||
row.Cells[i].Style = rowParameters.Style;
|
||||
}
|
||||
if (i == 0 && rowParameters.FirstCellParagraphAlignment != null)
|
||||
{
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment((PdfParagraphAlignmentType)rowParameters.FirstCellParagraphAlignment);
|
||||
}
|
||||
else
|
||||
{
|
||||
row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment);
|
||||
}
|
||||
if (rowParameters.RowHeight is not null)
|
||||
{
|
||||
row.Height = Unit.FromCentimeter((double)rowParameters.RowHeight);
|
||||
}
|
||||
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].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
||||
protected void CreateChart(PdfChartParameters chartParams)
|
||||
{
|
||||
if (_section == null)
|
||||
return;
|
||||
|
||||
Chart chart = new Chart(ChartType.Bar2D);
|
||||
chart.Width = "15cm";
|
||||
chart.Height = "8cm";
|
||||
|
||||
foreach (var dataSeries in chartParams.Data)
|
||||
{
|
||||
Series series = chart.SeriesCollection.AddSeries();
|
||||
series.Name = dataSeries.Key;
|
||||
series.Add(dataSeries.Value.Select(x => (double)x).ToArray());
|
||||
}
|
||||
|
||||
chart.TopArea.AddParagraph(chartParams.Title);
|
||||
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
|
||||
_ = chartParams.LegendAlignment switch
|
||||
{
|
||||
LegendAlignment.Top => chart.TopArea.AddLegend(),
|
||||
LegendAlignment.Right => chart.RightArea.AddLegend(),
|
||||
LegendAlignment.Bottom => chart.BottomArea.AddLegend(),
|
||||
LegendAlignment.Left => chart.LeftArea.AddLegend(),
|
||||
_ => chart.BottomArea.AddLegend(),
|
||||
};
|
||||
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
|
||||
_section.Add(chart);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
using Components.Nonvisual;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Components.SaveToPdfHelpers
|
||||
{
|
||||
internal class PdfChartParameters
|
||||
{
|
||||
public Dictionary<string, int[]> Data = new();
|
||||
|
||||
public string Title = string.Empty;
|
||||
|
||||
public LegendAlignment LegendAlignment = LegendAlignment.Bottom;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
|
||||
namespace Components.SaveToPdfHelpers
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
public string Style { get; set; } = string.Empty;
|
||||
|
||||
public double? RowHeight { get; set; }
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
public string FirstCellStyle { get; set; } = string.Empty;
|
||||
public PdfParagraphAlignmentType? FirstCellParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
92
TestingForm/FormMain.Designer.cs
generated
92
TestingForm/FormMain.Designer.cs
generated
@ -1,92 +0,0 @@
|
||||
namespace TestingForm
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
userControlTableDocument1 = new Components.UserControlTableDocument(components);
|
||||
button1 = new Button();
|
||||
button2 = new Button();
|
||||
userControlConfigurableTableDocument1 = new Components.Nonvisual.UserControlConfigurableTableDocument(components);
|
||||
button3 = new Button();
|
||||
userControlHist1 = new Components.Nonvisual.UserControlHist(components);
|
||||
SuspendLayout();
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(12, 12);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(188, 65);
|
||||
button1.TabIndex = 0;
|
||||
button1.Text = "Сохранить первый компонент";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(218, 12);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(188, 65);
|
||||
button2.TabIndex = 1;
|
||||
button2.Text = "Сохранить второй компонент";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += button2_Click;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Location = new Point(433, 12);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(188, 65);
|
||||
button3.TabIndex = 2;
|
||||
button3.Text = "Сохранить третий компонент";
|
||||
button3.UseVisualStyleBackColor = true;
|
||||
button3.Click += button3_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
Name = "FormMain";
|
||||
Text = "Testing form";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Components.UserControlTableDocument userControlTableDocument1;
|
||||
private Button button1;
|
||||
private Button button2;
|
||||
private Components.Nonvisual.UserControlConfigurableTableDocument userControlConfigurableTableDocument1;
|
||||
private Button button3;
|
||||
private Components.Nonvisual.UserControlHist userControlHist1;
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
using Components.Nonvisual;
|
||||
|
||||
namespace TestingForm
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "pdf|*.pdf",
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
|
||||
List<string[][]> tables = new List<string[][]>();
|
||||
string[][] table1 = new string[2][];
|
||||
table1[0] = new string[] { "test", "test 2" };
|
||||
table1[1] = new string[] { "test next", "test next 2" };
|
||||
|
||||
string[][] table2 = new string[3][];
|
||||
table2[0] = new string[] { "ttt", "ttt 2", "ttt 3" };
|
||||
table2[1] = new string[] { "ttt next", "ttt next 2" };
|
||||
table2[2] = new string[] { "next" };
|
||||
|
||||
tables.Add(table1);
|
||||
tables.Add(table2);
|
||||
|
||||
try
|
||||
{
|
||||
userControlTableDocument1.SaveToDocument(
|
||||
"Çàãîëîâîê äîêóìåíòà",
|
||||
dialog.FileName,
|
||||
tables
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Óñïåøíî");
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "pdf|*.pdf",
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
List<TestUser> users = new List<TestUser>
|
||||
{
|
||||
new TestUser(1, "user 1", 20, 50000),
|
||||
new TestUser(2, "user 2", 19, 30000),
|
||||
new TestUser(3, "user 3", 26, 70000)
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
userControlConfigurableTableDocument1.SaveToDocument(
|
||||
dialog.FileName,
|
||||
"Çàãîëîâîê äîêóìåíòà",
|
||||
new List<(double width, string header, string propName)>
|
||||
{
|
||||
(2.0, "ID", "Id"),
|
||||
(6.0, "Èìÿ", "Name"),
|
||||
(2.0, "Âîçðàñò", "Age"),
|
||||
(6.0, "Çàðïëàòà", "Salary"),
|
||||
},
|
||||
7.0,
|
||||
2.0,
|
||||
users
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Óñïåøíî");
|
||||
}
|
||||
|
||||
private void button3_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "pdf|*.pdf",
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Dictionary<string, int[]> data = new Dictionary<string, int[]>
|
||||
{
|
||||
{ "test 1", new int[] {1, 2, 3, 6, 7, 9} },
|
||||
{ "test 2", new int[] {6, 8, 11, 16, 4, 2} },
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
userControlHist1.CreateHist(dialog.FileName, "Çàãîëîâîê", "Test", LegendAlignment.Bottom, data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Óñïåøíî");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="userControlTableDocument1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="userControlConfigurableTableDocument1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>222, 17</value>
|
||||
</metadata>
|
||||
<metadata name="userControlHist1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>496, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -1,24 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TestingForm
|
||||
{
|
||||
public class TestUser
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public int Age { get; private set; }
|
||||
public int Salary { get; private set; }
|
||||
|
||||
public TestUser(int id, string name, int age, int salary)
|
||||
{
|
||||
Id = id;
|
||||
Name = name;
|
||||
Age = age;
|
||||
Salary = salary;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user