Skip to content

Commit d3954f1

Browse files
Service command changes for Hotkey Handler and more
WARNING: this version of YAMDCC (and Service) are incompatible with previous versions - Add new service commands for temporarily changing fan profile and performance modes - Split "Change to fan profile" options into separate drop-down (will also be used for performance modes) - Fix *slightly* too tall progress bar in progress dialog
1 parent e7d1581 commit d3954f1

File tree

10 files changed

+220
-82
lines changed

10 files changed

+220
-82
lines changed

YAMDCC.Common/Dialogs/ProgressDialog.Designer.cs

+5-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

YAMDCC.Common/Dialogs/ProgressDialog.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<root>
33
<!--
44
Microsoft ResX Schema

YAMDCC.ConfigEditor/MainForm.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ protected override void OnFormClosing(FormClosingEventArgs e)
204204
// Disable Full Blast if it was enabled while the program was running:
205205
if (chkFullBlast.Checked)
206206
{
207-
SendSvcMessage(new ServiceCommand(Command.FullBlast, false));
207+
SendSvcMessage(new ServiceCommand(Command.SetFullBlast, false));
208208
}
209209
}
210210

@@ -237,15 +237,15 @@ private void IPCMessage(object sender, PipeMessageEventArgs<ServiceResponse, Ser
237237
}
238238
switch ((Command)cmd)
239239
{
240-
case Command.ApplyConfig:
240+
case Command.ApplyConf:
241241
ToggleSvcCmds(true);
242242
UpdateStatus(StatusCode.ConfApplied);
243243
if (Config.KeyLightConf is not null)
244244
{
245245
SendSvcMessage(new ServiceCommand(Command.GetKeyLightBright));
246246
}
247247
break;
248-
case Command.FullBlast:
248+
case Command.SetFullBlast:
249249
ToggleSvcCmds(true);
250250
UpdateStatus(StatusCode.FullBlastToggled);
251251
break;
@@ -314,7 +314,7 @@ private void IPCMessage(object sender, PipeMessageEventArgs<ServiceResponse, Ser
314314
}
315315
case Response.FirmVer:
316316
{
317-
// no idea how the EcVer struct became a nested
317+
// no idea how the EcInfo class became a nested
318318
// object array, but this works so keeping it
319319
if (args[0] is object[] obj && obj.Length == 2 &&
320320
obj[0] is string ver && obj[1] is DateTime date)
@@ -997,7 +997,7 @@ private void btnGetModel_Click(object sender, EventArgs e)
997997
private void FullBlastToggle(object sender, EventArgs e)
998998
{
999999
ToggleSvcCmds(false);
1000-
SendSvcMessage(new ServiceCommand(Command.FullBlast, chkFullBlast.Checked));
1000+
SendSvcMessage(new ServiceCommand(Command.SetFullBlast, chkFullBlast.Checked));
10011001
}
10021002

10031003
private void RevertConf(object sender, EventArgs e)
@@ -1038,7 +1038,7 @@ private void ApplyConf(object sender, EventArgs e)
10381038
Config.Save(Paths.CurrentConf);
10391039

10401040
// Tell the service to reload and apply the updated config
1041-
SendSvcMessage(new ServiceCommand(Command.ApplyConfig));
1041+
SendSvcMessage(new ServiceCommand(Command.ApplyConf));
10421042
}
10431043

10441044
private void tmrPoll_Tick(object sender, EventArgs e)

YAMDCC.HotkeyHandler/Config/Hotkey.cs

+1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ public enum HotkeyAction
5050
KeyLightUp,
5151
KeyLightDown,
5252
SwitchFanProf,
53+
SwitchPerfMode,
5354
}

YAMDCC.HotkeyHandler/MainForm.Designer.cs

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

YAMDCC.HotkeyHandler/MainForm.cs

+46-40
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace YAMDCC.HotkeyHandler;
1515

