From ac5fc3f96e45e7f24a4c3fe2b83b76c3f4403ddc Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 12:21:28 +0200 Subject: [PATCH 01/10] Revert "Revert "Adjustment of Windows Power Overlay is now optional"" This reverts commit 8804d195670fd7a367b152d3ae78230ba7f34de6. --- app/AppConfig.cs | 1 + app/Extra.Designer.cs | 1 + app/Extra.cs | 9 +++++++++ app/Properties/Strings.Designer.cs | 11 ++++++++++- app/Properties/Strings.de.resx | 3 +++ app/Properties/Strings.es.resx | 3 +++ app/Properties/Strings.fr.resx | 3 +++ app/Properties/Strings.it.resx | 3 +++ app/Properties/Strings.resx | 3 +++ app/Properties/Strings.tr.resx | 3 +++ app/Properties/Strings.uk.resx | 3 +++ app/Properties/Strings.zh-CN.resx | 3 +++ app/Properties/Strings.zh-TW.resx | 3 +++ app/Settings.cs | 12 +++++++----- 14 files changed, 55 insertions(+), 6 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 76780195..cfb6fa26 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -69,6 +69,7 @@ public class AppConfig { config = new Dictionary(); config["performance_mode"] = 0; + config["auto_apply_power_plan"] = 1; string jsonString = JsonSerializer.Serialize(config); File.WriteAllText(configFile, jsonString); } diff --git a/app/Extra.Designer.cs b/app/Extra.Designer.cs index 76a6cdcb..cbf1945d 100644 --- a/app/Extra.Designer.cs +++ b/app/Extra.Designer.cs @@ -74,6 +74,7 @@ namespace GHelper checkSleepLid = new CheckBox(); checkShutdownLid = new CheckBox(); groupOther = new GroupBox(); + checkApplyWindowsPowerMode = new CheckBox(); checkKeyboardAuto = new CheckBox(); checkUSBC = new CheckBox(); checkNoOverdrive = new CheckBox(); diff --git a/app/Extra.cs b/app/Extra.cs index 9209c3a2..eae36690 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -73,6 +73,7 @@ namespace GHelper checkNoOverdrive.Text = Properties.Strings.DisableOverdrive; checkTopmost.Text = Properties.Strings.WindowTop; checkUSBC.Text = Properties.Strings.OptimizedUSBC; + checkApplyWindowsPowerMode.Text = Properties.Strings.ApplyWindowsPowerPlan; labelBacklight.Text = Properties.Strings.Keyboard; labelBacklightBar.Text = Properties.Strings.Lightbar; @@ -176,6 +177,8 @@ namespace GHelper checkUSBC.Checked = (Program.config.getConfig("optimized_usbc") == 1); checkUSBC.CheckedChanged += CheckUSBC_CheckedChanged; + checkApplyWindowsPowerMode.Checked = Program.config.getConfig("auto_apply_power_plan") == 1; + int kb_brightness = Program.config.getConfig("keyboard_brightness"); trackBrightness.Value = (kb_brightness >= 0 && kb_brightness <= 3) ? kb_brightness : 3; @@ -299,5 +302,11 @@ namespace GHelper Top = Program.settingsForm.Top; Left = Program.settingsForm.Left - Width - 5; } + + private void checkApplyWindowsPowerMode_CheckedChanged(object sender, EventArgs e) + { + CheckBox chk = (CheckBox)sender; + Program.config.setConfig("auto_apply_power_plan", chk.Checked ? 1 : 0); + } } } diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index 1d7a5479..bd136139 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -169,7 +169,16 @@ namespace GHelper.Properties { } /// - /// Looks up a localized string similar to Breathe. + /// Looks up a localized string similar to Auto Adjust Windows Power Plan. + /// + internal static string ApplyWindowsPowerPlan { + get { + return ResourceManager.GetString("ApplyWindowsPowerPlan", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Breathe. /// internal static string AuraBreathe { get { diff --git a/app/Properties/Strings.de.resx b/app/Properties/Strings.de.resx index 32da890a..a4ea4fb9 100644 --- a/app/Properties/Strings.de.resx +++ b/app/Properties/Strings.de.resx @@ -94,6 +94,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe diff --git a/app/Properties/Strings.es.resx b/app/Properties/Strings.es.resx index 791c96dd..37c76352 100644 --- a/app/Properties/Strings.es.resx +++ b/app/Properties/Strings.es.resx @@ -153,6 +153,9 @@ Aplicar límites de energía + + Auto Adjust Windows Power Plan + Respiración diff --git a/app/Properties/Strings.fr.resx b/app/Properties/Strings.fr.resx index 32da890a..40e9f2b4 100644 --- a/app/Properties/Strings.fr.resx +++ b/app/Properties/Strings.fr.resx @@ -301,6 +301,9 @@ Run on Startup + + Auto Adjust Windows Power Plan + Shutdown diff --git a/app/Properties/Strings.it.resx b/app/Properties/Strings.it.resx index 32da890a..a4ea4fb9 100644 --- a/app/Properties/Strings.it.resx +++ b/app/Properties/Strings.it.resx @@ -94,6 +94,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index d255a48f..6d47593a 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -153,6 +153,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe diff --git a/app/Properties/Strings.tr.resx b/app/Properties/Strings.tr.resx index 37b7146e..1e9811f7 100644 --- a/app/Properties/Strings.tr.resx +++ b/app/Properties/Strings.tr.resx @@ -153,6 +153,9 @@ Güç Sınırlarını Uygula + + Auto Adjust Windows Power Plan + Nefes diff --git a/app/Properties/Strings.uk.resx b/app/Properties/Strings.uk.resx index f2df1532..f2c89463 100644 --- a/app/Properties/Strings.uk.resx +++ b/app/Properties/Strings.uk.resx @@ -153,6 +153,9 @@ Застосувати потужність + + Auto Adjust Windows Power Plan + Дихання diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index 65426d2d..98fbf9f2 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -153,6 +153,9 @@ 应用功率限制 + + Auto Adjust Windows Power Plan + 呼吸 diff --git a/app/Properties/Strings.zh-TW.resx b/app/Properties/Strings.zh-TW.resx index 9b9b6bff..ac4c8472 100644 --- a/app/Properties/Strings.zh-TW.resx +++ b/app/Properties/Strings.zh-TW.resx @@ -153,6 +153,9 @@ 套用功率限制 + + Auto Adjust Windows Power Plan + 呼吸 diff --git a/app/Settings.cs b/app/Settings.cs index 5552f6ea..3a796f8e 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1286,11 +1286,13 @@ namespace GHelper AutoFans(); AutoPower(1000); - - if (Program.config.getConfigPerfString("scheme") is not null) - NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); - else - NativeMethods.SetPowerScheme(PerformanceMode); + if (Program.config.getConfigPerf("auto_apply_power_plan") == 1) + { + if (Program.config.getConfigPerfString("scheme") is not null) + NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); + else + NativeMethods.SetPowerScheme(PerformanceMode); + } if (Program.config.getConfigPerf("auto_boost") != -1) { From 7d968f5f084dea8bb04bc4e795e95790f35f33be Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 12:24:06 +0200 Subject: [PATCH 02/10] Do not set default value. --- app/AppConfig.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index cfb6fa26..76780195 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -69,7 +69,6 @@ public class AppConfig { config = new Dictionary(); config["performance_mode"] = 0; - config["auto_apply_power_plan"] = 1; string jsonString = JsonSerializer.Serialize(config); File.WriteAllText(configFile, jsonString); } From 8bec153da8b471f758e354cf0223a88a85fbee96 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 12:30:57 +0200 Subject: [PATCH 03/10] Fixed localization key for french --- app/Properties/Strings.fr.resx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Properties/Strings.fr.resx b/app/Properties/Strings.fr.resx index 40e9f2b4..a4ea4fb9 100644 --- a/app/Properties/Strings.fr.resx +++ b/app/Properties/Strings.fr.resx @@ -94,6 +94,9 @@ Apply Power Limits + + Auto Adjust Windows Power Plan + Breathe @@ -301,9 +304,6 @@ Run on Startup - - Auto Adjust Windows Power Plan - Shutdown From fd89d9c13a771b82bc3a016a206e02af06ae4bd6 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 12:33:15 +0200 Subject: [PATCH 04/10] Changed string to "Power Mode" instead of "power plan" --- app/Properties/Strings.de.resx | 2 +- app/Properties/Strings.es.resx | 2 +- app/Properties/Strings.it.resx | 2 +- app/Properties/Strings.tr.resx | 2 +- app/Properties/Strings.uk.resx | 2 +- app/Properties/Strings.zh-CN.resx | 2 +- app/Properties/Strings.zh-TW.resx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/Properties/Strings.de.resx b/app/Properties/Strings.de.resx index a4ea4fb9..c8af7f77 100644 --- a/app/Properties/Strings.de.resx +++ b/app/Properties/Strings.de.resx @@ -95,7 +95,7 @@ Apply Power Limits - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode Breathe diff --git a/app/Properties/Strings.es.resx b/app/Properties/Strings.es.resx index 37c76352..53eb4bb3 100644 --- a/app/Properties/Strings.es.resx +++ b/app/Properties/Strings.es.resx @@ -154,7 +154,7 @@ Aplicar límites de energía - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode Respiración diff --git a/app/Properties/Strings.it.resx b/app/Properties/Strings.it.resx index a4ea4fb9..c8af7f77 100644 --- a/app/Properties/Strings.it.resx +++ b/app/Properties/Strings.it.resx @@ -95,7 +95,7 @@ Apply Power Limits - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode Breathe diff --git a/app/Properties/Strings.tr.resx b/app/Properties/Strings.tr.resx index 1e9811f7..8279459a 100644 --- a/app/Properties/Strings.tr.resx +++ b/app/Properties/Strings.tr.resx @@ -154,7 +154,7 @@ Güç Sınırlarını Uygula - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode Nefes diff --git a/app/Properties/Strings.uk.resx b/app/Properties/Strings.uk.resx index f2c89463..59a6b309 100644 --- a/app/Properties/Strings.uk.resx +++ b/app/Properties/Strings.uk.resx @@ -154,7 +154,7 @@ Застосувати потужність - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode Дихання diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index 98fbf9f2..a24b5678 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -154,7 +154,7 @@ 应用功率限制 - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode 呼吸 diff --git a/app/Properties/Strings.zh-TW.resx b/app/Properties/Strings.zh-TW.resx index ac4c8472..9941dae4 100644 --- a/app/Properties/Strings.zh-TW.resx +++ b/app/Properties/Strings.zh-TW.resx @@ -154,7 +154,7 @@ 套用功率限制 - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode 呼吸 From 6896166c3c8395d0c15e7f476ec73b7d8fd22bd6 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 12:36:26 +0200 Subject: [PATCH 05/10] Fixed French translation value --- app/Properties/Strings.fr.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Properties/Strings.fr.resx b/app/Properties/Strings.fr.resx index a4ea4fb9..c8af7f77 100644 --- a/app/Properties/Strings.fr.resx +++ b/app/Properties/Strings.fr.resx @@ -95,7 +95,7 @@ Apply Power Limits - Auto Adjust Windows Power Plan + Auto Adjust Windows Power Mode Breathe From 71e007d8add309105183bcfbc99756e2cf5790e0 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 13:29:31 +0200 Subject: [PATCH 06/10] Fixed UI that VS Forms Designer broke --- app/Extra.Designer.cs | 24 ++++++++++++++++++------ app/Extra.cs | 7 ++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/Extra.Designer.cs b/app/Extra.Designer.cs index cbf1945d..a147d239 100644 --- a/app/Extra.Designer.cs +++ b/app/Extra.Designer.cs @@ -74,7 +74,7 @@ namespace GHelper checkSleepLid = new CheckBox(); checkShutdownLid = new CheckBox(); groupOther = new GroupBox(); - checkApplyWindowsPowerMode = new CheckBox(); + checkAutoApplyWindowsPowerMode = new CheckBox(); checkKeyboardAuto = new CheckBox(); checkUSBC = new CheckBox(); checkNoOverdrive = new CheckBox(); @@ -575,12 +575,13 @@ namespace GHelper // // groupOther // + groupOther.Controls.Add(checkAutoApplyWindowsPowerMode); groupOther.Controls.Add(checkKeyboardAuto); groupOther.Controls.Add(checkUSBC); groupOther.Controls.Add(checkNoOverdrive); groupOther.Controls.Add(checkTopmost); groupOther.Dock = DockStyle.Top; - groupOther.Location = new Point(10, 768); + groupOther.Location = new Point(5, 358); groupOther.Name = "groupOther"; groupOther.Size = new Size(954, 276); groupOther.TabIndex = 2; @@ -590,8 +591,8 @@ namespace GHelper // checkKeyboardAuto // checkKeyboardAuto.AutoSize = true; - checkKeyboardAuto.Location = new Point(25, 53); checkKeyboardAuto.MaximumSize = new Size(780, 0); + checkKeyboardAuto.Location = new Point(25, 40); checkKeyboardAuto.Name = "checkKeyboardAuto"; checkKeyboardAuto.Size = new Size(712, 36); checkKeyboardAuto.TabIndex = 46; @@ -601,7 +602,7 @@ namespace GHelper // checkUSBC // checkUSBC.AutoSize = true; - checkUSBC.Location = new Point(25, 210); + checkUSBC.Location = new Point(25, 85); checkUSBC.Name = "checkUSBC"; checkUSBC.Size = new Size(659, 36); checkUSBC.TabIndex = 4; @@ -611,7 +612,7 @@ namespace GHelper // checkNoOverdrive // checkNoOverdrive.AutoSize = true; - checkNoOverdrive.Location = new Point(25, 156); + checkNoOverdrive.Location = new Point(25, 130); checkNoOverdrive.Name = "checkNoOverdrive"; checkNoOverdrive.Size = new Size(307, 36); checkNoOverdrive.TabIndex = 3; @@ -621,13 +622,23 @@ namespace GHelper // checkTopmost // checkTopmost.AutoSize = true; - checkTopmost.Location = new Point(25, 104); + checkTopmost.Location = new Point(25, 175); checkTopmost.Name = "checkTopmost"; checkTopmost.Size = new Size(390, 36); checkTopmost.TabIndex = 1; checkTopmost.Text = Strings.WindowTop; checkTopmost.UseVisualStyleBackColor = true; // + // checkAutoApplyWindowsPowerMode + // + checkAutoApplyWindowsPowerMode.AutoSize = true; + checkAutoApplyWindowsPowerMode.Location = new Point(25, 220); + checkAutoApplyWindowsPowerMode.Name = "checkAutoApplyWindowsPowerMode"; + checkAutoApplyWindowsPowerMode.Size = new Size(211, 19); + checkAutoApplyWindowsPowerMode.TabIndex = 47; + checkAutoApplyWindowsPowerMode.Text = "Auto Adjust Windows Power Mode"; + checkAutoApplyWindowsPowerMode.UseVisualStyleBackColor = true; + // // Extra // AutoScaleDimensions = new SizeF(13F, 32F); @@ -715,5 +726,6 @@ namespace GHelper private Label labelBacklightTimeout; private NumericUpDown numericBacklightTime; private CheckBox checkKeyboardAuto; + private CheckBox checkAutoApplyWindowsPowerMode; } } \ No newline at end of file diff --git a/app/Extra.cs b/app/Extra.cs index eae36690..0a55e87a 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -73,7 +73,7 @@ namespace GHelper checkNoOverdrive.Text = Properties.Strings.DisableOverdrive; checkTopmost.Text = Properties.Strings.WindowTop; checkUSBC.Text = Properties.Strings.OptimizedUSBC; - checkApplyWindowsPowerMode.Text = Properties.Strings.ApplyWindowsPowerPlan; + checkAutoApplyWindowsPowerMode.Text = Properties.Strings.ApplyWindowsPowerPlan; labelBacklight.Text = Properties.Strings.Keyboard; labelBacklightBar.Text = Properties.Strings.Lightbar; @@ -177,7 +177,8 @@ namespace GHelper checkUSBC.Checked = (Program.config.getConfig("optimized_usbc") == 1); checkUSBC.CheckedChanged += CheckUSBC_CheckedChanged; - checkApplyWindowsPowerMode.Checked = Program.config.getConfig("auto_apply_power_plan") == 1; + checkAutoApplyWindowsPowerMode.Checked = Program.config.getConfig("auto_apply_power_plan") == 1; + checkAutoApplyWindowsPowerMode.CheckedChanged += checkAutoApplyWindowsPowerMode_CheckedChanged; int kb_brightness = Program.config.getConfig("keyboard_brightness"); trackBrightness.Value = (kb_brightness >= 0 && kb_brightness <= 3) ? kb_brightness : 3; @@ -303,7 +304,7 @@ namespace GHelper Left = Program.settingsForm.Left - Width - 5; } - private void checkApplyWindowsPowerMode_CheckedChanged(object sender, EventArgs e) + private void checkAutoApplyWindowsPowerMode_CheckedChanged(object sender, EventArgs e) { CheckBox chk = (CheckBox)sender; Program.config.setConfig("auto_apply_power_plan", chk.Checked ? 1 : 0); From b74b9ae2578061c069b32b438bbd42d14899d70a Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 13:29:48 +0200 Subject: [PATCH 07/10] Fix nullability --- app/Extra.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Extra.cs b/app/Extra.cs index 0a55e87a..89c7bd02 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -304,7 +304,7 @@ namespace GHelper Left = Program.settingsForm.Left - Width - 5; } - private void checkAutoApplyWindowsPowerMode_CheckedChanged(object sender, EventArgs e) + private void checkAutoApplyWindowsPowerMode_CheckedChanged(object? sender, EventArgs e) { CheckBox chk = (CheckBox)sender; Program.config.setConfig("auto_apply_power_plan", chk.Checked ? 1 : 0); From 69e5a0448ee7b3e6795ee8aa64b4b40540680378 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 13:30:08 +0200 Subject: [PATCH 08/10] Accomodate for non-exitent settings value --- app/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Settings.cs b/app/Settings.cs index 3a796f8e..32a51e5e 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1286,7 +1286,7 @@ namespace GHelper AutoFans(); AutoPower(1000); - if (Program.config.getConfigPerf("auto_apply_power_plan") == 1) + if (Program.config.getConfigPerf("auto_apply_power_plan") != 0) { if (Program.config.getConfigPerfString("scheme") is not null) NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); From 63c1829eddec61578d6f03a10518ce1e94cf2e79 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 13:34:26 +0200 Subject: [PATCH 09/10] We can reference the checkbox directly --- app/Extra.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Extra.cs b/app/Extra.cs index 89c7bd02..bdfb3e45 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -306,8 +306,7 @@ namespace GHelper private void checkAutoApplyWindowsPowerMode_CheckedChanged(object? sender, EventArgs e) { - CheckBox chk = (CheckBox)sender; - Program.config.setConfig("auto_apply_power_plan", chk.Checked ? 1 : 0); + Program.config.setConfig("auto_apply_power_plan", checkAutoApplyWindowsPowerMode.Checked ? 1 : 0); } } } From 8370217cefc3a237216b9b811d592dee4c611087 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Tue, 16 May 2023 13:34:40 +0200 Subject: [PATCH 10/10] This is not a perf config but a regular config value. --- app/Settings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Settings.cs b/app/Settings.cs index 32a51e5e..570c2b64 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1286,7 +1286,7 @@ namespace GHelper AutoFans(); AutoPower(1000); - if (Program.config.getConfigPerf("auto_apply_power_plan") != 0) + if (Program.config.getConfig("auto_apply_power_plan") != 0) { if (Program.config.getConfigPerfString("scheme") is not null) NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme"));