-
Notifications
You must be signed in to change notification settings - Fork 0
/
AboutBoxForm.cs
97 lines (91 loc) · 5.45 KB
/
AboutBoxForm.cs
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
using System.Globalization;
namespace DisksizeWatcher
{
partial class AboutBoxForm : Form
{
/// <summary>
/// Culture info
/// </summary>
private static readonly CultureInfo culture = CultureInfo.CurrentUICulture;
/// <summary>
/// Set a specific text to the status bar
/// </summary>
/// <param name="text">text with some information</param>
private void SetStatusbarText(string text)
{
labelInformation.Enabled = !string.IsNullOrEmpty(value: text);
labelInformation.Text = text;
}
/// <summary>
/// Constructor
/// </summary>
public AboutBoxForm()
{
InitializeComponent();
Text = string.Format(provider: culture, format: "Info about {0}", args: AssemblyInfo.AssemblyTitle);
labelProductName.Text = AssemblyInfo.AssemblyProduct;
labelVersion.Text = AssemblyInfo.AssemblyVersion;
labelCompanyName.Text = AssemblyInfo.AssemblyCompany;
labelCopyright.Text = AssemblyInfo.AssemblyCopyright;
textBoxDescription.Text = AssemblyInfo.AssemblyDescription;
}
/// <summary>
/// Load the form
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="e"/> and <paramref name="sender"/> are not needed, but must be indicated.</remarks>
private void AboutBoxForm_Load(object sender, EventArgs e) => SetStatusbarText(text: string.Empty);
/// <summary>
/// Detect the accessibility description to set as information text in the status bar
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameter <paramref name="e"/> is not needed, but must be indicated.</remarks>
private void SetStatusbar_Enter(object sender, EventArgs e)
{
switch (sender)
{
case TextBox textBox: SetStatusbarText(text: textBox.AccessibleDescription); break;
case Button button: SetStatusbarText(text: button.AccessibleDescription); break;
case RadioButton radioButton: SetStatusbarText(text: radioButton.AccessibleDescription); break;
case CheckBox checkBox: SetStatusbarText(text: checkBox.AccessibleDescription); break;
case DateTimePicker dateTimePicker: SetStatusbarText(text: dateTimePicker.AccessibleDescription); break;
case Label label: SetStatusbarText(text: label.AccessibleDescription); break;
case PictureBox pictureBox: SetStatusbarText(text: pictureBox.AccessibleDescription); break;
case CheckedListBox checkedListBox: SetStatusbarText(text: checkedListBox.AccessibleDescription); break;
case ComboBox box: SetStatusbarText(text: box.AccessibleDescription); break;
case DataGridView view: SetStatusbarText(text: view.AccessibleDescription); break;
case GroupBox group: SetStatusbarText(text: group.AccessibleDescription); break;
case ListBox box: SetStatusbarText(text: box.AccessibleDescription); break;
case ListView view: SetStatusbarText(text: view.AccessibleDescription); break;
case MaskedTextBox box: SetStatusbarText(text: box.AccessibleDescription); break;
case NumericUpDown numericUpDown: SetStatusbarText(text: numericUpDown.AccessibleDescription); break;
case MonthCalendar monthCalendar: SetStatusbarText(text: monthCalendar.AccessibleDescription); break;
case PropertyGrid propertyGrid: SetStatusbarText(text: propertyGrid.AccessibleDescription); break;
case RichTextBox richTextBox: SetStatusbarText(text: richTextBox.AccessibleDescription); break;
case ScrollBar scrollBar: SetStatusbarText(text: scrollBar.AccessibleDescription); break;
case TrackBar trackBar: SetStatusbarText(text: trackBar.AccessibleDescription); break;
case WebBrowser webBrowser: SetStatusbarText(text: webBrowser.AccessibleDescription); break;
case DomainUpDown domainUpDown: SetStatusbarText(text: domainUpDown.AccessibleDescription); break;
case ToolStripButton toolStripButton: SetStatusbarText(text: toolStripButton.AccessibleDescription); break;
case ToolStripMenuItem toolStripMenuItem: SetStatusbarText(text: toolStripMenuItem.AccessibleDescription); break;
case ToolStripLabel toolStripLabel: SetStatusbarText(text: toolStripLabel.AccessibleDescription); break;
case ToolStripComboBox toolStripComboBox: SetStatusbarText(text: toolStripComboBox.AccessibleDescription); break;
case ToolStripDropDown toolStripDropDown: SetStatusbarText(text: toolStripDropDown.AccessibleDescription); break;
case ToolStripDropDownButton toolStripDropDownButton: SetStatusbarText(text: toolStripDropDownButton.AccessibleDescription); break;
case ToolStripDropDownItem toolStripDropDownItem: SetStatusbarText(text: toolStripDropDownItem.AccessibleDescription); break;
case ToolStripProgressBar progressBar: SetStatusbarText(text: progressBar.AccessibleDescription); break;
case ToolStripSeparator toolStripSeparator: SetStatusbarText(text: toolStripSeparator.AccessibleDescription); break;
case ToolStripTextBox toolStripTextBox: SetStatusbarText(text: toolStripTextBox.AccessibleDescription); break;
}
}
/// <summary>
/// Clear the information text of the status bar
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="e"/> and <paramref name="sender"/> are not needed, but must be indicated.</remarks>
private void ClearStatusbar_Leave(object sender, EventArgs e) => SetStatusbarText(text: string.Empty);
}
}