168 lines
4.9 KiB
C#
168 lines
4.9 KiB
C#
using MigraDoc.DocumentObjectModel;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using ViewComponents.Exeption;
|
|
using ViewComponents.NotVisualComponents;
|
|
|
|
namespace TestView
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
list_with_choice.Fill_List("ïåðâûé");
|
|
list_with_choice.Fill_List("âòîðîé");
|
|
list_with_choice.Fill_List("òðåòèé");
|
|
list_with_choice.Fill_List("÷åòâ¸ðòûé");
|
|
}
|
|
|
|
private void buttonClear_Click(object sender, EventArgs e)
|
|
{
|
|
list_with_choice.Clean_List();
|
|
}
|
|
|
|
private void buttonSelect_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(list_with_choice.Element ?? "null", "Âûáðàííûé ýëåìåíò");
|
|
}
|
|
|
|
private void list_with_choice_SelectedItemChange(string obj)
|
|
{
|
|
MessageBox.Show(obj, "Ñîáûòèå âûáîðà ýëåìåíòà");
|
|
}
|
|
|
|
private void buttonDip_Click(object sender, EventArgs e)
|
|
{
|
|
input_text.MinLen = 5;
|
|
input_text.MaxLen = 25;
|
|
|
|
MessageBox.Show($"Min: {input_text.MinLen}; Max: {input_text.MaxLen}");
|
|
}
|
|
|
|
private void buttonVal_Click(object sender, EventArgs e)
|
|
{
|
|
input_text.Element = "Sample text";
|
|
}
|
|
|
|
private void input_text_ItemChange(string obj)
|
|
{
|
|
MessageBox.Show(obj, "Ñîáûòèå èçìåíåíèÿ òåêñòà");
|
|
}
|
|
|
|
private void buttonCheck_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (input_text.Element.Equals("Range exeption"))
|
|
throw new TextBoundsNotSetExeption("Äèàïàçîí íå çàäàí");
|
|
if (input_text.Element.Equals("Value exeption"))
|
|
throw new TextOutOfBoundsExeption("Ñëîâî âíå äèàïàçîíà");
|
|
|
|
MessageBox.Show(input_text.Element, "×åðåç ñâîéñòâî");
|
|
}
|
|
catch (TextBoundsNotSetExeption ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
catch (TextOutOfBoundsExeption ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void buttonIerarhy_Click(object sender, EventArgs e)
|
|
{
|
|
myTreeView.setHierarchy(new List<(string, bool)> { ("Genre", false), ("Author", false), ("Title", true) });
|
|
MessageBox.Show("Èåðàðõèÿ çàäàíà");
|
|
}
|
|
|
|
private void buttonAddBook_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
myTreeView.addItem(new Book("Ðîìàí", "Ãîãîëü Í.Â.", "̸ðòâûå äóøè"));
|
|
myTreeView.addItem(new Book("Ðîìàí", "Òóðãåíåâ È.Ñ.", "Îòöû è äåòè"));
|
|
myTreeView.addItem(new Book("Ôàíòàñòèêà", "Äæîðäæ Îðóýëë", "1984"));
|
|
myTreeView.addItem(new Book("Ôàíòàñòèêà", "Ðîóëèíã", "Ãàððè Ïîòòåð"));
|
|
}
|
|
|
|
private void buttonGetValue_Click(object sender, EventArgs e)
|
|
{
|
|
Book? book = myTreeView.getSelecetedNodeValue<Book>();
|
|
if (book == null) return;
|
|
MessageBox.Show("Æàíð: " + book.Genre + ", Àâòîð: " + book.Author + ", Íàçâàíèå: " + book.Title);
|
|
}
|
|
|
|
private void buttonGetIndex_Click(object sender, EventArgs e)
|
|
{
|
|
MessageBox.Show(myTreeView.SelectedNodeIndex.ToString());
|
|
}
|
|
|
|
private void buttonSetIndex_Click(object sender, EventArgs e)
|
|
{
|
|
myTreeView.SelectedNodeIndex = 1;
|
|
}
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void buttonPdfImages_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\\xarla\\OneDrive\\Äîêóìåíòû\\test.pdf";
|
|
MessageBox.Show(path);
|
|
if (pdfImages1.CreatePdfDoc(new ImagesForPDF(path, "Ðóññêàÿ ëèòåðàòóðà", files))) MessageBox.Show("Óñïåõ!");
|
|
else MessageBox.Show("Îøèáêà, ïðîâåðüòå êîíñîëü");
|
|
}
|
|
|
|
private void buttonTestPdfTable_Click(object sender, EventArgs e)
|
|
{
|
|
List<BookInfo> books = new List<BookInfo>
|
|
{
|
|
new BookInfo("Ýêñìî", "Íèêîëàé", "Ãîãîëü", "1809-1852", "̸ðòâûå äóøè"),
|
|
new BookInfo("Òðèóìô", "Èâàí", "Òóðãåíåâ", "1818-1883", "Îòöû è äåòè"),
|
|
new BookInfo("Ýêñìî", "Äæîðäæ", "Îðóýëë", "1903-1950", "1984"),
|
|
new BookInfo("ÀÑÒ", "Äæîàíà", "Ðîóëèíã", "1965 - í.â.", "Ãàððè Ïîòòåð")
|
|
};
|
|
|
|
List<(int, int)> merges = new List<(int, int)>();
|
|
merges.Add((2, 4));
|
|
|
|
List<int> heights = new List<int> { 10, 40, 60, 20, 25, 15, 20 };
|
|
|
|
string path = "C:\\Users\\xarla\\OneDrive\\Äîêóìåíòû\\test.pdf";
|
|
|
|
List<(bool, string)> headers = new List<(bool, string)> { (false, "id"), (false, "Ðåäàêöèÿ"),
|
|
(true, "Àâòîð"), (false, "Èìÿ"),
|
|
(false, "Ôàìèëèÿ"), (false, "Ãîäû æèçíè"),
|
|
(false, "Íàçâàíèå êíèãè") };
|
|
|
|
if (pdfTable1.createTable(new DataForPDFTable<BookInfo>(path, "test2", heights, merges, headers, books))) MessageBox.Show("Óñïåõ");
|
|
}
|
|
|
|
private void buttonChart_Click(object sender, EventArgs e)
|
|
{
|
|
string path = "C:\\Users\\xarla\\OneDrive\\Äîêóìåíòû\\chart.pdf";
|
|
List<(double, string)> elements = new List<(double, string)>
|
|
{
|
|
(200, "̸ðòâûå äóøè"),
|
|
(157, "Ìóìó"),
|
|
(344, "Îòöû è Äåòè"),
|
|
(588, "Ãàððè Ïîòòåð"),
|
|
(286, "Ìåòðî 2033")
|
|
};
|
|
|
|
if(pieChartpdf1.CreatePieChart(new DataForPDFPieChart(path, "Çàãîëîâîê", "Êðóãîâàÿ äèàãðàììà", DiagramLegendEnum.Top ,"Ïðîäàæè êíèã", elements))) MessageBox.Show("Óñïåõ");
|
|
}
|
|
}
|
|
} |