Add project files.

This commit is contained in:
seerge
2023-02-16 19:26:53 +01:00
parent 66576eaa1b
commit fae1893b5d
11 changed files with 937 additions and 0 deletions

4
.editorconfig Normal file
View File

@@ -0,0 +1,4 @@
[*.{cs,vb}]
# IDE0017: Simplify object initialization
dotnet_style_object_initializer = true

6
App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>

45
GHelper.csproj Normal file
View File

@@ -0,0 +1,45 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows10.0.22621.0</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<IsPublishable>True</IsPublishable>
<ApplicationManifest>app.manifest</ApplicationManifest>
<StartupObject>Program</StartupObject>
<ApplicationIcon>Resources\standard.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<COMReference Include="MMC20">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
<Guid>8e80422b-cac4-472b-b272-9635f1dfef3b</Guid>
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</ItemGroup>
<ItemGroup>
<Content Include="Resources\standard.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Management.Infrastructure">
<HintPath>..\..\.nuget\packages\microsoft.management.infrastructure\2.0.0\ref\net451\Microsoft.Management.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Management.Infrastructure.Native">
<HintPath>..\..\.nuget\packages\microsoft.management.infrastructure.runtime.win\2.0.0\runtimes\win10-x64\lib\netstandard1.6\Microsoft.Management.Infrastructure.Native.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

30
GHelper.sln Normal file
View File

@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33403.182
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GHelper", "GHelper.csproj", "{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B6E44CC6-5D28-4CB9-8EE2-BE9D6238E2D6}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6138BB1-8FDB-4835-87EF-2FE41A3DD604}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B1BF5148-497A-4B5A-B079-5C00CD047DAF}
EndGlobalSection
EndGlobal

221
Program.cs Normal file
View File

