From 2a82e418949b2fe2e1d90148e7b7c99b016ac0a9 Mon Sep 17 00:00:00 2001 From: Carsten Braun Date: Mon, 15 May 2023 13:23:20 +0200 Subject: [PATCH] Adjustment of Windows Power Overlay is now optional --- app/AppConfig.cs | 1 + app/Fans.Designer.cs | 33 +++++++++++++++++++++++------- app/Fans.cs | 8 ++++++++ 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, 79 insertions(+), 13 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/Fans.Designer.cs b/app/Fans.Designer.cs index cf092519..3e37af29 100644 --- a/app/Fans.Designer.cs +++ b/app/Fans.Designer.cs @@ -86,6 +86,7 @@ namespace GHelper panelTitleGPU = new Panel(); pictureGPU = new PictureBox(); labelGPU = new Label(); + checkApplyWindowsPowerPlan = new RCheckBox(); panelFans.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit(); tableFanCharts.SuspendLayout(); @@ -323,12 +324,14 @@ namespace GHelper // // panelApplyPower // + panelApplyPower.Controls.Add(checkApplyWindowsPowerPlan); panelApplyPower.Controls.Add(checkApplyPower); panelApplyPower.Dock = DockStyle.Bottom; - panelApplyPower.Location = new Point(0, 445); + panelApplyPower.Location = new Point(0, 307); + panelApplyPower.Margin = new Padding(2); panelApplyPower.Name = "panelApplyPower"; - panelApplyPower.Padding = new Padding(10); - panelApplyPower.Size = new Size(523, 92); + panelApplyPower.Padding = new Padding(6); + panelApplyPower.Size = new Size(392, 98); panelApplyPower.TabIndex = 44; // // checkApplyPower @@ -336,11 +339,11 @@ namespace GHelper checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; checkApplyPower.AutoSize = true; checkApplyPower.BackColor = SystemColors.ControlLight; - checkApplyPower.Location = new Point(18, 22); - checkApplyPower.Margin = new Padding(10); + checkApplyPower.Location = new Point(10, 50); + checkApplyPower.Margin = new Padding(6); checkApplyPower.Name = "checkApplyPower"; - checkApplyPower.Padding = new Padding(15, 5, 15, 5); - checkApplyPower.Size = new Size(277, 46); + checkApplyPower.Padding = new Padding(8, 3, 8, 3); + checkApplyPower.Size = new Size(205, 35); checkApplyPower.TabIndex = 45; checkApplyPower.Text = Properties.Strings.ApplyPowerLimits; checkApplyPower.UseVisualStyleBackColor = false; @@ -731,6 +734,21 @@ namespace GHelper labelGPU.TabIndex = 40; labelGPU.Text = "GPU Settings"; // + // checkApplyWindowsPowerPlan + // + checkApplyWindowsPowerPlan.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + checkApplyWindowsPowerPlan.AutoSize = true; + checkApplyWindowsPowerPlan.BackColor = SystemColors.ControlLight; + checkApplyWindowsPowerPlan.Location = new Point(10, 13); + checkApplyWindowsPowerPlan.Margin = new Padding(6); + checkApplyWindowsPowerPlan.Name = "checkApplyWindowsPowerPlan"; + checkApplyWindowsPowerPlan.Padding = new Padding(8, 3, 8, 3); + checkApplyWindowsPowerPlan.Size = new Size(319, 35); + checkApplyWindowsPowerPlan.TabIndex = 46; + checkApplyWindowsPowerPlan.Text = "Auto Adjust Windows Power Plan"; + checkApplyWindowsPowerPlan.UseVisualStyleBackColor = false; + checkApplyWindowsPowerPlan.CheckedChanged += checkApplyWindowsPowerPlan_CheckedChanged; + // // Fans // AutoScaleDimensions = new SizeF(192F, 192F); @@ -842,5 +860,6 @@ namespace GHelper private Label labelGPUTemp; private Label labelGPUTempTitle; private TrackBar trackGPUTemp; + private RCheckBox checkApplyWindowsPowerPlan; } } \ No newline at end of file diff --git a/app/Fans.cs b/app/Fans.cs index b6cf81e7..0000456a 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -28,6 +28,7 @@ namespace GHelper labelPowerLimits.Text = Properties.Strings.PowerLimits; labelInfo.Text = Properties.Strings.PPTExperimental; checkApplyPower.Text = Properties.Strings.ApplyPowerLimits; + checkApplyWindowsPowerPlan.Text = Properties.Strings.ApplyWindowsPowerPlan; labelFans.Text = Properties.Strings.FanCurves; labelBoost.Text = Properties.Strings.CPUBoost; @@ -377,6 +378,7 @@ namespace GHelper int limit_total; int limit_cpu; bool apply = Program.config.getConfigPerf("auto_apply_power") == 1; + bool applyPP = Program.config.getConfig("auto_apply_power_plan") == 1; if (changed) { @@ -401,6 +403,7 @@ namespace GHelper trackTotal.Value = limit_total; trackCPU.Value = limit_cpu; checkApplyPower.Checked = apply; + checkApplyWindowsPowerPlan.Checked = applyPP; labelTotal.Text = trackTotal.Value.ToString() + "W"; labelCPU.Text = trackCPU.Value.ToString() + "W"; @@ -689,6 +692,11 @@ namespace GHelper } } + private void checkApplyWindowsPowerPlan_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 1b0a0653..7d0c12fc 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1238,11 +1238,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) {