Custom Power schemes support

This commit is contained in:
seerge
2023-04-11 18:50:12 +02:00
parent 2daf1f5434
commit bee7f35475
8 changed files with 86 additions and 8 deletions

View File

@@ -186,6 +186,12 @@ public class AppConfig
return curve; return curve;
} }
public string getConfigPerfString(string name)
{
int mode = getConfig("performance_mode");
return getConfigString(name + "_" + mode);
}
public int getConfigPerf(string name) public int getConfigPerf(string name)
{ {
int mode = getConfig("performance_mode"); int mode = getConfig("performance_mode");

View File

@@ -20,8 +20,8 @@ Global
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.ActiveCfg = Debug|x64 {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|Any CPU.Build.0 = Debug|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.ActiveCfg = Release|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.ActiveCfg = Debug|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|x64.Build.0 = Release|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.ActiveCfg = Release|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.Build.0 = Release|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.Build.0 = Release|x64
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.ActiveCfg = Release|x64 {D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|x64.ActiveCfg = Release|x64

View File

@@ -163,7 +163,7 @@ namespace GHelper
groupLight.Dock = DockStyle.Top; groupLight.Dock = DockStyle.Top;
groupLight.Location = new Point(10, 252); groupLight.Location = new Point(10, 252);
groupLight.Name = "groupLight"; groupLight.Name = "groupLight";
groupLight.Size = new Size(756, 304); groupLight.Size = new Size(756, 320);
groupLight.TabIndex = 1; groupLight.TabIndex = 1;
groupLight.TabStop = false; groupLight.TabStop = false;
groupLight.Text = Properties.Strings.KeyboardBacklight; groupLight.Text = Properties.Strings.KeyboardBacklight;
@@ -174,6 +174,7 @@ namespace GHelper
labelSpeed.Location = new Point(25, 237); labelSpeed.Location = new Point(25, 237);
labelSpeed.Name = "labelSpeed"; labelSpeed.Name = "labelSpeed";
labelSpeed.Size = new Size(198, 32); labelSpeed.Size = new Size(198, 32);
labelSpeed.MaximumSize = new Size(200, 0);
labelSpeed.TabIndex = 40; labelSpeed.TabIndex = 40;
labelSpeed.Text = Properties.Strings.AnimationSpeed; labelSpeed.Text = Properties.Strings.AnimationSpeed;
// //
@@ -252,6 +253,8 @@ namespace GHelper
checkKeyboardAuto.Location = new Point(25, 51); checkKeyboardAuto.Location = new Point(25, 51);
checkKeyboardAuto.Name = "checkKeyboardAuto"; checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36); checkKeyboardAuto.Size = new Size(712, 36);
checkKeyboardAuto.MaximumSize = new Size(712, 0);
checkKeyboardAuto.AutoEllipsis = true;
checkKeyboardAuto.TabIndex = 2; checkKeyboardAuto.TabIndex = 2;
checkKeyboardAuto.Text = Properties.Strings.KeyboardAuto; checkKeyboardAuto.Text = Properties.Strings.KeyboardAuto;
checkKeyboardAuto.UseVisualStyleBackColor = true; checkKeyboardAuto.UseVisualStyleBackColor = true;

View File

@@ -1,4 +1,5 @@
using System.ComponentModel; using GHelper;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using static Tools.ScreenInterrogatory; using static Tools.ScreenInterrogatory;
@@ -731,6 +732,12 @@ public class NativeMethods
Logger.WriteLine("Boost " + boost); 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) public static void SetPowerScheme(int mode)
{ {
switch (mode) switch (mode)

View File

@@ -34,7 +34,7 @@ namespace GHelper
Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture; Thread.CurrentThread.CurrentCulture = CultureInfo.CurrentCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture; 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) if (Process.GetProcesses().Count(p => p.ProcessName == "GHelper") > 1)
{ {

View File

@@ -1,5 +1,64 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
@@ -185,7 +244,7 @@
<value>Perfil ventilador central</value> <value>Perfil ventilador central</value>
</data> </data>
<data name="FanProfiles" xml:space="preserve"> <data name="FanProfiles" xml:space="preserve">
<value>Perfiles de ventiladores</value> <value>Ventiladores</value>
</data> </data>
<data name="FansAndPower" xml:space="preserve"> <data name="FansAndPower" xml:space="preserve">
<value>Ventiladores y energía</value> <value>Ventiladores y energía</value>

View File

@@ -136,7 +136,7 @@
<value>Перезавантажитися зараз?</value> <value>Перезавантажитися зараз?</value>
</data> </data>
<data name="AnimationSpeed" xml:space="preserve"> <data name="AnimationSpeed" xml:space="preserve">
<value>Анімация</value> <value>Швидкість Анімації</value>
</data> </data>
<data name="AnimeMatrix" xml:space="preserve"> <data name="AnimeMatrix" xml:space="preserve">
<value>Аніме Матриця</value> <value>Аніме Матриця</value>

View File

@@ -1019,7 +1019,10 @@ namespace GHelper
NativeMethods.SetCPUBoost(Program.config.getConfigPerf("auto_boost")); 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) if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0)
{ {