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

92 lines
2.8 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
{
2024-10-15 11:27:49 +04:00
var docEntry = new DocumentSymple(@"\5semestr\KOP\KOP-PIbd-32-Katysheva-N-E\docs", "Word.docx", richTextBoxWord.Lines);
2024-09-30 23:54:03 +04:00
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>");
2024-10-15 11:27:49 +04:00
dataGridViewTable.Columns.Add("Column3", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>1", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1","2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>2", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2", "2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>3", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3", "2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>4", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4", "2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>4");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>5", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5", "2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>5");
dataGridViewTable.Rows.Add("<22><><EFBFBD><EFBFBD>6", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>6", "2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>6");
}
2024-09-30 23:54:03 +04:00
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>
2024-10-15 11:27:49 +04:00
var docEntry = new DocumentSymple(@"\5semestr\KOP\KOP-PIbd-32-Katysheva-N-E\docs", "Table.docx", data.Select(row => string.Join("\t", row)).ToArray());
2024-09-30 23:54:03 +04:00
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>",
2024-10-15 11:27:49 +04:00
MessageBoxButtons.OK, MessageBoxIcon.Information);
2024-09-30 23:54:03 +04:00
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
2024-09-30 22:43:40 +04:00
}
}
}