Skip to content

Commit fd9145e

Browse files
authored
Merge pull request #18 from Mijo-Software/mjohne-patch-202506081535
Add files via upload
2 parents 58c708c + 326f14f commit fd9145e

16 files changed

+4440
-869
lines changed

AboutBoxForm.Designer.cs

Lines changed: 42 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AboutBoxForm.cs

Lines changed: 28 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Diagnostics;
2+
using System.Media;
23
using Julian_and_his_dates.Properties;
34
using NLog;
45

@@ -9,7 +10,7 @@ namespace Julian_and_his_dates
910
/// </summary>
1011
[DebuggerDisplay(value: $"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
1112

12-
internal partial class AboutBoxForm : Form
13+
internal sealed partial class AboutBoxForm : Form
1314
{
1415
/// <summary>
1516
/// Logger instance for logging messages and exceptions.
@@ -19,12 +20,12 @@ internal partial class AboutBoxForm : Form
1920
/// <summary>
2021
/// The color used for white font.
2122
/// </summary>
22-
private readonly Color colorWhiteFont = Color.WhiteSmoke;
23+
private readonly Color _colorWhiteFont = Color.WhiteSmoke;
2324

2425
/// <summary>
2526
/// The color used for the dark background.
2627
/// </summary>
27-
private readonly Color colorDarkBackground = Color.FromArgb(red: 29, green: 32, blue: 41);
28+
private readonly Color _colorDarkBackground = Color.FromArgb(red: 29, green: 32, blue: 41);
2829

2930
/// <summary>
3031
/// Returns a string that represents the current object for debugging purposes.
@@ -36,7 +37,7 @@ internal partial class AboutBoxForm : Form
3637
/// Sets a specific text to the status bar.
3738
/// </summary>
3839
/// <param name="text">The text with some information to display in the status bar.</param>
39-
private void SetStatusbarText(string text)
40+
private void SetStatusBarText(string text)
4041
{
4142
labelInformation.Enabled = !string.IsNullOrWhiteSpace(value: text);
4243
labelInformation.Text = text;
@@ -55,17 +56,17 @@ private static void HandleException(Exception ex, string message, object? sender
5556
Debug.WriteLine(value: msg);
5657
Console.WriteLine(value: msg);
5758
Logger.Error(exception: ex, message: msg);
58-
_ = MessageBox.Show(text: message, caption: "Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
59+
_ = MessageBox.Show(text: message, caption: @"Error", buttons: MessageBoxButtons.OK, icon: MessageBoxIcon.Error);
5960
}
6061

6162
/// <summary>
6263
/// Sets the dark mode
6364
/// </summary>
6465
public void SetDarkMode()
6566
{
66-
statusStrip.BackColor = colorDarkBackground;
67-
labelInformation.BackColor = colorDarkBackground;
68-
labelInformation.ForeColor = colorWhiteFont;
67+
statusStrip.BackColor = _colorDarkBackground;
68+
labelInformation.BackColor = _colorDarkBackground;
69+
labelInformation.ForeColor = _colorWhiteFont;
6970
}
7071

7172
/// <summary>
@@ -76,14 +77,14 @@ public AboutBoxForm()
7677
{
7778
InitializeComponent();
7879
Logger.Info(message: "AboutBoxForm initialized.");
79-
Text = $"Info about {AssemblyInfo.AssemblyTitle}";
80+
Text = $@"Info about {AssemblyInfo.AssemblyTitle}";
8081
labelProductName.Text = AssemblyInfo.AssemblyProduct;
81-
labelVersion.Text = $"Version {AssemblyInfo.AssemblyVersion}";
82+
labelVersion.Text = $@"Version {AssemblyInfo.AssemblyVersion}";
8283
labelCopyright.Text = AssemblyInfo.AssemblyCopyright;
8384
labelCompanyName.Text = AssemblyInfo.AssemblyCompany;
8485
textBoxDescription.Text = AssemblyInfo.AssemblyDescription;
85-
this.KeyDown += new KeyEventHandler(AboutBoxForm_KeyDown);
86-
this.KeyPreview = true; // Ensures the form receives key events before the controls
86+
KeyDown += AboutBoxForm_KeyDown;
87+
KeyPreview = true; // Ensures the form receives key events before the controls
8788
}
8889

8990
/// <summary>
@@ -93,7 +94,7 @@ public AboutBoxForm()
9394
/// <param name="e"></param>
9495
private void LogoPictureBox_Click(object sender, EventArgs e)
9596
{
96-
using System.Media.SoundPlayer sound = new(stream: Resources.wavBleep);
97+
using SoundPlayer sound = new(stream: Resources.wavBleep);
9798
sound.Play();
9899
}
99100

@@ -103,45 +104,26 @@ private void LogoPictureBox_Click(object sender, EventArgs e)
103104
/// </summary>
104105
/// <param name="sender">The source of the event.</param>
105106
/// <param name="e">The <see cref="EventArgs"/> instance that contains the event data.</param>
106-
private void AboutBoxForm_Load(object sender, EventArgs e) => SetStatusbarText(text: string.Empty);
107+
private void AboutBoxForm_Load(object sender, EventArgs e) => SetStatusBarText(text: string.Empty);
107108

108109
/// <summary>
109110
/// Detect the accessibility description to set as information text in the status bar
110111
/// </summary>
111112
/// <param name="sender">The event source</param>
112113
/// <param name="e">The <see cref="EventArgs"/> instance that contains the event data</param>
113-
private void SetStatusbar_Enter(object sender, EventArgs e)
114+
private void SetStatusBar_Enter(object sender, EventArgs e)
114115
{
115-
try
116+
// Set the status bar text based on the sender's accessible description
117+
switch (sender)
116118
{
117-
if (sender is Control { AccessibleDescription: { } } control)
118-
{
119-
SetStatusbarText(text: control.AccessibleDescription);
120-
}
121-
else if (sender is ToolStripMenuItem { AccessibleDescription: { } } control2)
122-
{
123-
SetStatusbarText(text: control2.AccessibleDescription);
124-
}
125-
else if (sender is ToolStripStatusLabel { AccessibleDescription: { } } control3)
126-
{
127-
SetStatusbarText(text: control3.AccessibleDescription);
128-
}
129-
else if (sender is ToolStripButton { AccessibleDescription: { } } control4)
130-
{
131-
SetStatusbarText(text: control4.AccessibleDescription);
132-
}
133-
else if (sender is ToolStripDropDownButton { AccessibleDescription: { } } control5)
134-
{
135-
SetStatusbarText(text: control5.AccessibleDescription);
136-
}
137-
else if (sender is ToolStripSplitButton { AccessibleDescription: { } } control6)
138-
{
139-
SetStatusbarText(text: control6.AccessibleDescription);
140-
}
141-
}
142-
catch (Exception ex)
143-
{
144-
HandleException(ex: ex, message: "An error occurred while setting the status bar text.", sender: sender, e: e);
119+
// If the sender is a control with an accessible description, set the status bar text
120+
// If the sender is a ToolStripItem with an accessible description, set the status bar text
121+
case Control { AccessibleDescription: not null } control:
122+
SetStatusBarText(text: control.AccessibleDescription);
123+
break;
124+
case ToolStripItem { AccessibleDescription: not null } item:
125+
SetStatusBarText(text: item.AccessibleDescription);
126+
break;
145127
}
146128
}
147129

@@ -150,7 +132,7 @@ private void SetStatusbar_Enter(object sender, EventArgs e)
150132
/// </summary>
151133
/// <param name="sender">The source of the event.</param>
152134
/// <param name="e">The <see cref="EventArgs"/> instance that contains the event data.</param>
153-
private void ClearStatusbar_Leave(object sender, EventArgs e) => SetStatusbarText(text: string.Empty);
135+
private void ClearStatusBar_Leave(object sender, EventArgs e) => SetStatusBarText(text: string.Empty);
154136

155137
/// <summary>
156138
/// Handles the KeyDown event of the ExportDataSheetForm.
@@ -162,7 +144,7 @@ private void AboutBoxForm_KeyDown(object? sender, KeyEventArgs e)
162144
{
163145
if (e.KeyCode == Keys.Escape)
164146
{
165-
this.Close();
147+
Close();
166148
}
167149
}
168150
}

Julian and his dates.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<StartupObject>Julian_and_his_dates.Program</StartupObject>
1414
<SignAssembly>True</SignAssembly>
1515
<Title>Julian and his dates</Title>
16-
<Version>1.3.1.7</Version>
16+
<Version>1.3.2.8</Version>
1717
<Company>Mijo Software</Company>
1818
<Copyright>Copyright © 2017-2025</Copyright>
1919
<Description>Calculates various versions of the Julian date.</Description>
@@ -90,7 +90,7 @@
9090
</ItemGroup>
9191

9292
<ItemGroup>
93-
<PackageReference Include="NLog" Version="5.4.0" />
93+
<PackageReference Include="NLog" Version="5.5.0" />
9494
</ItemGroup>
9595

9696
<ItemGroup>

Julian and his dates.csproj.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Compile Update="AboutBoxForm.cs">
88
<SubType>Form</SubType>
99
</Compile>
10-
<Compile Update="JulianandhisdatesForm.cs">
10+
<Compile Update="MainForm.cs">
1111
<SubType>Form</SubType>
1212
</Compile>
1313
<Compile Update="JulianDateCalculatorForm.cs">

0 commit comments

Comments
 (0)