load/save project file

This commit is contained in:
tomse
2025-08-23 16:07:41 +02:00
parent 2993807605
commit ef6c017950
4 changed files with 162 additions and 18 deletions

View File

@@ -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;
}
}

View File

@@ -280,7 +280,6 @@ namespace PDFWorkflowManager
checkSimplex.Enabled = true;
}
// FIXME - Call a function here to check dirs and files
check_input_dir();
}
@@ -1084,6 +1083,8 @@ namespace PDFWorkflowManager
fileName += title;
var selectedItem = (dynamic)cmbLanguage.SelectedItem;
if (selectedItem != null)
{
var selectedValue = selectedItem.Value;
if (selectedValue != "eng")
@@ -1094,6 +1095,11 @@ namespace PDFWorkflowManager
{
fileName += $"_[{cmbResolution.SelectedItem}dpi][ocr]";
}
}
else
{
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<string, string>();
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<string>
{
"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);
}
}
}
}
}

View File

@@ -154,6 +154,7 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="PDFWorkflowManager.csproj" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>