From 200a6904d78c966f5d326426aa521b6775999e41 Mon Sep 17 00:00:00 2001 From: thetechconspiracy Date: Mon, 14 Sep 2020 22:17:44 -0400 Subject: [PATCH] Added Show Folder function to saving PDFs --- NAPS2.Core/ImportExport/Pdf/PdfSettings.cs | 2 + .../ImportExport/Pdf/SavePdfOperation.cs | 7 + NAPS2.Core/WinForms/FPdfSettings.Designer.cs | 10 + NAPS2.Core/WinForms/FPdfSettings.cs | 7 + NAPS2.Core/WinForms/FPdfSettings.resx | 347 +++++++++++++++--- 5 files changed, 315 insertions(+), 58 deletions(-) diff --git a/NAPS2.Core/ImportExport/Pdf/PdfSettings.cs b/NAPS2.Core/ImportExport/Pdf/PdfSettings.cs index 9c3e7f7e10..bf86069e79 100644 --- a/NAPS2.Core/ImportExport/Pdf/PdfSettings.cs +++ b/NAPS2.Core/ImportExport/Pdf/PdfSettings.cs @@ -21,6 +21,8 @@ public PdfSettings() public bool SinglePagePdf { get; set; } + public bool ShowFolder { get; set; } + public PdfMetadata Metadata { get => metadata; diff --git a/NAPS2.Core/ImportExport/Pdf/SavePdfOperation.cs b/NAPS2.Core/ImportExport/Pdf/SavePdfOperation.cs index df87e38c5e..ecc31ac58f 100644 --- a/NAPS2.Core/ImportExport/Pdf/SavePdfOperation.cs +++ b/NAPS2.Core/ImportExport/Pdf/SavePdfOperation.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -172,6 +173,12 @@ public bool Start(string fileName, DateTime dateTime, ICollection Pages = snapshots.Count, FileFormat = ".pdf" }); + + if (pdfSettings.ShowFolder) + { + String filePath = Path.GetDirectoryName(fileName); + Process.Start("explorer.exe", filePath); + } } } }, TaskContinuationOptions.OnlyOnRanToCompletion); diff --git a/NAPS2.Core/WinForms/FPdfSettings.Designer.cs b/NAPS2.Core/WinForms/FPdfSettings.Designer.cs index a55235d369..c4c74a9d21 100644 --- a/NAPS2.Core/WinForms/FPdfSettings.Designer.cs +++ b/NAPS2.Core/WinForms/FPdfSettings.Designer.cs @@ -65,6 +65,7 @@ private void InitializeComponent() this.groupCompat = new System.Windows.Forms.GroupBox(); this.cmbCompat = new System.Windows.Forms.ComboBox(); this.cbSinglePagePdf = new System.Windows.Forms.CheckBox(); + this.cbShowFolder = new System.Windows.Forms.CheckBox(); this.groupMetadata.SuspendLayout(); this.groupProtection.SuspendLayout(); this.groupCompat.SuspendLayout(); @@ -277,10 +278,18 @@ private void InitializeComponent() this.cbSinglePagePdf.Name = "cbSinglePagePdf"; this.cbSinglePagePdf.UseVisualStyleBackColor = true; // + // cbShowFolder + // + resources.ApplyResources(this.cbShowFolder, "cbShowFolder"); + this.cbShowFolder.Name = "cbShowFolder"; + this.cbShowFolder.UseVisualStyleBackColor = true; + this.cbShowFolder.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); + // // FPdfSettings // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.cbShowFolder); this.Controls.Add(this.cbSinglePagePdf); this.Controls.Add(this.groupCompat); this.Controls.Add(this.cbSkipSavePrompt); @@ -340,5 +349,6 @@ private void InitializeComponent() private System.Windows.Forms.GroupBox groupCompat; private System.Windows.Forms.ComboBox cmbCompat; private System.Windows.Forms.CheckBox cbSinglePagePdf; + private System.Windows.Forms.CheckBox cbShowFolder; } } diff --git a/NAPS2.Core/WinForms/FPdfSettings.cs b/NAPS2.Core/WinForms/FPdfSettings.cs index 0d68833384..7e8dc3a3d1 100644 --- a/NAPS2.Core/WinForms/FPdfSettings.cs +++ b/NAPS2.Core/WinForms/FPdfSettings.cs @@ -46,6 +46,7 @@ private void UpdateValues(PdfSettings pdfSettings) txtDefaultFilePath.Text = pdfSettings.DefaultFileName; cbSkipSavePrompt.Checked = pdfSettings.SkipSavePrompt; cbSinglePagePdf.Checked = pdfSettings.SinglePagePdf; + cbShowFolder.Checked = pdfSettings.ShowFolder; txtTitle.Text = pdfSettings.Metadata.Title; txtAuthor.Text = pdfSettings.Metadata.Author; txtSubject.Text = pdfSettings.Metadata.Subject; @@ -84,6 +85,7 @@ private void btnOK_Click(object sender, EventArgs e) DefaultFileName = txtDefaultFilePath.Text, SkipSavePrompt = cbSkipSavePrompt.Checked, SinglePagePdf = cbSinglePagePdf.Checked, + ShowFolder = cbShowFolder.Checked, Metadata = { Title = txtTitle.Text, @@ -164,5 +166,10 @@ private void btnChooseFolder_Click(object sender, EventArgs e) txtDefaultFilePath.Text = savePath; } } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + + } } } diff --git a/NAPS2.Core/WinForms/FPdfSettings.resx b/NAPS2.Core/WinForms/FPdfSettings.resx index 7a9ae5caf6..63845005f7 100644 --- a/NAPS2.Core/WinForms/FPdfSettings.resx +++ b/NAPS2.Core/WinForms/FPdfSettings.resx @@ -145,7 +145,7 @@ $this - 12 + 13 NoControl @@ -172,11 +172,131 @@ $this - 11 + 12 17, 17 + + txtKeywords + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 0 + + + label6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 1 + + + txtSubject + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 2 + + + label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 3 + + + txtAuthor + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 4 + + + label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 5 + + + txtTitle + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 6 + + + label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupMetadata + + + 7 + + + 12, 114 + + + 408, 175 + + + 20 + + + Metadata + + + groupMetadata + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 11 + 6, 149 @@ -381,28 +501,124 @@ 7 - - 12, 114 + + clbPerms - - 408, 175 + + System.Windows.Forms.CheckedListBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 20 + + groupProtection - - Metadata + + 0 - - groupMetadata + + cbShowUserPassword - + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 1 + + + cbShowOwnerPassword + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 2 + + + txtUserPassword + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 3 + + + lblUserPassword + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 4 + + + txtOwnerPassword + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 5 + + + lblOwnerPassword + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 6 + + + cbEncryptPdf + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupProtection + + + 7 + + + 12, 295 + + + 408, 250 + + + 21 + + + Encryption + + + groupProtection + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - + 10 @@ -633,30 +849,6 @@ 7 - - 12, 295 - - - 408, 250 - - - 21 - - - Encryption - - - groupProtection - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 9 - True @@ -682,7 +874,7 @@ $this - 8 + 9 True @@ -709,7 +901,7 @@ $this - 7 + 8 True @@ -739,7 +931,7 @@ $this - 4 + 5 12, 25 @@ -760,7 +952,7 @@ $this - 5 + 6 True @@ -790,7 +982,7 @@ $this - 6 + 7 NoControl @@ -817,7 +1009,7 @@ $this - 3 + 4 True @@ -844,16 +1036,7 @@ $this - 2 - - - 6, 19 - - - 217, 21 - - - 0 + 3 cmbCompat @@ -889,7 +1072,28 @@ $this - 1 + 2 + + + 6, 19 + + + 217, 21 + + + 0 + + + cmbCompat + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + groupCompat + + + 0 True @@ -919,6 +1123,33 @@ $this + 1 + + + True + + + 155, 68 + + + 151, 17 + + + 37 + + + Show folder on completion + + + cbShowFolder + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 0 @@ -967,12 +1198,12 @@ ilProfileIcons - NAPS2.WinForms.ILProfileIcons, NAPS2.Core, Version=6.0.4.18241, Culture=neutral, PublicKeyToken=null + NAPS2.WinForms.ILProfileIcons, NAPS2.Core, Version=6.1.2.28642, Culture=neutral, PublicKeyToken=null FPdfSettings - NAPS2.WinForms.FormBase, NAPS2.Core, Version=6.0.4.18241, Culture=neutral, PublicKeyToken=null + NAPS2.WinForms.FormBase, NAPS2.Core, Version=6.1.2.28642, Culture=neutral, PublicKeyToken=null \ No newline at end of file