140 lines
4.9 KiB
C#
140 lines
4.9 KiB
C#
using CustomComponents.Helpers;
|
|
using WinFormForTest.TestClasses;
|
|
|
|
namespace WinFormForTest
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
List<Plant> plants = new List<Plant>();
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
customListBox1.AddToList("Ýëåìåíò 1");
|
|
customListBox1.AddToList("Ýëåìåíò 2");
|
|
customListBox1.AddToList("Ýëåìåíò 3");
|
|
Plant pl1 = new Plant("îâîùü", "ïîìèäîð", "êðàñíûé");
|
|
Plant pl2 = new Plant("îâîùü", "ïîìèäîð", "æ¸ëòûé");
|
|
Plant pl3 = new Plant("îâîùü", "îãóðåö", "çåë¸íûé");
|
|
Plant pl4 = new Plant("ôðóêò", "ÿáëîêî", "çåë¸íûé");
|
|
Plant pl5 = new Plant("ôðóêò", "àïåëüñèí", "îðàíæåâûé");
|
|
Plant pl6 = new Plant("ôðóêò", "àïåëüñèí", "êðàñíûé");
|
|
plants.Add(pl1);
|
|
plants.Add(pl2);
|
|
plants.Add(pl3);
|
|
plants.Add(pl4);
|
|
plants.Add(pl5);
|
|
plants.Add(pl6);
|
|
LoadTree();
|
|
}
|
|
|
|
public void LoadTree()
|
|
{
|
|
customTree1.Hierarcy = new List<string> { "Type", "Name", "Color" };
|
|
foreach (Plant plant in plants)
|
|
{
|
|
customTree1.AddNode(plant);
|
|
}
|
|
}
|
|
private void buttonClear_Click(object sender, EventArgs e)
|
|
{
|
|
customListBox1.Clear();
|
|
}
|
|
|
|
private void buttonCheck_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
|
|
if (customComboBox1.TextBoxValue != null)
|
|
{
|
|
checkBoxValid.Text = "ïîäõîäèò";
|
|
checkBoxValid.Checked = true;
|
|
checkBoxValid.BackColor = Color.Green;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
checkBoxValid.Text = "íå ïîäõîäèò";
|
|
checkBoxValid.Checked = false;
|
|
checkBoxValid.BackColor = Color.Red;
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void buttonEnter_Click(object sender, EventArgs e)
|
|
{
|
|
customListBox1.AddToList("Ýëåìåíò 4");
|
|
customListBox1.AddToList("Ýëåìåíò 5");
|
|
customListBox1.AddToList("Ýëåìåíò 6");
|
|
}
|
|
|
|
private void buttonGet_Click(object sender, EventArgs e)
|
|
{
|
|
labelItem.Text = customListBox1.SelectedElement;
|
|
}
|
|
|
|
private void buttonPdfImage_Click(object sender, EventArgs e)
|
|
{
|
|
var res = openFileDialog1.ShowDialog(this);
|
|
if (res != DialogResult.OK) return;
|
|
var files = openFileDialog1.FileNames;
|
|
openFileDialog1.Dispose();
|
|
string path = "C:\\Users\\annal\\Desktop\\test_cop_lab2\\testImage.pdf";
|
|
MessageBox.Show(path);
|
|
if (pdfImage1.CreatePdfDoc(new DataForImage(path, "Êàðòèíêè", files))) MessageBox.Show("Success!");
|
|
else MessageBox.Show("Error");
|
|
}
|
|
|
|
private void buttonPdfTable_Click(object sender, EventArgs e)
|
|
{
|
|
List<Film> films = new List<Film>()
|
|
{
|
|
new Film("Ìàñêà", "êîìåäèÿ, êðèìèíàë, ôýíòåçè", "1÷. 36ìèí.", "12+"),
|
|
new Film("Çâ¸çäíàÿ ïûëü", "ìåëîäðàìà, ïðèêëþ÷åíèÿ, ôýíòåçè", "2÷. 7ìèí.", "18+"),
|
|
new Film("Àâàòàð", "ïðèêëþ÷åíèÿ, ôàíòàñòèêà, áîåâèê, äðàìà", "2÷. 58ìèí.", "18+"),
|
|
new Film("Êîíñòàíòèí", "ôýíòåçè, óæàñû, áîåâèê, äåòåêòèâ", "2÷. 1ìèí.", "18+")
|
|
};
|
|
|
|
List<(int, int)> merges = new List<(int, int)>();
|
|
merges.Add((1, 2));
|
|
|
|
List<int> heights = new List<int> { 10, 80, 30, 50, 25, 25 };
|
|
|
|
string path = "C:\\Users\\annal\\Desktop\\test_cop_lab2\\testTable.pdf";
|
|
|
|
List<(string, string)> headers = new List<(string, string)>
|
|
{
|
|
("id", "Id"),
|
|
("", "Ôèëüì"),
|
|
("Name", "Íàçâàíèå"),
|
|
("Ganre", "Æàíð"),
|
|
("Duration", "Ïðîäîëæèòåëüíîñòü"),
|
|
("AgeRange", "Âîçðàñòíîå îãðàíè÷åíèå")
|
|
};
|
|
|
|
if (pdfTable1.createTable(new DataForTable<Film>(path, "Òàáëèöà ôèëüìîâ", heights, merges, headers, films)))
|
|
{
|
|
MessageBox.Show("Success!");
|
|
}
|
|
}
|
|
|
|
private void buttonPdfChart_Click(object sender, EventArgs e)
|
|
{
|
|
string path = "C:\\Users\\annal\\Desktop\\test_cop_lab2\\testPieChart.pdf";
|
|
List<(double, string)> elements = new List<(double, string)>
|
|
{
|
|
(20, "Êîëÿ"),
|
|
(37, "Äàøà"),
|
|
(10, "Åãîð"),
|
|
(15, "Òàíÿ"),
|
|
(18, "Âàëåðà")
|
|
};
|
|
|
|
if (pdfPieChart1.CreatePieChart(new DataForPieChart(path, "Êðóãîâàÿ äèàãðàììà", "Óñïåõ ïðîñìîòðà 100 ôèëüìîâ", DiagramLegendEnum.Bottom, "Ïðîñìîòðåíî", elements)))
|
|
{
|
|
MessageBox.Show("Success!");
|
|
}
|
|
}
|
|
}
|
|
}
|