get filepath form title by default
This commit is contained in:
parent
91c595cc6d
commit
faa9a059bc
@ -1,39 +1,43 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="PdfScribe.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
<system.diagnostics>
|
||||
<trace autoflush="true"/>
|
||||
<sources>
|
||||
<source name="PdfScribe" switchName="PdfScribeAll">
|
||||
<listeners>
|
||||
<add name="textwriterListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="PdfScribe_trace.log" traceOutputOptions="DateTime"/>
|
||||
<remove name="Default"/>
|
||||
<clear/> <!-- Remove the <clear /> element to turn on tracing output -->
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<switches>
|
||||
<add name="PdfScribeAll" value="Verbose"/>
|
||||
</switches>
|
||||
</system.diagnostics>
|
||||
<applicationSettings>
|
||||
<PdfScribe.Properties.Settings>
|
||||
<setting name="OutputFile" serializeAs="String">
|
||||
<value>%UserProfile%\PDFSCRIBE.PDF</value>
|
||||
</setting>
|
||||
<setting name="OpenAfterCreating" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="AskUserForOutputFilename" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</PdfScribe.Properties.Settings>
|
||||
</applicationSettings>
|
||||
<configSections>
|
||||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="PdfScribe.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
<system.diagnostics>
|
||||
<trace autoflush="true"/>
|
||||
<sources>
|
||||
<source name="PdfScribe" switchName="PdfScribeAll">
|
||||
<listeners>
|
||||
<add name="textwriterListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="PdfScribe_trace.log" traceOutputOptions="DateTime"/>
|
||||
<remove name="Default"/>
|
||||
<clear/>
|
||||
<!-- Remove the <clear /> element to turn on tracing output -->
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<switches>
|
||||
<add name="PdfScribeAll" value="Verbose"/>
|
||||
</switches>
|
||||
</system.diagnostics>
|
||||
<applicationSettings>
|
||||
<PdfScribe.Properties.Settings>
|
||||
<setting name="OutputFile" serializeAs="String">
|
||||
<value>%UserProfile%\PDFSCRIBE.PDF</value>
|
||||
</setting>
|
||||
<setting name="OpenAfterCreating" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
<setting name="UsePrintTitleAsOutputFileName" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
<setting name="AskUserForOutputFilename" serializeAs="String">
|
||||
<value>False</value>
|
||||
</setting>
|
||||
</PdfScribe.Properties.Settings>
|
||||
</applicationSettings>
|
||||
</configuration>
|
||||
|
@ -59,6 +59,7 @@ namespace PdfScribe
|
||||
}
|
||||
}
|
||||
|
||||
GetPathFormTitle(ref outputFilename, standardInputFilename);
|
||||
if (GetPdfOutputFilename(ref outputFilename))
|
||||
{
|
||||
// Remove the existing PDF file if present
|
||||
@ -170,6 +171,7 @@ namespace PdfScribe
|
||||
pdfFilenameDialog.ShowHelp = false;
|
||||
pdfFilenameDialog.Title = "PDF Scribe - Set output filename";
|
||||
pdfFilenameDialog.ValidateNames = true;
|
||||
pdfFilenameDialog.FileName = outputFile;
|
||||
if (pdfFilenameDialog.ShowDialog(dialogOwner) == DialogResult.OK)
|
||||
{
|
||||
outputFile = pdfFilenameDialog.FileName;
|
||||
@ -182,7 +184,7 @@ namespace PdfScribe
|
||||
default:
|
||||
try
|
||||
{
|
||||
outputFile = GetOutputFilename();
|
||||
outputFile = Properties.Settings.Default.UsePrintTitleAsOutputFileName && string.IsNullOrEmpty(outputFile) ? GetOutputFilename() : outputFile;
|
||||
// Test if we can write to the destination
|
||||
using (FileStream newOutputFile = File.Create(outputFile))
|
||||
{ }
|
||||
@ -227,6 +229,25 @@ namespace PdfScribe
|
||||
|
||||
}
|
||||
|
||||
private static void GetPathFormTitle(ref String outputFilename,
|
||||
String standardInputFilename)
|
||||
{
|
||||
const String titlePrefix = "%%Title: ";
|
||||
using (var fs = new FileStream(standardInputFilename, FileMode.Open, FileAccess.Read))
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
string line = String.Empty;
|
||||
while ((line = sr.ReadLine()) != null)
|
||||
{
|
||||
if (line.StartsWith(titlePrefix))
|
||||
{
|
||||
outputFilename = line.Substring(titlePrefix.Length);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String GetOutputFilename()
|
||||
{
|
||||
String outputFilename = Path.GetFullPath(Environment.ExpandEnvironmentVariables(Properties.Settings.Default.OutputFile));
|
||||
|
19
PdfScribe/Properties/Settings.Designer.cs
generated
19
PdfScribe/Properties/Settings.Designer.cs
generated
@ -1,10 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
@ -12,7 +12,7 @@ namespace PdfScribe.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
@ -44,6 +44,15 @@ namespace PdfScribe.Properties {
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool UsePrintTitleAsOutputFileName {
|
||||
get {
|
||||
return ((bool)(this["UsePrintTitleAsOutputFileName"]));
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.ApplicationScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("False")]
|
||||
public bool AskUserForOutputFilename {
|
||||
get {
|
||||
return ((bool)(this["AskUserForOutputFilename"]));
|
||||
|
@ -8,8 +8,11 @@
|
||||
<Setting Name="OpenAfterCreating" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
|
||||
<Setting Name="UsePrintTitleAsOutputFileName" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="AskUserForOutputFilename" Type="System.Boolean" Scope="Application">
|
||||
<Value Profile="(Default)">False</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
Loading…
Reference in New Issue
Block a user