-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOptionsForm.cs
208 lines (190 loc) · 7.99 KB
/
OptionsForm.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
using System;
using System.Windows.Forms;
using Hipparcos_DB.Properties;
namespace Hipparcos_DB
{
/// <summary>
/// OptionsForm
/// </summary>
public partial class OptionsForm : Form
{
/// <summary>
/// Settings
/// </summary>
private readonly Settings settings = new Settings();
/// <summary>
/// Constructor
/// </summary>
public OptionsForm()
{
InitializeComponent();
checkBoxEnableHoverEffect.Checked = settings.UserEnableHoverEffect;
checkBoxEnableQuickDownload.Checked = settings.UserEnableQuickDownload;
checkBoxEnableDoubleClickCopy.Checked = settings.UserEnableCopyMethod;
comboBoxDataTableStyle.SelectedIndex = settings.UserDataTableStyle;
comboBoxStartPosition.SelectedIndex = settings.UserStartPosition;
textBoxHost.Text = settings.UserHostName;
textBoxHipparcosDirectory.Text = settings.UserHipparcosCatalogDirectory;
textBoxTychoDirectory.Text = settings.UserTychoCatalogDirectory;
switch (settings.UserStartPosition)
{
case 0: StartPosition = FormStartPosition.CenterParent; break;
case 1: StartPosition = FormStartPosition.CenterScreen; break;
default: StartPosition = FormStartPosition.CenterParent; break;
}
}
/// <summary>
/// Set the information text in the status bar
/// </summary>
/// <param name="text">text to show</param>
private void SetStatusbar(string text)
{
toolStripStatusLabelInfo.Text = text;
}
/// <summary>
/// Clear the information text in the status bar
/// </summary>
private void ClearStatusbar() => toolStripStatusLabelInfo.Text = string.Empty;
/// <summary>
/// Load the window
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void OptionsForm_Load(object sender, EventArgs e) => ClearStatusbar();
#region Enter event handlers
/// <summary>
/// Set the information text in the status bar while entering a control
/// </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)
{
if (sender is Control control)
{
SetStatusbar(text: control.AccessibleDescription);
}
else if (sender is ToolStripButton toolStripButton)
{
SetStatusbar(text: toolStripButton.AccessibleDescription);
}
else if (sender is ToolStripMenuItem toolStripMenuItem)
{
SetStatusbar(text: toolStripMenuItem.AccessibleDescription);
}
else if (sender is ToolStripLabel toolStripLabel)
{
SetStatusbar(text: toolStripLabel.AccessibleDescription);
}
else if (sender is ToolStripComboBox toolStripComboBox)
{
SetStatusbar(text: toolStripComboBox.AccessibleDescription);
}
else if (sender is ToolStripDropDown toolStripDropDown)
{
SetStatusbar(text: toolStripDropDown.AccessibleDescription);
}
else if (sender is ToolStripDropDownButton toolStripDropDownButton)
{
SetStatusbar(text: toolStripDropDownButton.AccessibleDescription);
}
else if (sender is ToolStripDropDownItem toolStripDropDownItem)
{
SetStatusbar(text: toolStripDropDownItem.AccessibleDescription);
}
else if (sender is ToolStripDropDownMenu toolStripDropDownMenu)
{
SetStatusbar(text: toolStripDropDownMenu.AccessibleDescription);
}
else if (sender is ToolStripProgressBar toolStripProgressBar)
{
SetStatusbar(text: toolStripProgressBar.AccessibleDescription);
}
else if (sender is ToolStripSplitButton toolStripSplitButton)
{
SetStatusbar(text: toolStripSplitButton.AccessibleDescription);
}
else if (sender is ToolStripSeparator toolStripSeparator)
{
SetStatusbar(text: toolStripSeparator.AccessibleDescription);
}
else if (sender is ToolStripStatusLabel toolStripStatusLabel)
{
SetStatusbar(text: toolStripStatusLabel.AccessibleDescription);
}
else if (sender is ToolStripTextBox toolStripTextBox)
{
SetStatusbar(text: toolStripTextBox.AccessibleDescription);
}
}
#endregion
#region Leave event handlers
/// <summary>
/// Clear the information text in the status bar while leaving a control
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void ClearStatusbar_Leave(object sender, EventArgs e) => ClearStatusbar();
#endregion
#region Click event handlers
/// <summary>
/// Apply the settings
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void ButtonApply_Click(object sender, EventArgs e)
{
settings.UserEnableHoverEffect = checkBoxEnableHoverEffect.Checked;
settings.UserEnableCopyMethod = checkBoxEnableDoubleClickCopy.Checked;
settings.UserDataTableStyle = (byte)comboBoxDataTableStyle.SelectedIndex;
settings.UserEnableQuickDownload = checkBoxEnableQuickDownload.Checked;
settings.UserHostName = textBoxHost.Text;
settings.UserHipparcosCatalogDirectory = textBoxHipparcosDirectory.Text;
settings.UserTychoCatalogDirectory = textBoxTychoDirectory.Text;
settings.UserStartPosition = (byte)comboBoxStartPosition.SelectedIndex;
settings.Save();
}
/// <summary>
/// Load the default settings
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void ButtonDefaultSettings_Click(object sender, EventArgs e)
{
checkBoxEnableHoverEffect.Checked = settings.DefaultEnableHoverEffect;
comboBoxStartPosition.SelectedIndex = settings.DefaultStartPosition;
checkBoxEnableDoubleClickCopy.Checked = settings.DefaultEnableCopyMethod;
comboBoxDataTableStyle.SelectedIndex = settings.DefaultDataTableStyle;
checkBoxEnableQuickDownload.Checked = settings.DefaultEnableQuickDownload;
textBoxHost.Text = settings.DefaultHostName;
textBoxHipparcosDirectory.Text = settings.DefaultHipparcosCatalogDirectory;
textBoxTychoDirectory.Text = settings.DefaultTychoCatalogDirectory;
}
/// <summary>
/// Restore the default host
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void ButtonRestoreHost_Click(object sender, EventArgs e) => textBoxHost.Text = settings.DefaultHostName;
/// <summary>
/// Restore the default Hipparcos directory
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void ButtonRestoreHipparcosDirectory_Click(object sender, EventArgs e) => textBoxHipparcosDirectory.Text = settings.DefaultHipparcosCatalogDirectory;
/// <summary>
/// Restore the default Tycho directory
/// </summary>
/// <param name="sender">object sender</param>
/// <param name="e">event arguments</param>
/// <remarks>The parameters <paramref name="sender"/> and <paramref name="e"/> are not needed, but must be indicated.</remarks>
private void ButtonRestoreTychoDirectory_Click(object sender, EventArgs e) => textBoxTychoDirectory.Text = settings.DefaultTychoCatalogDirectory;
#endregion
}
}