PDF-Merge/MainForm.cs
2024-08-05 18:19:39 -04:00

81 lines
2.3 KiB
C#

using System.Configuration;
namespace PDF_Merge
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
SetPathLable();
}
private static string getOutputPath()
{
string pdfPath = ConfigurationManager.AppSettings["PDF-Output"] + Path.DirectorySeparatorChar + ConfigurationManager.AppSettings["PDF-Name"];
return pdfPath;
}
public void SetPathLable()
{
string sourcePath = ConfigurationManager.AppSettings["PDF-Path"];
if (sourcePath != null)
{
if (sourcePath != "")
{
if (Directory.Exists(sourcePath))
{
srcPathLable.Text = "Source Path: " + sourcePath;
}
else
{
srcPathLable.Text = "The configured path does not exist.";
}
}
else
{
srcPathLable.Text = "The configured path is blank.";
}
}
else
{
srcPathLable.Text = "No path has been configured.";
}
outputLable.Text = "Output Path: " + getOutputPath();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
string[] pdf_files = MergePDFs.CollectPdfFiles();
MergePDFs.MergePdfFiles(pdf_files, getOutputPath());
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
AboutBox1 AboutWindow = new AboutBox1();
AboutWindow.Show();
}
private void configureToolStripMenuItem_Click(object sender, EventArgs e)
{
ConfForm ConfForm = new ConfForm();
ConfForm.Show();
}
private void MainForm_Activated(object sender, EventArgs e)
{
SetPathLable();
}
}
}