ну доделал 2 лабу
This commit is contained in:
parent
17d45a0339
commit
b56ba80fad
36
Cop_25/Controls/DiagramComponent.Designer.cs
generated
Normal file
36
Cop_25/Controls/DiagramComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Controls
|
||||
{
|
||||
partial class DiagramComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
102
Cop_25/Controls/DiagramComponent.cs
Normal file
102
Cop_25/Controls/DiagramComponent.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using PdfSharp.Charting;
|
||||
using PdfSharp.Drawing;
|
||||
using PdfSharp.Pdf;
|
||||
using PdfSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Controls.Models;
|
||||
|
||||
namespace Controls
|
||||
{
|
||||
public partial class DiagramComponent : Component
|
||||
{
|
||||
public DiagramComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public DiagramComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateLineDiagram(string docPath, string title, string header, Dictionary<string, List<Double>> data, LegendAlign legendAlign = LegendAlign.top)
|
||||
{
|
||||
if (string.IsNullOrEmpty(docPath))
|
||||
{
|
||||
throw new ArgumentNullException("Введите путь до файла!");
|
||||
}
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
throw new ArgumentNullException("Введите заголовок");
|
||||
}
|
||||
if (string.IsNullOrEmpty(header))
|
||||
{
|
||||
throw new ArgumentNullException("Введите заголовок для диаграммы");
|
||||
}
|
||||
if (data.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("Нету данных");
|
||||
}
|
||||
|
||||
Chart chart = new Chart(ChartType.Line);
|
||||
|
||||
//Задание легенды
|
||||
chart.Legend.Docking = (DockingType)legendAlign;
|
||||
chart.Legend.LineFormat.Visible = true;
|
||||
|
||||
|
||||
//Добавление серий
|
||||
foreach (var item in data)
|
||||
{
|
||||
Series series = chart.SeriesCollection.AddSeries();
|
||||
series.Name = item.Key;
|
||||
double[] vals = new double[item.Value.Count];
|
||||
for (int i = 0; i < item.Value.Count; i++)
|
||||
{
|
||||
vals.SetValue(Convert.ToDouble(item.Value[i]), i);
|
||||
}
|
||||
|
||||
series.Add(vals);
|
||||
}
|
||||
|
||||
//Объявление осей
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
|
||||
chart.PlotArea.LineFormat.Color = XColors.DarkGray;
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
|
||||
chart.Legend.LineFormat.Visible = true;
|
||||
|
||||
ChartFrame chartFrame = new ChartFrame();
|
||||
chartFrame.Location = new XPoint(50, 70);
|
||||
chartFrame.Size = new XSize(500, 400);
|
||||
chartFrame.Add(chart);
|
||||
|
||||
PdfDocument document = new PdfDocument(docPath);
|
||||
|
||||
PdfPage page = document.AddPage();
|
||||
page.Size = PageSize.A4;
|
||||
|
||||
XGraphics gfx = XGraphics.FromPdfPage(page);
|
||||
|
||||
XFont font = new XFont("Times New Roman", 14);
|
||||
|
||||
gfx.DrawString(title, font, XBrushes.Black, new XRect(20, 20, page.Width, page.Height), XStringFormats.TopLeft);
|
||||
gfx.DrawString(header, font, XBrushes.Black, new XRect(20, 40, page.Width, page.Height), XStringFormats.TopCenter);
|
||||
|
||||
chartFrame.Draw(gfx);
|
||||
document.Close();
|
||||
}
|
||||
}
|
||||
}
|
22
Cop_25/Controls/Models/ColumnInfo.cs
Normal file
22
Cop_25/Controls/Models/ColumnInfo.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Controls.Models
|
||||
{
|
||||
public class ColumnInfo
|
||||
{
|
||||
public string PropertyName;
|
||||
public string Header;
|
||||
public int Width;
|
||||
|
||||
public ColumnInfo(string propertyName, string header, int width)
|
||||
{
|
||||
PropertyName = propertyName;
|
||||
Header = header;
|
||||
Width = width;
|
||||
}
|
||||
}
|
||||
}
|
16
Cop_25/Controls/Models/LegendAlign.cs
Normal file
16
Cop_25/Controls/Models/LegendAlign.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Controls.Models
|
||||
{
|
||||
public enum LegendAlign
|
||||
{
|
||||
top,
|
||||
bottom,
|
||||
left,
|
||||
right
|
||||
}
|
||||
}
|
20
Cop_25/Controls/Models/MergeCells.cs
Normal file
20
Cop_25/Controls/Models/MergeCells.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Controls.Models
|
||||
{
|
||||
public class MergeCells
|
||||
{
|
||||
public string Header;
|
||||
public int[] Indexes;
|
||||
|
||||
public MergeCells(string header, int[] indexes)
|
||||
{
|
||||
Header = header;
|
||||
Indexes = indexes;
|
||||
}
|
||||
}
|
||||
}
|
36
Cop_25/Controls/TableComponent.Designer.cs
generated
Normal file
36
Cop_25/Controls/TableComponent.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace Controls
|
||||
{
|
||||
partial class TableComponent
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
146
Cop_25/Controls/TableComponent.cs
Normal file
146
Cop_25/Controls/TableComponent.cs
Normal file
@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Controls.Models;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.Rendering;
|
||||
|
||||
namespace Controls
|
||||
{
|
||||
public partial class TableComponent : Component
|
||||
{
|
||||
private Document? _document;
|
||||
|
||||
private Section? _section;
|
||||
|
||||
public TableComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public TableComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateTable<T>(string docPath, string title, List<MergeCells>? mergeCells, List<ColumnInfo> colInfo, List<T> data) where T : class, new()
|
||||
{
|
||||
if (string.IsNullOrEmpty(docPath))
|
||||
{
|
||||
throw new ArgumentNullException("Введите путь до файла!");
|
||||
}
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
throw new ArgumentNullException("Введите заголовок");
|
||||
}
|
||||
if (colInfo == null)
|
||||
{
|
||||
throw new ArgumentNullException("Введите все заголовки");
|
||||
}
|
||||
if (data == null)
|
||||
{
|
||||
throw new ArgumentNullException("Нету информации для вывода");
|
||||
}
|
||||
|
||||
_document = new Document();
|
||||
var style = _document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
|
||||
_section = _document.AddSection();
|
||||
|
||||
//Заголовок
|
||||
var paragraph = _section.AddParagraph(title);
|
||||
paragraph.Format.SpaceAfter = "0.3cm";
|
||||
|
||||
//Создание таблицы
|
||||
var table = _section.AddTable();
|
||||
table.Borders.Visible = true;
|
||||
|
||||
//Создание колонок
|
||||
for (int i = 0; i < colInfo.Count; i++)
|
||||
{
|
||||
table.AddColumn(colInfo[i].Width);
|
||||
}
|
||||
|
||||
//Создание строк
|
||||
if (mergeCells != null)
|
||||
{
|
||||
table.AddRow();
|
||||
}
|
||||
var row = table.AddRow();
|
||||
|
||||
for (int i = 0; i < colInfo.Count; i++)
|
||||
{
|
||||
row[i].AddParagraph(colInfo[i].Header);
|
||||
}
|
||||
|
||||
List<int> MergeColls = new List<int>();
|
||||
|
||||
//Объединение ячеек в строке
|
||||
if (mergeCells != null)
|
||||
{
|
||||
foreach (var cell in mergeCells)
|
||||
{
|
||||
MergeColls.AddRange(cell.Indexes[1..]);
|
||||
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].MergeRight = cell.Indexes[2..].Length;
|
||||
table.Rows[cell.Indexes[0]].Cells[cell.Indexes[1] - 1].AddParagraph(cell.Header);
|
||||
}
|
||||
}
|
||||
|
||||
int cellsCount = table.Rows[1].Cells.Count;
|
||||
|
||||
//Объединение ячеек в столбце
|
||||
if (MergeColls.Count != 0)
|
||||
{
|
||||
for (int i = 0; i < cellsCount; i++)
|
||||
{
|
||||
var cell = table.Rows[0].Cells[i];
|
||||
if (!MergeColls.Contains(i + 1))
|
||||
{
|
||||
cell.MergeDown = 1;
|
||||
cell.AddParagraph(colInfo[i].Header);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Вывод данных
|
||||
|
||||
int rowData = 2;
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
var properties = item.GetType().GetProperties();
|
||||
if (properties.Count() != cellsCount)
|
||||
{
|
||||
throw new Exception("Кол-во полей объекта не совпадает с кол-вом колонок");
|
||||
}
|
||||
|
||||
for (int i = 0; i < properties.Count(); i++)
|
||||
{
|
||||
var property = properties[i];
|
||||
var propValue = property.GetValue(item);
|
||||
if (propValue == null) throw new Exception("Пустое поле");
|
||||
if (property.Name == colInfo[i].PropertyName)
|
||||
{
|
||||
if (table.Rows.Count <= rowData) table.AddRow();
|
||||
table.Rows[rowData].Cells[i].AddParagraph(propValue.ToString()!);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
rowData++;
|
||||
}
|
||||
|
||||
var renderer = new PdfDocumentRenderer(true);
|
||||
renderer.Document = _document;
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(docPath);
|
||||
}
|
||||
}
|
||||
}
|
BIN
Cop_25/Controls/docs/cat.jpg
Normal file
BIN
Cop_25/Controls/docs/cat.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 255 KiB |
BIN
Cop_25/Controls/docs/diagram.pdf
Normal file
BIN
Cop_25/Controls/docs/diagram.pdf
Normal file
Binary file not shown.
BIN
Cop_25/Controls/docs/table.pdf
Normal file
BIN
Cop_25/Controls/docs/table.pdf
Normal file
Binary file not shown.
175
Cop_25/Forms/FormMain.Designer.cs
generated
175
Cop_25/Forms/FormMain.Designer.cs
generated
@ -29,132 +29,85 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
customTextBoxNumber = new Controls.CustomTextBoxNumber();
|
||||
customComboBox = new Controls.CustomComboBox();
|
||||
labelNum = new Label();
|
||||
labelCombo = new Label();
|
||||
labelList = new Label();
|
||||
customListBox = new Controls.CustomListBox();
|
||||
buttonValidate = new Button();
|
||||
buttonGetBro = new Button();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
|
||||
toolTip = new ToolTip(components);
|
||||
button1 = new Button();
|
||||
largeTextComponent1 = new Controls.LargeTextComponent(components);
|
||||
buttonLargeText = new Button();
|
||||
tableComponent1 = new Controls.TableComponent(components);
|
||||
button1 = new Button();
|
||||
diagramComponent1 = new Controls.DiagramComponent(components);
|
||||
button2 = new Button();
|
||||
pictureBox1 = new PictureBox();
|
||||
textBox1 = new TextBox();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// customTextBoxNumber
|
||||
//
|
||||
customTextBoxNumber.Location = new Point(2, 187);
|
||||
customTextBoxNumber.Name = "customTextBoxNumber";
|
||||
customTextBoxNumber.NumPattern = null;
|
||||
customTextBoxNumber.Size = new Size(261, 105);
|
||||
customTextBoxNumber.TabIndex = 0;
|
||||
//
|
||||
// customComboBox
|
||||
//
|
||||
customComboBox.Location = new Point(2, 19);
|
||||
customComboBox.Name = "customComboBox";
|
||||
customComboBox.SelectedItem = " ";
|
||||
customComboBox.Size = new Size(301, 188);
|
||||
customComboBox.TabIndex = 1;
|
||||
//
|
||||
// labelNum
|
||||
//
|
||||
labelNum.AutoSize = true;
|
||||
labelNum.Location = new Point(68, 187);
|
||||
labelNum.Name = "labelNum";
|
||||
labelNum.Size = new Size(130, 20);
|
||||
labelNum.TabIndex = 2;
|
||||
labelNum.Text = "Номер телефона:";
|
||||
//
|
||||
// labelCombo
|
||||
//
|
||||
labelCombo.AutoSize = true;
|
||||
labelCombo.Location = new Point(88, 42);
|
||||
labelCombo.Name = "labelCombo";
|
||||
labelCombo.Size = new Size(95, 20);
|
||||
labelCombo.TabIndex = 3;
|
||||
labelCombo.Text = "Комбо бокс:";
|
||||
//
|
||||
// labelList
|
||||
//
|
||||
labelList.AutoSize = true;
|
||||
labelList.Location = new Point(509, 19);
|
||||
labelList.Name = "labelList";
|
||||
labelList.Size = new Size(59, 20);
|
||||
labelList.TabIndex = 4;
|
||||
labelList.Text = "Спсиок";
|
||||
//
|
||||
// customListBox
|
||||
//
|
||||
customListBox.Location = new Point(334, 42);
|
||||
customListBox.Name = "customListBox";
|
||||
customListBox.SelectedIndex = -1;
|
||||
customListBox.Size = new Size(454, 250);
|
||||
customListBox.TabIndex = 5;
|
||||
//
|
||||
// buttonValidate
|
||||
//
|
||||
buttonValidate.Location = new Point(22, 298);
|
||||
buttonValidate.Name = "buttonValidate";
|
||||
buttonValidate.Size = new Size(215, 29);
|
||||
buttonValidate.TabIndex = 6;
|
||||
buttonValidate.Text = "проверка телефона";
|
||||
buttonValidate.UseVisualStyleBackColor = true;
|
||||
buttonValidate.Click += buttonValidate_Click;
|
||||
//
|
||||
// buttonGetBro
|
||||
//
|
||||
buttonGetBro.Location = new Point(334, 263);
|
||||
buttonGetBro.Name = "buttonGetBro";
|
||||
buttonGetBro.Size = new Size(273, 29);
|
||||
buttonGetBro.TabIndex = 7;
|
||||
buttonGetBro.Text = "получить друга";
|
||||
buttonGetBro.UseVisualStyleBackColor = true;
|
||||
buttonGetBro.Click += buttonGetObject_Click;
|
||||
//
|
||||
// toolTip
|
||||
//
|
||||
toolTip.ToolTipTitle = "AAAA";
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(22, 119);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(94, 29);
|
||||
button1.TabIndex = 8;
|
||||
button1.Text = "добавить";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonLargeText
|
||||
//
|
||||
buttonLargeText.Location = new Point(840, 42);
|
||||
buttonLargeText.Location = new Point(28, 21);
|
||||
buttonLargeText.Name = "buttonLargeText";
|
||||
buttonLargeText.Size = new Size(132, 51);
|
||||
buttonLargeText.Size = new Size(310, 51);
|
||||
buttonLargeText.TabIndex = 9;
|
||||
buttonLargeText.Text = "СОЗДАТЬ PDF";
|
||||
buttonLargeText.Text = "СОЗДАТЬ PDF ТЕКСТ";
|
||||
buttonLargeText.UseVisualStyleBackColor = true;
|
||||
buttonLargeText.Click += buttonLargeText_CLick;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(28, 94);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(310, 66);
|
||||
button1.TabIndex = 10;
|
||||
button1.Text = "СОЗДАТЬ ТАБЛИЦУ PDF";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += buttonCreateTable_Click;
|
||||
//
|
||||
// button2
|
||||
//
|
||||
button2.Location = new Point(28, 185);
|
||||
button2.Name = "button2";
|
||||
button2.Size = new Size(310, 72);
|
||||
button2.TabIndex = 11;
|
||||
button2.Text = "СОЗДАТЬ ДИАГРАММУ PDF";
|
||||
button2.UseVisualStyleBackColor = true;
|
||||
button2.Click += buttonDiagram_Click;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.BackgroundImage = (Image)resources.GetObject("pictureBox1.BackgroundImage");
|
||||
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
pictureBox1.Location = new Point(359, 21);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(364, 304);
|
||||
pictureBox1.TabIndex = 12;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// textBox1
|
||||
//
|
||||
textBox1.Location = new Point(372, 33);
|
||||
textBox1.Name = "textBox1";
|
||||
textBox1.Size = new Size(336, 27);
|
||||
textBox1.TabIndex = 13;
|
||||
textBox1.Text = "НАЖМИТЕ НА КНОПКУ ЧТОБЫ СОЗДАТЬ";
|
||||
textBox1.TextAlign = HorizontalAlignment.Center;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1025, 450);
|
||||
ClientSize = new Size(806, 381);
|
||||
Controls.Add(textBox1);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(buttonLargeText);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(buttonGetBro);
|
||||
Controls.Add(buttonValidate);
|
||||
Controls.Add(customListBox);
|
||||
Controls.Add(labelList);
|
||||
Controls.Add(labelCombo);
|
||||
Controls.Add(labelNum);
|
||||
Controls.Add(customComboBox);
|
||||
Controls.Add(customTextBoxNumber);
|
||||
Controls.Add(pictureBox1);
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -164,19 +117,15 @@
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Controls.CustomTextBoxNumber customTextBoxNumber;
|
||||
private Controls.CustomComboBox customComboBox;
|
||||
private Label labelNum;
|
||||
private Label labelCombo;
|
||||
private Label labelList;
|
||||
private Controls.CustomListBox customListBox;
|
||||
private Button buttonValidate;
|
||||
private Button buttonGetBro;
|
||||
#endregion
|
||||
private ToolTip toolTip;
|
||||
private Button button1;
|
||||
private Controls.LargeTextComponent largeTextComponent1;
|
||||
private Button buttonLargeText;
|
||||
private Controls.TableComponent tableComponent1;
|
||||
private Button button1;
|
||||
private Controls.DiagramComponent diagramComponent1;
|
||||
private Button button2;
|
||||
private PictureBox pictureBox1;
|
||||
private TextBox textBox1;
|
||||
}
|
||||
}
|
@ -9,6 +9,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Controls.Models;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
|
||||
namespace Forms
|
||||
{
|
||||
@ -17,52 +19,7 @@ namespace Forms
|
||||
public FormMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
customComboBox.ComboBoxItems.Add("aboba1");
|
||||
customComboBox.ComboBoxItems.Add("aboba2");
|
||||
customComboBox.SelectedItem = "aboba1";
|
||||
|
||||
customTextBoxNumber.NumPattern = @"^\+7\d{10}$";
|
||||
|
||||
customListBox.SetTemplateString("Имя: {FirstName}, Фамилия: {LastName}, Возраст: {Age}", "{", "}");
|
||||
Person person1 = new Person { FirstName = "{Лена}", LastName = "{Пряникова}", Age = "{18}" };
|
||||
Person person2 = new Person { FirstName = "{Сергей}", LastName = "{Конфеткович}", Age = "{20}" };
|
||||
customListBox.FillProperty(person1, 0, "FirstName");
|
||||
customListBox.FillProperty(person1, 0, "LastName");
|
||||
customListBox.FillProperty(person1, 0, "Age");
|
||||
|
||||
customListBox.FillProperty(person2, 1, "FirstName");
|
||||
customListBox.FillProperty(person2, 1, "LastName");
|
||||
customListBox.FillProperty(person2, 1, "Age");
|
||||
}
|
||||
private void buttonValidate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string phoneNumber = customTextBoxNumber.TextBoxNumber;
|
||||
MessageBox.Show($"Введенный номер: {phoneNumber}");
|
||||
}
|
||||
catch (CustomNumberException ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonGetObject_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
Person selectedPerson = customListBox.GetObjectFromStr<Person>();
|
||||
MessageBox.Show($"Ваш друг. Имя: {selectedPerson.FirstName}, Фамилия: {selectedPerson.LastName}, Возраст: {selectedPerson.Age}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Ошибка: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
customComboBox.ComboBoxItems.Add("abobaSECRET");
|
||||
|
||||
}
|
||||
|
||||
private void buttonLargeText_CLick(object sender, EventArgs e)
|
||||
@ -71,5 +28,39 @@ namespace Forms
|
||||
LargeTextComponent largeText = new LargeTextComponent();
|
||||
largeText.CreateDocument("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\text.pdf", "OMEGA LABA 2", strings);
|
||||
}
|
||||
|
||||
private void buttonCreateTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<ColumnInfo> columnInfos = new List<ColumnInfo>()
|
||||
{
|
||||
new ColumnInfo("FirstName","Имя",50),
|
||||
new ColumnInfo("LastName","Фамилия",100),
|
||||
new ColumnInfo("Age","Возраст",200),
|
||||
};
|
||||
|
||||
List<MergeCells> mergeCells = new List<MergeCells>()
|
||||
{
|
||||
new MergeCells("Данные", new int[] {0,2,2})
|
||||
};
|
||||
|
||||
List<Person> people = new List<Person>()
|
||||
{
|
||||
new Person("aboba", "not aboba", "19"),
|
||||
new Person("aboba2", "not aboba2", "25"),
|
||||
new Person("aboba3", "not aboba3", "20"),
|
||||
};
|
||||
|
||||
tableComponent1.CreateTable("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\table.pdf", "TABLE LUTI", mergeCells, columnInfos, people);
|
||||
}
|
||||
|
||||
private void buttonDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
Dictionary<string, List<Double>> data = new Dictionary<string, List<Double>>();
|
||||
data.Add("Знач1", new List<double> { 0.5, 1, 2, 5, 2 });
|
||||
data.Add("Знач2", new List<double> { 3, 2, 1, 3, 6 });
|
||||
data.Add("Знач3", new List<double> { 7, 3, 1, 2, 5 });
|
||||
|
||||
diagramComponent1.CreateLineDiagram("C:\\Ulstu\\COP\\Cop_25\\Controls\\docs\\diagram.pdf", "Заголовок", "Линейная диаграмма", data, LegendAlign.bottom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,4 +12,19 @@
|
||||
<ProjectReference Include="..\Controls\Controls.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -11,5 +11,12 @@ namespace Forms
|
||||
public string FirstName { get; set; }
|
||||
public string LastName { get; set; }
|
||||
public string Age { get; set; }
|
||||
public Person(string fn, string ln, string ag)
|
||||
{
|
||||
FirstName = fn;
|
||||
LastName = ln;
|
||||
Age = ag;
|
||||
}
|
||||
public Person() { }
|
||||
}
|
||||
}
|
||||
|
63
Cop_25/Forms/Properties/Resources.Designer.cs
generated
Normal file
63
Cop_25/Forms/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Forms.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Forms.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
Cop_25/Forms/Properties/Resources.resx
Normal file
120
Cop_25/Forms/Properties/Resources.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?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>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user