mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added CPU boost control
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows8.0</TargetFramework>
|
||||
<TargetFramework>net7.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
@@ -10,7 +10,6 @@
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<StartupObject>GHelper.Program</StartupObject>
|
||||
<ApplicationIcon>Resources\standard.ico</ApplicationIcon>
|
||||
<SupportedOSPlatformVersion>8.0</SupportedOSPlatformVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
136
Program.cs
136
Program.cs
@@ -1,12 +1,15 @@
|
||||
using Microsoft.Win32.TaskScheduler;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Drawing;
|
||||
|
||||
public class ASUSWmi
|
||||
{
|
||||
private ManagementObject mo;
|
||||
@@ -60,7 +63,8 @@ public class ASUSWmi
|
||||
status = int.Parse(property.Value.ToString());
|
||||
status -= 65536;
|
||||
return status;
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -70,7 +74,8 @@ public class ASUSWmi
|
||||
try
|
||||
{
|
||||
return int.Parse(property.Value.ToString());
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -214,9 +219,91 @@ public class AppConfig
|
||||
}
|
||||
|
||||
|
||||
public class PowerPlan {
|
||||
static void RunCommands(List<string> cmds, string workingDirectory = "")
|
||||
{
|
||||
var process = new Process();
|
||||
var psi = new ProcessStartInfo();
|
||||
psi.FileName = "powershell";
|
||||
psi.RedirectStandardInput = true;
|
||||
psi.RedirectStandardOutput = true;
|
||||
psi.RedirectStandardError = true;
|
||||
psi.UseShellExecute = false;
|
||||
|
||||
psi.CreateNoWindow = true;
|
||||
|
||||
psi.WorkingDirectory = workingDirectory;
|
||||
process.StartInfo = psi;
|
||||
process.Start();
|
||||
process.OutputDataReceived += (sender, e) => { Debug.WriteLine(e.Data); };
|
||||
process.ErrorDataReceived += (sender, e) => { Debug.WriteLine(e.Data); };
|
||||
process.BeginOutputReadLine();
|
||||
process.BeginErrorReadLine();
|
||||
using (StreamWriter sw = process.StandardInput)
|
||||
{
|
||||
foreach (var cmd in cmds)
|
||||
{
|
||||
sw.WriteLine(cmd);
|
||||
}
|
||||
}
|
||||
process.WaitForExit();
|
||||
}
|
||||
|
||||
|
||||
public static int getBoostStatus()
|
||||
{
|
||||
List<string> cmds = new List<string>
|
||||
{
|
||||
"$asGuid = [regex]::Match((powercfg /getactivescheme),'(\\{){0,1}[0-9a-fA-F]{8}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{4}\\-[0-9a-fA-F]{12}(\\}){0,1}').Value",
|
||||
"$statusFull = (powercfg /QUERY $asGuid 54533251-82be-4824-96c1-47b60b740d00 be337238-0d82-4146-a960-4f3749d470c7) -match 'Current AC Power Setting Index'",
|
||||
"[regex]::Match($statusFull,'(0x.{8})').Value"
|
||||
};
|
||||
|
||||
RunCommands(cmds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class NativeMethods
|
||||
{
|
||||
|
||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||
static extern UInt32 PowerWriteDCValueIndex(IntPtr RootPowerKey,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
|
||||
int AcValueIndex);
|
||||
|
||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||
static extern UInt32 PowerReadACValueIndex(IntPtr RootPowerKey,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
|
||||
out IntPtr AcValueIndex
|
||||
);
|
||||
|
||||
|
||||
|
||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||
static extern UInt32 PowerWriteACValueIndex(IntPtr RootPowerKey,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SubGroupOfPowerSettingsGuid,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid PowerSettingGuid,
|
||||
int AcValueIndex);
|
||||
|
||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||
static extern UInt32 PowerSetActiveScheme(IntPtr RootPowerKey,
|
||||
[MarshalAs(UnmanagedType.LPStruct)] Guid SchemeGuid);
|
||||
|
||||
[DllImport("PowrProf.dll", CharSet = CharSet.Unicode)]
|
||||
static extern UInt32 PowerGetActiveScheme(IntPtr UserPowerKey, out IntPtr ActivePolicyGuid);
|
||||
|
||||
static readonly Guid GUID_CPU = new Guid("54533251-82be-4824-96c1-47b60b740d00");
|
||||
static readonly Guid GUID_BOOST = new Guid("be337238-0d82-4146-a960-4f3749d470c7");
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
public struct DEVMODE
|
||||
{
|
||||
@@ -350,8 +437,46 @@ public class NativeMethods
|
||||
|
||||
}
|
||||
|
||||
static Guid GetActiveScheme()
|
||||
{
|
||||
IntPtr pActiveSchemeGuid;
|
||||
var hr = PowerGetActiveScheme(IntPtr.Zero, out pActiveSchemeGuid);
|
||||
Guid activeSchemeGuid = (Guid)Marshal.PtrToStructure(pActiveSchemeGuid, typeof(Guid));
|
||||
return activeSchemeGuid;
|
||||
}
|
||||
|
||||
public static int GetCPUBoost()
|
||||
{
|
||||
IntPtr AcValueIndex;
|
||||
Guid activeSchemeGuid = GetActiveScheme();
|
||||
|
||||
UInt32 value = PowerReadACValueIndex(IntPtr.Zero,
|
||||
activeSchemeGuid,
|
||||
GUID_CPU,
|
||||
GUID_BOOST, out AcValueIndex);
|
||||
|
||||
return AcValueIndex.ToInt32();
|
||||
|
||||
}
|
||||
|
||||
public static void SetCPUBoost(int boost = 0)
|
||||
{
|
||||
Guid activeSchemeGuid = GetActiveScheme();
|
||||
|
||||
var hr = PowerWriteACValueIndex(
|
||||
IntPtr.Zero,
|
||||
activeSchemeGuid,
|
||||
GUID_CPU,
|
||||
GUID_BOOST,
|
||||
boost);
|
||||
|
||||
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
static class Program
|
||||
@@ -386,6 +511,7 @@ namespace GHelper
|
||||
settingsForm = new SettingsForm();
|
||||
|
||||
settingsForm.InitGPUMode();
|
||||
settingsForm.InitBoost();
|
||||
|
||||
settingsForm.SetPerformanceMode(config.getConfig("performance_mode"));
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
|
||||
85
Settings.Designer.cs
generated
85
Settings.Designer.cs
generated
@@ -55,6 +55,7 @@
|
||||
this.button120Hz = new System.Windows.Forms.Button();
|
||||
this.button60Hz = new System.Windows.Forms.Button();
|
||||
this.checkScreen = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoost = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBattery)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBattery)).BeginInit();
|
||||
this.tableGPU.SuspendLayout();
|
||||
@@ -69,7 +70,7 @@
|
||||
//
|
||||
this.checkStartup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.checkStartup.AutoSize = true;
|
||||
this.checkStartup.Location = new System.Drawing.Point(34, 836);
|
||||
this.checkStartup.Location = new System.Drawing.Point(34, 852);
|
||||
this.checkStartup.Name = "checkStartup";
|
||||
this.checkStartup.Size = new System.Drawing.Size(206, 36);
|
||||
this.checkStartup.TabIndex = 2;
|
||||
@@ -82,11 +83,11 @@
|
||||
this.trackBattery.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.trackBattery.LargeChange = 20;
|
||||
this.trackBattery.Location = new System.Drawing.Point(23, 744);
|
||||
this.trackBattery.Location = new System.Drawing.Point(23, 766);
|
||||
this.trackBattery.Maximum = 100;
|
||||
this.trackBattery.Minimum = 50;
|
||||
this.trackBattery.Name = "trackBattery";
|
||||
this.trackBattery.Size = new System.Drawing.Size(651, 90);
|
||||
this.trackBattery.Size = new System.Drawing.Size(672, 90);
|
||||
this.trackBattery.SmallChange = 10;
|
||||
this.trackBattery.TabIndex = 3;
|
||||
this.trackBattery.TickFrequency = 10;
|
||||
@@ -97,7 +98,7 @@
|
||||
//
|
||||
this.labelBattery.AutoSize = true;
|
||||
this.labelBattery.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelBattery.Location = new System.Drawing.Point(83, 701);
|
||||
this.labelBattery.Location = new System.Drawing.Point(83, 723);
|
||||
this.labelBattery.Name = "labelBattery";
|
||||
this.labelBattery.Size = new System.Drawing.Size(248, 32);
|
||||
this.labelBattery.TabIndex = 4;
|
||||
@@ -107,7 +108,7 @@
|
||||
//
|
||||
this.labelBatteryLimit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelBatteryLimit.AutoSize = true;
|
||||
this.labelBatteryLimit.Location = new System.Drawing.Point(596, 699);
|
||||
this.labelBatteryLimit.Location = new System.Drawing.Point(617, 721);
|
||||
this.labelBatteryLimit.Name = "labelBatteryLimit";
|
||||
this.labelBatteryLimit.Size = new System.Drawing.Size(73, 32);
|
||||
this.labelBatteryLimit.TabIndex = 5;
|
||||
@@ -115,8 +116,9 @@
|
||||
//
|
||||
// pictureBattery
|
||||
//
|
||||
this.pictureBattery.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.pictureBattery.Image = global::GHelper.Properties.Resources.icons8_charging_battery_48;
|
||||
this.pictureBattery.Location = new System.Drawing.Point(32, 693);
|
||||
this.pictureBattery.Location = new System.Drawing.Point(32, 715);
|
||||
this.pictureBattery.Name = "pictureBattery";
|
||||
this.pictureBattery.Size = new System.Drawing.Size(48, 48);
|
||||
this.pictureBattery.TabIndex = 6;
|
||||
@@ -126,7 +128,7 @@
|
||||
//
|
||||
this.labelGPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelGPUFan.AutoSize = true;
|
||||
this.labelGPUFan.Location = new System.Drawing.Point(515, 234);
|
||||
this.labelGPUFan.Location = new System.Drawing.Point(536, 260);
|
||||
this.labelGPUFan.Name = "labelGPUFan";
|
||||
this.labelGPUFan.Size = new System.Drawing.Size(155, 32);
|
||||
this.labelGPUFan.TabIndex = 8;
|
||||
@@ -143,11 +145,11 @@
|
||||
this.tableGPU.Controls.Add(this.buttonUltimate, 2, 0);
|
||||
this.tableGPU.Controls.Add(this.buttonStandard, 1, 0);
|
||||
this.tableGPU.Controls.Add(this.buttonEco, 0, 0);
|
||||
this.tableGPU.Location = new System.Drawing.Point(23, 276);
|
||||
this.tableGPU.Location = new System.Drawing.Point(23, 302);
|
||||
this.tableGPU.Name = "tableGPU";
|
||||
this.tableGPU.RowCount = 1;
|
||||
this.tableGPU.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
|
||||
this.tableGPU.Size = new System.Drawing.Size(651, 106);
|
||||
this.tableGPU.Size = new System.Drawing.Size(672, 106);
|
||||
this.tableGPU.TabIndex = 7;
|
||||
//
|
||||
// buttonUltimate
|
||||
@@ -156,10 +158,10 @@
|
||||
this.buttonUltimate.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.buttonUltimate.FlatAppearance.BorderSize = 0;
|
||||
this.buttonUltimate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.buttonUltimate.Location = new System.Drawing.Point(444, 10);
|
||||
this.buttonUltimate.Location = new System.Drawing.Point(458, 10);
|
||||
this.buttonUltimate.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.buttonUltimate.Name = "buttonUltimate";
|
||||
this.buttonUltimate.Size = new System.Drawing.Size(197, 86);
|
||||
this.buttonUltimate.Size = new System.Drawing.Size(204, 86);
|
||||
this.buttonUltimate.TabIndex = 2;
|
||||
this.buttonUltimate.Text = "Ultimate";
|
||||
this.buttonUltimate.UseVisualStyleBackColor = false;
|
||||
@@ -170,10 +172,10 @@
|
||||
this.buttonStandard.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.buttonStandard.FlatAppearance.BorderSize = 0;
|
||||
this.buttonStandard.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.buttonStandard.Location = new System.Drawing.Point(227, 10);
|
||||
this.buttonStandard.Location = new System.Drawing.Point(234, 10);
|
||||
this.buttonStandard.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.buttonStandard.Name = "buttonStandard";
|
||||
this.buttonStandard.Size = new System.Drawing.Size(197, 86);
|
||||
this.buttonStandard.Size = new System.Drawing.Size(204, 86);
|
||||
this.buttonStandard.TabIndex = 1;
|
||||
this.buttonStandard.Text = "Standard";
|
||||
this.buttonStandard.UseVisualStyleBackColor = false;
|
||||
@@ -188,7 +190,7 @@
|
||||
this.buttonEco.Location = new System.Drawing.Point(10, 10);
|
||||
this.buttonEco.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.buttonEco.Name = "buttonEco";
|
||||
this.buttonEco.Size = new System.Drawing.Size(197, 86);
|
||||
this.buttonEco.Size = new System.Drawing.Size(204, 86);
|
||||
this.buttonEco.TabIndex = 0;
|
||||
this.buttonEco.Text = "Eco";
|
||||
this.buttonEco.UseVisualStyleBackColor = false;
|
||||
@@ -197,7 +199,7 @@
|
||||
//
|
||||
this.labelGPU.AutoSize = true;
|
||||
this.labelGPU.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelGPU.Location = new System.Drawing.Point(82, 234);
|
||||
this.labelGPU.Location = new System.Drawing.Point(82, 260);
|
||||
this.labelGPU.Name = "labelGPU";
|
||||
this.labelGPU.Size = new System.Drawing.Size(136, 32);
|
||||
this.labelGPU.TabIndex = 9;
|
||||
@@ -205,8 +207,9 @@
|
||||
//
|
||||
// pictureGPU
|
||||
//
|
||||
this.pictureGPU.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.pictureGPU.Image = global::GHelper.Properties.Resources.icons8_video_card_48;
|
||||
this.pictureGPU.Location = new System.Drawing.Point(32, 226);
|
||||
this.pictureGPU.Location = new System.Drawing.Point(32, 252);
|
||||
this.pictureGPU.Name = "pictureGPU";
|
||||
this.pictureGPU.Size = new System.Drawing.Size(48, 48);
|
||||
this.pictureGPU.TabIndex = 10;
|
||||
@@ -216,7 +219,7 @@
|
||||
//
|
||||
this.labelCPUFan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelCPUFan.AutoSize = true;
|
||||
this.labelCPUFan.Location = new System.Drawing.Point(517, 39);
|
||||
this.labelCPUFan.Location = new System.Drawing.Point(538, 39);
|
||||
this.labelCPUFan.Name = "labelCPUFan";
|
||||
this.labelCPUFan.Size = new System.Drawing.Size(154, 32);
|
||||
this.labelCPUFan.TabIndex = 12;
|
||||
@@ -237,7 +240,7 @@
|
||||
this.tablePerf.Name = "tablePerf";
|
||||
this.tablePerf.RowCount = 1;
|
||||
this.tablePerf.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
|
||||
this.tablePerf.Size = new System.Drawing.Size(651, 106);
|
||||
this.tablePerf.Size = new System.Drawing.Size(672, 106);
|
||||
this.tablePerf.TabIndex = 11;
|
||||
//
|
||||
// buttonTurbo
|
||||
@@ -247,10 +250,10 @@
|
||||
this.buttonTurbo.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
|
||||
this.buttonTurbo.FlatAppearance.BorderSize = 0;
|
||||
this.buttonTurbo.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.buttonTurbo.Location = new System.Drawing.Point(444, 10);
|
||||
this.buttonTurbo.Location = new System.Drawing.Point(458, 10);
|
||||
this.buttonTurbo.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.buttonTurbo.Name = "buttonTurbo";
|
||||
this.buttonTurbo.Size = new System.Drawing.Size(197, 86);
|
||||
this.buttonTurbo.Size = new System.Drawing.Size(204, 86);
|
||||
this.buttonTurbo.TabIndex = 2;
|
||||
this.buttonTurbo.Text = "Turbo";
|
||||
this.buttonTurbo.UseVisualStyleBackColor = false;
|
||||
@@ -262,10 +265,10 @@
|
||||
this.buttonBalanced.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
|
||||
this.buttonBalanced.FlatAppearance.BorderSize = 0;
|
||||
this.buttonBalanced.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.buttonBalanced.Location = new System.Drawing.Point(227, 10);
|
||||
this.buttonBalanced.Location = new System.Drawing.Point(234, 10);
|
||||
this.buttonBalanced.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.buttonBalanced.Name = "buttonBalanced";
|
||||
this.buttonBalanced.Size = new System.Drawing.Size(197, 86);
|
||||
this.buttonBalanced.Size = new System.Drawing.Size(204, 86);
|
||||
this.buttonBalanced.TabIndex = 1;
|
||||
this.buttonBalanced.Text = "Balanced";
|
||||
this.buttonBalanced.UseVisualStyleBackColor = false;
|
||||
@@ -281,13 +284,14 @@
|
||||
this.buttonSilent.Location = new System.Drawing.Point(10, 10);
|
||||
this.buttonSilent.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.buttonSilent.Name = "buttonSilent";
|
||||
this.buttonSilent.Size = new System.Drawing.Size(197, 86);
|
||||
this.buttonSilent.Size = new System.Drawing.Size(204, 86);
|
||||
this.buttonSilent.TabIndex = 0;
|
||||
this.buttonSilent.Text = "Silent";
|
||||
this.buttonSilent.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// picturePerf
|
||||
//
|
||||
this.picturePerf.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.picturePerf.Image = global::GHelper.Properties.Resources.icons8_speed_48;
|
||||
this.picturePerf.Location = new System.Drawing.Point(32, 29);
|
||||
this.picturePerf.Name = "picturePerf";
|
||||
@@ -308,7 +312,7 @@
|
||||
// checkGPU
|
||||
//
|
||||
this.checkGPU.AutoSize = true;
|
||||
this.checkGPU.Location = new System.Drawing.Point(34, 385);
|
||||
this.checkGPU.Location = new System.Drawing.Point(34, 410);
|
||||
this.checkGPU.Name = "checkGPU";
|
||||
this.checkGPU.Size = new System.Drawing.Size(614, 36);
|
||||
this.checkGPU.TabIndex = 15;
|
||||
@@ -320,7 +324,7 @@
|
||||
//
|
||||
this.buttonQuit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonQuit.BackColor = System.Drawing.SystemColors.ButtonFace;
|
||||
this.buttonQuit.Location = new System.Drawing.Point(551, 830);
|
||||
this.buttonQuit.Location = new System.Drawing.Point(572, 846);
|
||||
this.buttonQuit.Name = "buttonQuit";
|
||||
this.buttonQuit.Size = new System.Drawing.Size(120, 46);
|
||||
this.buttonQuit.TabIndex = 16;
|
||||
@@ -329,8 +333,9 @@
|
||||
//
|
||||
// pictureScreen
|
||||
//
|
||||
this.pictureScreen.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.pictureScreen.Image = global::GHelper.Properties.Resources.icons8_laptop_48;
|
||||
this.pictureScreen.Location = new System.Drawing.Point(32, 463);
|
||||
this.pictureScreen.Location = new System.Drawing.Point(32, 485);
|
||||
this.pictureScreen.Name = "pictureScreen";
|
||||
this.pictureScreen.Size = new System.Drawing.Size(48, 48);
|
||||
this.pictureScreen.TabIndex = 18;
|
||||
@@ -340,7 +345,7 @@
|
||||
//
|
||||
this.labelSreen.AutoSize = true;
|
||||
this.labelSreen.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||
this.labelSreen.Location = new System.Drawing.Point(82, 471);
|
||||
this.labelSreen.Location = new System.Drawing.Point(82, 493);
|
||||
this.labelSreen.Name = "labelSreen";
|
||||
this.labelSreen.Size = new System.Drawing.Size(176, 32);
|
||||
this.labelSreen.TabIndex = 17;
|
||||
@@ -356,11 +361,11 @@
|
||||
this.tableScreen.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
|
||||
this.tableScreen.Controls.Add(this.button120Hz, 1, 0);
|
||||
this.tableScreen.Controls.Add(this.button60Hz, 0, 0);
|
||||
this.tableScreen.Location = new System.Drawing.Point(23, 513);
|
||||
this.tableScreen.Location = new System.Drawing.Point(23, 535);
|
||||
this.tableScreen.Name = "tableScreen";
|
||||
this.tableScreen.RowCount = 1;
|
||||
this.tableScreen.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 106F));
|
||||
this.tableScreen.Size = new System.Drawing.Size(651, 103);
|
||||
this.tableScreen.Size = new System.Drawing.Size(672, 103);
|
||||
this.tableScreen.TabIndex = 19;
|
||||
//
|
||||
// button120Hz
|
||||
@@ -370,10 +375,10 @@
|
||||
this.button120Hz.FlatAppearance.BorderColor = System.Drawing.SystemColors.ActiveBorder;
|
||||
this.button120Hz.FlatAppearance.BorderSize = 0;
|
||||
this.button120Hz.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.button120Hz.Location = new System.Drawing.Point(227, 10);
|
||||
this.button120Hz.Location = new System.Drawing.Point(234, 10);
|
||||
this.button120Hz.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.button120Hz.Name = "button120Hz";
|
||||
this.button120Hz.Size = new System.Drawing.Size(197, 86);
|
||||
this.button120Hz.Size = new System.Drawing.Size(204, 86);
|
||||
this.button120Hz.TabIndex = 1;
|
||||
this.button120Hz.Text = "120Hz + OD";
|
||||
this.button120Hz.UseVisualStyleBackColor = false;
|
||||
@@ -390,7 +395,7 @@
|
||||
this.button60Hz.Location = new System.Drawing.Point(10, 10);
|
||||
this.button60Hz.Margin = new System.Windows.Forms.Padding(10);
|
||||
this.button60Hz.Name = "button60Hz";
|
||||
this.button60Hz.Size = new System.Drawing.Size(197, 86);
|
||||
this.button60Hz.Size = new System.Drawing.Size(204, 86);
|
||||
this.button60Hz.TabIndex = 0;
|
||||
this.button60Hz.Text = "60Hz";
|
||||
this.button60Hz.UseVisualStyleBackColor = false;
|
||||
@@ -398,18 +403,29 @@
|
||||
// checkScreen
|
||||
//
|
||||
this.checkScreen.AutoSize = true;
|
||||
this.checkScreen.Location = new System.Drawing.Point(34, 622);
|
||||
this.checkScreen.Location = new System.Drawing.Point(34, 640);
|
||||
this.checkScreen.Name = "checkScreen";
|
||||
this.checkScreen.Size = new System.Drawing.Size(562, 36);
|
||||
this.checkScreen.TabIndex = 20;
|
||||
this.checkScreen.Text = "Switch 60Hz on battery, and back when plugged";
|
||||
this.checkScreen.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoost
|
||||
//
|
||||
this.checkBoost.AutoSize = true;
|
||||
this.checkBoost.Location = new System.Drawing.Point(34, 188);
|
||||
this.checkBoost.Name = "checkBoost";
|
||||
this.checkBoost.Size = new System.Drawing.Size(250, 36);
|
||||
this.checkBoost.TabIndex = 21;
|
||||
this.checkBoost.Text = "CPU Boost enabled";
|
||||
this.checkBoost.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(705, 900);
|
||||
this.ClientSize = new System.Drawing.Size(726, 916);
|
||||
this.Controls.Add(this.checkBoost);
|
||||
this.Controls.Add(this.checkScreen);
|
||||
this.Controls.Add(this.tableScreen);
|
||||
this.Controls.Add(this.pictureScreen);
|
||||
@@ -481,5 +497,6 @@
|
||||
private Button button120Hz;
|
||||
private Button button60Hz;
|
||||
private CheckBox checkScreen;
|
||||
private CheckBox checkBoost;
|
||||
}
|
||||
}
|
||||
31
Settings.cs
31
Settings.cs
@@ -49,6 +49,8 @@ namespace GHelper
|
||||
|
||||
buttonQuit.Click += ButtonQuit_Click;
|
||||
|
||||
checkBoost.Click += CheckBoost_Click;
|
||||
|
||||
checkScreen.CheckedChanged += checkScreen_CheckedChanged;
|
||||
|
||||
SetTimer();
|
||||
@@ -56,6 +58,15 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
private void CheckBoost_Click(object? sender, EventArgs e)
|
||||
{
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
if (chk.Checked)
|
||||
NativeMethods.SetCPUBoost(3);
|
||||
else
|
||||
NativeMethods.SetCPUBoost(0);
|
||||
}
|
||||
|
||||
private void Button120Hz_Click(object? sender, EventArgs e)
|
||||
{
|
||||
SetScreen(1000, 1);
|
||||
@@ -91,6 +102,12 @@ namespace GHelper
|
||||
}
|
||||
|
||||
|
||||
public void InitBoost()
|
||||
{
|
||||
int boost = NativeMethods.GetCPUBoost();
|
||||
checkBoost.Checked = (boost > 0);
|
||||
}
|
||||
|
||||
public void InitScreen()
|
||||
{
|
||||
|
||||
@@ -197,7 +214,7 @@ namespace GHelper
|
||||
InitScreen();
|
||||
|
||||
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
|
||||
this.Top = Screen.FromControl(this).Bounds.Height - 100 - this.Height;
|
||||
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
||||
this.Activate();
|
||||
aTimer.Enabled = true;
|
||||
}
|
||||
@@ -401,7 +418,7 @@ namespace GHelper
|
||||
break;
|
||||
case ASUSWmi.GPUModeUltimate:
|
||||
buttonUltimate.FlatAppearance.BorderSize = buttonActive;
|
||||
labelGPU.Text = "GPU Mode: Ultimate (dGPU exclusive)";
|
||||
labelGPU.Text = "GPU Mode: Ultimate (dGPU is main)";
|
||||
Program.trayIcon.Icon = GHelper.Properties.Resources.ultimate;
|
||||
break;
|
||||
default:
|
||||
@@ -413,8 +430,6 @@ namespace GHelper
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void ButtonSilent_Click(object? sender, EventArgs e)
|
||||
{
|
||||
SetPerformanceMode(ASUSWmi.PerformanceSilent);
|
||||
@@ -480,28 +495,20 @@ namespace GHelper
|
||||
{
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
if (chk.Checked)
|
||||
{
|
||||
Program.config.setConfig("gpu_auto", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.config.setConfig("gpu_auto", 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkScreen_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
if (chk.Checked)
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user