2024-11-17 13:25:39 +04:00
|
|
|
|
using MyUserControls;
|
2024-11-17 17:05:03 +04:00
|
|
|
|
using MyUserControls.Components.office_package.Implements;
|
|
|
|
|
using MyUserControls.Components.PdfImage;
|
2024-11-17 14:18:00 +04:00
|
|
|
|
using System.ComponentModel;
|
2024-11-17 13:25:39 +04:00
|
|
|
|
|
2024-11-17 17:05:03 +04:00
|
|
|
|
|
2024-11-17 13:25:39 +04:00
|
|
|
|
namespace WinFormsApp1
|
|
|
|
|
{
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
2024-11-17 17:05:03 +04:00
|
|
|
|
private List<byte[]> selectedImages = new List<byte[]>();
|
2024-11-17 13:25:39 +04:00
|
|
|
|
public Form1()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
InitialChekedListBox();
|
|
|
|
|
InitialSmartTextBox();
|
|
|
|
|
InitialTree();
|
2024-11-17 14:18:00 +04:00
|
|
|
|
testComponent1.FileName = "1.txt";
|
2024-11-17 13:25:39 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitialChekedListBox()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
smartCheckedListBox1.AddItem("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1");
|
|
|
|
|
smartCheckedListBox1.AddItem("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2");
|
|
|
|
|
smartCheckedListBox1.AddItem("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3");
|
|
|
|
|
|
|
|
|
|
smartCheckedListBox1.SelectedValue = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitialSmartTextBox()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
smartTextBox1.MinLength = 0;
|
|
|
|
|
smartTextBox1.MaxLength = 1000;
|
|
|
|
|
smartTextBox1.InputText = "jjjjj";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitialTree()
|
|
|
|
|
{
|
|
|
|
|
var obj1 = new SampleClass { Name = "Item1", Category = "Category1", SubCategory = "SubCategory1" };
|
|
|
|
|
var obj2 = new SampleClass { Name = "Item2", Category = "Category1", SubCategory = "SubCategory2" };
|
|
|
|
|
|
|
|
|
|
List<string> properties = new List<string>
|
|
|
|
|
{
|
|
|
|
|
"Name",
|
|
|
|
|
"Category",
|
|
|
|
|
"SubCategory"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
hierarchicalTreeView.SetPropertyHierarchy(properties);
|
|
|
|
|
|
|
|
|
|
hierarchicalTreeView.AddObject(obj1);
|
|
|
|
|
hierarchicalTreeView.AddObject(obj2);
|
|
|
|
|
|
|
|
|
|
hierarchicalTreeView.SelectNode(1, "SubCategory2");
|
|
|
|
|
|
|
|
|
|
smartTextBox1.InputText = hierarchicalTreeView.GetSelectedItem<SampleClass>().ToString();
|
|
|
|
|
}
|
2024-11-17 14:18:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void buttonSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
testComponent1.SaveToFile(richTextBoxText.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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-17 17:05:03 +04:00
|
|
|
|
|
|
|
|
|
private void chooseImage_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using OpenFileDialog openFileDialog = new OpenFileDialog
|
|
|
|
|
{
|
|
|
|
|
Multiselect = true,
|
|
|
|
|
Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp"
|
|
|
|
|
};
|
|
|
|
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
selectedImages.Clear();
|
|
|
|
|
listBoxImages.Items.Clear();
|
|
|
|
|
foreach (string filePath in openFileDialog.FileNames)
|
|
|
|
|
{
|
|
|
|
|
selectedImages.Add(File.ReadAllBytes(filePath));
|
|
|
|
|
listBoxImages.Items.Add(Path.GetFileName(filePath));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createPdfImages_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (selectedImages.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string currentDirectory = Directory.GetCurrentDirectory();
|
|
|
|
|
|
|
|
|
|
string filePath = Path.Combine(currentDirectory, @"..\..\..\Documents\PdfWithImage.pdf");
|
|
|
|
|
|
|
|
|
|
var info = new PdfImageInfo
|
|
|
|
|
{
|
|
|
|
|
FileName = filePath,
|
|
|
|
|
Title = "title",
|
|
|
|
|
Images = selectedImages
|
|
|
|
|
};
|
|
|
|
|
pdfImage.CreatePdf(info);
|
|
|
|
|
MessageBox.Show("<22><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-17 13:25:39 +04:00
|
|
|
|
}
|
|
|
|
|
}
|