-
Notifications
You must be signed in to change notification settings - Fork 0
/
SettingsForm.cs
102 lines (96 loc) · 5.4 KB
/
SettingsForm.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
98
99
100
101
102
namespace DisksizeWatcher
{
/// <summary>
/// Show the setting window of the application
/// </summary>
public partial class SettingsForm : Form
{
/// <summary>
/// Get or set to stay on top
/// </summary>
public bool StayOnTop
{
get => checkBoxStayOnTop.Checked;
set => checkBoxStayOnTop.Checked = value;
}
/// <summary>
/// Get or set to minimize to system tray
/// </summary>
public bool MinimizeToSystemTray
{
get => checkBoxMinimizeToSystemTray.Checked;
set => checkBoxMinimizeToSystemTray.Checked = value;
}
/// <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 SettingsForm() => InitializeComponent();
/// <summary>
/// Load the settings 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 SettingsForm_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);
}
}