174 lines
9.0 KiB
C#
174 lines
9.0 KiB
C#
using RodionovLibrary.NonVisualComponents.HelperModels;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WinForms
|
|
{
|
|
public partial class FormTest : Form
|
|
{
|
|
public FormTest()
|
|
{
|
|
InitializeComponent();
|
|
comboBoxControl.AddItems(new List<string> { "Çíà÷åíèå 1", "Çíà÷åíèå 2", "Çíà÷åíèå 3", "Çíà÷åíèå 4", "Çíà÷åíèå 5" });
|
|
|
|
textBoxControl.Pattern = @"^[a-z0-9._%+-]+\@([a-z0-9-]+\.)+[a-z]{2,4}$";
|
|
textBoxControl.SetTooltipText("example@gmail.com");
|
|
|
|
listBoxControl.SetParams("Èìÿ: {FirstName}, ôàìèëèÿ: {LastName}. {Gender} ({Age}) ëåò.", '{', '}');
|
|
listBoxControl.AddItems(new List<Person> { new() { FirstName = "Êèðèëë", LastName = "Ïåòðîâ", Age = 23, Gender = "ìóæ" },
|
|
new() { FirstName = "Ìàðèÿ", LastName = "Èâàíîâà", Age = 18, Gender = "æåí" },
|
|
new() { FirstName = "Åâà", LastName = "Ïàíôèëîâà", Age = 40, Gender = "æåí" } });
|
|
}
|
|
|
|
private void ButtonClear_Click(object sender, EventArgs e)
|
|
{
|
|
comboBoxControl.Clear();
|
|
}
|
|
|
|
private void ButtonGetComboBox_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(comboBoxControl.SelectedValue, "Ïîëó÷åííîå çíà÷åíèå");
|
|
}
|
|
|
|
private void ButtonSetComboBox_Click(object sender, EventArgs e)
|
|
{
|
|
comboBoxControl.SelectedValue = "Çíà÷åíèå 3";
|
|
}
|
|
|
|
private void ButtonGetTextBox_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(textBoxControl.Value, "Ïîëó÷åííîå çíà÷åíèå");
|
|
}
|
|
|
|
private void ButtonSetTextBox_Click(object sender, EventArgs e)
|
|
{
|
|
textBoxControl.Value = "forum98761@gmail.com";
|
|
}
|
|
|
|
private void ButtonSetWrongTextBox_Click(object sender, EventArgs e)
|
|
{
|
|
textBoxControl.Value = "smth";
|
|
}
|
|
|
|
private void ButtonGetObject_Click(object sender, EventArgs e)
|
|
{
|
|
Person? selectedPerson = listBoxControl.GetObject<Person>();
|
|
if (selectedPerson == null)
|
|
MessageBox.Show("Îáüåêò ïóñòîé");
|
|
MessageBox.Show($"Èìÿ: {selectedPerson?.FirstName}, Ôàìèëèÿ: {selectedPerson?.LastName}, " +
|
|
$"Âîçðàñò: {selectedPerson?.Age}, Ïîë: {selectedPerson?.Gender}");
|
|
}
|
|
|
|
private void ButtonGetIndex_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(listBoxControl.SelectedIndex.ToString(), "Ïîëó÷åííîå çíà÷åíèå");
|
|
}
|
|
|
|
private void ButtonSetIndex_Click(object sender, EventArgs e)
|
|
{
|
|
listBoxControl.SelectedIndex = 0;
|
|
}
|
|
|
|
private void ButtonWordText_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
wordLongTextComponent.CreateWordText(new WordLongTextInfo()
|
|
{
|
|
FileName = AppDomain.CurrentDomain.BaseDirectory + "test_long_text.docx",
|
|
Title = "ÃËÀÂÀ 1. Íåæäàííûå ãîñòè",
|
|
Paragraphs = new string[] { "Æèë-áûë â íîðå ïîä çåìëåé õîááèò. Íå â êàêîé-òî òàì ìåðçêîé ãðÿçíîé ñûðîé íîðå, ãäå ñî âñåõ ñòîðîí òîð÷àò õâîñòû ÷åðâåé è ïðîòèâíî ïàõíåò ïëåñåíüþ, íî è íå â ñóõîé ïåñ÷àíîé ãîëîé íîðå, ãäå íå íà ÷òî ñåñòü è íå÷åãî ñúåñòü. Íåò, íîðà áûëà õîááè÷üÿ, à çíà÷èò — áëàãîóñòðîåííàÿ.",
|
|
"Îíà íà÷èíàëàñü èäåàëüíî êðóãëîé, êàê èëëþìèíàòîð, äâåðüþ, âûêðàøåííîé çåëåíîé êðàñêîé, ñ ñèÿþùåé ìåäíîé ðó÷êîé òî÷íî ïîñåðåäèíå. Äâåðü îòâîðÿëàñü âíóòðü, â äëèííûé êîðèäîð, ïîõîæèé íà æåëåçíîäîðîæíûé òóííåëü, íî òóííåëü áåç ãàðè è áåç äûìà è òîæå î÷åíü áëàãîóñòðîåííûé: ñòåíû òàì áûëè îáøèòû ïàíåëÿìè, ïîë âûëîæåí ïëèòêàìè è óñòëàí êîâðîì, âäîëü ñòåí ñòîÿëè ïîëèðîâàííûå ñòóëüÿ, è âñþäó áûëè ïðèáèòû êðþ÷î÷êè äëÿ øëÿï è ïàëüòî, òàê êàê õîááèò ëþáèë ãîñòåé.",
|
|
"Òóííåëü âèëñÿ âñå äàëüøå è äàëüøå è çàõîäèë äîâîëüíî ãëóáîêî, íî íå â ñàìóþ ãëóáèíó Õîëìà, êàê åãî èìåíîâàëè æèòåëè íà ìíîãî ìèëü â îêðóæíîñòè. Ïî îáåèì ñòîðîíàì òóííåëÿ øëè äâåðè — ìíîãî-ìíîãî êðóãëûõ äâåðåé. Õîááèò íå ïðèçíàâàë âîñõîæäåíèé ïî ëåñòíèöàì: ñïàëüíè, âàííûå, ïîãðåáà, êëàäîâûå (öåëàÿ êó÷à êëàäîâûõ), ãàðäåðîáíûå (õîááèò îòâåë íåñêîëüêî êîìíàò ïîä õðàíåíèå îäåæäû), êóõíè, ñòîëîâûå ðàñïîëàãàëèñü â îäíîì ýòàæå è, áîëåå òîãî, â îäíîì è òîì æå êîðèäîðå.",
|
|
"Ëó÷øèå êîìíàòû íàõîäèëèñü ïî ëåâóþ ðóêó, è òîëüêî â íèõ èìåëèñü îêíà — ãëóáîêî ñèäÿùèå êðóãëûå îêîøå÷êè ñ âèäîì íà ñàä è íà äàëüíèå ëóãà, ñïóñêàâøèåñÿ ê ðåêå."}
|
|
});
|
|
MessageBox.Show("Ãîòîâî!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ïðîèçîøëà îøèáêà: " + ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
|
|
private void ButtonWordTable_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var firstRowColumns = new List<ColumnParameters>
|
|
{
|
|
new() { Header = "Èäåíò", PropertyName = "", Width = 1.2 },
|
|
new() { Header = "Ñòàòóñ", PropertyName = "", Width = 1.2 },
|
|
new() { Header = "Ëè÷íûå äàííûå", PropertyName = "", Width = 1.6 },
|
|
new() { Header = "Ëè÷íûå äàííûå", PropertyName = "", Width = 1.6 },
|
|
new() { Header = "Ëè÷íûå äàííûå", PropertyName = "", Width = 1.6 },
|
|
new() { Header = "Äåòè", PropertyName = "", Width = 1.2 },
|
|
new() { Header = "Ìàøèíà", PropertyName = "", Width = 1.6 },
|
|
new() { Header = "Ðàáîòà", PropertyName = "", Width = 2.5 },
|
|
new() { Header = "Ðàáîòà", PropertyName = "", Width = 2.5 },
|
|
new() { Header = "Ïðåìèÿ", PropertyName = "", Width = 2 }
|
|
};
|
|
|
|
var secondRowColumns = new List<ColumnParameters>
|
|
{
|
|
new() { Header = "Èäåíò", PropertyName = "Id", Width = 1.2 },
|
|
new() { Header = "Ñòàòóñ", PropertyName = "Status", Width = 1.2 },
|
|
new() { Header = "Èìÿ", PropertyName = "FirstName", Width = 1.6 },
|
|
new() { Header = "Ôàìèëèÿ", PropertyName = "LastName", Width = 1.6 },
|
|
new() { Header = "Âîçðàñò", PropertyName = "Age", Width = 1.6 },
|
|
new() { Header = "Äåòè", PropertyName = "Children", Width = 1.2 },
|
|
new() { Header = "Ìàøèíà", PropertyName = "Car", Width = 1.6 },
|
|
new() { Header = "Ïîäðàçäåëåíèå", PropertyName = "Department", Width = 2.5 },
|
|
new() { Header = "Äîëæíîñòü", PropertyName = "Position", Width = 2.5 },
|
|
new() { Header = "Ïðåìèÿ", PropertyName = "Bonus", Width = 2 }
|
|
};
|
|
|
|
var employees = new List<Employee>
|
|
{
|
|
new() { Id = 1, Status = "íåò", FirstName = "Èâàí", LastName = "Èâàíîâ", Age = 34, Children = "íåò", Car = "åñòü", Department = "Äåïàðòàìåíò 1", Position = "Èíæåíåð", Bonus = 2000.1 },
|
|
new() { Id = 2, Status = "íåò", FirstName = "Ïåòð", LastName = "Ïåòðîâ", Age = 44, Children = "åñòü", Car = "åñòü", Department = "Äåïàðòàìåíò 1", Position = "Èíæåíåð", Bonus = 2000.1 },
|
|
new() { Id = 3, Status = "äà", FirstName = "Ñåðãåé", LastName = "Ñåðãååâ", Age = 55, Children = "íåò", Car = "íåò", Department = "Äåïàðòàìåíò 1", Position = "Ðóêîâîäèòåëü", Bonus = 5000.5 },
|
|
new() { Id = 4, Status = "íåò", FirstName = "Îëüãà", LastName = "Èâàíîâà", Age = 34, Children = "åñòü", Car = "íåò", Department = "Áóõãàëòåðèÿ", Position = "Áóõãàëòåð", Bonus = 2000.1 },
|
|
new() { Id = 5, Status = "äà", FirstName = "Òàòüÿíà", LastName = "Ïåòðîâà", Age = 44, Children = "íåò", Car = "íåò", Department = "Áóõãàëòåðèÿ", Position = "Ñòàðøèé áóõãàëòåð", Bonus = 7000.6 }
|
|
};
|
|
|
|
var mergedColumns = new List<(int, int)>
|
|
{
|
|
(2, 4),
|
|
(7, 8)
|
|
};
|
|
|
|
var tableInfo = new WordTableInfo<Employee>
|
|
{
|
|
FileName = AppDomain.CurrentDomain.BaseDirectory + "test_table.docx",
|
|
Title = "Çàãîëîâîê",
|
|
FirstRowColumnParameters = firstRowColumns,
|
|
SecondRowColumnParameters = secondRowColumns,
|
|
Items = employees,
|
|
MergedColumns = mergedColumns
|
|
};
|
|
|
|
wordTableComponent.CreateTable(tableInfo);
|
|
|
|
MessageBox.Show("Ãîòîâî!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ïðîèçîøëà îøèáêà: " + ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void ButtonWordDiagram_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
MessageBox.Show("Ãîòîâî!");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ïðîèçîøëà îøèáêà: " + ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
}
|