Update the PathLable in the main form when configuration changes.

This commit is contained in:
efrick 2024-08-05 13:55:36 -04:00
parent 6d06fa90e5
commit b1368e3c53
2 changed files with 17 additions and 4 deletions

1
MainForm.Designer.cs generated
View File

@ -119,6 +119,7 @@
MainMenuStrip = menuStrip1; MainMenuStrip = menuStrip1;
Name = "MainForm"; Name = "MainForm";
Text = "PDF-Merge"; Text = "PDF-Merge";
Activated += MainForm_Activated;
Load += Form1_Load; Load += Form1_Load;
menuStrip1.ResumeLayout(false); menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout(); menuStrip1.PerformLayout();

View File

@ -7,6 +7,11 @@ namespace PDF_Merge
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
SetPathLable();
}
public void SetPathLable()
{
string sourcePath = ConfigurationManager.AppSettings["PDF-Path"]; string sourcePath = ConfigurationManager.AppSettings["PDF-Path"];
if (sourcePath != null) if (sourcePath != null)
{ {
@ -14,16 +19,19 @@ namespace PDF_Merge
{ {
if (Directory.Exists(sourcePath)) if (Directory.Exists(sourcePath))
{ {
pathLable.Text = pathLable.Text + sourcePath; pathLable.Text = "Path: " + sourcePath;
} else }
else
{ {
pathLable.Text = "The configured path does not exist."; pathLable.Text = "The configured path does not exist.";
} }
} else }
else
{ {
pathLable.Text = "The configured path is blank."; pathLable.Text = "The configured path is blank.";
} }
} else }
else
{ {
pathLable.Text = "No path has been configured."; pathLable.Text = "No path has been configured.";
} }
@ -61,5 +69,9 @@ namespace PDF_Merge
ConfForm ConfForm = new ConfForm(); ConfForm ConfForm = new ConfForm();
ConfForm.Show(); ConfForm.Show();
} }
private void MainForm_Activated(object sender, EventArgs e)
{
SetPathLable();
}
} }
} }