From bee7f35475a9883224a612a45867ab5e5af9cee4 Mon Sep 17 00:00:00 2001 From: seerge Date: Tue, 11 Apr 2023 18:50:12 +0200 Subject: [PATCH] Custom Power schemes support --- app/AppConfig.cs | 6 ++++ app/GHelper.sln | 4 +-- app/Keyboard.Designer.cs | 5 ++- app/NativeMethods.cs | 9 ++++- app/Program.cs | 2 +- app/Properties/Strings.es.resx | 61 +++++++++++++++++++++++++++++++++- app/Properties/Strings.uk.resx | 2 +- app/Settings.cs | 5 ++- 8 files changed, 86 insertions(+), 8 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 05264acd..76780195 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -186,6 +186,12 @@ public class AppConfig return curve; } + public string getConfigPerfString(string name) + { + int mode = getConfig("performance_mode"); + return getConfigString(name + "_" + mode); + } + public int getConfigPerf(string name) { int mode = getConfig("performance_mode"); diff --git a/app/GHelper.sln b/app/GHelper.sln index a726faaa..dde3e8b5 100644 --- a/app/GHelper.sln +++ b/app/GHelper.sln @@ -20,8 +20,8 @@ Global GlobalSection(ProjectConfigurationPlatforms) = postSolution {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.ActiveCfg = Debug|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.Build.0 = Debug|x64 - {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.ActiveCfg = Release|x64 - {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.Build.0 = Release|x64 + {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.ActiveCfg = Debug|x64 + {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.Build.0 = Debug|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.ActiveCfg = Release|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.Build.0 = Release|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.ActiveCfg = Release|x64 diff --git a/app/Keyboard.Designer.cs b/app/Keyboard.Designer.cs index 9f3bdaef..a3d8e735 100644 --- a/app/Keyboard.Designer.cs +++ b/app/Keyboard.Designer.cs @@ -163,7 +163,7 @@ namespace GHelper groupLight.Dock = DockStyle.Top; groupLight.Location = new Point(10, 252); groupLight.Name = "groupLight"; - groupLight.Size = new Size(756, 304); + groupLight.Size = new Size(756, 320); groupLight.TabIndex = 1; groupLight.TabStop = false; groupLight.Text = Properties.Strings.KeyboardBacklight; @@ -174,6 +174,7 @@ namespace GHelper labelSpeed.Location = new Point(25, 237); labelSpeed.Name = "labelSpeed"; labelSpeed.Size = new Size(198, 32); + labelSpeed.MaximumSize = new Size(200, 0); labelSpeed.TabIndex = 40; labelSpeed.Text = Properties.Strings.AnimationSpeed; // @@ -252,6 +253,8 @@ namespace GHelper checkKeyboardAuto.Location = new Point(25, 51); checkKeyboardAuto.Name = "checkKeyboardAuto"; checkKeyboardAuto.Size = new Size(712, 36); + checkKeyboardAuto.MaximumSize = new Size(712, 0); + checkKeyboardAuto.AutoEllipsis = true; checkKeyboardAuto.TabIndex = 2; checkKeyboardAuto.Text = Properties.Strings.KeyboardAuto; checkKeyboardAuto.UseVisualStyleBackColor = true; diff --git a/app/NativeMethods.cs b/app/NativeMethods.cs index 84235b29..6b595ac8 100644 --- a/app/NativeMethods.cs +++ b/app/NativeMethods.cs @@ -1,4 +1,5 @@ -using System.ComponentModel; +using GHelper; +using System.ComponentModel; using System.Diagnostics; using System.Runtime.InteropServices; using static Tools.ScreenInterrogatory; @@ -731,6 +732,12 @@ public class NativeMethods Logger.WriteLine("Boost " + boost); } + public static void SetPowerScheme(string scheme) + { + PowerSetActiveScheme(IntPtr.Zero, new Guid(scheme)); + PowerSetActiveOverlayScheme(new Guid(scheme)); + } + public static void SetPowerScheme(int mode) { switch (mode) diff --git a/app/Program.cs b/app/Program.cs index 196807fb..35caa9b8 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -34,7 +34,7 @@ namespace GHelper Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("es"); + //Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("zh"); if (Process.GetProcesses().Count(p => p.ProcessName == "GHelper") > 1) { diff --git a/app/Properties/Strings.es.resx b/app/Properties/Strings.es.resx index 8eab46e9..98ca75ee 100644 --- a/app/Properties/Strings.es.resx +++ b/app/Properties/Strings.es.resx @@ -1,5 +1,64 @@  + @@ -185,7 +244,7 @@ Perfil ventilador central - Perfiles de ventiladores + Ventiladores Ventiladores y energía diff --git a/app/Properties/Strings.uk.resx b/app/Properties/Strings.uk.resx index 0d5ab5c2..474747cf 100644 --- a/app/Properties/Strings.uk.resx +++ b/app/Properties/Strings.uk.resx @@ -136,7 +136,7 @@ Перезавантажитися зараз? - Анімация + Швидкість Анімації Аніме Матриця diff --git a/app/Settings.cs b/app/Settings.cs index 5d5c5c67..8db9c591 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -1019,7 +1019,10 @@ namespace GHelper NativeMethods.SetCPUBoost(Program.config.getConfigPerf("auto_boost")); } - NativeMethods.SetPowerScheme(PerformanceMode); + if (Program.config.getConfigPerfString("scheme") is not null) + NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme")); + else + NativeMethods.SetPowerScheme(PerformanceMode); if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0) {