load project file if one is existing when opening a project
This commit is contained in:
@@ -1429,8 +1429,58 @@ namespace PDFWorkflowManager
|
|||||||
{
|
{
|
||||||
check_input_dir();
|
check_input_dir();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Load the first .pdfproj file if it exists
|
||||||
|
string[] pdfProjFiles = Directory.GetFiles(txtProjectDir.Text, "*.pdfproj");
|
||||||
|
if (pdfProjFiles.Length > 0)
|
||||||
|
{
|
||||||
|
string firstPdfProjFile = pdfProjFiles[0];
|
||||||
|
LoadProjectFile(firstPdfProjFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadProjectFile(string filePath)
|
||||||
|
{
|
||||||
|
var lines = File.ReadAllLines(filePath);
|
||||||
|
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"] : "";
|
||||||
|
|
||||||
|
toolStripStatusLabel1.Text = "Project file loaded: " + filePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
using (OpenFileDialog openFileDialog = new OpenFileDialog())
|
||||||
|
|||||||
Reference in New Issue
Block a user