From 626197a22bab439cfad566709ad46237ba824118 Mon Sep 17 00:00:00 2001 From: tomse <1444539+tomse@users.noreply.github.com> Date: Sat, 23 Aug 2025 16:22:44 +0200 Subject: [PATCH] fixed hardcoded version info + code cleanup --- .../PDFWorkflowManager/ImageService.cs | 1 - .../PDFWorkflowManager/LanguagesForm.cs | 6 --- .../PDFWorkflowManager/MainForm.cs | 54 +++++++++++-------- .../PDFWorkflowManager/PdfService.cs | 1 - .../Properties/AssemblyInfo.cs | 6 +-- .../PDFWorkflowManager/SettingsForm.cs | 4 +- 6 files changed, 37 insertions(+), 35 deletions(-) diff --git a/PDFWorkflowManager/PDFWorkflowManager/ImageService.cs b/PDFWorkflowManager/PDFWorkflowManager/ImageService.cs index 28db40d..72e8622 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/ImageService.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/ImageService.cs @@ -1,7 +1,6 @@ using ImageMagick; using System.Drawing; using System.Drawing.Imaging; -using System.IO; namespace PDFWorkflowManager { diff --git a/PDFWorkflowManager/PDFWorkflowManager/LanguagesForm.cs b/PDFWorkflowManager/PDFWorkflowManager/LanguagesForm.cs index 497f5ba..87e1a43 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/LanguagesForm.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/LanguagesForm.cs @@ -1,11 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace PDFWorkflowManager diff --git a/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs b/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs index a0c3602..c9ea5db 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs @@ -7,6 +7,7 @@ using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Linq; +using System.Reflection; using System.Security.Cryptography; using System.Threading; using System.Threading.Tasks; @@ -239,8 +240,8 @@ namespace PDFWorkflowManager btnMakePDF.Enabled = true; //public string txtPostProcessor.text = ""; - - } + + } private void btnProjectDir_Click(object sender, EventArgs e) @@ -301,8 +302,8 @@ namespace PDFWorkflowManager // Check input dir for origs dir and files - private void check_input_dir() - { + private void check_input_dir() + { Cursor.Current = Cursors.WaitCursor; @@ -311,7 +312,7 @@ namespace PDFWorkflowManager MessageBox.Show("Origs dir not found.", "Origs dir not found.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - else if (Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir), "*.tif").Length == 0 + else if (Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir), "*.tif").Length == 0 && Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir), "*.tiff").Length == 0 && Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.OrigsDir), "*.png").Length == 0) { @@ -421,7 +422,7 @@ namespace PDFWorkflowManager // Set Banner if (Properties.Settings.Default.Banner != 2) - { + { if ((image.Width > 4000 || image.Height > 5500) && (cmbResolution.SelectedItem.ToString() == "600")) { cmbBanner.SelectedIndex = 0; @@ -702,7 +703,7 @@ namespace PDFWorkflowManager toolStripProgressBar1.Value = 0; toolStripStatusLabel1.Text = "Converting files to pdf."; - Task convertpdf = Task.Run(() => + Task convertpdf = Task.Run(() => { Parallel.ForEach(strFiles, inputFile => { @@ -909,7 +910,7 @@ namespace PDFWorkflowManager txtPageCount.Text = outFiles.Length.ToString(); } catch - { + { } } @@ -921,7 +922,7 @@ namespace PDFWorkflowManager } try - { + { toolStripProgressBar1.Maximum = 1; toolStripStatusLabel1.Text = "Creating final pdf."; toolStripProgressBar1.Value = 0; @@ -956,7 +957,7 @@ namespace PDFWorkflowManager // TODO make this configurable startInfo.FileName = Properties.Settings.Default.PDFtk; - startInfo.Arguments = "\"" + Path.Combine(outputDir, "*.pdf") + "\" " + bannerPage + " cat output " + "\"" + tempFile + "\""; + startInfo.Arguments = "\"" + Path.Combine(outputDir, "*.pdf") + "\" " + bannerPage + " cat output " + "\"" + tempFile + "\""; using (var process = Process.Start(startInfo)) { process.WaitForExit(); @@ -1032,7 +1033,7 @@ namespace PDFWorkflowManager string dateTimeNow = DateTime.Now.ToString("yyyyMMddHHmmss"); string pdfMetaData = $"[ /Title ({txtTitle.Text})\r\n"; - pdfMetaData += $" /Author ("+ txtPDFAuthor.Text + ")\r\n"; + pdfMetaData += $" /Author (" + txtPDFAuthor.Text + ")\r\n"; pdfMetaData += $" /Subject ({txtType.Text})\r\n"; pdfMetaData += $" /Keywords ({txtPDFKeywords.Text})\r\n"; pdfMetaData += $" /ModDate (D:{dateTimeNow})\r\n"; @@ -1056,7 +1057,7 @@ namespace PDFWorkflowManager string[] origFiles = Directory.GetFiles(origsDir, "*.tif"); int count = origFiles.Length; var startOrig = new FileInfo(origFiles[0]); - var endOrig = new FileInfo(origFiles[count-1]); + var endOrig = new FileInfo(origFiles[count - 1]); string startTimeFile = startOrig.LastWriteTime.ToString(); string endTimeFile = endOrig.LastWriteTime.ToString(); @@ -1166,10 +1167,10 @@ namespace PDFWorkflowManager string strOcrText = ""; //if (Directory.GetFiles(workOutDir, "*.tif").Length == txtFiles.Length) //{ - foreach (string ocrFile in txtFiles) - { - strOcrText += File.ReadAllText(ocrFile) + "\r\n\r\n\r\n"; - } + foreach (string ocrFile in txtFiles) + { + strOcrText += File.ReadAllText(ocrFile) + "\r\n\r\n\r\n"; + } //} File.WriteAllText(Path.Combine(txtProjectDir.Text, txtFileName.Text + ".ocr.txt"), strOcrText); } @@ -1328,13 +1329,22 @@ namespace PDFWorkflowManager private void aboutToolStripMenuItem_Click(object sender, EventArgs e) { - MessageBox.Show("PDF Workflow Manager v0.9.4 \r\n\r\nCopyright (c) 2023-2025 https://retro-commodore.eu", "Version", MessageBoxButtons.OK, MessageBoxIcon.Information); - } + var assembly = Assembly.GetExecutingAssembly(); + var version = assembly.GetName().Version.ToString(); - private void button1_Click(object sender, EventArgs e) - { - //GalleryForm sf = new GalleryForm(workOutDir); - //sf.ShowDialog(); + var copyrightAttr = assembly + .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false) + .OfType() + .FirstOrDefault(); + + var copyright = copyrightAttr?.Copyright ?? "Copyright info not found"; + + MessageBox.Show( + $"PDF Workflow Manager v{version}\r\n\r\n{copyright}", + "Version", + MessageBoxButtons.OK, + MessageBoxIcon.Information + ); } diff --git a/PDFWorkflowManager/PDFWorkflowManager/PdfService.cs b/PDFWorkflowManager/PDFWorkflowManager/PdfService.cs index 17fe59f..8cc86b6 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/PdfService.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/PdfService.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.IO; namespace PDFWorkflowManager { diff --git a/PDFWorkflowManager/PDFWorkflowManager/Properties/AssemblyInfo.cs b/PDFWorkflowManager/PDFWorkflowManager/Properties/AssemblyInfo.cs index 099c4bd..c4c768f 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/Properties/AssemblyInfo.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/Properties/AssemblyInfo.cs @@ -9,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Retro Commodore")] [assembly: AssemblyProduct("PDF Workflow Manager")] -[assembly: AssemblyCopyright("Copyright © 2023-2024 https://retro-commodore.eu")] +[assembly: AssemblyCopyright("Copyright © 2023-2025 https://retro-commodore.eu")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.9.3")] -[assembly: AssemblyFileVersion("0.9.3")] +[assembly: AssemblyVersion("0.9.4")] +[assembly: AssemblyFileVersion("0.9.4")] diff --git a/PDFWorkflowManager/PDFWorkflowManager/SettingsForm.cs b/PDFWorkflowManager/PDFWorkflowManager/SettingsForm.cs index c9e2d89..72215f2 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/SettingsForm.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/SettingsForm.cs @@ -6,8 +6,8 @@ namespace PDFWorkflowManager { public partial class SettingsForm : Form { - - + + public SettingsForm() { InitializeComponent();