1616
public partial class MainForm : Form
1717
{
18-
private readonly HotkeyConf Config;
18+
private readonly HotkeyConf HotkeyConf;
1919

2020
private readonly List<TextBox> txtHotkeys = [];
2121

@@ -42,13 +42,13 @@ public MainForm()
4242

4343
try
4444
{
45-
Config = HotkeyConf.Load(Paths.HotkeyConf);
45+
HotkeyConf = HotkeyConf.Load(Paths.HotkeyConf);
4646
}
4747
catch (Exception ex)
4848
{
4949
if (ex is FileNotFoundException or InvalidOperationException or InvalidConfigException)
5050
{
51-
Config = new();
51+
HotkeyConf = new();
5252
}
5353
else
5454
{
@@ -61,7 +61,7 @@ public MainForm()
6161

6262
private void CurrentDomain_ProcessExit(object sender, EventArgs e)
6363
{
64-
Config?.Save(Paths.HotkeyConf);
64+
HotkeyConf?.Save(Paths.HotkeyConf);
6565
}
6666

6767
protected override void SetVisibleCore(bool value)
@@ -162,23 +162,31 @@ private void tsiSysStart_Click(object sender, EventArgs e)
162162

163163
private void ReloadHotkeys()
164164
{
165-
if (Config.Hotkeys.Count == 0)
165+
if (HotkeyConf.Hotkeys.Count == 0)
166166
{
167-
Config.Hotkeys.Add(new Hotkey());
167+
HotkeyConf.Hotkeys.Add(new Hotkey());
168168
}
169169

170170
float scale = AutoScaleDimensions.Width / 96;
171171
tblHotKeys.SuspendLayout();
172172
txtHotkeys.Clear();
173173
tblHotKeys.Controls.Clear();
174174
tblHotKeys.RowStyles.Clear();
175-
tblHotKeys.RowCount = Config.Hotkeys.Count + 1;
175+
tblHotKeys.RowCount = HotkeyConf.Hotkeys.Count + 1;
176176

177-
for (int i = 0; i < Config.Hotkeys.Count; i++)
177+
for (int i = 0; i < HotkeyConf.Hotkeys.Count; i++)
178178
{
179-
Hotkey hk = Config.Hotkeys[i];
179+
Hotkey hk = HotkeyConf.Hotkeys[i];
180180
tblHotKeys.RowStyles.Add(new RowStyle());
181181
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);
182190
txtHotkeys.Add(new TextBox
183191
{
184192
ReadOnly = true,
@@ -190,9 +198,9 @@ private void ReloadHotkeys()
190198
txtHotkeys[i].Leave += KeyBindLeave;
191199
txtHotkeys[i].KeyDown += KeyBindDown;
192200
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);
196204
}
197205
tblHotKeys.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
198206
tblHotKeys.ResumeLayout();
@@ -202,7 +210,7 @@ private void KeyBindLeave(object sender, EventArgs e)
202210
{
203211
if (BindInProgress)
204212
{
205-
Config.Hotkeys[(int)((Control)sender).Tag] = OldHotkey;
213+
HotkeyConf.Hotkeys[(int)((Control)sender).Tag] = OldHotkey;
206214
BindInProgress = false;
207215
}
208216
}
@@ -214,8 +222,8 @@ private void KeyBindDown(object sender, KeyEventArgs e)
214222

215223
if (!BindInProgress)
216224
{
217-
OldHotkey = Config.Hotkeys[i];
218-
Config.Hotkeys[i].Modifiers = 0;
225+
OldHotkey = HotkeyConf.Hotkeys[i];
226+
HotkeyConf.Hotkeys[i].Modifiers = 0;
219227
BindInProgress = true;
220228
tb.Clear();
221229
}
@@ -230,33 +238,33 @@ private void KeyBindDown(object sender, KeyEventArgs e)
230238
case Keys.LMenu:
231239
case Keys.RMenu:
232240
case Keys.Menu:
233-
if ((Config.Hotkeys[i].Modifiers & HotkeyModifiers.Alt) != HotkeyModifiers.Alt)
241+
if ((HotkeyConf.Hotkeys[i].Modifiers & HotkeyModifiers.Alt) != HotkeyModifiers.Alt)
234242
{
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);
237245
}
238246
break;
239247
case Keys.LControlKey:
240248
case Keys.RControlKey:
241249
case Keys.ControlKey:
242-
if ((Config.Hotkeys[i].Modifiers & HotkeyModifiers.Ctrl) != HotkeyModifiers.Ctrl)
250+
if ((HotkeyConf.Hotkeys[i].Modifiers & HotkeyModifiers.Ctrl) != HotkeyModifiers.Ctrl)
243251
{
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);
246254
}
247255
break;
248256
case Keys.LShiftKey:
249257
case Keys.RShiftKey:
250258
case Keys.ShiftKey:
251-
if ((Config.Hotkeys[i].Modifiers & HotkeyModifiers.Shift) != HotkeyModifiers.Shift)
259+
if ((HotkeyConf.Hotkeys[i].Modifiers & HotkeyModifiers.Shift) != HotkeyModifiers.Shift)
252260
{
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);
255263
}
256264
break;
257265
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;
260268
BindInProgress = false;
261269
break;
262270
}
@@ -277,29 +285,29 @@ private void KeyBindUp(object sender, KeyEventArgs e)
277285
case Keys.LMenu:
278286
case Keys.RMenu:
279287
case Keys.Menu:
280-
if ((Config.Hotkeys[i].Modifiers & HotkeyModifiers.Alt) == HotkeyModifiers.Alt)
288+
if ((HotkeyConf.Hotkeys[i].Modifiers & HotkeyModifiers.Alt) == HotkeyModifiers.Alt)
281289
{
282-
Config.Hotkeys[i].Modifiers &= ~HotkeyModifiers.Alt;
290+
HotkeyConf.Hotkeys[i].Modifiers &= ~HotkeyModifiers.Alt;
283291
}
284292
break;
285293
case Keys.LControlKey:
286294
case Keys.RControlKey:
287295
case Keys.ControlKey:
288-
if ((Config.Hotkeys[i].Modifiers & HotkeyModifiers.Ctrl) == HotkeyModifiers.Ctrl)
296+
if ((HotkeyConf.Hotkeys[i].Modifiers & HotkeyModifiers.Ctrl) == HotkeyModifiers.Ctrl)
289297
{
290-
Config.Hotkeys[i].Modifiers &= ~HotkeyModifiers.Ctrl;
298+
HotkeyConf.Hotkeys[i].Modifiers &= ~HotkeyModifiers.Ctrl;
291299
}
292300
break;
293301
case Keys.LShiftKey:
294302
case Keys.RShiftKey:
295303
case Keys.ShiftKey:
296-
if ((Config.Hotkeys[i].Modifiers & HotkeyModifiers.Shift) == HotkeyModifiers.Shift)
304+
if ((HotkeyConf.Hotkeys[i].Modifiers & HotkeyModifiers.Shift) == HotkeyModifiers.Shift)
297305
{
298-
Config.Hotkeys[i].Modifiers &= ~HotkeyModifiers.Shift;
306+
HotkeyConf.Hotkeys[i].Modifiers &= ~HotkeyModifiers.Shift;
299307
}
300308
break;
301309
}
302-
tb.Text = HotkeyText(Config.Hotkeys[i].Modifiers);
310+
tb.Text = HotkeyText(HotkeyConf.Hotkeys[i].Modifiers);
303311
}
304312

