KOP-PIbd-32-Katysheva-N-E/ComponentsView/FormComponents.cs

89 lines
2.5 KiB
C#
Raw Normal View History

2024-09-30 23:54:03 +04:00
using System.Windows.Forms;
2024-09-30 22:43:40 +04:00
namespace ComponentsView
{
public partial class FormComponents : Form
{
public FormComponents()
{
InitializeComponent();
testComponent.FileName = "2.txt";
2024-09-30 23:54:03 +04:00
InitializeDataGridView();
2024-09-30 22:43:40 +04:00
}
private void buttonSaveText_Click(object sender, EventArgs e)
{
try
{
testComponent.SaveToFile(richTextBoxTest.Lines);
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonSaveTextWord_Click(object sender, EventArgs e)
{
2024-09-30 23:54:03 +04:00
try
{
var docEntry = new DocumentSymple(@"C:\Users\Natalia\Desktop\5semestr\KOP\KOP-PIbd-32-Katysheva-N-E\docs", "Word.docx", richTextBoxWord.Lines);
componentBigText.SetText(docEntry.FileUrl, docEntry.FileName, docEntry.Text);
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void InitializeDataGridView()
{
dataGridViewTable.Columns.Add("Column1", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
dataGridViewTable.Columns.Add("Column2", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>1", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>2", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2");
}
private void buttonSaveTable_Click(object sender, EventArgs e)
{
try
{
List<string[]> data = new List<string[]>();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> DataGridView
foreach (DataGridViewRow row in dataGridViewTable.Rows)
{
if (row.IsNewRow) continue; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
string[] rowData = new string[dataGridViewTable.Columns.Count];
for (int i = 0; i < dataGridViewTable.Columns.Count; i++)
{
rowData[i] = row.Cells[i].Value?.ToString() ?? string.Empty;
}
data.Add(rowData);
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var docEntry = new DocumentSymple(@"C:\Users\Natalia\Desktop\5semestr\KOP\KOP-PIbd-32-Katysheva-N-E\docs", "Table.docx", data.Select(row => string.Join("\t", row)).ToArray());
componentBigText.SetText(docEntry.FileUrl, docEntry.FileName, docEntry.Text);
MessageBox.Show("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
2024-09-30 22:43:40 +04:00
}
}
}