The date format is now selectable.
Added the form controls and AppSettings keys to allow the user to select the format of the date appended to the output file. Further update to issue #1.
This commit is contained in:
+39
-7
@@ -21,12 +21,24 @@ namespace PDF_Merge
|
||||
string outputPath = ConfigurationManager.AppSettings["PDF-Output"];
|
||||
string outputName = ConfigurationManager.AppSettings["PDF-Name"];
|
||||
string outputExt = ConfigurationManager.AppSettings["PDF-Extension"];
|
||||
string dateIndex = ConfigurationManager.AppSettings["dateIndex"];
|
||||
|
||||
int dateIndexValue;
|
||||
|
||||
bool indexSet = int.TryParse(dateIndex, out dateIndexValue);
|
||||
if (indexSet)
|
||||
{
|
||||
dateFormatOpts.SelectedIndex = dateIndexValue;
|
||||
} else
|
||||
{
|
||||
dateFormatOpts.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
sourceBox.Text = sourcePath;
|
||||
outputBox.Text = outputPath;
|
||||
FileNameBox.Text = outputName;
|
||||
fileExtlabel.Text = outputExt;
|
||||
|
||||
|
||||
if (ConfigurationManager.AppSettings["overwrite"] == true.ToString())
|
||||
{
|
||||
overrideCBox.Checked = true;
|
||||
@@ -35,21 +47,23 @@ namespace PDF_Merge
|
||||
{
|
||||
overrideCBox.Checked = false;
|
||||
}
|
||||
if (ConfigurationManager.AppSettings["appendDate"] == true.ToString() )
|
||||
if (ConfigurationManager.AppSettings["appendDate"] == true.ToString())
|
||||
{
|
||||
appendDatecheckBox.Checked = true;
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
appendDatecheckBox.Checked = false;
|
||||
}
|
||||
CheckAppend();
|
||||
}
|
||||
|
||||
private void cancelBtn_Click(object sender, EventArgs e)
|
||||
private void CancelBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
private void SaveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
||||
AppSettingsSection appSettings = appConfig.AppSettings;
|
||||
@@ -79,12 +93,14 @@ namespace PDF_Merge
|
||||
}
|
||||
appSettings.Settings["overwrite"].Value = overrideCBox.Checked.ToString();
|
||||
appSettings.Settings["appendDate"].Value = appendDatecheckBox.Checked.ToString();
|
||||
appSettings.Settings["dateFormat"].Value = dateFormatOpts.SelectedItem.ToString();
|
||||
appSettings.Settings["dateIndex"].Value = dateFormatOpts.SelectedIndex.ToString();
|
||||
appConfig.Save(ConfigurationSaveMode.Modified);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void sourceDirBtn_Click(object sender, EventArgs e)
|
||||
private void SourceDirBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var SourceDirPicker = new FolderBrowserDialog())
|
||||
{
|
||||
@@ -105,7 +121,7 @@ namespace PDF_Merge
|
||||
}
|
||||
}
|
||||
|
||||
private void outPathBtn_Click(object sender, EventArgs e)
|
||||
private void OutPathBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var OutPathPicker = new FolderBrowserDialog())
|
||||
{
|
||||
@@ -117,5 +133,21 @@ namespace PDF_Merge
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendDatecheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckAppend();
|
||||
}
|
||||
private void CheckAppend()
|
||||
{
|
||||
if (appendDatecheckBox.Checked)
|
||||
{
|
||||
dateFormatOpts.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dateFormatOpts.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user