@@ -0,0 +1,221 @@
using System;
using System.Windows.Forms;
using System.Text.Json;
using System.Management;
using Microsoft.Win32.TaskScheduler;
using System.Diagnostics;
using System.Reflection.Emit;
using System.Runtime.InteropServices;
using System.Reflection;
using System.Diagnostics;
using GHelper;
using System.Dynamic;
public class ASUSWmi
{
private ManagementObject mo;
private ManagementClass classInstance;
public const int CPU_Fan = 0x00110013;
public const int GPU_Fan = 0x00110014;
public const int PerformanceMode = 0x00120075;
public const int GPUEco = 0x00090020;
public const int GPUMux = 0x00090016;
public const int PerformanceBalanced = 0;
public const int PerformanceTurbo = 1;
public const int PerformanceSilent = 2;
public const int GPUModeEco = 0;
public const int GPUModeStandard = 1;
public const int GPUModeUltimate = 2;
public ASUSWmi()
{
this.classInstance = new ManagementClass(new ManagementScope("root\\wmi"), new ManagementPath("AsusAtkWmi_WMNB"), null);
foreach (ManagementObject mo in this.classInstance.GetInstances())
{
this.mo = mo;
}
}
private int WMICall(string MethodName, int Device_Id, int Control_status = -1)
{
ManagementBaseObject inParams = this.classInstance.Methods[MethodName].InParameters;
inParams["Device_ID"] = Device_Id;
if (Control_status != -1)
{
inParams["Control_status"] = Control_status;
}
ManagementBaseObject outParams = this.mo.InvokeMethod(MethodName, inParams, null);
foreach (PropertyData property in outParams.Properties)
{
if (property.Name == "device_status") return int.Parse(property.Value.ToString()) - 65536;
if (property.Name == "result") return int.Parse(property.Value.ToString());
}
return -1;
}
public int DeviceGet(int Device_Id)
{
return this.WMICall("DSTS", Device_Id);
}
public int DeviceSet(int Device_Id, int Control_status)
{
return this.WMICall("DEVS", Device_Id, Control_status);
}
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
{
ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.EventArrived += new EventArrivedEventHandler(EventHandler);
watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
}
}
static class Program
{
static NotifyIcon trayIcon;
public static ASUSWmi wmi;
public static dynamic config = new System.Dynamic.ExpandoObject();
public static SettingsForm settingsForm;
// The main entry point for the application
public static void Main()
{
trayIcon = new NotifyIcon
{
Text = "G14 Helper",
Icon = new System.Drawing.Icon("Resources/standard.ico"),
Visible = true
};
trayIcon.MouseClick += TrayIcon_MouseClick; ;
wmi = new ASUSWmi();
wmi.SubscribeToEvents(WatcherEventArrived);
settingsForm = new SettingsForm();
//settingsForm.Show();
int GpuMode = GetGPUMode();
settingsForm.SetPerformanceMode();
settingsForm.VisualiseGPUMode(GpuMode);
settingsForm.FormClosed += SettingsForm_FormClosed;
config.PerformanceMode = 0;
Application.Run();
}
public static int GetGPUMode ()
{
int eco = wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = wmi.DeviceGet(ASUSWmi.GPUMux);
int GpuMode;
if (mux == 0)
{
GpuMode = ASUSWmi.GPUModeUltimate;
}
else
{
if (eco == 1)
{
GpuMode = ASUSWmi.GPUModeEco;
}
else
{
GpuMode = ASUSWmi.GPUModeStandard;
}
if (mux != 1)
{
settingsForm.Disable_Ultimate();
}
}
config.gpu_mode = GpuMode;
return GpuMode;
}
private static void SettingsForm_FormClosed(object? sender, FormClosedEventArgs e)
{
trayIcon.Visible = false;
Application.Exit();
}
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
{
var collection = (ManagementEventWatcher)sender;
int EventID = int.Parse(e.NewEvent["EventID"].ToString());
Debug.WriteLine(EventID);
switch (EventID)
{
case 56:
case 174:
CyclePerformanceMode();
return;
}
}
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (settingsForm.Visible)
{
settingsForm.Hide();
} else
{
settingsForm.Show();
settingsForm.Activate();
}
}
}
static void CyclePerformanceMode()
{
settingsForm.BeginInvoke(delegate
{
settingsForm.SetPerformanceMode(config.PerformanceMode + 1);
});
}
static void OnExit(object sender, EventArgs e)
{
trayIcon.Visible = false;
Application.Exit();
}
}

View File

@@ -0,0 +1,8 @@
{
"profiles": {
"GHelper": {
"commandName": "Project",
"workingDirectory": "C:\\Users\\serge\\source\\GHelper"
}
}
}

BIN
Resources/standard.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

