Compare commits
12 Commits
8c5d3f9e06
...
issue#4
| Author | SHA1 | Date | |
|---|---|---|---|
| 66695f595f | |||
| cd64c19fa3 | |||
| 70cc9583af | |||
| a1c79ab1f3 | |||
| d0a9bc9055 | |||
| 006228647d | |||
| af2f15fd40 | |||
| 065df71090 | |||
| a17d288f92 | |||
| ba059015cf | |||
| 3b57fb0edf | |||
| 1e75972ae9 |
@@ -37,7 +37,7 @@ namespace PDF_Merge
|
||||
return titleAttribute.Title;
|
||||
}
|
||||
}
|
||||
return System.IO.Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
|
||||
return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().Location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace PDF_Merge
|
||||
{
|
||||
get
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
return Assembly.GetExecutingAssembly()?.GetName()?.Version?.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
<appSettings>
|
||||
<add key="PDF-Path" value=""/>
|
||||
<add key="PDF-Output" value=""/>
|
||||
<add key="PDF-Name" value="merged.pdf"/>
|
||||
<add key="PDF-Name" value="merged"/>
|
||||
<add key ="PDF-Extension" value=".pdf"/>
|
||||
<add key="overwrite" value="true"/>
|
||||
<add key="appendDate" value="false"/>
|
||||
<add key ="dateFormat" value="yyyy-MM-dd"/>
|
||||
<add key="dateIndex" value="0"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
88
ConfForm.Designer.cs
generated
88
ConfForm.Designer.cs
generated
@@ -30,8 +30,8 @@ namespace PDF_Merge
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
saveBtn = new Button();
|
||||
cancelBtn = new Button();
|
||||
SaveBtn = new Button();
|
||||
CancelBtn = new Button();
|
||||
sourceBox = new TextBox();
|
||||
outputBox = new TextBox();
|
||||
folderBrowserDialog1 = new FolderBrowserDialog();
|
||||
@@ -42,27 +42,30 @@ namespace PDF_Merge
|
||||
outPathBtn = new Button();
|
||||
FileLable = new Label();
|
||||
FileNameBox = new TextBox();
|
||||
fileExtlabel = new Label();
|
||||
appendDatecheckBox = new CheckBox();
|
||||
dateFormatOpts = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// saveBtn
|
||||
// SaveBtn
|
||||
//
|
||||
saveBtn.Location = new Point(327, 227);
|
||||
saveBtn.Name = "saveBtn";
|
||||
saveBtn.Size = new Size(112, 34);
|
||||
saveBtn.TabIndex = 0;
|
||||
saveBtn.Text = "Save";
|
||||
saveBtn.UseVisualStyleBackColor = true;
|
||||
saveBtn.Click += saveBtn_Click;
|
||||
SaveBtn.Location = new Point(327, 227);
|
||||
SaveBtn.Name = "SaveBtn";
|
||||
SaveBtn.Size = new Size(112, 34);
|
||||
SaveBtn.TabIndex = 0;
|
||||
SaveBtn.Text = "Save";
|
||||
SaveBtn.UseVisualStyleBackColor = true;
|
||||
SaveBtn.Click += SaveBtn_Click;
|
||||
//
|
||||
// cancelBtn
|
||||
// CancelBtn
|
||||
//
|
||||
cancelBtn.Location = new Point(193, 227);
|
||||
cancelBtn.Name = "cancelBtn";
|
||||
cancelBtn.Size = new Size(112, 34);
|
||||
cancelBtn.TabIndex = 1;
|
||||
cancelBtn.Text = "Cancel";
|
||||
cancelBtn.UseVisualStyleBackColor = true;
|
||||
cancelBtn.Click += cancelBtn_Click;
|
||||
CancelBtn.Location = new Point(193, 227);
|
||||
CancelBtn.Name = "CancelBtn";
|
||||
CancelBtn.Size = new Size(112, 34);
|
||||
CancelBtn.TabIndex = 1;
|
||||
CancelBtn.Text = "Cancel";
|
||||
CancelBtn.UseVisualStyleBackColor = true;
|
||||
CancelBtn.Click += CancelBtn_Click;
|
||||
//
|
||||
// sourceBox
|
||||
//
|
||||
@@ -116,7 +119,7 @@ namespace PDF_Merge
|
||||
sourceDirBtn.TabIndex = 7;
|
||||
sourceDirBtn.Text = "...";
|
||||
sourceDirBtn.UseVisualStyleBackColor = true;
|
||||
sourceDirBtn.Click += sourceDirBtn_Click;
|
||||
sourceDirBtn.Click += SourceDirBtn_Click;
|
||||
//
|
||||
// outPathBtn
|
||||
//
|
||||
@@ -126,7 +129,7 @@ namespace PDF_Merge
|
||||
outPathBtn.TabIndex = 8;
|
||||
outPathBtn.Text = "...";
|
||||
outPathBtn.UseVisualStyleBackColor = true;
|
||||
outPathBtn.Click += outPathBtn_Click;
|
||||
outPathBtn.Click += OutPathBtn_Click;
|
||||
//
|
||||
// FileLable
|
||||
//
|
||||
@@ -144,11 +147,43 @@ namespace PDF_Merge
|
||||
FileNameBox.Size = new Size(150, 31);
|
||||
FileNameBox.TabIndex = 10;
|
||||
//
|
||||
// fileExtlabel
|
||||
//
|
||||
fileExtlabel.AutoSize = true;
|
||||
fileExtlabel.Location = new Point(327, 114);
|
||||
fileExtlabel.Name = "fileExtlabel";
|
||||
fileExtlabel.Size = new Size(44, 25);
|
||||
fileExtlabel.TabIndex = 11;
|
||||
fileExtlabel.Text = ".pdf";
|
||||
//
|
||||
// appendDatecheckBox
|
||||
//
|
||||
appendDatecheckBox.AutoSize = true;
|
||||
appendDatecheckBox.Location = new Point(171, 187);
|
||||
appendDatecheckBox.Name = "appendDatecheckBox";
|
||||
appendDatecheckBox.Size = new Size(144, 29);
|
||||
appendDatecheckBox.TabIndex = 12;
|
||||
appendDatecheckBox.Text = "Append Date";
|
||||
appendDatecheckBox.UseVisualStyleBackColor = true;
|
||||
appendDatecheckBox.CheckedChanged += AppendDatecheckBox_CheckedChanged;
|
||||
//
|
||||
// dateFormatOpts
|
||||
//
|
||||
dateFormatOpts.FormattingEnabled = true;
|
||||
dateFormatOpts.Items.AddRange(new object[] { "yyyy-MM-dd", "MM-dd-yyyy" });
|
||||
dateFormatOpts.Location = new Point(321, 188);
|
||||
dateFormatOpts.Name = "dateFormatOpts";
|
||||
dateFormatOpts.Size = new Size(182, 33);
|
||||
dateFormatOpts.TabIndex = 13;
|
||||
//
|
||||
// ConfForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(500, 282);
|
||||
ClientSize = new Size(546, 282);
|
||||
Controls.Add(dateFormatOpts);
|
||||
Controls.Add(appendDatecheckBox);
|
||||
Controls.Add(fileExtlabel);
|
||||
Controls.Add(FileNameBox);
|
||||
Controls.Add(FileLable);
|
||||
Controls.Add(outPathBtn);
|
||||
@@ -158,8 +193,8 @@ namespace PDF_Merge
|
||||
Controls.Add(sourceLabel);
|
||||
Controls.Add(outputBox);
|
||||
Controls.Add(sourceBox);
|
||||
Controls.Add(cancelBtn);
|
||||
Controls.Add(saveBtn);
|
||||
Controls.Add(CancelBtn);
|
||||
Controls.Add(SaveBtn);
|
||||
Name = "ConfForm";
|
||||
Text = "Configure";
|
||||
ResumeLayout(false);
|
||||
@@ -168,8 +203,8 @@ namespace PDF_Merge
|
||||
|
||||
#endregion
|
||||
|
||||
private Button saveBtn;
|
||||
private Button cancelBtn;
|
||||
private Button SaveBtn;
|
||||
private Button CancelBtn;
|
||||
private TextBox sourceBox;
|
||||
private TextBox outputBox;
|
||||
private FolderBrowserDialog folderBrowserDialog1;
|
||||
@@ -180,5 +215,8 @@ namespace PDF_Merge
|
||||
private Button outPathBtn;
|
||||
private Label FileLable;
|
||||
private TextBox FileNameBox;
|
||||
private Label fileExtlabel;
|
||||
private CheckBox appendDatecheckBox;
|
||||
private ComboBox dateFormatOpts;
|
||||
}
|
||||
}
|
||||
57
ConfForm.cs
57
ConfForm.cs
@@ -17,13 +17,28 @@ namespace PDF_Merge
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
string sourcePath = ConfigurationManager.AppSettings["PDF-Path"];
|
||||
string outputPath = ConfigurationManager.AppSettings["PDF-Output"];
|
||||
string outputName = ConfigurationManager.AppSettings["PDF-Name"];
|
||||
string sourcePath = ConfigurationManager.AppSettings["PDF-Path"] ?? "";
|
||||
string outputPath = ConfigurationManager.AppSettings["PDF-Output"] ?? "";
|
||||
string outputName = ConfigurationManager.AppSettings["PDF-Name"] ?? "merged";
|
||||
string outputExt = ConfigurationManager.AppSettings["PDF-Extension"] ?? ".pdf";
|
||||
string dateIndex = ConfigurationManager.AppSettings["dateIndex"] ?? "0";
|
||||
|
||||
int dateIndexValue;
|
||||
|
||||
bool indexSet = int.TryParse(dateIndex, out dateIndexValue);
|
||||
if (indexSet)
|
||||
{
|
||||
dateFormatOpts.SelectedIndex = dateIndexValue;
|
||||
} else
|
||||
{
|
||||
dateFormatOpts.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
sourceBox.Text = sourcePath;
|
||||
outputBox.Text = outputPath;
|
||||
FileNameBox.Text = outputName;
|
||||
fileExtlabel.Text = outputExt;
|
||||
|
||||
if (ConfigurationManager.AppSettings["overwrite"] == true.ToString())
|
||||
{
|
||||
overrideCBox.Checked = true;
|
||||
@@ -32,14 +47,23 @@ namespace PDF_Merge
|
||||
{
|
||||
overrideCBox.Checked = false;
|
||||
}
|
||||
if (ConfigurationManager.AppSettings["appendDate"] == true.ToString())
|
||||
{
|
||||
appendDatecheckBox.Checked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
appendDatecheckBox.Checked = false;
|
||||
}
|
||||
CheckAppend();
|
||||
}
|
||||
|
||||
private void cancelBtn_Click(object sender, EventArgs e)
|
||||
private void CancelBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
private void SaveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
AppSettingsSection appSettings = appConfig.AppSettings;
|
||||
@@ -68,12 +92,15 @@ namespace PDF_Merge
|
||||
MessageBox.Show("File must be named.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
appSettings.Settings["overwrite"].Value = overrideCBox.Checked.ToString();
|
||||
appSettings.Settings["appendDate"].Value = appendDatecheckBox.Checked.ToString();
|
||||
appSettings.Settings["dateFormat"].Value = dateFormatOpts.SelectedItem.ToString();
|
||||
appSettings.Settings["dateIndex"].Value = dateFormatOpts.SelectedIndex.ToString();
|
||||
appConfig.Save(ConfigurationSaveMode.Modified);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void sourceDirBtn_Click(object sender, EventArgs e)
|
||||
private void SourceDirBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var SourceDirPicker = new FolderBrowserDialog())
|
||||
{
|
||||
@@ -94,7 +121,7 @@ namespace PDF_Merge
|
||||
}
|
||||
}
|
||||
|
||||
private void outPathBtn_Click(object sender, EventArgs e)
|
||||
private void OutPathBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var OutPathPicker = new FolderBrowserDialog())
|
||||
{
|
||||
@@ -106,5 +133,21 @@ namespace PDF_Merge
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendDatecheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckAppend();
|
||||
}
|
||||
private void CheckAppend()
|
||||
{
|
||||
if (appendDatecheckBox.Checked)
|
||||
{
|
||||
dateFormatOpts.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dateFormatOpts.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
MainForm.cs
12
MainForm.cs
@@ -12,12 +12,20 @@ namespace PDF_Merge
|
||||
}
|
||||
private static string getOutputPath()
|
||||
{
|
||||
string pdfPath = ConfigurationManager.AppSettings["PDF-Output"] + Path.DirectorySeparatorChar + ConfigurationManager.AppSettings["PDF-Name"];
|
||||
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"];
|
||||
string sourcePath = ConfigurationManager.AppSettings["PDF-Path"] ?? "";
|
||||
|
||||
if (sourcePath != null)
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
}
|
||||
public static string[] CollectPdfFiles()
|
||||
{
|
||||
string dirPath = ConfigurationManager.AppSettings["PDF-Path"];
|
||||
string dirPath = ConfigurationManager.AppSettings["PDF-Path"] ?? "";
|
||||
Console.WriteLine(dirPath);
|
||||
string[] pdfFiles = Directory.EnumerateFiles(dirPath, "*.pdf").ToArray();
|
||||
Array.Sort(pdfFiles);
|
||||
@@ -77,6 +77,13 @@
|
||||
}
|
||||
return pdfFiles;
|
||||
}
|
||||
|
||||
public static string GetDate()
|
||||
{
|
||||
DateTime date = DateTime.Now;
|
||||
string dateFormat = ConfigurationManager.AppSettings["dateFormat"] ?? "yyyy-MM-dd";
|
||||
return date.ToString(dateFormat);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<PackageLicenseFile>LICENSE</PackageLicenseFile>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<Version>2024.08.05</Version>
|
||||
<Version>2024.08.06.01</Version>
|
||||
<Company>ABSC Inc.</Company>
|
||||
<Description>This tool merges PDF files from a configured directory into a single PDF.</Description>
|
||||
<Copyright>GNU GPL v3 2024</Copyright>
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="PDFsharp" Version="6.1.1" />
|
||||
<PackageReference Include="QuestPDF" Version="2024.7.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -23,7 +23,7 @@ Var Current_Version
|
||||
|
||||
Function SetWelcomeMsg
|
||||
StrCpy $Company_Name "Applied Business Solutions Consulting, Inc. (ABSC)"
|
||||
StrCpy $Current_Version "2024.08.05.1"
|
||||
StrCpy $Current_Version "2024.08.06.1"
|
||||
SendMessage $mui.WelcomePage.Text= ${WM_SETTEXT} 0 "STR: Merge several PDFs into a single file.$\n Requiers .NET version 6 $\n Version: $Current_Version $\n Developed by: $Company_Name"
|
||||
FunctionEnd
|
||||
|
||||
@@ -34,7 +34,23 @@ SectionGroup "PDF-Merge" pdf_merge_inst
|
||||
File "bin\Release\PDF-Merge.zip"
|
||||
nsisunz::UnzipToLog "$INSTDIR\PDF-Merge.zip" "$INSTDIR"
|
||||
Delete "$INSTDIR\PDF-Merge.zip"
|
||||
|
||||
nsExec::ExecToStack 'icacls "$INSTDIR" /grant Everyone:F /T'
|
||||
CreateShortCut "$DESKTOP\PDF-Merge.lnk" "${APP_EXE}"
|
||||
File "PDF-Merge Icon.ico"
|
||||
; Write the registry keys to add the program to the Installed Programs list
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\" "InstallDate" 0x00000000
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\" "DisplayName" "PDF-Merge"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\" "DisplayVersion" "$Current_Version"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\" "Publisher" "$Company_Name"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\" "UninstallString" '"$INSTDIR\uninst.exe"'
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\" "DisplayIcon" '"$INSTDIR\PDF-Merge Icon.ico"'
|
||||
|
||||
WriteUninstaller "uninst.exe"
|
||||
SectionEnd
|
||||
SectionGroupEnd
|
||||
|
||||
Section "Uninstall"
|
||||
Delete "$DESKTOP\PDF-Merge.lnk"
|
||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\PDF-Merge\"
|
||||
RMDir /r "$INSTDIR"
|
||||
SectionEnd
|
||||
|
||||
Reference in New Issue
Block a user