145 lines
3.6 KiB
C#
145 lines
3.6 KiB
C#
using ShabComponentsLibrary;
|
|
using ShabComponentsLibrary.Exceptions;
|
|
|
|
namespace FormsTesting
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
|
|
InitializeSelectComponent();
|
|
InitializeInputComponent();
|
|
InitializeGridComponent();
|
|
}
|
|
|
|
private void InitializeSelectComponent()
|
|
{
|
|
SelectComponent.SetItems(new List<string>
|
|
{
|
|
"Çíà÷åíèå 1",
|
|
"Çíà÷åíèå 2",
|
|
"Çíà÷åíèå 3",
|
|
"Çíà÷åíèå 4",
|
|
"Çíà÷åíèå 5",
|
|
});
|
|
}
|
|
|
|
private void InitializeInputComponent()
|
|
{
|
|
InputComponent.IntValue = 1500;
|
|
}
|
|
|
|
private void InitializeGridComponent()
|
|
{
|
|
GridComponent.ConfigureColumns(new List<ColumnInfo>
|
|
{
|
|
new ColumnInfo("", 0, false, "Id"),
|
|
new ColumnInfo("Ôàìèëèÿ", 150, true, "LastName"),
|
|
new ColumnInfo("Èìÿ", 150, true, "FirstName"),
|
|
new ColumnInfo("Âîçðàñò", 100, true, "Age"),
|
|
});
|
|
|
|
List<TestPerson> Persons = new List<TestPerson>
|
|
{
|
|
new TestPerson(1, "Èâàí", "Èâàíîâ", 34),
|
|
new TestPerson(2, "Ïåòð", "Ïåòðîâ", 44),
|
|
new TestPerson(3, "Ñåðãåé", "Ñåðãååâ", 55),
|
|
new TestPerson(4, "Îëüãà", "Èâàíîâà", 34),
|
|
new TestPerson(5, "Òàòüÿíà", "Ïåòðîâà", 44),
|
|
};
|
|
|
|
GridComponent.InsertValues(Persons);
|
|
}
|
|
|
|
private void SelectComponent_ItemSelected(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(SelectComponent.SelectedItem);
|
|
}
|
|
|
|
private void InputComponent_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void ClearListButton_Click(object sender, EventArgs e)
|
|
{
|
|
SelectComponent.ClearList();
|
|
}
|
|
|
|
private void ShowIntButton_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
int? Value = InputComponent.IntValue;
|
|
if (Value != null)
|
|
{
|
|
MessageBox.Show($"Ââåäåííîå ÷èñëî: {Value}");
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Çíà÷åíèå - null");
|
|
}
|
|
}
|
|
catch (MalformedIntegralException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
catch (EmptyValueException ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void PrintObjectButton_Click(object sender, EventArgs e)
|
|
{
|
|
var Test = GridComponent.GetSelectedObject<TestPerson>();
|
|
MessageBox.Show(Test.ToString());
|
|
}
|
|
|
|
private void CreateDocumentWithTables_Click(object sender, EventArgs e)
|
|
{
|
|
string[][] table1 =
|
|
[
|
|
["Ñòð 1 Êîë 1", "Ñòð 1 Êîë 2", "Ñòð 1 Êîë 3"],
|
|
["Ñòð 2 Êîë 1", "Ñòð 2 Êîë 2", "Ñòð 2 Êîë 3"]
|
|
];
|
|
|
|
string[][] table2 =
|
|
[
|
|
["Ñòð 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"],
|
|
];
|
|
|
|
DocumentContextComponent.CreateDocument(
|
|
@"C:\Comps\Doc1.pdf",
|
|
"Sample text",
|
|
new List<string[][]> { table1, table2 });
|
|
}
|
|
|
|
private void CreateConfigurableTable_Click(object sender, EventArgs e)
|
|
{
|
|
List<TestPerson> Persons = new List<TestPerson>
|
|
{
|
|
new TestPerson(1, "Èâàí", "Èâàíîâ", 34),
|
|
new TestPerson(2, "Ïåòð", "Ïåòðîâ", 44),
|
|
new TestPerson(3, "Ñåðãåé", "Ñåðãååâ", 55),
|
|
new TestPerson(4, "Îëüãà", "Èâàíîâà", 34),
|
|
new TestPerson(5, "Òàòüÿíà", "Ïåòðîâà", 44),
|
|
};
|
|
|
|
ConfigurableTableComponent.CreateDocument(
|
|
@"C:\Comps\Doc2.pdf",
|
|
"Íàñòðàèâàåìàÿ òàáëèöà",
|
|
new List<string> { "3cm", "2cm", "3cm", "4cm" },
|
|
new List<string> { "1cm", "0.6cm" },
|
|
new List<string> { "Ôàìèëèÿ", "Èäåíò.", "Èìÿ", "Âîçðàñò" },
|
|
new List<string> { "LastName", "Id", "FirstName", "Age" },
|
|
Persons);
|
|
}
|
|
}
|
|
}
|