250
Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,250 @@
namespace GHelper
{
partial class SettingsForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupPerf = new System.Windows.Forms.GroupBox();
this.labelCPUFan = new System.Windows.Forms.Label();
this.tablePerf = new System.Windows.Forms.TableLayoutPanel();
this.buttonTurbo = new System.Windows.Forms.Button();
this.buttonBalanced = new System.Windows.Forms.Button();
this.buttonSilent = new System.Windows.Forms.Button();
this.groupGPU = new System.Windows.Forms.GroupBox();
this.labelGPUFan = new System.Windows.Forms.Label();
this.tableGPU = new System.Windows.Forms.TableLayoutPanel();
this.buttonUltimate = new System.Windows.Forms.Button();
this.buttonStandard = new System.Windows.Forms.Button();
this.buttonEco = new System.Windows.Forms.Button();
this.groupPerf.SuspendLayout();
this.tablePerf.SuspendLayout();
this.groupGPU.SuspendLayout();
this.tableGPU.SuspendLayout();
this.SuspendLayout();
//
// groupPerf
//
this.groupPerf.Controls.Add(this.labelCPUFan);
this.groupPerf.Controls.Add(this.tablePerf);
this.groupPerf.Dock = System.Windows.Forms.DockStyle.Top;
this.groupPerf.Location = new System.Drawing.Point(10, 10);
this.groupPerf.Margin = new System.Windows.Forms.Padding(10);
this.groupPerf.Name = "groupPerf";
this.groupPerf.Padding = new System.Windows.Forms.Padding(10);
this.groupPerf.Size = new System.Drawing.Size(666, 188);
this.groupPerf.TabIndex = 0;
this.groupPerf.TabStop = false;
this.groupPerf.Text = "Performance Mode";
//
// labelCPUFan
//
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(491, 28);
this.labelCPUFan.Name = "labelCPUFan";
this.labelCPUFan.Size = new System.Drawing.Size(154, 32);
this.labelCPUFan.TabIndex = 2;
this.labelCPUFan.Text = "CPU Fan : 0%";
//
// tablePerf
//
this.tablePerf.ColumnCount = 3;
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tablePerf.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tablePerf.Controls.Add(this.buttonTurbo, 2, 0);
this.tablePerf.Controls.Add(this.buttonBalanced, 1, 0);
this.tablePerf.Controls.Add(this.buttonSilent, 0, 0);
this.tablePerf.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tablePerf.Location = new System.Drawing.Point(10, 72);
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(646, 106);
this.tablePerf.TabIndex = 0;
//
// buttonTurbo
//
this.buttonTurbo.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonTurbo.FlatAppearance.BorderSize = 0;
this.buttonTurbo.Location = new System.Drawing.Point(440, 10);
this.buttonTurbo.Margin = new System.Windows.Forms.Padding(10);
this.buttonTurbo.Name = "buttonTurbo";
this.buttonTurbo.Size = new System.Drawing.Size(196, 86);
this.buttonTurbo.TabIndex = 2;
this.buttonTurbo.Text = "Turbo";
this.buttonTurbo.UseVisualStyleBackColor = true;
//
// buttonBalanced
//
this.buttonBalanced.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.buttonBalanced.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonBalanced.FlatAppearance.BorderSize = 0;
this.buttonBalanced.Location = new System.Drawing.Point(225, 10);
this.buttonBalanced.Margin = new System.Windows.Forms.Padding(10);
this.buttonBalanced.Name = "buttonBalanced";
this.buttonBalanced.Size = new System.Drawing.Size(195, 86);
this.buttonBalanced.TabIndex = 1;
this.buttonBalanced.Text = "Balanced";
this.buttonBalanced.UseVisualStyleBackColor = false;
//
// buttonSilent
//
this.buttonSilent.CausesValidation = false;
this.buttonSilent.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonSilent.FlatAppearance.BorderSize = 0;
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(195, 86);
this.buttonSilent.TabIndex = 0;
this.buttonSilent.Text = "Silent";
this.buttonSilent.UseVisualStyleBackColor = true;
//
// groupGPU
//
this.groupGPU.Controls.Add(this.labelGPUFan);
this.groupGPU.Controls.Add(this.tableGPU);
this.groupGPU.Dock = System.Windows.Forms.DockStyle.Top;
this.groupGPU.Location = new System.Drawing.Point(10, 198);
this.groupGPU.Margin = new System.Windows.Forms.Padding(10);
this.groupGPU.Name = "groupGPU";
this.groupGPU.Padding = new System.Windows.Forms.Padding(10);
this.groupGPU.Size = new System.Drawing.Size(666, 188);
this.groupGPU.TabIndex = 1;
this.groupGPU.TabStop = false;
this.groupGPU.Text = "GPU Mode";
//
// labelGPUFan
//
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(491, 33);
this.labelGPUFan.Name = "labelGPUFan";
this.labelGPUFan.Size = new System.Drawing.Size(155, 32);
this.labelGPUFan.TabIndex = 3;
this.labelGPUFan.Text = "GPU Fan : 0%";
//
// tableGPU
//
this.tableGPU.ColumnCount = 3;
this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableGPU.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
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.Dock = System.Windows.Forms.DockStyle.Bottom;
this.tableGPU.Location = new System.Drawing.Point(10, 72);
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(646, 106);
this.tableGPU.TabIndex = 0;
//
// buttonUltimate
//
this.buttonUltimate.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonUltimate.FlatAppearance.BorderSize = 0;
this.buttonUltimate.Location = new System.Drawing.Point(440, 10);
this.buttonUltimate.Margin = new System.Windows.Forms.Padding(10);
this.buttonUltimate.Name = "buttonUltimate";
this.buttonUltimate.Size = new System.Drawing.Size(196, 86);
this.buttonUltimate.TabIndex = 2;
this.buttonUltimate.Text = "Ultimate";
this.buttonUltimate.UseVisualStyleBackColor = true;
//
// buttonStandard
//
this.buttonStandard.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.buttonStandard.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonStandard.FlatAppearance.BorderSize = 0;
this.buttonStandard.Location = new System.Drawing.Point(225, 10);
this.buttonStandard.Margin = new System.Windows.Forms.Padding(10);
this.buttonStandard.Name = "buttonStandard";
this.buttonStandard.Size = new System.Drawing.Size(195, 86);
this.buttonStandard.TabIndex = 1;
this.buttonStandard.Text = "Standard";
this.buttonStandard.UseVisualStyleBackColor = false;
//
// buttonEco
//
this.buttonEco.CausesValidation = false;
this.buttonEco.Dock = System.Windows.Forms.DockStyle.Fill;
this.buttonEco.FlatAppearance.BorderSize = 0;
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(195, 86);
this.buttonEco.TabIndex = 0;
this.buttonEco.Text = "Eco";
this.buttonEco.UseVisualStyleBackColor = true;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(686, 636);
this.Controls.Add(this.groupGPU);
this.Controls.Add(this.groupPerf);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MdiChildrenMinimizedAnchorBottom = false;
this.MinimizeBox = false;
this.Name = "SettingsForm";
this.Padding = new System.Windows.Forms.Padding(10);
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "G14 Helper";
this.Load += new System.EventHandler(this.Settings_Load);
this.groupPerf.ResumeLayout(false);
this.groupPerf.PerformLayout();
this.tablePerf.ResumeLayout(false);
this.groupGPU.ResumeLayout(false);
this.groupGPU.PerformLayout();
this.tableGPU.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private GroupBox groupPerf;
private TableLayoutPanel tablePerf;
private Button buttonSilent;
private Button buttonTurbo;
private Button buttonBalanced;
private GroupBox groupGPU;
private TableLayoutPanel tableGPU;
private Button buttonUltimate;
private Button buttonStandard;
private Button buttonEco;
private Label labelCPUFan;
private Label labelGPUFan;
}
}