305313
private ComboBox ActionComboBox(int tag, float scale, HotkeyAction action)
@@ -319,10 +327,8 @@ private ComboBox ActionComboBox(int tag, float scale, HotkeyAction action)
319327
"Toggle Win/Fn swap",
320328
"Increase keyboard backlight",
321329
"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",
326332
]);
327333
cbo.SelectedIndex = (int)action;
328334
cbo.SelectedIndexChanged += new EventHandler(ActionChanged);
@@ -345,21 +351,21 @@ private Button HotkeyButton(int tag, bool del, float scale)
345351
private void ActionAdd(object sender, EventArgs e)
346352
{
347353
Button b = (Button)sender;
348-
Config.Hotkeys.Insert((int)b.Tag + 1, new Hotkey());
354+
HotkeyConf.Hotkeys.Insert((int)b.Tag + 1, new Hotkey());
349355
ReloadHotkeys();
350356
}
351357

352358
private void ActionDel(object sender, EventArgs e)
353359
{
354360
Button b = (Button)sender;
355-
Config.Hotkeys.RemoveAt((int)b.Tag);
361+
HotkeyConf.Hotkeys.RemoveAt((int)b.Tag);
356362
ReloadHotkeys();
357363
}
358364

359365
private void ActionChanged(object sender, EventArgs e)
360366
{
361367
ComboBox cb = (ComboBox)sender;
362-
Config.Hotkeys[(int)cb.Tag].Action = (HotkeyAction)cb.SelectedIndex;
368+
HotkeyConf.Hotkeys[(int)cb.Tag].Action = (HotkeyAction)cb.SelectedIndex;
363369
}
364370

365371
private static string HotkeyText(HotkeyModifiers modifiers, Keys key = Keys.None)

0 commit comments

Comments
 (0)