-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGilatharForm.cs
More file actions
103 lines (88 loc) · 3.05 KB
/
Copy pathGilatharForm.cs
File metadata and controls
103 lines (88 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
namespace Narthalas
{
public partial class GilatharForm : Form
{
public GilatharForm()
{
InitializeComponent();
}
#region Helpers
/// <summary>
/// Sets the status bar text.
/// </summary>
/// <param name="text">The main text to be displayed on the status bar.</param>
/// <param name="additionalInfo">Additional information to be displayed alongside the main text.</param>
private void SetStatusBar(string text, string additionalInfo = "")
{
// Check if the text is not null or whitespace
if (string.IsNullOrWhiteSpace(value: text))
{
return;
}
// Set the status bar text and enable it
toolStripStatusLabelInfo.Enabled = true;
toolStripStatusLabelInfo.Text = string.IsNullOrWhiteSpace(value: additionalInfo) ? text : $"{text} - {additionalInfo}";
}
/// <summary>
/// Clears the status bar text.
/// </summary>
private void ClearStatusBar()
{
// Clear the status bar text and disable it
toolStripStatusLabelInfo.Enabled = false;
toolStripStatusLabelInfo.Text = string.Empty;
}
#endregion
#region Enter event handlers
/// <summary>
/// Called when the mouse pointer moves over a control.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The <see cref="EventArgs"/> instance that contains the event data.</param>
private void SetStatusBar_Enter(object sender, EventArgs e)
{
// Set the status bar text based on the sender's accessible description
switch (sender)
{
// If the sender is a control with an accessible description, set the status bar text
// If the sender is a ToolStripItem with an accessible description, set the status bar text
case Control { AccessibleDescription: not null } control:
SetStatusBar(text: control.AccessibleDescription);
break;
case ToolStripItem { AccessibleDescription: not null } item:
SetStatusBar(text: item.AccessibleDescription);
break;
}
}
#endregion
#region Leave event handler
/// <summary>
/// Called when the mouse pointer leaves a control.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The <see cref="EventArgs"/> instance that contains the event data.</param>
private void ClearStatusBar_Leave(object sender, EventArgs e) => ClearStatusBar();
#endregion
#region KeyDown event handlers
/// <summary>
/// Handles the KeyDown event of the GilatharForm.
/// Closes the form when the Escape key is pressed.
/// </summary>
/// <param name="sender">The event source.</param>
/// <param name="e">The <see cref="EventArgs"/> instance that contains the event data.</param>
private void Gilathar_KeyDown(object? sender, KeyEventArgs e)
{
// Check if the sender is null
ArgumentNullException.ThrowIfNull(argument: sender);
// Check if the Escape key is pressed
if (e.KeyCode == Keys.Escape)
{
// Close the form
Close();
}
}
#endregion
#region Click event handlers
#endregion
}
}