2024-10-07 00:07:33 +04:00
|
|
|
|
namespace WinFormsApp
|
|
|
|
|
{
|
|
|
|
|
public partial class FormNoVisual : Form
|
|
|
|
|
{
|
|
|
|
|
public FormNoVisual()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonCreateExcelFile_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string[] list = new string[listBoxImages.Items.Count];
|
|
|
|
|
for (int i = 0; i < listBoxImages.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
list[i] = listBoxImages.Items[i].ToString();
|
|
|
|
|
}
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
componentExcelWithImage.CreateExcelWithImages(textBoxFilePath.Text, textBoxTitle.Text, list);
|
2024-10-07 12:52:54 +04:00
|
|
|
|
MessageBox.Show("Файл успешно создан", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
2024-10-07 00:07:33 +04:00
|
|
|
|
}
|
2024-10-07 12:52:54 +04:00
|
|
|
|
catch (Exception ex)
|
2024-10-07 00:07:33 +04:00
|
|
|
|
{
|
2024-10-07 12:52:54 +04:00
|
|
|
|
MessageBox.Show($"Ошибка при создании файла:\n{ex.Message}", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
2024-10-07 00:07:33 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSetFilePath_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var filePath = string.Empty;
|
|
|
|
|
|
|
|
|
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
|
|
|
|
{
|
|
|
|
|
openFileDialog.InitialDirectory = "d:\\tmp";
|
|
|
|
|
openFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
|
|
|
|
|
openFileDialog.FilterIndex = 1;
|
|
|
|
|
openFileDialog.RestoreDirectory = true;
|
|
|
|
|
|
|
|
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
filePath = openFileDialog.FileName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
|
|
|
{
|
|
|
|
|
textBoxFilePath.Text = filePath;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
textBoxFilePath.Text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonAddImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var filePath = string.Empty;
|
|
|
|
|
|
|
|
|
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
|
|
|
|
{
|
|
|
|
|
openFileDialog.InitialDirectory = "d:\\tmp";
|
2024-10-07 12:52:54 +04:00
|
|
|
|
openFileDialog.Filter = "Image files (*.jpeg;*.jpg;*.png)|*.jpeg;*.jpg;*.png|All files (*.*)|*.*";
|
2024-10-07 00:07:33 +04:00
|
|
|
|
openFileDialog.FilterIndex = 1;
|
|
|
|
|
openFileDialog.RestoreDirectory = true;
|
|
|
|
|
|
|
|
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
filePath = openFileDialog.FileName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(filePath))
|
|
|
|
|
{
|
|
|
|
|
listBoxImages.Items.Add(filePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonClearImages_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
listBoxImages.Items.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|