diff --git a/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs b/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs index 4c14ebb..cf1e695 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs @@ -31,6 +31,10 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.quitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -94,6 +98,7 @@ this.tabPage2 = new System.Windows.Forms.TabPage(); this.pictureBox2 = new System.Windows.Forms.PictureBox(); this.groupExport = new System.Windows.Forms.GroupBox(); + this.chkMagazines = new System.Windows.Forms.CheckBox(); this.panelBanner = new System.Windows.Forms.Panel(); this.btnMakePDF = new System.Windows.Forms.Button(); this.cmbBanner = new System.Windows.Forms.ComboBox(); @@ -118,7 +123,6 @@ this.btnDisposePics = new System.Windows.Forms.Button(); this.btnDeleteTemp = new System.Windows.Forms.Button(); this.btnDeleteCacheWork = new System.Windows.Forms.Button(); - this.chkMagazines = new System.Windows.Forms.CheckBox(); this.menuStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -155,15 +159,43 @@ // fileToolStripMenuItem // this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.loadToolStripMenuItem, + this.toolStripSeparator1, + this.saveToolStripMenuItem, + this.toolStripSeparator2, this.quitToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Text = "&File"; // + // loadToolStripMenuItem + // + this.loadToolStripMenuItem.Name = "loadToolStripMenuItem"; + this.loadToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.loadToolStripMenuItem.Text = "&Load..."; + this.loadToolStripMenuItem.Click += new System.EventHandler(this.loadToolStripMenuItem_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(177, 6); + // + // saveToolStripMenuItem + // + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.saveToolStripMenuItem.Text = "&Save"; + this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(177, 6); + // // quitToolStripMenuItem // this.quitToolStripMenuItem.Name = "quitToolStripMenuItem"; - this.quitToolStripMenuItem.Size = new System.Drawing.Size(97, 22); + this.quitToolStripMenuItem.Size = new System.Drawing.Size(180, 22); this.quitToolStripMenuItem.Text = "&Quit"; this.quitToolStripMenuItem.Click += new System.EventHandler(this.quitToolStripMenuItem_Click); // @@ -778,6 +810,16 @@ this.groupExport.TabStop = false; this.groupExport.Text = "Exporting"; // + // chkMagazines + // + this.chkMagazines.AutoSize = true; + this.chkMagazines.Location = new System.Drawing.Point(7, 22); + this.chkMagazines.Name = "chkMagazines"; + this.chkMagazines.Size = new System.Drawing.Size(72, 17); + this.chkMagazines.TabIndex = 56; + this.chkMagazines.Text = "Magazine"; + this.chkMagazines.UseVisualStyleBackColor = true; + // // panelBanner // this.panelBanner.Controls.Add(this.btnMakePDF); @@ -1030,16 +1072,6 @@ this.btnDeleteCacheWork.UseVisualStyleBackColor = true; this.btnDeleteCacheWork.Click += new System.EventHandler(this.btnDeleteCacheWork_Click); // - // chkMagazines - // - this.chkMagazines.AutoSize = true; - this.chkMagazines.Location = new System.Drawing.Point(7, 22); - this.chkMagazines.Name = "chkMagazines"; - this.chkMagazines.Size = new System.Drawing.Size(72, 17); - this.chkMagazines.TabIndex = 56; - this.chkMagazines.Text = "Magazine"; - this.chkMagazines.UseVisualStyleBackColor = true; - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1187,6 +1219,10 @@ private System.Windows.Forms.Button btnDeleteTemp; private System.Windows.Forms.Button btnDeleteCacheWork; private System.Windows.Forms.CheckBox chkMagazines; + private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; } } diff --git a/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs b/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs index a5e250c..355839d 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs @@ -280,7 +280,6 @@ namespace PDFWorkflowManager checkSimplex.Enabled = true; } - // FIXME - Call a function here to check dirs and files check_input_dir(); } @@ -1084,15 +1083,22 @@ namespace PDFWorkflowManager fileName += title; var selectedItem = (dynamic)cmbLanguage.SelectedItem; - var selectedValue = selectedItem.Value; - - if (selectedValue != "eng") + if (selectedItem != null) { - fileName += "_(" + languageCodes[cmbLanguage.Text] + ")" + $"[{cmbResolution.SelectedItem}dpi][ocr]"; + var selectedValue = selectedItem.Value; + + if (selectedValue != "eng") + { + fileName += "_(" + languageCodes[cmbLanguage.Text] + ")" + $"[{cmbResolution.SelectedItem}dpi][ocr]"; + } + else + { + fileName += $"_[{cmbResolution.SelectedItem}dpi][ocr]"; + } } else { - fileName += $"_[{cmbResolution.SelectedItem}dpi][ocr]"; + cmbLanguage.SelectedIndex = cmbLanguage.FindStringExact("English"); } txtFileName.Text = fileName; @@ -1373,5 +1379,106 @@ namespace PDFWorkflowManager check_input_dir(); } } + + private void loadToolStripMenuItem_Click(object sender, EventArgs e) + { + using (OpenFileDialog openFileDialog = new OpenFileDialog()) + { + openFileDialog.Filter = "PDF Project Files (*.pdfproj)|*.pdfproj|All Files (*.*)|*.*"; + openFileDialog.Title = "Open PDF Project File"; + openFileDialog.Multiselect = false; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + { + string selectedFile = openFileDialog.FileName; + var lines = File.ReadAllLines(selectedFile); + var dict = new Dictionary(); + foreach (var line in lines) + { + var parts = line.Split(new[] { '=' }, 2); + if (parts.Length == 2) + dict[parts[0]] = parts[1]; + } + + txtFileName.Text = dict.ContainsKey("FileName") ? dict["FileName"] : ""; + txtTitle.Text = dict.ContainsKey("Title") ? dict["Title"] : ""; + cmbLanguage.SelectedIndex = cmbLanguage.FindStringExact(dict.ContainsKey("Language") ? dict["Language"] : ""); + txtLanguages.Text = dict.ContainsKey("Languages") ? dict["Languages"] : ""; + txtType.Text = dict.ContainsKey("Type") ? dict["Type"] : ""; + txtPublisher.Text = dict.ContainsKey("Publisher") ? dict["Publisher"] : ""; + txtAuthor.Text = dict.ContainsKey("Author") ? dict["Author"] : ""; + txtISBN.Text = dict.ContainsKey("ISBN") ? dict["ISBN"] : ""; + txtDate.Text = dict.ContainsKey("Date") ? dict["Date"] : ""; + txtPageCount.Text = dict.ContainsKey("PageCount") ? dict["PageCount"] : ""; + cmbResolution.SelectedIndex = cmbResolution.FindStringExact(dict.ContainsKey("Resolution") ? dict["Resolution"] : ""); + checkPhotocopy.Checked = dict.ContainsKey("Photocopy") ? dict["Photocopy"] == "True" : false; + checkReplace.Checked = dict.ContainsKey("Replace") ? dict["Replace"] == "True" : false; + txtPartnumber.Text = dict.ContainsKey("Partnumber") ? dict["Partnumber"] : ""; + if (int.TryParse(dict.ContainsKey("Quality") ? dict["Quality"] : "4", out int quality)) + trackBar1.Value = Math.Max(trackBar1.Minimum, Math.Min(trackBar1.Maximum, quality)); + txtContributor.Text = dict.ContainsKey("Contributor") ? dict["Contributor"] : ""; + txtContributorURL.Text = dict.ContainsKey("ContributorURL") ? dict["ContributorURL"] : ""; + txtPostProcessor.Text = dict.ContainsKey("PostProcessor") ? dict["PostProcessor"] : ""; + txtTimeSpent.Text = dict.ContainsKey("TimeSpent") ? dict["TimeSpent"] : ""; + txtPDFAuthor.Text = dict.ContainsKey("PDFMetaAuthor") ? dict["PDFMetaAuthor"] : ""; + txtPDFKeywords.Text = dict.ContainsKey("PDFKeywords") ? dict["PDFKeywords"] : ""; + cmbBanner.SelectedIndex = cmbBanner.FindStringExact(dict.ContainsKey("Banner") ? dict["Banner"] : ""); + chkMagazines.Checked = dict.ContainsKey("Magazine") ? dict["Magazine"] == "True" : false; + checkSimplex.Checked = dict.ContainsKey("Simplex") ? dict["Simplex"] == "True" : false; + txtProjectDir.Text = dict.ContainsKey("ProjectDir") ? dict["ProjectDir"] : ""; + + MessageBox.Show("Loaded file: " + selectedFile, "File Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } + + private void saveToolStripMenuItem_Click(object sender, EventArgs e) + { + using (SaveFileDialog saveFileDialog = new SaveFileDialog()) + { + saveFileDialog.Filter = "PDF Project Files (*.pdfproj)|*.pdfproj|All Files (*.*)|*.*"; + saveFileDialog.Title = "Save PDF Project File"; + saveFileDialog.DefaultExt = "pdfproj"; + saveFileDialog.AddExtension = true; + + if (saveFileDialog.ShowDialog() == DialogResult.OK) + { + string selectedFile = saveFileDialog.FileName; + + // Collect all form data + var lines = new List + { + "FileName=" + txtFileName.Text, + "Title=" + txtTitle.Text, + "Language=" + cmbLanguage.Text, + "Languages=" + txtLanguages.Text, + "Type=" + txtType.Text, + "Publisher=" + txtPublisher.Text, + "Author=" + txtAuthor.Text, + "ISBN=" + txtISBN.Text, + "Date=" + txtDate.Text, + "PageCount=" + txtPageCount.Text, + "Resolution=" + cmbResolution.Text, + "Photocopy=" + checkPhotocopy.Checked, + "Replace=" + checkReplace.Checked, + "Partnumber=" + txtPartnumber.Text, + "Quality=" + trackBar1.Value, + "Contributor=" + txtContributor.Text, + "ContributorURL=" + txtContributorURL.Text, + "PostProcessor=" + txtPostProcessor.Text, + "TimeSpent=" + txtTimeSpent.Text, + "PDFMetaAuthor=" + txtPDFAuthor.Text, + "PDFKeywords=" + txtPDFKeywords.Text, + "Banner=" + cmbBanner.Text, + "Magazine=" + chkMagazines.Checked, + "Simplex=" + checkSimplex.Checked, + "ProjectDir=" + txtProjectDir.Text + }; + + File.WriteAllLines(selectedFile, lines); + MessageBox.Show("Saved file: " + selectedFile, "File Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + } } } diff --git a/PDFWorkflowManager/PDFWorkflowManager/PDF Workflow Manager.csproj b/PDFWorkflowManager/PDFWorkflowManager/PDF Workflow Manager.csproj index 08dc8df..3e8b372 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/PDF Workflow Manager.csproj +++ b/PDFWorkflowManager/PDFWorkflowManager/PDF Workflow Manager.csproj @@ -154,6 +154,7 @@ Always + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/PDFWorkflowManager/PDFWorkflowManager/PDFWorkflowManager.csproj b/PDFWorkflowManager/PDFWorkflowManager/PDFWorkflowManager.csproj new file mode 100644 index 0000000..e69de29