@@ -15,7 +15,7 @@ namespace YAMDCC.HotkeyHandler;
15
15
16
16
public partial class MainForm : Form
17
17
{
18
- private readonly HotkeyConf Config ;
18
+ private readonly HotkeyConf HotkeyConf ;
19
19
20
20
private readonly List < TextBox > txtHotkeys = [ ] ;
21
21
@@ -42,13 +42,13 @@ public MainForm()
42
42
43
43
try
44
44
{
45
- Config = HotkeyConf . Load ( Paths . HotkeyConf ) ;
45
+ HotkeyConf = HotkeyConf . Load ( Paths . HotkeyConf ) ;
46
46
}
47
47
catch ( Exception ex )
48
48
{
49
49
if ( ex is FileNotFoundException or InvalidOperationException or InvalidConfigException )
50
50
{
51
- Config = new ( ) ;
51
+ HotkeyConf = new ( ) ;
52
52
}
53
53
else
54
54
{
@@ -61,7 +61,7 @@ public MainForm()
61
61
62
62
private void CurrentDomain_ProcessExit ( object sender , EventArgs e )
63
63
{
64
- Config ? . Save ( Paths . HotkeyConf ) ;
64
+ HotkeyConf ? . Save ( Paths . HotkeyConf ) ;
65
65
}
66
66
67
67
protected override void SetVisibleCore ( bool value )
@@ -162,23 +162,31 @@ private void tsiSysStart_Click(object sender, EventArgs e)
162
162
163
163
private void ReloadHotkeys ( )
164
164
{
165
- if ( Config . Hotkeys . Count == 0 )
165
+ if ( HotkeyConf . Hotkeys . Count == 0 )
166
166
{
167
- Config . Hotkeys . Add ( new Hotkey ( ) ) ;
167
+ HotkeyConf . Hotkeys . Add ( new Hotkey ( ) ) ;
168
168
}
169
169
170
170
float scale = AutoScaleDimensions . Width / 96 ;
171
171
tblHotKeys . SuspendLayout ( ) ;
172
172
txtHotkeys . Clear ( ) ;
173
173
tblHotKeys . Controls . Clear ( ) ;
174
174
tblHotKeys . RowStyles . Clear ( ) ;
175
- tblHotKeys . RowCount = Config . Hotkeys . Count + 1 ;
175
+ tblHotKeys . RowCount = HotkeyConf . Hotkeys . Count + 1 ;
176
176
177
- for ( int i = 0 ; i < Config . Hotkeys . Count ; i ++ )
177
+ for ( int i = 0 ; i < HotkeyConf . Hotkeys . Count ; i ++ )
178
178
{
179
- Hotkey hk = Config . Hotkeys [ i ] ;
179
+ Hotkey hk = HotkeyConf . Hotkeys [ i ] ;
180
180
tblHotKeys . RowStyles . Add ( new RowStyle ( ) ) ;
181
181
tblHotKeys . Controls . Add ( ActionComboBox ( i , scale , hk . Action ) , 0 , i ) ;
182
+ tblHotKeys . Controls . Add ( new ComboBox ( )
183
+ {
184
+ Dock = DockStyle . Fill ,
185
+ DropDownStyle = ComboBoxStyle . DropDownList ,
186
+ Enabled = false ,
187
+ Margin = new Padding ( ( int ) ( 2 * scale ) ) ,
188
+ Tag = i ,
189
+ } , 1 , i ) ;
182
190
txtHotkeys . Add ( new TextBox
183
191
{
184
192
ReadOnly = true ,
@@ -190,9 +198,9 @@ private void ReloadHotkeys()
190
198
txtHotkeys [ i ] . Leave += KeyBindLeave ;
191
199
txtHotkeys [ i ] . KeyDown += KeyBindDown ;
192
200
txtHotkeys [ i ] . KeyUp += KeyBindUp ;
193
- tblHotKeys . Controls . Add ( txtHotkeys [ i ] , 1 , i ) ;
194
- tblHotKeys . Controls . Add ( HotkeyButton ( i , false , scale ) , 2 , i ) ;
195
- tblHotKeys . Controls . Add ( HotkeyButton ( i , true , scale ) , 3 , i ) ;
201
+ tblHotKeys . Controls . Add ( txtHotkeys [ i ] , 2 , i ) ;
202
+ tblHotKeys . Controls . Add ( HotkeyButton ( i , false , scale ) , 3 , i ) ;
203
+ tblHotKeys . Controls . Add ( HotkeyButton ( i , true , scale ) , 4 , i ) ;
196
204
}
197
205
tblHotKeys . RowStyles . Add ( new RowStyle ( SizeType . Percent , 100 ) ) ;
198
206
tblHotKeys . ResumeLayout ( ) ;
@@ -202,7 +210,7 @@ private void KeyBindLeave(object sender, EventArgs e)
202
210
{
203
211
if ( BindInProgress )
204
212
{
205
- Config . Hotkeys [ ( int ) ( ( Control ) sender ) . Tag ] = OldHotkey ;
213
+ HotkeyConf . Hotkeys [ ( int ) ( ( Control ) sender ) . Tag ] = OldHotkey ;
206
214
BindInProgress = false ;
207
215
}
208
216
}
@@ -214,8 +222,8 @@ private void KeyBindDown(object sender, KeyEventArgs e)
214
222
215
223
if ( ! BindInProgress )
216
224
{
217
- OldHotkey = Config . Hotkeys [ i ] ;
218
- Config . Hotkeys [ i ] . Modifiers = 0 ;
225
+ OldHotkey = HotkeyConf . Hotkeys [ i ] ;
226
+ HotkeyConf . Hotkeys [ i ] . Modifiers = 0 ;
219
227
BindInProgress = true ;
220
228
tb . Clear ( ) ;
221
229
}
@@ -230,33 +238,33 @@ private void KeyBindDown(object sender, KeyEventArgs e)
230
238
case Keys . LMenu :
231
239
case Keys . RMenu :
232
240
case Keys . Menu :
233
- if ( ( Config . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Alt ) != HotkeyModifiers . Alt )
241
+ if ( ( HotkeyConf . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Alt ) != HotkeyModifiers . Alt )
234
242
{
235
- Config . Hotkeys [ i ] . Modifiers |= HotkeyModifiers . Alt ;
236
- tb . Text = HotkeyText ( Config . Hotkeys [ i ] . Modifiers ) ;
243
+ HotkeyConf . Hotkeys [ i ] . Modifiers |= HotkeyModifiers . Alt ;
244
+ tb . Text = HotkeyText ( HotkeyConf . Hotkeys [ i ] . Modifiers ) ;
237
245
}
238
246
break ;
239
247
case Keys . LControlKey :
240
248
case Keys . RControlKey :
241
249
case Keys . ControlKey :
242
- if ( ( Config . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Ctrl ) != HotkeyModifiers . Ctrl )
250
+ if ( ( HotkeyConf . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Ctrl ) != HotkeyModifiers . Ctrl )
243
251
{
244
- Config . Hotkeys [ i ] . Modifiers |= HotkeyModifiers . Ctrl ;
245
- tb . Text = HotkeyText ( Config . Hotkeys [ i ] . Modifiers ) ;
252
+ HotkeyConf . Hotkeys [ i ] . Modifiers |= HotkeyModifiers . Ctrl ;
253
+ tb . Text = HotkeyText ( HotkeyConf . Hotkeys [ i ] . Modifiers ) ;
246
254
}
247
255
break ;
248
256
case Keys . LShiftKey :
249
257
case Keys . RShiftKey :
250
258
case Keys . ShiftKey :
251
- if ( ( Config . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Shift ) != HotkeyModifiers . Shift )
259
+ if ( ( HotkeyConf . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Shift ) != HotkeyModifiers . Shift )
252
260
{
253
- Config . Hotkeys [ i ] . Modifiers |= HotkeyModifiers . Shift ;
254
- tb . Text = HotkeyText ( Config . Hotkeys [ i ] . Modifiers ) ;
261
+ HotkeyConf . Hotkeys [ i ] . Modifiers |= HotkeyModifiers . Shift ;
262
+ tb . Text = HotkeyText ( HotkeyConf . Hotkeys [ i ] . Modifiers ) ;
255
263
}
256
264
break ;
257
265
default :
258
- tb . Text = HotkeyText ( Config . Hotkeys [ i ] . Modifiers , e . KeyCode ) ;
259
- Config . Hotkeys [ i ] . KeyCode = e . KeyCode ;
266
+ tb . Text = HotkeyText ( HotkeyConf . Hotkeys [ i ] . Modifiers , e . KeyCode ) ;
267
+ HotkeyConf . Hotkeys [ i ] . KeyCode = e . KeyCode ;
260
268
BindInProgress = false ;
261
269
break ;
262
270
}
@@ -277,29 +285,29 @@ private void KeyBindUp(object sender, KeyEventArgs e)
277
285
case Keys . LMenu :
278
286
case Keys . RMenu :
279
287
case Keys . Menu :
280
- if ( ( Config . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Alt ) == HotkeyModifiers . Alt )
288
+ if ( ( HotkeyConf . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Alt ) == HotkeyModifiers . Alt )
281
289
{
282
- Config . Hotkeys [ i ] . Modifiers &= ~ HotkeyModifiers . Alt ;
290
+ HotkeyConf . Hotkeys [ i ] . Modifiers &= ~ HotkeyModifiers . Alt ;
283
291
}
284
292
break ;
285
293
case Keys . LControlKey :
286
294
case Keys . RControlKey :
287
295
case Keys . ControlKey :
288
- if ( ( Config . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Ctrl ) == HotkeyModifiers . Ctrl )
296
+ if ( ( HotkeyConf . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Ctrl ) == HotkeyModifiers . Ctrl )
289
297
{
290
- Config . Hotkeys [ i ] . Modifiers &= ~ HotkeyModifiers . Ctrl ;
298
+ HotkeyConf . Hotkeys [ i ] . Modifiers &= ~ HotkeyModifiers . Ctrl ;
291
299
}
292
300
break ;
293
301
case Keys . LShiftKey :
294
302
case Keys . RShiftKey :
295
303
case Keys . ShiftKey :
296
- if ( ( Config . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Shift ) == HotkeyModifiers . Shift )
304
+ if ( ( HotkeyConf . Hotkeys [ i ] . Modifiers & HotkeyModifiers . Shift ) == HotkeyModifiers . Shift )
297
305
{
298
- Config . Hotkeys [ i ] . Modifiers &= ~ HotkeyModifiers . Shift ;
306
+ HotkeyConf . Hotkeys [ i ] . Modifiers &= ~ HotkeyModifiers . Shift ;
299
307
}
300
308
break ;
301
309
}
302
- tb . Text = HotkeyText ( Config . Hotkeys [ i ] . Modifiers ) ;
310
+ tb . Text = HotkeyText ( HotkeyConf . Hotkeys [ i ] . Modifiers ) ;
303
311
}
304
312
305
313
private ComboBox ActionComboBox ( int tag , float scale , HotkeyAction action )
@@ -319,10 +327,8 @@ private ComboBox ActionComboBox(int tag, float scale, HotkeyAction action)
319
327
"Toggle Win/Fn swap" ,
320
328
"Increase keyboard backlight" ,
321
329
"Decrease keyboard backlight" ,
322
- "Switch to next fan profile" ,
323
- "Switch to Default" ,
324
- "Switch to Silent" ,
325
- "Switch to Performance" ,
330
+ "Switch fan profiles" ,
331
+ "Switch performance modes" ,
326
332
] ) ;
327
333
cbo . SelectedIndex = ( int ) action ;
328
334
cbo . SelectedIndexChanged += new EventHandler ( ActionChanged ) ;
@@ -345,21 +351,21 @@ private Button HotkeyButton(int tag, bool del, float scale)
345
351
private void ActionAdd ( object sender , EventArgs e )
346
352
{
347
353
Button b = ( Button ) sender ;
348
- Config . Hotkeys . Insert ( ( int ) b . Tag + 1 , new Hotkey ( ) ) ;
354
+ HotkeyConf . Hotkeys . Insert ( ( int ) b . Tag + 1 , new Hotkey ( ) ) ;
349
355
ReloadHotkeys ( ) ;
350
356
}
351
357
352
358
private void ActionDel ( object sender , EventArgs e )
353
359
{
354
360
Button b = ( Button ) sender ;
355
- Config . Hotkeys . RemoveAt ( ( int ) b . Tag ) ;
361
+ HotkeyConf . Hotkeys . RemoveAt ( ( int ) b . Tag ) ;
356
362
ReloadHotkeys ( ) ;
357
363
}
358
364
359
365
private void ActionChanged ( object sender , EventArgs e )
360
366
{
361
367
ComboBox cb = ( ComboBox ) sender ;
362
- Config . Hotkeys [ ( int ) cb . Tag ] . Action = ( HotkeyAction ) cb . SelectedIndex ;
368
+ HotkeyConf . Hotkeys [ ( int ) cb . Tag ] . Action = ( HotkeyAction ) cb . SelectedIndex ;
363
369
}
364
370
365
371
private static string HotkeyText ( HotkeyModifiers modifiers , Keys key = Keys . None )
0 commit comments