Added "OpenAfterCreating" app setting

This commit is contained in:
S T Chan 2018-10-08 22:20:15 -04:00
parent faf775a12c
commit 5f96177f74
5 changed files with 142 additions and 110 deletions

View File

@ -29,12 +29,15 @@
</system.diagnostics> </system.diagnostics>
<applicationSettings> <applicationSettings>
<PdfScribe.Properties.Settings> <PdfScribe.Properties.Settings>
<setting name="OutputFile" serializeAs="String"> <setting name="OutputFile" serializeAs="String">
<value>%UserProfile%\PDFSCRIBE.PDF</value> <value>%UserProfile%\PDFSCRIBE.PDF</value>
</setting> </setting>
<setting name="AskUserForOutputFilename" serializeAs="String"> <setting name="AskUserForOutputFilename" serializeAs="String">
<value>True</value> <value>False</value>
</setting> </setting>
<setting name="OpenAfterCreating" serializeAs="String">
<value>False</value>
</setting>
</PdfScribe.Properties.Settings> </PdfScribe.Properties.Settings>
</applicationSettings> </applicationSettings>
</configuration> </configuration>

View File

@ -69,6 +69,7 @@ namespace PdfScribe
String.Format("-sOutputFile={0}", outputFilename), standardInputFilename }; String.Format("-sOutputFile={0}", outputFilename), standardInputFilename };
GhostScript64.CallAPI(ghostScriptArguments); GhostScript64.CallAPI(ghostScriptArguments);
DisplayPdf(outputFilename);
} }
} }
catch (IOException ioEx) catch (IOException ioEx)
@ -241,6 +242,22 @@ namespace PdfScribe
return pathIsValid; return pathIsValid;
} }
/// <summary>
/// Opens the PDF in the default viewer
/// if the OpenAfterCreating app setting is "True"
/// and the file extension is .PDF
/// </summary>
/// <param name="pdfFilename"></param>
static void DisplayPdf(String pdfFilename)
{
if (Properties.Settings.Default.OpenAfterCreating &&
!String.IsNullOrEmpty(Path.GetExtension(pdfFilename)) &&
(Path.GetExtension(pdfFilename).ToUpper() == ".PDF"))
{
Process.Start(pdfFilename);
}
}
/// <summary> /// <summary>
/// Displays up a topmost, OK-only message box for the error message /// Displays up a topmost, OK-only message box for the error message
/// </summary> /// </summary>

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34003 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -12,7 +12,7 @@ namespace PdfScribe.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.7.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -25,7 +25,7 @@ namespace PdfScribe.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("%Temp%\\PDFSCRIBE.PDF")] [global::System.Configuration.DefaultSettingValueAttribute("%UserProfile%\\PDFSCRIBE.PDF")]
public string OutputFile { public string OutputFile {
get { get {
return ((string)(this["OutputFile"])); return ((string)(this["OutputFile"]));
@ -40,5 +40,14 @@ namespace PdfScribe.Properties {
return ((bool)(this["AskUserForOutputFilename"])); return ((bool)(this["AskUserForOutputFilename"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool OpenAfterCreating {
get {
return ((bool)(this["OpenAfterCreating"]));
}
}
} }
} }

View File

@ -3,10 +3,13 @@
<Profiles /> <Profiles />
<Settings> <Settings>
<Setting Name="OutputFile" Type="System.String" Scope="Application"> <Setting Name="OutputFile" Type="System.String" Scope="Application">
<Value Profile="(Default)">%Temp%\PDFSCRIBE.PDF</Value> <Value Profile="(Default)">%UserProfile%\PDFSCRIBE.PDF</Value>
</Setting> </Setting>
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application"> <Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value> <Value Profile="(Default)">False</Value>
</Setting> </Setting>
<Setting Name="OpenAfterCreating" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -1,4 +1,4 @@
# PdfScribe v1.0.5 # PdfScribe v1.0.6
PdfScribe is a PDF virtual printer. Check the [releases](https://github.com/stchan/PdfScribe/releases) page for this project to download a prebuilt MSI package. PdfScribe is a PDF virtual printer. Check the [releases](https://github.com/stchan/PdfScribe/releases) page for this project to download a prebuilt MSI package.
@ -9,7 +9,7 @@ PdfScribe is a PDF virtual printer. Check the [releases](https://github.com/stch
## Building from source ## Building from source
Visual Studio 2015, Wix 3.11, and Votive 2015 are required to build PdfScribe. Visual Studio 2017, Wix 3.11, and Votive 2017 are required to build PdfScribe.
PdfScribe links to, and distributes the following third party components: PdfScribe links to, and distributes the following third party components:
@ -19,7 +19,7 @@ PdfScribe links to, and distributes the following third party components:
## License ## License
Redmon is distributed under the GPL v3. Ghostscript is AGPL (more restrictive than GPLv3), so PdfScribe is bound by that license. Ghostscript is AGPL (more restrictive than GPLv3), so PdfScribe is bound by that license.
@ -29,7 +29,7 @@ In the application config file (PdfScribe.exe.config), there are two settings in
* ****AskUserForOutputFilename**** - set value to *true* if you want PdfScribe to ask the user where to save the PDF. * ****AskUserForOutputFilename**** - set value to *true* if you want PdfScribe to ask the user where to save the PDF.
* ****OutputFile**** - if there is a constant filename you want the PDF to be saved to, set its value here. Environment variables can be used. PdfScribe will overwrite each time. This setting is ignored if **AskUserForOutputFilename** is set to *true*. * ****OutputFile**** - if there is a constant filename you want the PDF to be saved to, set its value here. Environment variables can be used. PdfScribe will overwrite each time. This setting is ignored if **AskUserForOutputFilename** is set to *true*.
* ****OpenAfterCreating**** - set value to *true* if you want the PDF automatically opened with the default viewer. This setting is ignored if the file extension is not .PDF
## To do ## To do