237
Settings.cs Normal file
View File

@@ -0,0 +1,237 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Dynamic;
using System.Linq;
using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;
using Windows.ApplicationModel.Store;
namespace GHelper
{
public partial class SettingsForm : Form
{
static Color colorActive = Color.LightGray;
static System.Timers.Timer aTimer;
public SettingsForm()
{
InitializeComponent();
buttonSilent.Click += ButtonSilent_Click;
buttonBalanced.Click += ButtonBalanced_Click;
buttonTurbo.Click += ButtonTurbo_Click;
buttonEco.Click += ButtonEco_Click;
buttonStandard.Click += ButtonStandard_Click;
buttonUltimate.Click += ButtonUltimate_Click;
VisibleChanged += SettingsForm_VisibleChanged;
SetTimer();
}
private void ButtonUltimate_Click(object? sender, EventArgs e)
{
SetGPUMode(ASUSWmi.GPUModeUltimate);
}
private void ButtonStandard_Click(object? sender, EventArgs e)
{
SetGPUMode(ASUSWmi.GPUModeStandard);
}
private void ButtonEco_Click(object? sender, EventArgs e)
{
SetGPUMode(ASUSWmi.GPUModeEco);
}
private static void SetTimer()
{
aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
}
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
var cpuFan = Math.Round(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)/0.6);
var gpuFan = Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan)/0.6);
Program.settingsForm.BeginInvoke(delegate
{
Program.settingsForm.labelCPUFan.Text = "CPU Fan: " + cpuFan.ToString() + "%";
Program.settingsForm.labelGPUFan.Text = "GPU Fan: " + gpuFan.ToString() + "%";
});
}
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
{
if (this.Visible)
{
this.Left = Screen.FromControl(this).Bounds.Width - 10 - this.Width;
this.Top = Screen.FromControl(this).Bounds.Height - 100 - this.Height;
this.Activate();
aTimer.Enabled = true;
} else
{
aTimer.Enabled = false;
}
}
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced)
{
buttonSilent.UseVisualStyleBackColor = true;
buttonBalanced.UseVisualStyleBackColor = true;
buttonTurbo.UseVisualStyleBackColor = true;
switch (PerformanceMode)
{
case ASUSWmi.PerformanceSilent:
buttonSilent.BackColor = colorActive;
groupPerf.Text = "Peformance Mode: Silent";
break;
case ASUSWmi.PerformanceTurbo:
buttonTurbo.BackColor = colorActive;
groupPerf.Text = "Peformance Mode: Turbo";
break;
default:
buttonBalanced.BackColor = colorActive;
groupPerf.Text = "Peformance Mode: Balanced";
PerformanceMode = ASUSWmi.PerformanceBalanced;
break;
}
Program.config.PerformanceMode = PerformanceMode;
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
}
public void SetGPUMode(int GPUMode = ASUSWmi.GPUModeStandard)
{
int CurrentGPU = ASUSWmi.GPUModeStandard;
if (((IDictionary<String, object>) Program.config).ContainsKey("gpu_mode")) {
CurrentGPU = Program.config.gpu_mode;
}
if (CurrentGPU == GPUMode) { return; }
var restart = false;
var changed = false;
if (CurrentGPU == ASUSWmi.GPUModeUltimate)
{
DialogResult dialogResult = MessageBox.Show("Switching off Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 1);
restart = true;
changed = true;
}
} else if (GPUMode == ASUSWmi.GPUModeUltimate)
{
DialogResult dialogResult = MessageBox.Show(" Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 0);
restart = true;
changed = true;
}
} else if (GPUMode == ASUSWmi.GPUModeEco)
{
VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
changed = true;
} else if (GPUMode == ASUSWmi.GPUModeStandard)
{
VisualiseGPUMode(GPUMode);
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
changed = true;
}
if (changed)
{
Program.config.gpu_mode = GPUMode;
}
if (restart)
{
VisualiseGPUMode(GPUMode);
Process.Start("shutdown", "/r /t 1");
}
}
public void VisualiseGPUMode (int GPUMode)
{
buttonEco.UseVisualStyleBackColor = true;
buttonStandard.UseVisualStyleBackColor = true;
buttonUltimate.UseVisualStyleBackColor = true;
switch (GPUMode)
{
case ASUSWmi.GPUModeEco:
buttonEco.BackColor = colorActive;
groupGPU.Text = "GPU Mode: Eco (iGPU only)";
break;
case ASUSWmi.GPUModeUltimate:
buttonUltimate.BackColor = colorActive;
groupGPU.Text = "GPU Mode: Ultimate (dGPU exclusive)";
break;
default:
buttonStandard.BackColor = colorActive;
groupGPU.Text = "GPU Mode: Eco (iGPU and dGPU)";
break;
}
}
private void ButtonSilent_Click(object? sender, EventArgs e)
{
SetPerformanceMode(ASUSWmi.PerformanceSilent);
}
private void ButtonBalanced_Click(object? sender, EventArgs e)
{
SetPerformanceMode(ASUSWmi.PerformanceBalanced);
}
private void ButtonTurbo_Click(object? sender, EventArgs e)
{
SetPerformanceMode(ASUSWmi.PerformanceTurbo);
}
private void Settings_Load(object sender, EventArgs e)
{
}
public void Disable_Ultimate()
{
buttonUltimate.Enabled= false;
}
}
}

60
Settings.resx Normal file
View File

@@ -0,0 +1,60 @@
<root>
<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:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

76
app.manifest Normal file
View File

@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>