PDF-Merge/MainForm.cs
efrick 1e75972ae9 Appending a date to the output file is now working.
This commit should resolve issue #1. Appending a date to the output file
is now a selectable option in the app configuration.
2024-08-06 09:53:40 -04:00

89 lines
2.7 KiB
C#

using System.Configuration;
namespace PDF_Merge
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
SetPathLable();
}
private static string getOutputPath()
{
string pdfPath;
if (ConfigurationManager.AppSettings["appendDate"] == true.ToString())
{
pdfPath = ConfigurationManager.AppSettings["PDF-Output"] + Path.DirectorySeparatorChar + ConfigurationManager.AppSettings["PDF-Name"] + "_" + MergePDFs.GetDate() + ConfigurationManager.AppSettings["PDF-Extension"];
}
else
{
pdfPath = ConfigurationManager.AppSettings["PDF-Output"] + Path.DirectorySeparatorChar + ConfigurationManager.AppSettings["PDF-Name"] + ConfigurationManager.AppSettings["PDF-Extension"];
}
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();
}
}
}