improved project load/save
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.saveAsToolStripMenuItem = 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();
|
||||
@@ -124,7 +125,6 @@
|
||||
this.btnDisposePics = new System.Windows.Forms.Button();
|
||||
this.btnDeleteTemp = new System.Windows.Forms.Button();
|
||||
this.btnDeleteCacheWork = new System.Windows.Forms.Button();
|
||||
this.saveToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
@@ -164,8 +164,8 @@
|
||||
this.newToolStripMenuItem,
|
||||
this.toolStripSeparator1,
|
||||
this.loadToolStripMenuItem,
|
||||
this.saveToolStripMenuItem1,
|
||||
this.saveToolStripMenuItem,
|
||||
this.saveAsToolStripMenuItem,
|
||||
this.toolStripSeparator2,
|
||||
this.quitToolStripMenuItem});
|
||||
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
|
||||
@@ -195,9 +195,16 @@
|
||||
//
|
||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem.Text = "&Save...";
|
||||
this.saveToolStripMenuItem.Text = "S&ave";
|
||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||
//
|
||||
// saveAsToolStripMenuItem
|
||||
//
|
||||
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveAsToolStripMenuItem.Text = "&Save...";
|
||||
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
@@ -1083,12 +1090,6 @@
|
||||
this.btnDeleteCacheWork.UseVisualStyleBackColor = true;
|
||||
this.btnDeleteCacheWork.Click += new System.EventHandler(this.btnDeleteCacheWork_Click);
|
||||
//
|
||||
// saveToolStripMenuItem1
|
||||
//
|
||||
this.saveToolStripMenuItem1.Name = "saveToolStripMenuItem1";
|
||||
this.saveToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||
this.saveToolStripMenuItem1.Text = "S&ave";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -1238,10 +1239,10 @@
|
||||
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.ToolStripMenuItem saveAsToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.ToolStripMenuItem newToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace PDFWorkflowManager
|
||||
private SemaphoreSlim semaphore = new SemaphoreSlim(1);
|
||||
|
||||
string bannerPage = "";
|
||||
|
||||
private string loadedProjectFilePath = string.Empty;
|
||||
private string workDir = Properties.Settings.Default.WorkDir;
|
||||
private string workOutDir = Properties.Settings.Default.WorkOutDir;
|
||||
private string origsDir = Properties.Settings.Default.OrigsDir;
|
||||
@@ -244,6 +244,22 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
|
||||
|
||||
// Handle Ctrl+S key press to save metadata
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
// Check if the user pressed Control + S
|
||||
if (keyData == (Keys.Control | Keys.S))
|
||||
{
|
||||
// Trigger the saveToolStripMenuItem_Click event
|
||||
saveToolStripMenuItem_Click(this, EventArgs.Empty);
|
||||
return true; // Indicate that the key press was handled
|
||||
}
|
||||
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
|
||||
// Select Project Directory
|
||||
private void btnProjectDir_Click(object sender, EventArgs e)
|
||||
{
|
||||
CommonOpenFileDialog dialog = new CommonOpenFileDialog();
|
||||
@@ -292,7 +308,9 @@ namespace PDFWorkflowManager
|
||||
GC.WaitForPendingFinalizers();
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
{
|
||||
MessageBox.Show("Could not clear preview images.", "Error clearing preview images.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
txtProjectDir.ReadOnly = true;
|
||||
checkSimplex.Enabled = true;
|
||||
}
|
||||
@@ -339,7 +357,7 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
MessageBox.Show("Could not load preview image from Origs directory.", "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
else if (Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkDir)))
|
||||
@@ -365,6 +383,7 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Could not load preview image from Work directory.", "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
if (Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkOutDir)))
|
||||
@@ -390,6 +409,7 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Could not load preview image from Work\\out directory.", "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -548,6 +568,7 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Could not create Work\\out directory.", "Error creating Work\\out directory.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,7 +698,7 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1425,8 +1446,8 @@ namespace PDFWorkflowManager
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string selectedFile = openFileDialog.FileName;
|
||||
var lines = File.ReadAllLines(selectedFile);
|
||||
loadedProjectFilePath = openFileDialog.FileName; // Store the loaded file path
|
||||
var lines = File.ReadAllLines(loadedProjectFilePath);
|
||||
var dict = new Dictionary<string, string>();
|
||||
foreach (var line in lines)
|
||||
{
|
||||
@@ -1462,15 +1483,24 @@ namespace PDFWorkflowManager
|
||||
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);
|
||||
// MessageBox.Show("Loaded file: " + loadedProjectFilePath, "File Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
toolStripStatusLabel1.Text = "Project file loaded: ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (SaveFileDialog saveFileDialog = new SaveFileDialog())
|
||||
{
|
||||
// Set the initial directory to the value of txtProjectDir.Text if it is set
|
||||
if (!string.IsNullOrWhiteSpace(txtProjectDir.Text))
|
||||
{
|
||||
saveFileDialog.InitialDirectory = txtProjectDir.Text;
|
||||
saveFileDialog.FileName = Path.GetFileName(txtProjectDir.Text); // Suggest directory name as the file name
|
||||
}
|
||||
|
||||
saveFileDialog.Filter = "PDF Project Files (*.pdfproj)|*.pdfproj|All Files (*.*)|*.*";
|
||||
saveFileDialog.Title = "Save PDF Project File";
|
||||
saveFileDialog.DefaultExt = "pdfproj";
|
||||
@@ -1511,7 +1541,8 @@ namespace PDFWorkflowManager
|
||||
};
|
||||
|
||||
File.WriteAllLines(selectedFile, lines);
|
||||
MessageBox.Show("Saved file: " + selectedFile, "File Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
// MessageBox.Show("Saved file: " + selectedFile, "File Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
toolStripStatusLabel1.Text = "File saved: " + selectedFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1588,5 +1619,56 @@ namespace PDFWorkflowManager
|
||||
// Optionally log or handle error
|
||||
}
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(loadedProjectFilePath))
|
||||
{
|
||||
// Overwrite the loaded file
|
||||
SaveProjectToFile(loadedProjectFilePath);
|
||||
// MessageBox.Show("File saved successfully: " + loadedProjectFilePath, "File Saved", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
toolStripStatusLabel1 .Text = "Project saved: " + loadedProjectFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No file loaded, prompt to save as a new file
|
||||
saveAsToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveProjectToFile(string filePath)
|
||||
{
|
||||
// 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(filePath, lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\packages\wix.3.14.1\build\wix.props" Condition="Exists('..\packages\wix.3.14.1\build\wix.props')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
@@ -74,14 +73,14 @@
|
||||
<ApplicationIcon>chicken_lips.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Magick.NET-Q8-AnyCPU, Version=14.8.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Magick.NET-Q8-AnyCPU.14.8.0\lib\netstandard20\Magick.NET-Q8-AnyCPU.dll</HintPath>
|
||||
<Reference Include="Magick.NET-Q8-AnyCPU, Version=14.10.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Magick.NET-Q8-AnyCPU.14.10.2\lib\netstandard20\Magick.NET-Q8-AnyCPU.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Magick.NET.Core, Version=14.8.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Magick.NET.Core.14.8.0\lib\netstandard20\Magick.NET.Core.dll</HintPath>
|
||||
<Reference Include="Magick.NET.Core, Version=14.10.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Magick.NET.Core.14.10.2\lib\netstandard20\Magick.NET.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Magick.NET.SystemDrawing, Version=8.0.0.0, Culture=neutral, PublicKeyToken=2004825badfa91ec, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Magick.NET.SystemDrawing.8.0.8\lib\net462\Magick.NET.SystemDrawing.dll</HintPath>
|
||||
<HintPath>..\packages\Magick.NET.SystemDrawing.8.0.15\lib\net462\Magick.NET.SystemDrawing.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAPICodePack, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll</HintPath>
|
||||
@@ -155,6 +154,7 @@
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<None Include="PDFWorkflowManager.csproj" />
|
||||
<None Include="ProjectGuidelines.md" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
@@ -188,8 +188,7 @@
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Magick.NET-Q8-AnyCPU.14.8.0\build\netstandard20\Magick.NET-Q8-AnyCPU.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Magick.NET-Q8-AnyCPU.14.8.0\build\netstandard20\Magick.NET-Q8-AnyCPU.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\wix.3.14.1\build\wix.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\wix.3.14.1\build\wix.props'))" />
|
||||
<Error Condition="!Exists('..\packages\Magick.NET-Q8-AnyCPU.14.10.2\build\netstandard20\Magick.NET-Q8-AnyCPU.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Magick.NET-Q8-AnyCPU.14.10.2\build\netstandard20\Magick.NET-Q8-AnyCPU.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Magick.NET-Q8-AnyCPU.14.8.0\build\netstandard20\Magick.NET-Q8-AnyCPU.targets" Condition="Exists('..\packages\Magick.NET-Q8-AnyCPU.14.8.0\build\netstandard20\Magick.NET-Q8-AnyCPU.targets')" />
|
||||
<Import Project="..\packages\Magick.NET-Q8-AnyCPU.14.10.2\build\netstandard20\Magick.NET-Q8-AnyCPU.targets" Condition="Exists('..\packages\Magick.NET-Q8-AnyCPU.14.10.2\build\netstandard20\Magick.NET-Q8-AnyCPU.targets')" />
|
||||
</Project>
|
||||
@@ -9,7 +9,7 @@ using System.Runtime.InteropServices;
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Retro Commodore")]
|
||||
[assembly: AssemblyProduct("PDF Workflow Manager")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023-2025 https://retro-commodore.eu")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023-2026 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.4")]
|
||||
[assembly: AssemblyFileVersion("0.9.4")]
|
||||
[assembly: AssemblyVersion("0.9.5")]
|
||||
[assembly: AssemblyFileVersion("0.9.5")]
|
||||
|
||||
Reference in New Issue
Block a user