Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
b3c5ccb7bc | |||
193a9f1ab8 |
310
YunusovComponentsLibrary/Form1/Form1.Designer.cs
generated
Normal file
310
YunusovComponentsLibrary/Form1/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,310 @@
|
||||
namespace Form1
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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>
|
||||
public 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();
|
||||
selectComponent = new YunusovComponentsLibrary.SelectedComponent();
|
||||
groupBoxSelect = new GroupBox();
|
||||
buttonGetSelected = new Button();
|
||||
buttonClear = new Button();
|
||||
textBox = new TextBox();
|
||||
buttonAdd = new Button();
|
||||
inputComponent = new YunusovComponentsLibrary.InputComponent();
|
||||
groupBoxInput = new GroupBox();
|
||||
buttonShowFloat = new Button();
|
||||
groupBoxListOutput = new GroupBox();
|
||||
buttonGetListOutput = new Button();
|
||||
buttonAddListOutput = new Button();
|
||||
buttonClearListOutput = new Button();
|
||||
listOutputComponent = new YunusovComponentsLibrary.ListOutputComponent();
|
||||
wordDocumentContext1 = new YunusovComponentsLibrary.WordDocumentContext(components);
|
||||
groupBoxSimpelTable = new GroupBox();
|
||||
buttonSimpleTable = new Button();
|
||||
groupBoxDiagram = new GroupBox();
|
||||
buttonCreateDiagram = new Button();
|
||||
wordDiagram = new YunusovComponentsLibrary.WordDiagram(components);
|
||||
groupBoxTableWithHeaders = new GroupBox();
|
||||
buttonWordTableWithHeaders = new Button();
|
||||
wordDocumentTable1 = new YunusovComponentsLibrary.WordDocumentTable(components);
|
||||
groupBoxSelect.SuspendLayout();
|
||||
groupBoxInput.SuspendLayout();
|
||||
groupBoxListOutput.SuspendLayout();
|
||||
groupBoxSimpelTable.SuspendLayout();
|
||||
groupBoxDiagram.SuspendLayout();
|
||||
groupBoxTableWithHeaders.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// selectComponent
|
||||
//
|
||||
selectComponent.Location = new Point(6, 32);
|
||||
selectComponent.Name = "selectComponent";
|
||||
selectComponent.SelectedItem = "";
|
||||
selectComponent.Size = new Size(164, 226);
|
||||
selectComponent.TabIndex = 0;
|
||||
//
|
||||
// groupBoxSelect
|
||||
//
|
||||
groupBoxSelect.Controls.Add(buttonGetSelected);
|
||||
groupBoxSelect.Controls.Add(buttonClear);
|
||||
groupBoxSelect.Controls.Add(textBox);
|
||||
groupBoxSelect.Controls.Add(buttonAdd);
|
||||
groupBoxSelect.Controls.Add(selectComponent);
|
||||
groupBoxSelect.Location = new Point(12, 1);
|
||||
groupBoxSelect.Name = "groupBoxSelect";
|
||||
groupBoxSelect.Size = new Size(302, 241);
|
||||
groupBoxSelect.TabIndex = 1;
|
||||
groupBoxSelect.TabStop = false;
|
||||
groupBoxSelect.Text = "Selected";
|
||||
//
|
||||
// buttonGetSelected
|
||||
//
|
||||
buttonGetSelected.Location = new Point(171, 192);
|
||||
buttonGetSelected.Name = "buttonGetSelected";
|
||||
buttonGetSelected.Size = new Size(125, 29);
|
||||
buttonGetSelected.TabIndex = 4;
|
||||
buttonGetSelected.Text = "Get selected";
|
||||
buttonGetSelected.UseVisualStyleBackColor = true;
|
||||
buttonGetSelected.Click += SelectComponent_ItemSelected;
|
||||
//
|
||||
// buttonClear
|
||||
//
|
||||
buttonClear.Location = new Point(171, 140);
|
||||
buttonClear.Name = "buttonClear";
|
||||
buttonClear.Size = new Size(125, 29);
|
||||
buttonClear.TabIndex = 3;
|
||||
buttonClear.Text = "Clear";
|
||||
buttonClear.UseVisualStyleBackColor = true;
|
||||
buttonClear.Click += buttonClearList_Click;
|
||||
//
|
||||
// textBox
|
||||
//
|
||||
textBox.Location = new Point(171, 41);
|
||||
textBox.Name = "textBox";
|
||||
textBox.Size = new Size(125, 27);
|
||||
textBox.TabIndex = 2;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(171, 92);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(125, 29);
|
||||
buttonAdd.TabIndex = 1;
|
||||
buttonAdd.Text = "Add";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// inputComponent
|
||||
//
|
||||
inputComponent.Location = new Point(6, 26);
|
||||
inputComponent.Name = "inputComponent";
|
||||
inputComponent.Size = new Size(181, 49);
|
||||
inputComponent.TabIndex = 2;
|
||||
//
|
||||
// groupBoxInput
|
||||
//
|
||||
groupBoxInput.Controls.Add(buttonShowFloat);
|
||||
groupBoxInput.Controls.Add(inputComponent);
|
||||
groupBoxInput.Location = new Point(360, 1);
|
||||
groupBoxInput.Name = "groupBoxInput";
|
||||
groupBoxInput.Size = new Size(190, 241);
|
||||
groupBoxInput.TabIndex = 3;
|
||||
groupBoxInput.TabStop = false;
|
||||
groupBoxInput.Text = "Input";
|
||||
//
|
||||
// buttonShowFloat
|
||||
//
|
||||
buttonShowFloat.Location = new Point(45, 81);
|
||||
buttonShowFloat.Name = "buttonShowFloat";
|
||||
buttonShowFloat.Size = new Size(94, 29);
|
||||
buttonShowFloat.TabIndex = 4;
|
||||
buttonShowFloat.Text = "Show";
|
||||
buttonShowFloat.UseVisualStyleBackColor = true;
|
||||
buttonShowFloat.Click += buttonShowFloat_Click;
|
||||
//
|
||||
// groupBoxListOutput
|
||||
//
|
||||
groupBoxListOutput.Controls.Add(buttonGetListOutput);
|
||||
groupBoxListOutput.Controls.Add(buttonAddListOutput);
|
||||
groupBoxListOutput.Controls.Add(buttonClearListOutput);
|
||||
groupBoxListOutput.Controls.Add(listOutputComponent);
|
||||
groupBoxListOutput.Location = new Point(592, 1);
|
||||
groupBoxListOutput.Name = "groupBoxListOutput";
|
||||
groupBoxListOutput.Size = new Size(570, 241);
|
||||
groupBoxListOutput.TabIndex = 4;
|
||||
groupBoxListOutput.TabStop = false;
|
||||
groupBoxListOutput.Text = "ListOutput";
|
||||
//
|
||||
// buttonGetListOutput
|
||||
//
|
||||
buttonGetListOutput.Location = new Point(457, 143);
|
||||
buttonGetListOutput.Name = "buttonGetListOutput";
|
||||
buttonGetListOutput.Size = new Size(94, 29);
|
||||
buttonGetListOutput.TabIndex = 7;
|
||||
buttonGetListOutput.Text = "Get";
|
||||
buttonGetListOutput.UseVisualStyleBackColor = true;
|
||||
buttonGetListOutput.Click += buttonGetListOutput_Click;
|
||||
//
|
||||
// buttonAddListOutput
|
||||
//
|
||||
buttonAddListOutput.Location = new Point(457, 26);
|
||||
buttonAddListOutput.Name = "buttonAddListOutput";
|
||||
buttonAddListOutput.Size = new Size(94, 29);
|
||||
buttonAddListOutput.TabIndex = 6;
|
||||
buttonAddListOutput.Text = "Add";
|
||||
buttonAddListOutput.UseVisualStyleBackColor = true;
|
||||
buttonAddListOutput.Click += buttonAddListOutput_Click;
|
||||
//
|
||||
// buttonClearListOutput
|
||||
//
|
||||
buttonClearListOutput.Location = new Point(457, 81);
|
||||
buttonClearListOutput.Name = "buttonClearListOutput";
|
||||
buttonClearListOutput.Size = new Size(94, 29);
|
||||
buttonClearListOutput.TabIndex = 5;
|
||||
buttonClearListOutput.Text = "Clear";
|
||||
buttonClearListOutput.UseVisualStyleBackColor = true;
|
||||
buttonClearListOutput.Click += buttonClearListOutput_Click;
|
||||
//
|
||||
// listOutputComponent
|
||||
//
|
||||
listOutputComponent.Location = new Point(6, 26);
|
||||
listOutputComponent.Name = "listOutputComponent";
|
||||
listOutputComponent.SelectedRow = -1;
|
||||
listOutputComponent.Size = new Size(445, 209);
|
||||
listOutputComponent.TabIndex = 0;
|
||||
//
|
||||
// groupBoxSimpelTable
|
||||
//
|
||||
groupBoxSimpelTable.Controls.Add(buttonSimpleTable);
|
||||
groupBoxSimpelTable.Location = new Point(12, 265);
|
||||
groupBoxSimpelTable.Name = "groupBoxSimpelTable";
|
||||
groupBoxSimpelTable.Size = new Size(152, 101);
|
||||
groupBoxSimpelTable.TabIndex = 5;
|
||||
groupBoxSimpelTable.TabStop = false;
|
||||
groupBoxSimpelTable.Text = "SimpleTable";
|
||||
//
|
||||
// buttonSimpleTable
|
||||
//
|
||||
buttonSimpleTable.Location = new Point(6, 40);
|
||||
buttonSimpleTable.Name = "buttonSimpleTable";
|
||||
buttonSimpleTable.Size = new Size(138, 29);
|
||||
buttonSimpleTable.TabIndex = 6;
|
||||
buttonSimpleTable.Text = "Word таблицы";
|
||||
buttonSimpleTable.UseVisualStyleBackColor = true;
|
||||
buttonSimpleTable.Click += buttonSimpleTable_Click;
|
||||
//
|
||||
// groupBoxDiagram
|
||||
//
|
||||
groupBoxDiagram.Controls.Add(buttonCreateDiagram);
|
||||
groupBoxDiagram.Location = new Point(366, 265);
|
||||
groupBoxDiagram.Name = "groupBoxDiagram";
|
||||
groupBoxDiagram.Size = new Size(181, 101);
|
||||
groupBoxDiagram.TabIndex = 6;
|
||||
groupBoxDiagram.TabStop = false;
|
||||
groupBoxDiagram.Text = "Histogramma";
|
||||
//
|
||||
// buttonCreateDiagram
|
||||
//
|
||||
buttonCreateDiagram.Location = new Point(23, 40);
|
||||
buttonCreateDiagram.Name = "buttonCreateDiagram";
|
||||
buttonCreateDiagram.Size = new Size(127, 29);
|
||||
buttonCreateDiagram.TabIndex = 0;
|
||||
buttonCreateDiagram.Text = "Создать Word";
|
||||
buttonCreateDiagram.UseVisualStyleBackColor = true;
|
||||
buttonCreateDiagram.Click += createDiagram_Click;
|
||||
//
|
||||
// groupBoxTableWithHeaders
|
||||
//
|
||||
groupBoxTableWithHeaders.Controls.Add(buttonWordTableWithHeaders);
|
||||
groupBoxTableWithHeaders.Location = new Point(183, 265);
|
||||
groupBoxTableWithHeaders.Name = "groupBoxTableWithHeaders";
|
||||
groupBoxTableWithHeaders.Size = new Size(159, 101);
|
||||
groupBoxTableWithHeaders.TabIndex = 7;
|
||||
groupBoxTableWithHeaders.TabStop = false;
|
||||
groupBoxTableWithHeaders.Text = "TableWithHeaders";
|
||||
//
|
||||
// buttonWordTableWithHeaders
|
||||
//
|
||||
buttonWordTableWithHeaders.Location = new Point(6, 40);
|
||||
buttonWordTableWithHeaders.Name = "buttonWordTableWithHeaders";
|
||||
buttonWordTableWithHeaders.Size = new Size(132, 29);
|
||||
buttonWordTableWithHeaders.TabIndex = 0;
|
||||
buttonWordTableWithHeaders.Text = "Word таблица";
|
||||
buttonWordTableWithHeaders.UseVisualStyleBackColor = true;
|
||||
buttonWordTableWithHeaders.Click += WordSaveHeaders_Click;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1174, 376);
|
||||
Controls.Add(groupBoxTableWithHeaders);
|
||||
Controls.Add(groupBoxDiagram);
|
||||
Controls.Add(groupBoxSimpelTable);
|
||||
Controls.Add(groupBoxListOutput);
|
||||
Controls.Add(groupBoxInput);
|
||||
Controls.Add(groupBoxSelect);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
groupBoxSelect.ResumeLayout(false);
|
||||
groupBoxSelect.PerformLayout();
|
||||
groupBoxInput.ResumeLayout(false);
|
||||
groupBoxListOutput.ResumeLayout(false);
|
||||
groupBoxSimpelTable.ResumeLayout(false);
|
||||
groupBoxDiagram.ResumeLayout(false);
|
||||
groupBoxTableWithHeaders.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private YunusovComponentsLibrary.SelectedComponent selectComponent;
|
||||
private GroupBox groupBoxSelect;
|
||||
private Button buttonGetSelected;
|
||||
private Button buttonClear;
|
||||
private TextBox textBox;
|
||||
private Button buttonAdd;
|
||||
private YunusovComponentsLibrary.InputComponent inputComponent;
|
||||
private GroupBox groupBoxInput;
|
||||
private Button buttonShowFloat;
|
||||
private GroupBox groupBoxListOutput;
|
||||
private YunusovComponentsLibrary.ListOutputComponent listOutputComponent;
|
||||
private Button buttonGetListOutput;
|
||||
private Button buttonAddListOutput;
|
||||
private Button buttonClearListOutput;
|
||||
private YunusovComponentsLibrary.WordDocumentContext wordDocumentContext1;
|
||||
private GroupBox groupBoxSimpelTable;
|
||||
private Button buttonSimpleTable;
|
||||
private GroupBox groupBoxDiagram;
|
||||
private Button buttonCreateDiagram;
|
||||
private YunusovComponentsLibrary.WordDiagram wordDiagram;
|
||||
private GroupBox groupBoxTableWithHeaders;
|
||||
private Button buttonWordTableWithHeaders;
|
||||
private YunusovComponentsLibrary.WordDocumentTable wordDocumentTable1;
|
||||
}
|
||||
}
|
205
YunusovComponentsLibrary/Form1/Form1.cs
Normal file
205
YunusovComponentsLibrary/Form1/Form1.cs
Normal file
@ -0,0 +1,205 @@
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using Microsoft.VisualBasic.Devices;
|
||||
using System.Windows.Forms;
|
||||
using YunusovComponentsLibrary;
|
||||
using YunusovComponentsLibrary.Exceptions;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperModels;
|
||||
|
||||
namespace Form1
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
InitializeSelectComponent();
|
||||
InitializeInputComponent();
|
||||
|
||||
}
|
||||
private void InitializeSelectComponent()
|
||||
{
|
||||
selectComponent.Input("Çíà÷åíèå 1");
|
||||
selectComponent.Input("Çíà÷åíèå 2");
|
||||
selectComponent.Input("Çíà÷åíèå 3");
|
||||
selectComponent.Input("Çíà÷åíèå 4");
|
||||
selectComponent.Input("Çíà÷åíèå 5");
|
||||
}
|
||||
private void SelectComponent_ItemSelected(object sender, EventArgs e)
|
||||
{
|
||||
MessageBox.Show(selectComponent.SelectedItem);
|
||||
}
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (textBox.Text != "")
|
||||
selectComponent.Input(textBox.Text);
|
||||
}
|
||||
private void buttonClearList_Click(object sender, EventArgs e)
|
||||
{
|
||||
selectComponent.ClearList();
|
||||
}
|
||||
private void InitializeInputComponent()
|
||||
{
|
||||
inputComponent.FloatValue = 12.3f;
|
||||
}
|
||||
private void buttonShowFloat_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
float? Value = inputComponent.FloatValue;
|
||||
if (Value != null)
|
||||
{
|
||||
MessageBox.Show($"Ââåäåííîå ÷èñëî: {Value}");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Çíà÷åíèå - null");
|
||||
}
|
||||
}
|
||||
catch (NotFloatException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
catch (EmptyValueException ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
private void InitializeDataGridViewComponent()
|
||||
{
|
||||
listOutputComponent.ConfigColumn(new()
|
||||
{
|
||||
new ColumnInfo("", 0, false, "Id"),
|
||||
new ColumnInfo("Ôàìèëèÿ", 150, true, "Name"),
|
||||
new ColumnInfo("Èìÿ", 100, true, "Surname"),
|
||||
new ColumnInfo("Âîçðàñò", 100, true, "Age"),
|
||||
});
|
||||
List<TestPerson> Persons = new()
|
||||
{
|
||||
new TestPerson(1, "Âÿ÷åñëàâ", "Èâàíîâ", 20),
|
||||
new TestPerson(2, "Ðîñòèñëàâ", "Çàõàðîâ", 20),
|
||||
new TestPerson(3, "Ñåðãåé", "Ñåðãååâ", 59),
|
||||
new TestPerson(4, "Àðò¸ì", "ßøèí", 25),
|
||||
new TestPerson(5, "Ëåâ", "ßøèí", 89),
|
||||
};
|
||||
|
||||
foreach (TestPerson person in Persons)
|
||||
{
|
||||
listOutputComponent.AddItem(person);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAddListOutput_Click(object sender, EventArgs e)
|
||||
{
|
||||
InitializeDataGridViewComponent();
|
||||
}
|
||||
|
||||
private void buttonClearListOutput_Click(object sender, EventArgs e)
|
||||
{
|
||||
listOutputComponent.ClearDataGridView();
|
||||
}
|
||||
|
||||
private void buttonGetListOutput_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Test = listOutputComponent.GetSelectedObject<TestPerson>();
|
||||
MessageBox.Show(Test.ToString());
|
||||
}
|
||||
#region ïðîñòàÿ òàáëèöàÿ
|
||||
private void buttonSimpleTable_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string[,]> data = new List<string[,]>
|
||||
{
|
||||
new string[,]
|
||||
{
|
||||
{ "Ñòð 1 Êîë 1", "Ñòð 1 Êîë 2", "Ñòð 1 Êîë 3" },
|
||||
{ "Ñòð 2 Êîë 1", "Ñòð 2 Êîë 2", "Ñòð 2 Êîë 3" }
|
||||
},
|
||||
new string[,]
|
||||
{
|
||||
{ "Ñòð 1 Êîë 1", "Ñòð 1 Êîë 2", "Ñòð 1 Êîë 3", "Ñòð 1 Êîë 4", "Ñòð 1 Êîë 5", "Ñòð 1 Êîë 6" },
|
||||
{ "Ñòð 2 Êîë 1", "Ñòð 2 Êîë 2", "Ñòð 2 Êîë 3", "Ñòð 2 Êîë 4", "Ñòð 2 Êîë 5", "Ñòð 2 Êîë 6" },
|
||||
{ "Ñòð 3 Êîë 1", "Ñòð 3 Êîë 2", "Ñòð 3 Êîë 3", "Ñòð 3 Êîë 4", "Ñòð 3 Êîë 5", "Ñòð 3 Êîë 6" },
|
||||
{ "Ñòð 4 Êîë 1", "Ñòð 4 Êîë 2", "Ñòð 4 Êîë 3", "Ñòð 4 Êîë 4", "Ñòð 4 Êîë 5", "Ñòð 4 Êîë 6" },
|
||||
}
|
||||
};
|
||||
var info = new WordSimpleTable
|
||||
{
|
||||
FileName = "C://Users//niyaz//WordSimpleTable.docx",
|
||||
Title = "Çàãîëîâîê",
|
||||
Table = data,
|
||||
};
|
||||
wordDocumentContext1.CreateWord(info);
|
||||
MessageBox.Show("Word óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ñëîæíàÿ òàáëèöà
|
||||
|
||||
readonly List<PersonWordTable> PersonsWord = new()
|
||||
{
|
||||
new PersonWordTable("Äåïàðòàìåíò", "Âÿ÷åñëàâ", "Èâàíîâ", 20, 2000.1),
|
||||
new PersonWordTable("Äåïàðòàìåíò", "Ðîñòèñëàâ", "Çàõàðîâ", 20, 3000.5),
|
||||
new PersonWordTable("Äåïàðòàìåíò", "Ñåðãåé", "Ñåðãååâ", 59, 1001.3),
|
||||
new PersonWordTable("Áóõãàëòåðèÿ", "Àðò¸ì", "ßøèí", 25, 1234.23),
|
||||
new PersonWordTable("Áóõãàëòåðèÿ", "Ëåâ", "ßøèí", 89, 1457.34),
|
||||
};
|
||||
private void WordSaveHeaders_Click(object sender, EventArgs e)
|
||||
{
|
||||
wordDocumentTable1.CreateTable(new WordTableWithData<PersonWordTable>
|
||||
{
|
||||
FileName = "C://Users//niyaz//OneDrive//Äîêóìåíòû//HeaderTable.docx",
|
||||
Title = "Çàãîëîâîê",
|
||||
ColumnsRowsWidth = new List<(int Column, int Row)> { (5, 5), (10, 5), (10, 0), (5, 0), (10,5) },
|
||||
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
||||
{
|
||||
(0, 0, "Division", "Id"),
|
||||
(1, 0, "Surname", "Surname"),
|
||||
(2, 0, "Name", "Name"),
|
||||
(3, 0, "Age", "Age"),
|
||||
(4, 0, "Premia", "Premia"),
|
||||
},
|
||||
Data = PersonsWord,
|
||||
NullReplace = "null"
|
||||
});
|
||||
MessageBox.Show("Word äîêóìåíò ñ òàáëèöåé ñîçäàí!", "Óñïåõ");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ðàáîòà ñ äèàãðàììîé
|
||||
private void createDiagram_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
wordDiagram.CreateDiagram(
|
||||
new WordDiagramInfo
|
||||
{
|
||||
FileName = "C://Users//niyaz//OneDrive//Äîêóìåíòû//Diagram.docx",
|
||||
Title = "Çàãîëîâîê",
|
||||
ChartTitle = "Ãèñòîãðàììà",
|
||||
LegendLocation = YunusovComponentsLibrary.OfficePackage.HelperEnum.WordDiagramLegendLocation.Top,
|
||||
Series = new WordDiagramSeries
|
||||
{
|
||||
SeriesName = "Ãèñòîãðàììà",
|
||||
Data = new Dictionary<string, double>
|
||||
{
|
||||
{ "Windows", 71 },
|
||||
{ "OS X", 15.5 },
|
||||
{ "Linux", 4.5 },
|
||||
{ "Others", 8.5 },
|
||||
}
|
||||
}
|
||||
});
|
||||
MessageBox.Show("Word äîêóìåíò ñ äèàãðàììîé ñîçäàí!", "Óñïåõ");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show($"Îøèáêà: {ex.Message}");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
22
YunusovComponentsLibrary/Form1/Form1.csproj
Normal file
22
YunusovComponentsLibrary/Form1/Form1.csproj
Normal file
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="24.10.0" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1004" />
|
||||
<PackageReference Include="OxyPlot.WindowsForms" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\YunusovComponentsLibrary\YunusovComponentsLibrary.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
129
YunusovComponentsLibrary/Form1/Form1.resx
Normal file
129
YunusovComponentsLibrary/Form1/Form1.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?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="wordDocumentContext1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>165, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDiagram.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="wordDocumentTable1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>383, 17</value>
|
||||
</metadata>
|
||||
</root>
|
25
YunusovComponentsLibrary/Form1/PersonWordTable.cs
Normal file
25
YunusovComponentsLibrary/Form1/PersonWordTable.cs
Normal file
@ -0,0 +1,25 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public class PersonWordTable
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
|
||||
public int Age { get; set; }
|
||||
public double Premia { get; set; }
|
||||
public PersonWordTable()
|
||||
{ }
|
||||
|
||||
public PersonWordTable(string Id, string Name, string Surname, int Age, double Premia)
|
||||
{
|
||||
this.Id = Id;
|
||||
this.Name = Name;
|
||||
this.Surname = Surname;
|
||||
this.Age = Age;
|
||||
this.Premia = Premia;
|
||||
}
|
||||
}
|
||||
}
|
17
YunusovComponentsLibrary/Form1/Program.cs
Normal file
17
YunusovComponentsLibrary/Form1/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Form1
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
27
YunusovComponentsLibrary/Form1/TestPerson.cs
Normal file
27
YunusovComponentsLibrary/Form1/TestPerson.cs
Normal file
@ -0,0 +1,27 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public class TestPerson
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
|
||||
public int Age { get; set; }
|
||||
public TestPerson()
|
||||
{ }
|
||||
|
||||
public TestPerson(int Id, string Name, string Surname, int Age)
|
||||
{
|
||||
this.Id = Id;
|
||||
this.Name = Name;
|
||||
this.Surname = Surname;
|
||||
this.Age = Age;
|
||||
}
|
||||
public string ToString()
|
||||
{
|
||||
return $"{Id}. {Name} {Surname} Возраст: {Age}";
|
||||
}
|
||||
}
|
||||
}
|
31
YunusovComponentsLibrary/YunusovComponentsLibrary.sln
Normal file
31
YunusovComponentsLibrary/YunusovComponentsLibrary.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34221.43
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YunusovComponentsLibrary", "YunusovComponentsLibrary\YunusovComponentsLibrary.csproj", "{FADF2E43-1F76-4A8B-A586-4D59676F6335}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Form1", "Form1\Form1.csproj", "{9A55F075-005A-433D-B6CC-89E850999353}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{FADF2E43-1F76-4A8B-A586-4D59676F6335}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FADF2E43-1F76-4A8B-A586-4D59676F6335}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FADF2E43-1F76-4A8B-A586-4D59676F6335}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FADF2E43-1F76-4A8B-A586-4D59676F6335}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9A55F075-005A-433D-B6CC-89E850999353}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9A55F075-005A-433D-B6CC-89E850999353}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9A55F075-005A-433D-B6CC-89E850999353}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9A55F075-005A-433D-B6CC-89E850999353}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {5A6AC5CC-7959-44F7-8CAC-06D9B6C31516}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -0,0 +1,6 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public class ColumnInfo
|
||||
{
|
||||
public int ColumnsCount { get; set; }
|
||||
|
||||
public string Header { get; set; }
|
||||
|
||||
public int Width { get; set; }
|
||||
|
||||
public bool IsVisible { get; set; }
|
||||
|
||||
public string PropertiesName { get; set; }
|
||||
|
||||
public ColumnInfo(string Header, int Width, bool IsVisible, string PropertiesName)
|
||||
{
|
||||
this.Header = Header;
|
||||
this.Width = Width;
|
||||
this.IsVisible = IsVisible;
|
||||
this.PropertiesName = PropertiesName;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace YunusovComponentsLibrary.Exceptions
|
||||
{
|
||||
public class EmptyValueException : ApplicationException
|
||||
{
|
||||
public EmptyValueException()
|
||||
: base("Значение не введено")
|
||||
{ }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace YunusovComponentsLibrary.Exceptions
|
||||
{
|
||||
public class NotFloatException : ApplicationException
|
||||
{
|
||||
public NotFloatException()
|
||||
: base("Введенное значение не является вещественным")
|
||||
{ }
|
||||
}
|
||||
}
|
68
YunusovComponentsLibrary/YunusovComponentsLibrary/InputComponent.Designer.cs
generated
Normal file
68
YunusovComponentsLibrary/YunusovComponentsLibrary/InputComponent.Designer.cs
generated
Normal file
@ -0,0 +1,68 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class InputComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
public void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
IsNullCheckBox = new CheckBox();
|
||||
textBoxInput = new TextBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// IsNullCheckBox
|
||||
//
|
||||
IsNullCheckBox.AutoSize = true;
|
||||
IsNullCheckBox.Location = new Point(13, 20);
|
||||
IsNullCheckBox.Name = "IsNullCheckBox";
|
||||
IsNullCheckBox.Size = new Size(18, 17);
|
||||
IsNullCheckBox.TabIndex = 0;
|
||||
IsNullCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBoxInput
|
||||
//
|
||||
textBoxInput.Location = new Point(37, 14);
|
||||
textBoxInput.Name = "textBoxInput";
|
||||
textBoxInput.Size = new Size(125, 27);
|
||||
textBoxInput.TabIndex = 1;
|
||||
//
|
||||
// InputComponent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(textBoxInput);
|
||||
Controls.Add(IsNullCheckBox);
|
||||
Name = "InputComponent";
|
||||
Size = new Size(170, 55);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox IsNullCheckBox;
|
||||
private TextBox textBoxInput;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using YunusovComponentsLibrary.Exceptions;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class InputComponent : UserControl
|
||||
{
|
||||
private event EventHandler? _valueChanged;
|
||||
public InputComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public float? FloatValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsNullCheckBox.Checked)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxInput.Text))
|
||||
{
|
||||
throw new EmptyValueException();
|
||||
}
|
||||
|
||||
float ParsedFloat;
|
||||
if (float.TryParse(textBoxInput.Text, out ParsedFloat))
|
||||
{
|
||||
return ParsedFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotFloatException();
|
||||
}
|
||||
}
|
||||
set
|
||||
{
|
||||
SetNullState(value is null, true);
|
||||
if (value is not null)
|
||||
{
|
||||
textBoxInput.Text = value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
public event EventHandler? ValueChanged
|
||||
{
|
||||
add { _valueChanged += value; }
|
||||
remove { _valueChanged -= value; }
|
||||
}
|
||||
private void SetNullState(bool IsNull = false, bool ClearText = false)
|
||||
{
|
||||
IsNullCheckBox.Checked = IsNull;
|
||||
textBoxInput.Enabled = !IsNull;
|
||||
|
||||
if (ClearText)
|
||||
{
|
||||
textBoxInput.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private void textBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
_valueChanged?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
61
YunusovComponentsLibrary/YunusovComponentsLibrary/ListOutputComponent.Designer.cs
generated
Normal file
61
YunusovComponentsLibrary/YunusovComponentsLibrary/ListOutputComponent.Designer.cs
generated
Normal file
@ -0,0 +1,61 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class ListOutputComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
public void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(600, 338);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ListOutputComponent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ListOutputComponent";
|
||||
Size = new Size(600, 338);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class ListOutputComponent : UserControl
|
||||
{
|
||||
public ListOutputComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public DataGridViewRowCollection Rows
|
||||
{
|
||||
get { return dataGridView.Rows; }
|
||||
}
|
||||
public int SelectedRow
|
||||
{
|
||||
get
|
||||
{
|
||||
return dataGridView.SelectedRows.Count == 1 ? dataGridView.SelectedRows[0].Index : -1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 0 && value < dataGridView.Rows.Count)
|
||||
{
|
||||
dataGridView.Rows[value].Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void ConfigColumn(List<ColumnInfo> columns)
|
||||
{
|
||||
dataGridView.Columns.Clear();
|
||||
|
||||
dataGridView.ColumnCount = columns.Count;
|
||||
|
||||
for (int i = 0; i < columns.Count; ++i)
|
||||
{
|
||||
dataGridView.Columns[i].HeaderText = columns[i].Header;
|
||||
dataGridView.Columns[i].Width = columns[i].Width;
|
||||
dataGridView.Columns[i].Visible = columns[i].IsVisible;
|
||||
dataGridView.Columns[i].Name = columns[i].PropertiesName;
|
||||
}
|
||||
}
|
||||
public void ClearDataGridView()
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
}
|
||||
public T GetSelectedObject<T>() where T : class, new()
|
||||
{
|
||||
T obj = new();
|
||||
var properties = typeof(T).GetProperties();
|
||||
|
||||
foreach (var property in properties)
|
||||
{
|
||||
var cellValue = dataGridView.Rows[SelectedRow].Cells[property.Name].Value;
|
||||
if (cellValue != null)
|
||||
{
|
||||
property.SetValue(obj, Convert.ChangeType(cellValue, property.PropertyType));
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
public void AddItem<T>(T item)
|
||||
{
|
||||
if (item == null)
|
||||
return;
|
||||
|
||||
int rowIndex = dataGridView.Rows.Add();
|
||||
|
||||
foreach (DataGridViewColumn Column in dataGridView.Columns)
|
||||
{
|
||||
var Property = typeof(T).GetProperties().FirstOrDefault(x => x.Name == Column.Name);
|
||||
var Value = Property.GetValue(item);
|
||||
dataGridView.Rows[rowIndex].Cells[Column.Index].Value = Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperEnum
|
||||
{
|
||||
public enum WordDiagramLegendLocation
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperEnum
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
Both
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordDiagramInfo : WordInfo
|
||||
{
|
||||
public string ChartTitle { get; set; } = string.Empty;
|
||||
public WordDiagramLegendLocation LegendLocation { get; set; } = WordDiagramLegendLocation.Right;
|
||||
public WordDiagramSeries Series { get; set; } = new();
|
||||
|
||||
public void CheckFields()
|
||||
{
|
||||
if (string.IsNullOrEmpty(FileName))
|
||||
throw new ArgumentNullException(nameof(FileName), "File path and name cannot be null or empty.");
|
||||
if (string.IsNullOrEmpty(Title))
|
||||
throw new ArgumentNullException(nameof(Title), "Title cannot be null or empty.");
|
||||
if (Series == null)
|
||||
throw new ArgumentNullException(nameof(Series), "Data cannot be null or empty.");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordDiagramSeries
|
||||
{
|
||||
public string SeriesName { get; set; } = string.Empty;
|
||||
public Dictionary<string, double> Data = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string Style { get; set; } = string.Empty;
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordSimpleTable : WordInfo
|
||||
{
|
||||
public List<string[,]> Table { get; set; } = new List<string[,]>();
|
||||
|
||||
public void CheckFields()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(FileName) || string.IsNullOrWhiteSpace(Title) || Table == null || Table.Count == 0)
|
||||
{
|
||||
throw new ArgumentException("Все поля должны быть заполнены.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTableWithData<T> : WordTableWithHeader
|
||||
{
|
||||
public List<T> Data { get; set; }
|
||||
public void CheckFields()
|
||||
{
|
||||
if (Data == null || Data.Count == 0)
|
||||
throw new ArgumentNullException("No data");
|
||||
if (ColumnsRowsWidth is null || ColumnsRowsWidth.Count == 0)
|
||||
throw new ArgumentNullException("Rows width invalid");
|
||||
if (Headers is null || Headers.Count == 0)
|
||||
throw new ArgumentNullException("Header data invalid");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTableWithHeader : WordInfo
|
||||
{
|
||||
public (int Columns, int Rows) ColumnsRowsDataCount { get; set; }
|
||||
public List<(int Column, int Row)>? ColumnsRowsWidth { get; init; }
|
||||
public List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>? Headers { get; init; }
|
||||
public string NullReplace { get; set; } = "null";
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; } = string.Empty;
|
||||
public bool Bold { get; set; }
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,231 @@
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Aspose.Words.Drawing.Charts;
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing;
|
||||
using Body = DocumentFormat.OpenXml.Wordprocessing.Body;
|
||||
using Paragraph = DocumentFormat.OpenXml.Wordprocessing.Paragraph;
|
||||
using Run = DocumentFormat.OpenXml.Wordprocessing.Run;
|
||||
using Document = DocumentFormat.OpenXml.Wordprocessing.Document;
|
||||
|
||||
|
||||
namespace YunusovComponentsLibrary.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWord
|
||||
{
|
||||
private Document _document;
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
private Body? _docBody;
|
||||
/// <summary>
|
||||
/// Получение типа выравнивания
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType type)
|
||||
{
|
||||
return type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center, _ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
/// <summary>
|
||||
/// Настройки страницы
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var properties = new SectionProperties();
|
||||
var pageSize = new DocumentFormat.OpenXml.Wordprocessing.PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
properties.AppendChild(pageSize);
|
||||
return properties;
|
||||
}
|
||||
/// <summary>
|
||||
/// Задание форматирования для абзаца
|
||||
/// </summary>
|
||||
/// <param name="paragraphProperties"></param>
|
||||
/// <returns></returns>
|
||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
|
||||
{
|
||||
if (paragraphProperties == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var properties = new ParagraphProperties();
|
||||
properties.AppendChild(new Justification()
|
||||
{
|
||||
Val = GetJustificationValues(paragraphProperties.JustificationType)
|
||||
});
|
||||
properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
properties.AppendChild(new Indentation());
|
||||
var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
||||
{
|
||||
Val = paragraphProperties.Size
|
||||
});
|
||||
}
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
return properties;
|
||||
}
|
||||
public void CreateWord(WordInfo info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
public void CreateParagraph(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
var docRun = new Run();
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
docRun.AppendChild(properties);
|
||||
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
public void SaveWord(WordInfo info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Dispose();
|
||||
|
||||
}
|
||||
public void CreateTable(string[,] table)
|
||||
{
|
||||
if (_docBody == null || table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Table docTable = new Table();
|
||||
TableProperties tableProps = new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new BottomBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new LeftBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new RightBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideHorizontalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideVerticalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
}
|
||||
));
|
||||
docTable.AppendChild(tableProps);
|
||||
TableGrid tableGrid = new TableGrid();
|
||||
int height = table.GetLength(0);
|
||||
int width = table.GetLength(1);
|
||||
for (int i = 0; i < width; i++)
|
||||
{
|
||||
tableGrid.AppendChild(new GridColumn());
|
||||
}
|
||||
TableRow tableRow = new TableRow();
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
tableRow = new TableRow();
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
var element = table[i,j];
|
||||
tableRow.AppendChild(CreateTableCell(element));
|
||||
}
|
||||
docTable.AppendChild(tableRow);
|
||||
}
|
||||
_docBody.AppendChild(docTable);
|
||||
}
|
||||
private TableCell CreateTableCell(string element)
|
||||
{
|
||||
var tableParagraph = new Paragraph();
|
||||
var run = new Run();
|
||||
run.AppendChild(new Text { Text = element });
|
||||
tableParagraph.AppendChild(run);
|
||||
var tableCell = new TableCell();
|
||||
tableCell.AppendChild(tableParagraph);
|
||||
return tableCell;
|
||||
}
|
||||
|
||||
public void CreateDiagram(WordDiagramInfo parameters)
|
||||
{
|
||||
Aspose.Words.Document doc = new Aspose.Words.Document();
|
||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||
if (doc == null)
|
||||
throw new ArgumentNullException(nameof(doc), "Document is not created.");
|
||||
builder.ParagraphFormat.Style.Font.Size = 16;
|
||||
builder.Writeln(parameters.Title);
|
||||
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
|
||||
Chart chart = shape.Chart;
|
||||
GetLegendPosition(parameters, chart);
|
||||
ChartSeriesCollection seriesColl = chart.Series;
|
||||
seriesColl.Clear();
|
||||
ChartSeries series = chart.Series.Add(parameters.Series.SeriesName, parameters.Series.Data.Select(x => x.Key).ToArray(), parameters.Series.Data.Select(x => x.Value).ToArray());
|
||||
doc.Save(parameters.FileName);
|
||||
}
|
||||
|
||||
private void GetLegendPosition(WordDiagramInfo parameters, Chart chart)
|
||||
{
|
||||
switch (parameters.LegendLocation)
|
||||
{
|
||||
case WordDiagramLegendLocation.Left:
|
||||
chart.Legend.Position = LegendPosition.Left;
|
||||
break;
|
||||
case WordDiagramLegendLocation.Right:
|
||||
chart.Legend.Position = LegendPosition.Right;
|
||||
break;
|
||||
case WordDiagramLegendLocation.Top:
|
||||
chart.Legend.Position = LegendPosition.Top;
|
||||
break;
|
||||
case WordDiagramLegendLocation.Bottom:
|
||||
chart.Legend.Position = LegendPosition.Bottom;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
58
YunusovComponentsLibrary/YunusovComponentsLibrary/SelectedComponent.Designer.cs
generated
Normal file
58
YunusovComponentsLibrary/YunusovComponentsLibrary/SelectedComponent.Designer.cs
generated
Normal file
@ -0,0 +1,58 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class SelectedComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
public void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
listBox = new ListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// listBox
|
||||
//
|
||||
listBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
listBox.FormattingEnabled = true;
|
||||
listBox.ItemHeight = 20;
|
||||
listBox.Location = new Point(3, 3);
|
||||
listBox.Name = "listBox";
|
||||
listBox.Size = new Size(125, 164);
|
||||
listBox.TabIndex = 0;
|
||||
//
|
||||
// SelectedComponent
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(listBox);
|
||||
Name = "SelectedComponent";
|
||||
Size = new Size(131, 181);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ListBox listBox;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class SelectedComponent : UserControl
|
||||
{
|
||||
private event EventHandler _itemSelected;
|
||||
public SelectedComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void Input(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
throw new ArgumentNullException("input");
|
||||
listBox.Items.Add(str);
|
||||
}
|
||||
public void ClearList()
|
||||
{
|
||||
listBox.Items.Clear();
|
||||
}
|
||||
public string SelectedItem
|
||||
{
|
||||
get { return (string)listBox.SelectedItem ?? string.Empty; }
|
||||
set { listBox.SelectedItem = value; }
|
||||
}
|
||||
public event EventHandler? ItemSelected
|
||||
{
|
||||
add { _itemSelected += value; }
|
||||
remove { _itemSelected -= value; }
|
||||
}
|
||||
private void listBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
_itemSelected?.Invoke(this, e);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
73
YunusovComponentsLibrary/YunusovComponentsLibrary/Testing.Designer.cs
generated
Normal file
73
YunusovComponentsLibrary/YunusovComponentsLibrary/Testing.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class Testing
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
public void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Код, автоматически созданный конструктором компонентов
|
||||
|
||||
/// <summary>
|
||||
/// Требуемый метод для поддержки конструктора — не изменяйте
|
||||
/// содержимое этого метода с помощью редактора кода.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBox = new PictureBox();
|
||||
button = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBox
|
||||
//
|
||||
pictureBox.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
pictureBox.Location = new Point(3, 3);
|
||||
pictureBox.Name = "pictureBox";
|
||||
pictureBox.Size = new Size(187, 150);
|
||||
pictureBox.TabIndex = 0;
|
||||
pictureBox.TabStop = false;
|
||||
//
|
||||
// button
|
||||
//
|
||||
button.Anchor = AnchorStyles.Bottom;
|
||||
button.Location = new Point(49, 156);
|
||||
button.Name = "button";
|
||||
button.Size = new Size(94, 29);
|
||||
button.TabIndex = 1;
|
||||
button.Text = "Загрузить";
|
||||
button.UseVisualStyleBackColor = true;
|
||||
button.Click += button_Click;
|
||||
//
|
||||
// Testing
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(button);
|
||||
Controls.Add(pictureBox);
|
||||
Name = "Testing";
|
||||
Size = new Size(193, 188);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBox;
|
||||
private Button button;
|
||||
}
|
||||
}
|
68
YunusovComponentsLibrary/YunusovComponentsLibrary/Testing.cs
Normal file
68
YunusovComponentsLibrary/YunusovComponentsLibrary/Testing.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class Testing : UserControl
|
||||
{
|
||||
private event EventHandler? _avatarChanged;
|
||||
private event Action? _errorOccured;
|
||||
public string Error { get; private set; }
|
||||
public Image Avatar
|
||||
{
|
||||
get
|
||||
{
|
||||
return pictureBox.Image;
|
||||
}
|
||||
set
|
||||
{
|
||||
pictureBox.Image = value;
|
||||
}
|
||||
}
|
||||
public event EventHandler AvatarChanged
|
||||
{
|
||||
add { _avatarChanged += value; }
|
||||
remove { _avatarChanged -= value; }
|
||||
}
|
||||
public event Action AnErrorOccurred
|
||||
{
|
||||
add { _errorOccured += value; }
|
||||
remove { _errorOccured -= value; }
|
||||
}
|
||||
public Testing()
|
||||
{
|
||||
InitializeComponent();
|
||||
Error = string.Empty;
|
||||
}
|
||||
private void ButtonLoad_Click(object sender, EventArgs e)
|
||||
{
|
||||
var ofd = new OpenFileDialog();
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
pictureBox.Image =
|
||||
Image.FromFile(ofd.FileName);
|
||||
_avatarChanged?.Invoke(this, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Error = ex.Message;
|
||||
_errorOccured?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void button_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
YunusovComponentsLibrary/YunusovComponentsLibrary/Testing.resx
Normal file
120
YunusovComponentsLibrary/YunusovComponentsLibrary/Testing.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>
|
36
YunusovComponentsLibrary/YunusovComponentsLibrary/WordDiagram.Designer.cs
generated
Normal file
36
YunusovComponentsLibrary/YunusovComponentsLibrary/WordDiagram.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class WordDiagram
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperModels;
|
||||
using YunusovComponentsLibrary.OfficePackage.Implements;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class WordDiagram : Component
|
||||
{
|
||||
SaveToWord SaveToWord = new SaveToWord();
|
||||
public WordDiagram()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordDiagram(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
public void CreateDiagram(WordDiagramInfo info)
|
||||
{
|
||||
info.CheckFields();
|
||||
SaveToWord.CreateDiagram(info);
|
||||
}
|
||||
}
|
||||
}
|
36
YunusovComponentsLibrary/YunusovComponentsLibrary/WordDocumentContext.Designer.cs
generated
Normal file
36
YunusovComponentsLibrary/YunusovComponentsLibrary/WordDocumentContext.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class WordDocumentContext
|
||||
{
|
||||
/// <summary>
|
||||
/// Обязательная переменная конструктора.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Освободить все используемые ресурсы.
|
||||
/// </summary>
|
||||
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param>
|
||||
public 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
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YunusovComponentsLibrary.OfficePackage.Implements;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperModels;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class WordDocumentContext : Component
|
||||
{
|
||||
SaveToWord SaveToWord = new SaveToWord();
|
||||
public WordDocumentContext()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordDocumentContext(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateWord(WordSimpleTable info)
|
||||
{
|
||||
info.CheckFields();
|
||||
SaveToWord.CreateWord(info);
|
||||
SaveToWord.CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
foreach (var table in info.Table)
|
||||
{
|
||||
SaveToWord.CreateTable(table);
|
||||
SaveToWord.CreateParagraph(new WordParagraph());
|
||||
}
|
||||
SaveToWord.SaveWord(info);
|
||||
}
|
||||
}
|
||||
}
|
36
YunusovComponentsLibrary/YunusovComponentsLibrary/WordDocumentTable.Designer.cs
generated
Normal file
36
YunusovComponentsLibrary/YunusovComponentsLibrary/WordDocumentTable.Designer.cs
generated
Normal file
@ -0,0 +1,36 @@
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
partial class WordDocumentTable
|
||||
{
|
||||
/// <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
|
||||
}
|
||||
}
|
@ -0,0 +1,200 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.EMMA;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperEnum;
|
||||
using YunusovComponentsLibrary.OfficePackage.HelperModels;
|
||||
using YunusovComponentsLibrary.OfficePackage.Implements;
|
||||
|
||||
namespace YunusovComponentsLibrary
|
||||
{
|
||||
public partial class WordDocumentTable : Component
|
||||
{
|
||||
private Document _document = null;
|
||||
|
||||
private Body _body = null;
|
||||
|
||||
private DocumentFormat.OpenXml.Wordprocessing.Table _table = null;
|
||||
|
||||
private Document Document
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_document == null)
|
||||
{
|
||||
_document = new Document();
|
||||
}
|
||||
|
||||
return _document;
|
||||
}
|
||||
}
|
||||
|
||||
private Body Body
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_body == null)
|
||||
{
|
||||
_body = Document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
return _body;
|
||||
}
|
||||
}
|
||||
|
||||
private DocumentFormat.OpenXml.Wordprocessing.Table Table
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_table == null)
|
||||
{
|
||||
_table = new DocumentFormat.OpenXml.Wordprocessing.Table();
|
||||
}
|
||||
|
||||
return _table;
|
||||
}
|
||||
}
|
||||
public WordDocumentTable()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public WordDocumentTable(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void CreateTable<T>(WordTableWithData<T> config)
|
||||
{
|
||||
config.CheckFields();
|
||||
config.ColumnsRowsDataCount = (config.Data.Count + 2, config.ColumnsRowsWidth.Count);
|
||||
CreateHeader(config.Title);
|
||||
CreateTableWithHeader();
|
||||
CreateMultiHeader(config);
|
||||
var array = new string[config.Data.Count, config.Headers.Count];
|
||||
for (var j = 0; j < config.Data.Count; j++)
|
||||
{
|
||||
for (var i = 0; i < config.Headers.Count; i++)
|
||||
{
|
||||
(int, int, string, string) first = (0, 0, null, null)!;
|
||||
foreach (var x in config.Headers.Where(x => x.ColumnIndex == i))
|
||||
{
|
||||
first = x;
|
||||
break;
|
||||
}
|
||||
var (_, _, _, name) = first;
|
||||
if (name != null)
|
||||
{
|
||||
object? value = config.Data[j]?.GetType().GetProperty(name)!.GetValue(config.Data[j], null);
|
||||
array[j, i] = value == null
|
||||
? config.NullReplace
|
||||
: value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadDataToTableWithMultiHeader(array);
|
||||
SaveDoc(config.FileName);
|
||||
}
|
||||
public void SaveDoc(string filepath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filepath))
|
||||
{
|
||||
throw new ArgumentNullException("Имя файла не задано");
|
||||
}
|
||||
|
||||
if (_document == null || _body == null)
|
||||
{
|
||||
throw new ArgumentNullException("Документ не сформирован, сохранять нечего");
|
||||
}
|
||||
|
||||
if (_table != null)
|
||||
{
|
||||
Body.Append(Table);
|
||||
}
|
||||
|
||||
using WordprocessingDocument wordprocessingDocument = WordprocessingDocument.Create(filepath, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainDocumentPart = wordprocessingDocument.AddMainDocumentPart();
|
||||
mainDocumentPart.Document = Document;
|
||||
}
|
||||
public void LoadDataToTableWithMultiHeader(string[,] data)
|
||||
{
|
||||
for (int i = 0; i < data.GetLength(0); i++)
|
||||
{
|
||||
TableRow tablerow = new TableRow();
|
||||
for (int j = 0; j < data.GetLength(1); j++)
|
||||
{
|
||||
TableCell tableCell = new TableCell();
|
||||
tableCell.Append(new Paragraph(new Run(new Text(data[i, j]))));
|
||||
tablerow.Append(tableCell);
|
||||
}
|
||||
Table.Append(tablerow);
|
||||
}
|
||||
}
|
||||
public void CreateMultiHeader<T>(WordTableWithData<T> config)
|
||||
{
|
||||
if (config.Headers == null || !config.Headers.Any())
|
||||
return;
|
||||
TableProperties tblProperties = new TableProperties(
|
||||
new TableWidth { Type = TableWidthUnitValues.Dxa, Width = "5000" });
|
||||
Table.AppendChild(tblProperties);
|
||||
TableRow headerRow = new TableRow();
|
||||
foreach (var header in config.Headers.Where(h => h.ColumnIndex >= 0))
|
||||
{
|
||||
TableCell cell = new TableCell(new Paragraph(new Run(new Text(header.Header))));
|
||||
TableCellProperties cellProperties = new TableCellProperties(
|
||||
new TableCellWidth { Type = TableWidthUnitValues.Dxa, Width = (header.ColumnIndex * 100).ToString() });
|
||||
cell.AppendChild(cellProperties);
|
||||
headerRow.AppendChild(cell);
|
||||
}
|
||||
|
||||
Table.AppendChild(headerRow);
|
||||
}
|
||||
|
||||
public void CreateTableWithHeader()
|
||||
{
|
||||
Table.AppendChild(new TableProperties(new TableBorders(new TopBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = (UInt32Value)12u
|
||||
}, new BottomBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = (UInt32Value)12u
|
||||
}, new LeftBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = (UInt32Value)12u
|
||||
}, new RightBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = (UInt32Value)12u
|
||||
}, new InsideHorizontalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = (UInt32Value)12u
|
||||
}, new InsideVerticalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = (UInt32Value)12u
|
||||
})));
|
||||
}
|
||||
|
||||
public void CreateHeader(string header)
|
||||
{
|
||||
Paragraph paragraph = Body.AppendChild(new Paragraph());
|
||||
Run run = paragraph.AppendChild(new Run());
|
||||
run.AppendChild(new RunProperties(new Bold()));
|
||||
run.AppendChild(new Text(header));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||
<Version>$(VersionPrefix)1.0.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Aspose.Words" Version="24.10.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001" />
|
||||
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1004" />
|
||||
<PackageReference Include="OxyPlot.Core" Version="2.2.0" />
|
||||
<PackageReference Include="OxyPlot.WindowsForms" Version="2.2.0" />
|
||||
<PackageReference Include="OxyPlot.Wpf" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user