From f85361ed27607454fef4ac0d05402596abd46abe Mon Sep 17 00:00:00 2001 From: efrick Date: Mon, 5 Aug 2024 14:06:17 -0400 Subject: [PATCH] Add FolderPicker to source selection in config menu. --- ConfForm.Designer.cs | 1 + ConfForm.cs | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ConfForm.Designer.cs b/ConfForm.Designer.cs index ccd382b..d837486 100644 --- a/ConfForm.Designer.cs +++ b/ConfForm.Designer.cs @@ -114,6 +114,7 @@ namespace PDF_Merge sourceDirBtn.TabIndex = 7; sourceDirBtn.Text = "..."; sourceDirBtn.UseVisualStyleBackColor = true; + sourceDirBtn.Click += sourceDirBtn_Click; // // outPathBtn // diff --git a/ConfForm.cs b/ConfForm.cs index 652f423..b4729f0 100644 --- a/ConfForm.cs +++ b/ConfForm.cs @@ -44,14 +44,16 @@ namespace PDF_Merge if (sourceBox.Text.Length > 0) { appSettings.Settings["PDF-Path"].Value = sourceBox.Text; - } else + } + else { MessageBox.Show("Source path cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (outputBox.Text.Length > 0) { appSettings.Settings["PDF-Output"].Value = outputBox.Text; - } else + } + else { MessageBox.Show("Output path cannot be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } @@ -60,5 +62,17 @@ namespace PDF_Merge ConfigurationManager.RefreshSection("appSettings"); this.Close(); } + + private void sourceDirBtn_Click(object sender, EventArgs e) + { + using (var SourceDirPicker = new FolderBrowserDialog()) + { + if(SourceDirPicker.ShowDialog() == DialogResult.OK) + { + var sourceDir = SourceDirPicker.SelectedPath; + sourceBox.Text = sourceDir; + } + } + } } }