PIbd-31_Rodionov.I.A._COP_28/COP/WinForms/FormTest.cs
2024-09-22 13:24:14 +04:00

104 lines
4.9 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.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)
{
}
private void ButtonWordDiagram_Click(object sender, EventArgs e)
{
}
}
}