200 lines
7.2 KiB
C#
200 lines
7.2 KiB
C#
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using Library15Gerimovich;
|
|
using Library15Gerimovich.Exceptions;
|
|
using Library15Gerimovich.OfficePackage.HelperModels;
|
|
|
|
namespace WinFormsAppTest
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
|
|
InitializeDefaultList();
|
|
InitializeInputRealNumber();
|
|
InitializeOutputTableResults();
|
|
}
|
|
|
|
private void InitializeDefaultList()
|
|
{
|
|
defaultList.SetItems("RITG");
|
|
defaultList.SetItems("Simbirsoft");
|
|
}
|
|
|
|
private void InitializeInputRealNumber()
|
|
{
|
|
inputRealNumber.DoubleValue = 1500;
|
|
}
|
|
|
|
private void InitializeOutputTableResults()
|
|
{
|
|
outputTableResults.ConfigureColumns(new List<ColumnInfo>
|
|
{
|
|
new ColumnInfo("", 0, false, "Id"),
|
|
new ColumnInfo("Surname", 150, true, "Surname"),
|
|
new ColumnInfo("Name", 150, true, "Name"),
|
|
new ColumnInfo("Age", 50, true, "Age"),
|
|
});
|
|
TestObject TestOB = new TestObject(1, "Ôàìèëèÿ", "èìÿ", 10);
|
|
TestObject TestOB2 = new TestObject(1, "Èâàíîâ", "Èâàí", 29);
|
|
|
|
outputTableResults.InsertValue(TestOB);
|
|
outputTableResults.InsertValue(TestOB2);
|
|
|
|
}
|
|
|
|
private void defaultList_ItemSelected(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(defaultList.SelectedItem);
|
|
}
|
|
|
|
private void InputComponent_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void ClearListButton_Click(object sender, EventArgs e)
|
|
{
|
|
defaultList.ClearList();
|
|
}
|
|
|
|
private void PrintObjectButton_Click(object sender, EventArgs e)
|
|
{
|
|
var Test = outputTableResults.GetSelectedObject<TestObject>();
|
|
MessageBox.Show(Test.ToString());
|
|
}
|
|
|
|
private void CheckRealButton_Click_1(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
double? Value = inputRealNumber.DoubleValue;
|
|
if (Value != null)
|
|
{
|
|
MessageBox.Show($"Ââåäåíî âåùåñòâåííîå ÷èñëî: {Value}");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Çíà÷åíèå - null");
|
|
}
|
|
}
|
|
catch (MalformedRealException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
catch (EmptyValueException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void ClearDatagridButton_Click(object sender, EventArgs e)
|
|
{
|
|
outputTableResults.ClearGrid();
|
|
}
|
|
|
|
private void buttonSimpleTable_Click(object sender, EventArgs e)
|
|
{
|
|
List<string[,]> data = new List<string[,]>
|
|
{
|
|
new string[,]
|
|
{
|
|
{"123", "123", "123" },
|
|
{"123", "123", "123" },
|
|
{"123", "123", "123" },
|
|
},
|
|
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//user//Desktop//WordSimpleTable.docx",
|
|
Title = "Çàãîëîâîê",
|
|
Table = data,
|
|
};
|
|
wordContextTablesComponent1.CreateWord(info);
|
|
MessageBox.Show("Word óñïåøíî ñîçäàí!", "Óñïåõ", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
}
|
|
readonly List<TestWordTable> PersonsWord = new()
|
|
{
|
|
new TestWordTable("1", "123", "123", 20, 2000),
|
|
new TestWordTable("1", "123", "123", 20, 3000),
|
|
new TestWordTable("1", "123", "123", 59, 1001),
|
|
new TestWordTable("2", "123", "123", 25, 1234),
|
|
new TestWordTable("2", "123", "123", 89, 1457),
|
|
};
|
|
private void buttonHeadersTable_Click(object sender, EventArgs e)
|
|
{
|
|
wordTablesComponent1.CreateTable(new WordTableWithData<TestWordTable>
|
|
{
|
|
FileName = "C://Users//user//Desktop//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
|
|
});
|
|
//wordTablesComponent1.CreateTable(new WordTableWithHeader<TestWordTable>
|
|
//{
|
|
// FileName = "C://Users//user//Desktop//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 äîêóìåíò ñ òàáëèöåé ñîçäàí!", "Óñïåõ");
|
|
}
|
|
|
|
private void buttonCreateDiagram_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
wordDiagramComponent1.CreateDiagram(
|
|
new WordDiagramInfo
|
|
{
|
|
FileName = "C://Users//user//Desktop//Diagram.docx",
|
|
Title = "Çàãîëîâîê",
|
|
ChartTitle = "Ãèñòîãðàììà",
|
|
LegendLocation = Library15Gerimovich.OfficePackage.HelperEnums.WordDiagramLegendLocation.Top,
|
|
Series = new WordDiagramSeries
|
|
{
|
|
SeriesName = "Êîëè÷åñòâî îöåíîê",
|
|
Data = new Dictionary<string, double>
|
|
{
|
|
{ "5", 7 },
|
|
{ "4", 8 },
|
|
{ "3", 5 },
|
|
{ "2", 3 },
|
|
}
|
|
}
|
|
});
|
|
MessageBox.Show("Word äîêóìåíò ñ äèàãðàììîé ñîçäàí!", "Óñïåõ");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show($"Îøèáêà: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
} |