Compare commits

...

102 Commits
v0.34 ... v0.49

Author SHA1 Message Date
seerge
602dfea1a6 - 2023-04-09 12:26:38 +02:00
seerge
c13a6e9ded Custom keybinds for performance modes 2023-04-09 12:14:47 +02:00
seerge
e11027963f UI tweaks 2023-04-08 13:45:27 +02:00
seerge
9d2b8b506e Merge branch 'main' of https://github.com/seerge/g-helper 2023-04-07 13:37:02 +02:00
seerge
988c9e11dd Theme change fix 2023-04-07 13:37:00 +02:00
Serge
2c6bb32e4a Update README.md 2023-04-07 12:10:19 +02:00
Serge
e33a0d05ed Update README.md 2023-04-07 12:06:11 +02:00
Serge
1c283766aa Update README.md 2023-04-06 23:41:08 +02:00
Serge
f2ef6d197f Update README.md 2023-04-06 14:31:51 +02:00
seerge
13ec0f8911 GPU use simplified for now 2023-04-06 12:19:32 +02:00
seerge
fcf213f1a0 - 2023-04-06 00:02:17 +02:00
seerge
c73b4fce97 Added NVidia GPU usage 2023-04-05 20:25:05 +02:00
seerge
aab1e08729 IsUsedGPU fix 2023-04-05 19:59:10 +02:00
seerge
cf3a84aa3d Added GPU usage check 2023-04-05 19:33:53 +02:00
seerge
8d119b386d - 2023-04-05 13:02:02 +02:00
seerge
0605e63433 UI tweaks 2023-04-04 16:36:26 +02:00
seerge
4634404ed4 Fans + power ui simplification 2023-04-03 21:17:16 +02:00
seerge
dcfaf665cd Force GPU mode 2023-04-02 22:50:13 +02:00
seerge
15e791cbfd Merge branch 'main' of https://github.com/seerge/g-helper 2023-04-02 11:57:01 +02:00
seerge
5d86c821f6 Minor fixes 2023-04-02 11:56:59 +02:00
Serge
e5de404e5c Update README.md 2023-04-01 17:48:46 +02:00
Serge
13aa98e954 Update README.md 2023-04-01 17:40:36 +02:00
seerge
75c397d7a4 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-31 23:08:06 +02:00
seerge
0ad8efdb7d GPU temp reading 2023-03-31 23:08:04 +02:00
Serge
2064f29433 Update README.md 2023-03-31 23:07:43 +02:00
seerge
890c50d90e Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-31 20:05:16 +02:00
seerge
bd207113f8 Fix for possible fan issues on old laptops 2023-03-31 20:05:14 +02:00
Serge
650a5ff5c0 Update bug_report.md 2023-03-31 17:29:57 +02:00
Serge
01ce91a474 Update bug_report.md 2023-03-31 15:58:28 +02:00
seerge
253e1eb095 Added Strix/Scar built in aura modes 2023-03-31 13:50:10 +02:00
seerge
b95768d547 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-31 11:45:48 +02:00
seerge
dfbfd16d23 Clock fix 2023-03-31 11:45:46 +02:00
Serge
3eeac0353a Update README.md 2023-03-30 22:03:21 +02:00
Serge
5e7c9a4191 Update README.md 2023-03-30 21:56:59 +02:00
seerge
ee84ba6304 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-30 21:10:36 +02:00
seerge
d15c6cb073 Improved logging 2023-03-30 21:10:35 +02:00
Serge
1e683a0884 Update README.md 2023-03-30 15:00:04 +02:00
Serge
1ad48bf763 Update README.md 2023-03-30 13:54:53 +02:00
Serge
dcc052a574 Update README.md 2023-03-30 13:54:40 +02:00
Serge
38fca560df Update README.md 2023-03-30 12:14:29 +02:00
seerge
7e0459bd44 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-30 11:57:13 +02:00
seerge
228ad70b8d UI tweaks 2023-03-30 11:57:11 +02:00
Serge
b42e565cd6 Update README.md 2023-03-30 11:53:54 +02:00
Serge
e021d59737 Update README.md 2023-03-30 11:20:50 +02:00
Serge
dba7967ad5 Update README.md 2023-03-30 11:12:24 +02:00
seerge
a7a7170676 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-30 00:00:22 +02:00
seerge
1d43ca3ce4 Max fan RPM auto calibration 2023-03-30 00:00:20 +02:00
Serge
ff7618f16f Update README.md 2023-03-29 23:33:14 +02:00
seerge
bb947bf8bf Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 23:32:14 +02:00
seerge
63092d8415 Removed unsupported aura modes for some models 2023-03-29 23:32:12 +02:00
Serge
6fbce2f495 Update README.md 2023-03-29 21:06:36 +02:00
seerge
8d89a04608 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 17:51:28 +02:00
seerge
0cbc48d526 Added old cpu temp reading as fallback 2023-03-29 17:51:25 +02:00
Serge
81013ca0be Update README.md 2023-03-29 17:32:07 +02:00
seerge
af2509fc17 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 17:04:24 +02:00
seerge
136b5b4f55 Added native temp sensors, brightness controll, etc 2023-03-29 17:04:22 +02:00
Serge
4e2abff942 Update README.md 2023-03-29 13:58:03 +02:00
Serge
2c8a11fc24 Update README.md 2023-03-29 12:26:19 +02:00
seerge
8af8823ee4 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 12:19:02 +02:00
seerge
ec0a1b710e New slider 2023-03-29 12:19:00 +02:00
Serge
2ac2e84161 Update README.md 2023-03-28 22:09:06 +02:00
seerge
14dc1741f7 New battery slider 2023-03-28 20:11:30 +02:00
seerge
fbed195194 - 2023-03-28 16:35:20 +02:00
seerge
0d002edf65 Animatrix fix for 2020/2021 models 2023-03-28 16:05:24 +02:00
seerge
28a17562a8 CPU boost per mode 2023-03-28 14:19:51 +02:00
seerge
583cb677d0 Added option to disable screen overdrive 2023-03-27 15:21:52 +02:00
seerge
1888fe7bd9 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-27 14:28:31 +02:00
seerge
089b339e61 Minor tweaks 2023-03-27 14:28:28 +02:00
Serge
cab4a04339 Update README.md 2023-03-27 13:02:14 +02:00
seerge
7ab3b450cd Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-26 19:31:43 +02:00
seerge
ea2dc7b75d Animatrix tweaks 2023-03-26 19:31:41 +02:00
Serge
ccd69a8628 Update README.md 2023-03-26 14:40:12 +02:00
Serge
c1d23159a0 Update debloat.bat 2023-03-26 14:17:53 +02:00
Serge
1c865624e6 Update debloat.bat 2023-03-26 14:06:13 +02:00
seerge
4853c09c2c Added model name, and custom fan+ in profile names 2023-03-25 20:28:27 +01:00
seerge
08704d6826 Added sleep/awake/boot/shutdown control for keyboards 2023-03-25 16:21:47 +01:00
seerge
6edbcf5ecd Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-25 14:37:40 +01:00
seerge
7702dc8e38 Support for TUF RGB keyboards and other fixes 2023-03-25 14:37:37 +01:00
Serge
94391358ef Update README.md 2023-03-25 09:49:48 +01:00
Serge
feecd193ac Update README.md 2023-03-25 01:14:34 +01:00
Serge
444f7c76f0 Update README.md 2023-03-24 21:19:14 +01:00
Serge
701423fa0e Update README.md 2023-03-24 17:29:29 +01:00
Serge
7b3a6d319b Update README.md 2023-03-24 12:52:14 +01:00
seerge
8bc9325b3f Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-24 11:20:51 +01:00
seerge
64195c5082 Prevent multiple auto-applies when windows calls power event too often 2023-03-24 11:20:48 +01:00
Serge
2297532323 Update README.md 2023-03-23 22:17:47 +01:00
Serge
daac8b0a45 Update README.md 2023-03-23 22:16:25 +01:00
Serge
f061e3f43a Update README.md 2023-03-23 22:14:29 +01:00
seerge
85e02549f1 Update checker fixes 2023-03-23 20:04:25 +01:00
seerge
9053764930 Speedup update checker 2023-03-23 13:26:09 +01:00
seerge
64871e5554 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-23 00:38:06 +01:00
seerge
b1c778b30d Minor tweaks 2023-03-23 00:38:03 +01:00
Serge
6932bb1889 Update README.md 2023-03-22 17:55:10 +01:00
seerge
c90a342ce8 Fixed possible memory leack with clock ticks 2023-03-22 17:28:09 +01:00
seerge
f223ca4a33 Added informational toolip 2023-03-22 17:15:20 +01:00
seerge
023607da4b Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-22 14:38:04 +01:00
seerge
264631ab77 Added animatrix Clock 2023-03-22 14:38:01 +01:00
Serge
1bd5d79983 Update README.md 2023-03-21 17:40:06 +01:00
seerge
83b184a061 - 2023-03-21 15:23:41 +01:00
seerge
9ff572b8f6 UI tweaks, mid fan support 2023-03-21 13:14:53 +01:00
seerge
cdb633be04 Anime matrix fixes 2023-03-21 11:11:31 +01:00
seerge
7cb9b1f64f Mid Fan support 2023-03-21 01:24:42 +01:00
26 changed files with 2232 additions and 961 deletions

View File

@@ -1,31 +1,40 @@
--- ---
name: Bug report name: Bug report
about: Create a report to help us improve about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
--- ---
**Describe the bug** **Describe the bug**
A clear and concise description of what the bug is. A clear and concise description of what the bug is.
**To Reproduce** **Clear scenario to Reproduce**
Steps to reproduce the behavior: Steps to reproduce the behavior:
1. Go to '...' 1. Go to '...'
2. Click on '....' 2. Click on '....'
3. Scroll down to '....' 3. Scroll down to '....'
4. See error 4. Explanation of an error or a bug
**Expected behavior** **Expected behavior**
A clear and concise description of what you expected to happen. A clear and concise description of what you expected to happen.
**Screenshots** **App Logs**
Please include and attach log.txt from ``%AppData%\GHelper``
**Screenshots or screencasts**
If applicable, add screenshots to help explain your problem. If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):** **Desktop (please complete the following information):**
- OS: [e.g. iOS] - OS: [e.g. Windows 11]
- Laptop model - Laptop model
**Asus software**
- Armoury crate (or it's services installed)
- MyASUS installed
- Other Asus services running in background
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.
## NOTE
Bug reports without clear information or scenario to reproduce will be closed without answer.
Please respect time of the developer. Thanks.

View File

@@ -10,12 +10,19 @@ public class ASUSWmi
const uint DSTS = 0x53545344; const uint DSTS = 0x53545344;
const uint DEVS = 0x53564544; const uint DEVS = 0x53564544;
public const uint UniversalControl = 0x00100021;
public const int KB_Light_Up = 0xc4;
public const int KB_Light_Down = 0xc5;
public const uint CPU_Fan = 0x00110013; public const uint CPU_Fan = 0x00110013;
public const uint GPU_Fan = 0x00110014; public const uint GPU_Fan = 0x00110014;
public const uint Mid_Fan = 0x00110031;
public const uint PerformanceMode = 0x00120075; // Thermal Control public const uint PerformanceMode = 0x00120075; // Thermal Control
public const uint GPUEco = 0x00090020; public const uint GPUEco = 0x00090020;
public const uint GPUXGConnected = 0x00090018;
public const uint GPUXG = 0x00090019;
public const uint GPUMux = 0x00090016; public const uint GPUMux = 0x00090016;
public const uint BatteryLimit = 0x00120057; public const uint BatteryLimit = 0x00120057;
@@ -24,6 +31,11 @@ public class ASUSWmi
public const uint DevsCPUFanCurve = 0x00110024; public const uint DevsCPUFanCurve = 0x00110024;
public const uint DevsGPUFanCurve = 0x00110025; public const uint DevsGPUFanCurve = 0x00110025;
public const uint DevsMidFanCurve = 0x00110032;
public const int Temp_CPU = 0x00120094;
public const int Temp_GPU = 0x00120097;
public const int PPT_TotalA0 = 0x001200A0; // Total PPT on 2022 and CPU PPT on 2021 public const int PPT_TotalA0 = 0x001200A0; // Total PPT on 2022 and CPU PPT on 2021
public const int PPT_EDCA1 = 0x001200A1; // CPU EDC public const int PPT_EDCA1 = 0x001200A1; // CPU EDC
@@ -36,6 +48,9 @@ public class ASUSWmi
public const int PPT_APUC1 = 0x001200C1; public const int PPT_APUC1 = 0x001200C1;
public const int PPT_APUC2 = 0x001200C2; public const int PPT_APUC2 = 0x001200C2;
public const int TUF_KB = 0x00100056;
public const int TUF_KB_STATE = 0x00100057;
public const int PerformanceBalanced = 0; public const int PerformanceBalanced = 0;
public const int PerformanceTurbo = 1; public const int PerformanceTurbo = 1;
public const int PerformanceSilent = 2; public const int PerformanceSilent = 2;
@@ -45,11 +60,11 @@ public class ASUSWmi
public const int GPUModeUltimate = 2; public const int GPUModeUltimate = 2;
public const int MaxTotal = 150; public const int MaxTotal = 200;
public const int MinTotal = 5; public const int MinTotal = 5;
public const int DefaultTotal = 125; public const int DefaultTotal = 125;
public const int MaxCPU = 90; public const int MaxCPU = 130;
public const int MinCPU = 5; public const int MinCPU = 5;
public const int DefaultCPU = 80; public const int DefaultCPU = 80;
@@ -144,21 +159,31 @@ public class ASUSWmi
} }
public void DeviceSet(uint DeviceID, int Status) public int DeviceSet(uint DeviceID, int Status, string logName)
{ {
byte[] args = new byte[8]; byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0); BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
BitConverter.GetBytes((uint)Status).CopyTo(args, 4); BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
CallMethod(DEVS, args);
byte[] status = CallMethod(DEVS, args);
int result = BitConverter.ToInt32(status, 0);
Logger.WriteLine(logName + " = " + Status + " : " + (result == 1 ? "OK" : result));
return result;
} }
public void DeviceSet(uint DeviceID, byte[] Params) public int DeviceSet(uint DeviceID, byte[] Params, string logName)
{ {
byte[] args = new byte[4 + Params.Length]; byte[] args = new byte[4 + Params.Length];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0); BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
Params.CopyTo(args, 4); Params.CopyTo(args, 4);
CallMethod(DEVS, args);
byte[] status = CallMethod(DEVS, args);
int result = BitConverter.ToInt32(status, 0);
Logger.WriteLine(logName + " = " + BitConverter.ToString(Params) + " : " + (result == 1 ? "OK" : result));
return BitConverter.ToInt32(status, 0);
} }
@@ -167,7 +192,9 @@ public class ASUSWmi
byte[] args = new byte[8]; byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0); BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
byte[] status = CallMethod(DSTS, args); byte[] status = CallMethod(DSTS, args);
return BitConverter.ToInt32(status, 0) - 65536; return BitConverter.ToInt32(status, 0) - 65536;
} }
public byte[] DeviceGetBuffer(uint DeviceID, uint Status = 0) public byte[] DeviceGetBuffer(uint DeviceID, uint Status = 0)
@@ -175,22 +202,38 @@ public class ASUSWmi
byte[] args = new byte[8]; byte[] args = new byte[8];
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0); BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
BitConverter.GetBytes((uint)Status).CopyTo(args, 4); BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
return CallMethod(DSTS, args); return CallMethod(DSTS, args);
} }
public void SetFanCurve(int device, byte[] curve) public int SetFanCurve(int device, byte[] curve)
{ {
if (curve.Length != 16) return; if (curve.Length != 16) return -1;
if (curve.All(singleByte => singleByte == 0)) return; if (curve.All(singleByte => singleByte == 0)) return -1;
Logger.WriteLine("Fans" + ((device == 1) ? "GPU" : "CPU") + " " + BitConverter.ToString(curve)); int result;
if (device == 1) for (int i = 8; i < curve.Length; i++)
DeviceSet(DevsGPUFanCurve, curve); {
else curve[i] = Math.Max((byte)0, Math.Min((byte)99, curve[i])); // it seems to be a bug, when some old model's bios can go nuts if fan is set to 100%
DeviceSet(DevsCPUFanCurve, curve); }
switch (device)
{
case 1:
result = DeviceSet(DevsGPUFanCurve, curve, "FanGPU");
break;
case 2:
result = DeviceSet(DevsMidFanCurve, curve, "FanMid");
break;
default:
result = DeviceSet(DevsCPUFanCurve, curve, "FanCPU");
break;
}
return result;
} }
public byte[] GetFanCurve(int device, int mode = 0) public byte[] GetFanCurve(int device, int mode = 0)
@@ -205,20 +248,65 @@ public class ASUSWmi
default: fan_mode = 0; break; default: fan_mode = 0; break;
} }
if (device == 1) switch (device)
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode); {
else case 1:
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode); return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
case 2:
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
default:
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
}
} }
public void TUFKeyboardRGB(int mode, Color color, int speed)
{
byte[] setting = new byte[12];
setting[0] = (byte)1;
setting[1] = (byte)mode;
setting[2] = color.R;
setting[3] = color.G;
setting[4] = color.B;
setting[5] = (byte)speed;
DeviceSet(TUF_KB, setting, "TUF RGB");
//Debug.WriteLine(BitConverter.ToString(setting));
}
const int ASUS_WMI_KEYBOARD_POWER_BOOT = 0x03 << 16;
const int ASUS_WMI_KEYBOARD_POWER_AWAKE = 0x0C << 16;
const int ASUS_WMI_KEYBOARD_POWER_SLEEP = 0x30 << 16;
const int ASUS_WMI_KEYBOARD_POWER_SHUTDOWN = 0xC0 << 16;
public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{
int state = 0xbd;
if (boot) state = state | ASUS_WMI_KEYBOARD_POWER_BOOT;
if (awake) state = state | ASUS_WMI_KEYBOARD_POWER_AWAKE;
if (sleep) state = state | ASUS_WMI_KEYBOARD_POWER_SLEEP;
if (shutdown) state = state | ASUS_WMI_KEYBOARD_POWER_SHUTDOWN;
state = state | 0x01 << 8;
DeviceSet(TUF_KB_STATE, state, "TUF_KB");
}
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler) public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
{ {
ManagementEventWatcher watcher = new ManagementEventWatcher(); try
watcher.EventArrived += new EventArrivedEventHandler(EventHandler); {
watcher.Scope = new ManagementScope("root\\wmi"); ManagementEventWatcher watcher = new ManagementEventWatcher();
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent"); watcher.EventArrived += new EventArrivedEventHandler(EventHandler);
watcher.Start(); watcher.Scope = new ManagementScope("root\\wmi");
watcher.Query = new WqlEventQuery("SELECT * FROM AsusAtkWmiEvent");
watcher.Start();
} catch
{
Logger.WriteLine("Can't connect to ASUS WMI events");
}
} }
} }

View File

@@ -1,12 +1,11 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me // Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication; using Starlight.Communication;
using System.Diagnostics;
using System.Text;
using System.Management; using System.Management;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window; using System.Drawing.Drawing2D;
using System.Drawing.Imaging; using System.Text;
using System.Windows.Forms; using System.Globalization;
using System;
namespace Starlight.AnimeMatrix namespace Starlight.AnimeMatrix
{ {
@@ -60,13 +59,20 @@ namespace Starlight.AnimeMatrix
} }
} }
public enum AnimeType
{
GA401,
GA402
}
public enum BrightnessMode : byte public enum BrightnessMode : byte
{ {
Off = 0, Off = 0,
Dim = 1, Dim = 1,
Medium = 2, Medium = 2,
Full = 3, Full = 3
Super = 4, //test, doesn't work
} }
@@ -78,30 +84,39 @@ namespace Starlight.AnimeMatrix
byte[] _displayBuffer; byte[] _displayBuffer;
List<byte[]> frames = new List<byte[]>(); List<byte[]> frames = new List<byte[]>();
public int MaxColumns = 34;
public int MaxRows = 61; public int MaxRows = 61;
public int FullRows = 11; //public int FullRows = 11;
//public int FullEvenRows = -1;
public int EmptyFirstRow = 0; public int dx = 0;
public int MaxColumns = 34;
private int frameIndex = 0; private int frameIndex = 0;
private static AnimeType _model = AnimeType.GA402;
public AnimeMatrixDevice() public AnimeMatrixDevice()
: base(0x0B05, 0x193B, 640) : base(0x0B05, 0x193B, 640)
{ {
string model = GetModel(); string model = GetModel();
Debug.WriteLine(model); if (model.Contains("401"))
if (model is not null && model.Contains("401"))
{ {
EmptyFirstRow = 1;
FullRows = 6; _model = AnimeType.GA401;
MaxColumns = 33; MaxColumns = 33;
dx = 1;
//FullRows = 7;
//FullEvenRows = 3;
MaxRows = 55; MaxRows = 55;
LedCount = 1213; LedCount = 1245;
UpdatePageLength = 410; UpdatePageLength = 410;
} }
_displayBuffer = new byte[LedCount]; _displayBuffer = new byte[LedCount];
} }
@@ -126,7 +141,6 @@ namespace Starlight.AnimeMatrix
public void PresentNextFrame() public void PresentNextFrame()
{ {
//Debug.WriteLine(frameIndex);
if (frameIndex >= frames.Count) frameIndex = 0; if (frameIndex >= frames.Count) frameIndex = 0;
_displayBuffer = frames[frameIndex]; _displayBuffer = frames[frameIndex];
Present(); Present();
@@ -150,29 +164,110 @@ namespace Starlight.AnimeMatrix
} }
public int EmptyColumns(int row) public static int FirstX(int y)
{
switch (_model)
{
case AnimeType.GA401:
if (y < 5)
{
return 0;
}
else
{
return (y + 1) / 2 - 3;
}
case AnimeType.GA402:
if (y < 11)
{
return 0;
}
else
{
return (y) / 2 - 5;
}
default:
throw new ArgumentException("Invalid anime type", nameof(_model));
}
}
public static int Width(int y)
{
switch (_model)
{
case AnimeType.GA401:
return 33;
case AnimeType.GA402:
return 34;
default:
throw new ArgumentException("Invalid anime type", nameof(_model));
}
}
public static int Pitch(int y)
{
switch (_model)
{
case AnimeType.GA401:
switch (y)
{
case 0:
case 2:
case 4:
return 33;
case 1:
case 3:
return 35;
default:
return 36 - y / 2;
}
case AnimeType.GA402:
return Width(y) - FirstX(y);
default:
throw new ArgumentException("Invalid anime type", nameof(_model));
}
}
/*
public int XStart(int row)
{ {
if (row == 0) return EmptyFirstRow;
return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0); return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
} }
public int Columns(int row)
public int XEnd(int row)
{ {
EnsureRowInRange(row); if (row <= FullEvenRows)
return MaxColumns - EmptyColumns(row); {
if (row % 2 == 1) return MaxColumns + 2;
else return MaxColumns;
}
return MaxColumns;
} }
*/
public int RowToLinearAddress(int row) public int RowToLinearAddress(int y)
{ {
EnsureRowInRange(row); EnsureRowInRange(y);
var ret = 0; int ret = 0;
for (var i = 0; i < row; i++) for (var i = 0; i < y; i++)
ret += Columns(i); ret += Pitch(i);
return ret; return ret;
} }
public void SetLedPlanar(int x, int y, byte value)
{
EnsureRowInRange(y);
if (x >= FirstX(y) && x < Width(y))
{
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
//Debug.Write((RowToLinearAddress(y) - FirstX(y) + x + dx).ToString() + " ");
}
}
public void WakeUp() public void WakeUp()
{ {
Set(Packet<AnimeMatrixPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc."))); Set(Packet<AnimeMatrixPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")));
@@ -198,14 +293,7 @@ namespace Starlight.AnimeMatrix
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03)); Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
} }
public void SetLedPlanar(int x, int y, byte value)
{
EnsureRowInRange(y);
var start = RowToLinearAddress(y) - EmptyColumns(y);
if (x >= EmptyColumns(y))
SetLedLinear(start + x, value);
}
public void Clear(bool present = false) public void Clear(bool present = false)
{ {
@@ -272,49 +360,88 @@ namespace Starlight.AnimeMatrix
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte)); Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte));
} }
static int GetColor(Bitmap bmp, int x, int y)
public void PresentClock()
{ {
var pixel = bmp.GetPixel(Math.Max(0,Math.Min(bmp.Width - 1,x)), Math.Max(0, Math.Min(bmp.Height - 1, y))); int second = DateTime.Now.Second;
return (Math.Max((pixel.R + pixel.G + pixel.B) / 3 - 10, 0));
if (CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"))
PresentText(DateTime.Now.ToString("H" + ((second % 2 == 0)?":":" ") + "mm"));
else
PresentText(DateTime.Now.ToString("h" + ((second % 2 == 0) ? ":" : " ") + "mm"), DateTime.Now.ToString("tt"));
} }
public void GenerateFrame(Image image)
public void PresentText(string text1, string text2 = "")
{ {
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
int width = MaxColumns*3;
int height = MaxRows;
float scale;
Bitmap canvas = new Bitmap(width, height);
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
var graph = Graphics.FromImage(canvas);
var scaleWidth = (int)(image.Width * scale);
var scaleHeight = (int)(image.Height * scale);
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
graph.DrawImage(image, ((int)width - scaleWidth), 0, scaleWidth, scaleHeight);
Bitmap bmp = new Bitmap(canvas, MaxColumns * 2, MaxRows);
for (int y = 0; y < bmp.Height; y++)
{ {
for (int x = 0; x < bmp.Width; x++) using (Graphics g = Graphics.FromImage(bmp))
{ {
if (x % 2 == (y % 2)) g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
using (Font font = new Font("Arial", 12F))
{ {
var color = GetColor(bmp, x, y); SizeF textSize = g.MeasureString(text1, font);
//var color2= GetColor(bmp, x+1, y); g.DrawString(text1, font, Brushes.White, (MaxColumns*3 - textSize.Width)+3, -5);
SetLedPlanar(x/2,y, (byte)color);
} }
if (text2.Length > 0)
using (Font font = new Font("Arial", 9F))
{
SizeF textSize = g.MeasureString(text2, font);
g.DrawString(text2, font, Brushes.White, (MaxColumns * 3 - textSize.Width)+1, 25);
}
} }
GenerateFrame(bmp, InterpolationMode.Bicubic);
Present();
} }
} }
public void GenerateFrame(Image image, InterpolationMode interpolation = InterpolationMode.High)
{
int width = MaxColumns/2 * 6;
int height = MaxRows;
int targetWidth = MaxColumns * 2;
float scale;
using (Bitmap bmp = new Bitmap(targetWidth, height))
{
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
using (var graph = Graphics.FromImage(bmp))
{
var scaleWidth = (float)(image.Width * scale);
var scaleHeight = (float)(image.Height * scale);
graph.InterpolationMode = interpolation;
graph.CompositingQuality = CompositingQuality.HighQuality;
graph.SmoothingMode = SmoothingMode.AntiAlias;
graph.DrawImage(image, (float)Math.Round(targetWidth - scaleWidth * targetWidth / width), 0, (float)Math.Round(scaleWidth * targetWidth / width), scaleHeight);
}
for (int y = 0; y < bmp.Height; y++)
{
for (int x = 0; x < bmp.Width; x++)
if (x % 2 == (y+dx) % 2)
{
var pixel = bmp.GetPixel(x, y);
var color = (pixel.R + pixel.G + pixel.B) / 3;
if (color < 10) color = 0;
SetLedPlanar(x / 2, y, (byte)color);
}
}
}
}
private void EnsureRowInRange(int row) private void EnsureRowInRange(int row)
{ {
if (row < 0 || row >= MaxRows) if (row < 0 || row >= MaxRows)

View File

@@ -40,8 +40,7 @@ public class AppConfig
} }
public string GetModel()
public bool ContainsModel(string contains)
{ {
if (_model is null) if (_model is null)
{ {
@@ -56,6 +55,12 @@ public class AppConfig
} }
} }
return _model;
}
public bool ContainsModel(string contains)
{
GetModel();
return (_model is not null && _model.Contains(contains)); return (_model is not null && _model.Contains(contains));
} }
@@ -103,6 +108,8 @@ public class AppConfig
if (device == 1) if (device == 1)
name = "gpu"; name = "gpu";
else if (device == 2)
name = "mid";
else else
name = "cpu"; name = "cpu";

View File

@@ -1,78 +1,273 @@
using HidLibrary; using HidLibrary;
using System.Data;
using System.Diagnostics;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TextBox;
using System.Security.Policy;
using HidSharp.Utility;
public class Aura namespace GHelper
{ {
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0,0,0 }; [Flags]
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4}; public enum AuraDev19b6 : uint
public const int Static = 0;
public const int Breathe = 1;
public const int Strobe = 2;
public const int Rainbow = 3;
public const int Dingding = 4;
public const int SpeedSlow = 0xe1;
public const int SpeedMedium = 0xeb;
public const int SpeedHigh = 0xf5;
public static int Mode = Static;
public static Color Color1 = Color.White;
public static Color Color2 = Color.Black;
public static int Speed = SpeedSlow;
public static byte[] AuraMessage(int mode, Color color, Color color2, int speed)
{ {
byte[] msg = new byte[17]; BootLogo = 1,
msg[0] = 0x5d; BootKeyb = 1 << 1,
msg[1] = 0xb3; AwakeLogo = 1 << 2,
msg[2] = 0x00; // Zone AwakeKeyb = 1 << 3,
msg[3] = (byte)mode; // Aura Mode SleepLogo = 1 << 4,
msg[4] = (byte)(color.R); // R SleepKeyb = 1 << 5,
msg[5] = (byte)(color.G); // G ShutdownLogo = 1 << 6,
msg[6] = (byte)(color.B); // B ShutdownKeyb = 1 << 7,
msg[7] = (byte)speed; // aura.speed as u8; BootBar = 1u << (7 + 2),
msg[8] = 0; // aura.direction as u8; AwakeBar = 1u << (7 + 3),
msg[10] = (byte)(color2.R); // R SleepBar = 1u << (7 + 4),
msg[11] = (byte)(color2.G); // G ShutdownBar = 1u << (7 + 5),
msg[12] = (byte)(color2.B); // B BootLid = 1u << (15 + 1),
return msg; AwakeLid = 1u << (15 + 2),
SleepLid = 1u << (15 + 3),
ShutdownLid = 1u << (15 + 4)
} }
public static void ApplyAura() public static class AuraDev19b6Extensions
{
public static byte[] ToBytes(this AuraDev19b6[] controls)
{
uint a = 0;
foreach (var n in controls)
{
a |= (uint)n;
}
return new byte[] { 0x5d, 0xbd, 0x01, (byte)(a & 0xff), (byte)((a & 0xff00) >> 8), (byte)((a & 0xff0000) >> 16) };
}
public static ushort BitOr(this AuraDev19b6 self, AuraDev19b6 rhs)
{
return (ushort)(self | rhs);
}
public static ushort BitAnd(this AuraDev19b6 self, AuraDev19b6 rhs)
{
return (ushort)(self & rhs);
}
}
public static class Aura
{ {
HidDevice[] HidDeviceList; static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 };
int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 }; static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray(); static int[] deviceIds = { 0x1a30, 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
if (Mode == Dingding) private static int mode = 0;
{ private static int speed = 1;
Mode = 10; public static Color Color1 = Color.White;
Speed = SpeedMedium; public static Color Color2 = Color.Black;
}
else if (Mode == Rainbow)
{
Speed = SpeedMedium;
}
else
{
Speed = SpeedSlow;
}
foreach (HidDevice device in HidDeviceList)
public static Dictionary<int, string> GetSpeeds()
{ {
if (device.IsConnected && device.Description.Contains("HID")) return new Dictionary<int, string>
{ {
device.OpenDevice(); { 0, "Slow" },
byte[] msg = AuraMessage(Mode, Color1, Color2, Speed); { 1, "Normal" },
device.Write(msg); { 2, "Fast" }
device.Write(MESSAGE_SET); };
device.Write(MESSAGE_APPLY); }
device.CloseDevice();
static Dictionary<int, string> _modes = new Dictionary<int, string>
{
{ 0, "Static" },
{ 1, "Breathe" },
{ 2, "Color Cycle" },
{ 3, "Rainbow" },
{ 10, "Strobe" },
};
static Dictionary<int, string> _modesStrix = new Dictionary<int, string>
{
{ 0, "Static" },
{ 1, "Breathe" },
{ 2, "Color Cycle" },
{ 3, "Rainbow" },
{ 4, "Star" },
{ 5, "Rain" },
{ 6, "Highlight" },
{ 7, "Laser" },
{ 8, "Ripple" },
{ 10, "Strobe" },
{ 11, "Comet" },
{ 12, "Flash" },
};
public static Dictionary<int, string> GetModes()
{
if (Program.config.ContainsModel("TUF"))
{
_modes.Remove(3);
}
if (Program.config.ContainsModel("401"))
{
_modes.Remove(2);
_modes.Remove(3);
}
if (Program.config.ContainsModel("Strix") || Program.config.ContainsModel("Scar"))
{
return _modesStrix;
}
return _modes;
}
public static int Mode
{
get { return mode; }
set
{
if (GetModes().ContainsKey(value))
mode = value;
else
mode = 0;
} }
} }
public static bool HasSecondColor()
{
return (mode == 1 && !Program.config.ContainsModel("TUF"));
}
public static int Speed
{
get { return speed; }
set
{
if (GetSpeeds().ContainsKey(value))
speed = value;
else
speed = 1;
}
}
public static void SetColor(int colorCode)
{
Color1 = Color.FromArgb(colorCode);
}
public static void SetColor2(int colorCode)
{
Color2 = Color.FromArgb(colorCode);
}
public static byte[] AuraMessage(int mode, Color color, Color color2, int speed)
{
byte[] msg = new byte[17];
msg[0] = 0x5d;
msg[1] = 0xb3;
msg[2] = 0x00; // Zone
msg[3] = (byte)mode; // Aura Mode
msg[4] = (byte)(color.R); // R
msg[5] = (byte)(color.G); // G
msg[6] = (byte)(color.B); // B
msg[7] = (byte)speed; // aura.speed as u8;
msg[8] = 0; // aura.direction as u8;
msg[10] = (byte)(color2.R); // R
msg[11] = (byte)(color2.G); // G
msg[12] = (byte)(color2.B); // B
return msg;
}
public static void ApplyBrightness(int brightness)
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
foreach (HidDevice device in HidDeviceList)
if (device.IsConnected && device.Description.Contains("HID"))
{
device.OpenDevice();
device.Write(msg);
device.CloseDevice();
}
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
}
public static void ApplyAuraPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, 0x19b6).ToArray();
List<AuraDev19b6> flags = new List<AuraDev19b6>();
if (awake) flags.Add(AuraDev19b6.AwakeKeyb);
if (boot) flags.Add(AuraDev19b6.BootKeyb);
if (sleep) flags.Add(AuraDev19b6.SleepKeyb);
if (shutdown) flags.Add(AuraDev19b6.ShutdownKeyb);
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
Debug.WriteLine(BitConverter.ToString(msg));
foreach (HidDevice device in HidDeviceList)
if (device.IsConnected && device.Description.Contains("HID"))
{
device.OpenDevice();
device.Write(msg);
device.CloseDevice();
}
Logger.WriteLine("USB-KB = " + BitConverter.ToString(msg));
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardPower(awake, boot, sleep, shutdown);
}
public static void ApplyAura()
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
int _speed;
switch (Speed)
{
case 1:
_speed = 0xeb;
break;
case 2:
_speed = 0xf5;
break;
default:
_speed = 0xe1;
break;
}
byte[] msg = AuraMessage(Mode, Color1, Color2, _speed);
foreach (HidDevice device in HidDeviceList)
if (device.IsConnected && device.Description.Contains("HID"))
{
device.OpenDevice();
device.Write(msg);
device.Write(MESSAGE_SET);
device.Write(MESSAGE_APPLY);
device.CloseDevice();
}
if (Program.config.ContainsModel("TUF"))
Program.wmi.TUFKeyboardRGB(Mode, Color1, _speed);
}
} }
}
}

View File

@@ -1,4 +1,5 @@
using CustomControls; using CustomControls;
using WinFormsSliderBar;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Windows.Forms.DataVisualization.Charting; using System.Windows.Forms.DataVisualization.Charting;
@@ -6,51 +7,24 @@ public static class ControlHelper
{ {
static bool _invert = false; static bool _invert = false;
static bool _resize = false;
static float _scale = 1; static float _scale = 1;
static Color formBack; public static void Adjust(RForm container, bool invert = false)
static Color backMain;
static Color foreMain;
static Color foreAccent;
static Color borderMain;
static Color buttonMain;
public static void Adjust(RForm container, bool darkTheme = false, bool invert = false)
{ {
if (darkTheme) container.BackColor = RForm.formBack;
{ container.ForeColor = RForm.foreMain;
formBack = Color.FromArgb(255, 35, 35, 35);
backMain = Color.FromArgb(255, 50, 50, 50);
foreMain = Color.White;
foreAccent = Color.FromArgb(255, 100, 100, 100);
borderMain = Color.FromArgb(255, 50, 50, 50);
buttonMain = Color.FromArgb(255, 80, 80, 80);
}
else
{
formBack = SystemColors.Control;
backMain = SystemColors.ControlLightLight;
foreMain = SystemColors.ControlText;
foreAccent = Color.LightGray;
borderMain = Color.LightGray;
buttonMain = SystemColors.ControlLight;
}
container.BackColor = formBack;
container.ForeColor = foreMain;
_invert = invert; _invert = invert;
AdjustControls(container.Controls); AdjustControls(container.Controls);
_invert = false; _invert = false;
} }
public static void Resize(RForm container, float baseScale = 2) public static void Resize(RForm container, float baseScale = 2)
{ {
_scale = GetDpiScale(container).Value / baseScale; _scale = GetDpiScale(container).Value / baseScale;
ResizeControls(container.Controls); if (Math.Abs(_scale - 1) > 0.2) ResizeControls(container.Controls);
} }
@@ -62,9 +36,11 @@ public static class ControlHelper
if (button != null && button.Image is not null) if (button != null && button.Image is not null)
button.Image = ResizeImage(button.Image); button.Image = ResizeImage(button.Image);
/*
var pictureBox = control as PictureBox; var pictureBox = control as PictureBox;
if (pictureBox != null && pictureBox.BackgroundImage is not null) if (pictureBox != null && pictureBox.BackgroundImage is not null)
pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage); pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage);
*/
ResizeControls(control.Controls); ResizeControls(control.Controls);
} }
@@ -78,11 +54,11 @@ public static class ControlHelper
var button = control as RButton; var button = control as RButton;
if (button != null) if (button != null)
{ {
button.BackColor = button.Secondary ? buttonMain : backMain; button.BackColor = button.Secondary ? RForm.buttonSecond : RForm.buttonMain;
button.ForeColor = foreMain; button.ForeColor = RForm.foreMain;
button.FlatStyle = FlatStyle.Flat; button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderColor = borderMain; button.FlatAppearance.BorderColor = RForm.borderMain;
if (button.Image is not null) if (button.Image is not null)
button.Image = AdjustImage(button.Image); button.Image = AdjustImage(button.Image);
@@ -96,40 +72,52 @@ public static class ControlHelper
var combo = control as RComboBox; var combo = control as RComboBox;
if (combo != null) if (combo != null)
{ {
combo.BackColor = backMain; combo.BackColor = RForm.buttonMain;
combo.ForeColor = foreMain; combo.ForeColor = RForm.foreMain;
combo.BorderColor = backMain; combo.BorderColor = RForm.buttonMain;
combo.ButtonColor = buttonMain; combo.ButtonColor = RForm.buttonMain;
combo.ArrowColor = RForm.foreMain;
} }
var gb = control as GroupBox; var gb = control as GroupBox;
if (gb != null) if (gb != null)
{ {
gb.ForeColor = foreMain; gb.ForeColor = RForm.foreMain;
} }
var sl = control as Slider;
if (sl != null)
{
sl.borderColor = RForm.buttonMain;
}
var chk = control as CheckBox;
if (chk != null && chk.Padding.Left > 5)
{
chk.BackColor = RForm.buttonSecond;
}
var chart = control as Chart; var chart = control as Chart;
if (chart != null) if (chart != null)
{ {
chart.BackColor = backMain; chart.BackColor = RForm.chartMain;
chart.ChartAreas[0].BackColor = backMain; chart.ChartAreas[0].BackColor = RForm.chartMain;
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;
chart.ChartAreas[0].AxisX.TitleForeColor = foreMain; chart.ChartAreas[0].AxisX.TitleForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisY.TitleForeColor = foreMain; chart.ChartAreas[0].AxisY.TitleForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = foreMain; chart.ChartAreas[0].AxisX.LabelStyle.ForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = foreMain; chart.ChartAreas[0].AxisY.LabelStyle.ForeColor = RForm.foreMain;
chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = foreMain; chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = RForm.foreMain;
chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = foreMain; chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = RForm.foreMain;
chart.ChartAreas[0].AxisX.LineColor = foreAccent; chart.ChartAreas[0].AxisX.MajorGrid.LineColor = RForm.chartGrid;
chart.ChartAreas[0].AxisY.LineColor = foreAccent; chart.ChartAreas[0].AxisY.MajorGrid.LineColor = RForm.chartGrid;
chart.ChartAreas[0].AxisX.LineColor = RForm.chartGrid;
chart.ChartAreas[0].AxisY.LineColor = RForm.chartGrid;
chart.Titles[0].ForeColor = foreMain; chart.Titles[0].ForeColor = RForm.foreMain;
} }

View File

@@ -9,9 +9,18 @@ namespace CustomControls
public class RForm : Form public class RForm : Form
{ {
protected static Color colorEco = Color.FromArgb(255, 6, 180, 138); public static Color colorEco = Color.FromArgb(255, 6, 180, 138);
protected static Color colorStandard = Color.FromArgb(255, 58, 174, 239); public static Color colorStandard = Color.FromArgb(255, 58, 174, 239);
protected static Color colorTurbo = Color.FromArgb(255, 255, 32, 32); public static Color colorTurbo = Color.FromArgb(255, 255, 32, 32);
public static Color buttonMain;
public static Color buttonSecond;
public static Color formBack;
public static Color foreMain;
public static Color borderMain;
public static Color chartMain;
public static Color chartGrid;
[DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")] [DllImport("UXTheme.dll", SetLastError = true, EntryPoint = "#138")]
public static extern bool CheckSystemDarkModeStatus(); public static extern bool CheckSystemDarkModeStatus();
@@ -21,37 +30,74 @@ namespace CustomControls
public bool darkTheme = false; public bool darkTheme = false;
public static void InitColors(bool darkTheme)
{
if (darkTheme)
{
buttonMain = Color.FromArgb(255, 55, 55, 55);
buttonSecond = Color.FromArgb(255, 38, 38, 38);
formBack = Color.FromArgb(255, 28, 28, 28);
foreMain = Color.FromArgb(255, 240, 240, 240);
borderMain = Color.FromArgb(255, 50, 50, 50);
chartMain = Color.FromArgb(255, 35, 35, 35);
chartGrid = Color.FromArgb(255, 70, 70, 70);
}
else
{
buttonMain = SystemColors.ControlLightLight;
buttonSecond = SystemColors.ControlLight;
formBack = SystemColors.Control;
foreMain = SystemColors.ControlText;
borderMain = Color.LightGray;
chartMain = SystemColors.ControlLightLight;
chartGrid = Color.LightGray;
}
}
private static bool IsDarkTheme() private static bool IsDarkTheme()
{ {
using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"); using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
var registryValueObject = key?.GetValue("AppsUseLightTheme"); var registryValueObject = key?.GetValue("AppsUseLightTheme");
if (registryValueObject == null) return false; if (registryValueObject == null) return false;
return (int)registryValueObject <= 0; return (int)registryValueObject <= 0;
} }
public void InitTheme(bool setDPI = true) public bool InitTheme(bool setDPI = false)
{ {
bool newDarkTheme = IsDarkTheme(); bool newDarkTheme = CheckSystemDarkModeStatus();
bool changed = (darkTheme != newDarkTheme); bool changed = (darkTheme != newDarkTheme);
darkTheme = newDarkTheme; darkTheme = newDarkTheme;
InitColors(darkTheme);
if (setDPI) if (setDPI)
ControlHelper.Resize(this); ControlHelper.Resize(this);
DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4); if (changed)
ControlHelper.Adjust(this, darkTheme, changed); {
DwmSetWindowAttribute(this.Handle, 20, new[] { darkTheme ? 1 : 0 }, 4);
ControlHelper.Adjust(this, changed);
}
return changed;
} }
} }
public class RTrackBar : TrackBar public class RCheckBox : CheckBox
{ {
} }
public class RComboBox : ComboBox
public class RComboBox : ComboBox
{ {
private Color borderColor = Color.Gray; private Color borderColor = Color.Gray;
[DefaultValue(typeof(Color), "Gray")] [DefaultValue(typeof(Color), "Gray")]
@@ -67,8 +113,10 @@ namespace CustomControls
} }
} }
} }
private Color buttonColor = Color.LightGray;
[DefaultValue(typeof(Color), "LightGray")]
private Color buttonColor = Color.FromArgb(255, 255, 255, 255);
[DefaultValue(typeof(Color), "255, 255, 255")]
public Color ButtonColor public Color ButtonColor
{ {
get { return buttonColor; } get { return buttonColor; }
@@ -235,13 +283,18 @@ namespace CustomControls
{ {
//Fields //Fields
private int borderSize = 5; private int borderSize = 5;
private int borderRadius = 5; private int borderRadius = 5;
public int BorderRadius
private bool activated = false; {
private bool secondary = false; get { return borderRadius; }
set
{
borderRadius = value;
}
}
private Color borderColor = Color.Transparent; private Color borderColor = Color.Transparent;
public Color BorderColor public Color BorderColor
{ {
get { return borderColor; } get { return borderColor; }
@@ -252,6 +305,7 @@ namespace CustomControls
} }
private bool activated = false;
public bool Activated public bool Activated
{ {
get { return activated; } get { return activated; }
@@ -264,6 +318,7 @@ namespace CustomControls
} }
} }
private bool secondary = false;
public bool Secondary public bool Secondary
{ {
get { return secondary; } get { return secondary; }

191
app/Fans.Designer.cs generated
View File

@@ -31,10 +31,12 @@ namespace GHelper
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
ChartArea chartArea1 = new ChartArea(); ChartArea chartArea4 = new ChartArea();
Title title1 = new Title(); Title title4 = new Title();
ChartArea chartArea2 = new ChartArea(); ChartArea chartArea5 = new ChartArea();
Title title2 = new Title(); Title title5 = new Title();
ChartArea chartArea6 = new ChartArea();
Title title6 = new Title();
panelFans = new Panel(); panelFans = new Panel();
labelTip = new Label(); labelTip = new Label();
labelBoost = new Label(); labelBoost = new Label();
@@ -43,15 +45,14 @@ namespace GHelper
tableFanCharts = new TableLayoutPanel(); tableFanCharts = new TableLayoutPanel();
chartGPU = new Chart(); chartGPU = new Chart();
chartCPU = new Chart(); chartCPU = new Chart();
chartMid = new Chart();
labelFans = new Label(); labelFans = new Label();
checkAuto = new CheckBox(); checkApplyFans = new RCheckBox();
buttonReset = new RButton(); buttonReset = new RButton();
buttonApply = new RButton();
panelPower = new Panel(); panelPower = new Panel();
pictureBox1 = new PictureBox(); pictureBox1 = new PictureBox();
labelPowerLimits = new Label(); labelPowerLimits = new Label();
checkApplyPower = new CheckBox(); checkApplyPower = new RCheckBox();
buttonApplyPower = new RButton();
panelCPU = new Panel(); panelCPU = new Panel();
labelCPU = new Label(); labelCPU = new Label();
label2 = new Label(); label2 = new Label();
@@ -60,7 +61,6 @@ namespace GHelper
labelTotal = new Label(); labelTotal = new Label();
label1 = new Label(); label1 = new Label();
trackTotal = new TrackBar(); trackTotal = new TrackBar();
labelApplied = new Label();
pictureFine = new PictureBox(); pictureFine = new PictureBox();
labelInfo = new Label(); labelInfo = new Label();
panelFans.SuspendLayout(); panelFans.SuspendLayout();
@@ -68,6 +68,7 @@ namespace GHelper
tableFanCharts.SuspendLayout(); tableFanCharts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit(); ((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit(); ((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
((System.ComponentModel.ISupportInitialize)chartMid).BeginInit();
panelPower.SuspendLayout(); panelPower.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
panelCPU.SuspendLayout(); panelCPU.SuspendLayout();
@@ -85,9 +86,8 @@ namespace GHelper
panelFans.Controls.Add(picturePerf); panelFans.Controls.Add(picturePerf);
panelFans.Controls.Add(tableFanCharts); panelFans.Controls.Add(tableFanCharts);
panelFans.Controls.Add(labelFans); panelFans.Controls.Add(labelFans);
panelFans.Controls.Add(checkAuto); panelFans.Controls.Add(checkApplyFans);
panelFans.Controls.Add(buttonReset); panelFans.Controls.Add(buttonReset);
panelFans.Controls.Add(buttonApply);
panelFans.Dock = DockStyle.Left; panelFans.Dock = DockStyle.Left;
panelFans.Location = new Point(364, 0); panelFans.Location = new Point(364, 0);
panelFans.Margin = new Padding(0); panelFans.Margin = new Padding(0);
@@ -100,7 +100,7 @@ namespace GHelper
// //
labelTip.AutoSize = true; labelTip.AutoSize = true;
labelTip.BackColor = SystemColors.ControlLightLight; labelTip.BackColor = SystemColors.ControlLightLight;
labelTip.Location = new Point(245, 13); labelTip.Location = new Point(271, 13);
labelTip.Name = "labelTip"; labelTip.Name = "labelTip";
labelTip.Padding = new Padding(5); labelTip.Padding = new Padding(5);
labelTip.Size = new Size(107, 42); labelTip.Size = new Size(107, 42);
@@ -120,6 +120,7 @@ namespace GHelper
// //
comboBoost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; comboBoost.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
comboBoost.BorderColor = Color.White; comboBoost.BorderColor = Color.White;
comboBoost.ButtonColor = Color.FromArgb(255, 255, 255);
comboBoost.DropDownStyle = ComboBoxStyle.DropDownList; comboBoost.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoost.FormattingEnabled = true; comboBoost.FormattingEnabled = true;
comboBoost.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive" }); comboBoost.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive" });
@@ -147,44 +148,59 @@ namespace GHelper
tableFanCharts.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F)); tableFanCharts.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableFanCharts.Controls.Add(chartGPU, 0, 1); tableFanCharts.Controls.Add(chartGPU, 0, 1);
tableFanCharts.Controls.Add(chartCPU, 0, 0); tableFanCharts.Controls.Add(chartCPU, 0, 0);
tableFanCharts.Controls.Add(chartMid, 0, 2);
tableFanCharts.Location = new Point(28, 64); tableFanCharts.Location = new Point(28, 64);
tableFanCharts.Margin = new Padding(6); tableFanCharts.Margin = new Padding(6);
tableFanCharts.Name = "tableFanCharts"; tableFanCharts.Name = "tableFanCharts";
tableFanCharts.RowCount = 2; tableFanCharts.RowCount = 2;
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 33F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 33F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Percent, 33F));
tableFanCharts.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F));
tableFanCharts.Size = new Size(764, 992); tableFanCharts.Size = new Size(764, 992);
tableFanCharts.TabIndex = 36; tableFanCharts.TabIndex = 36;
// //
// chartGPU // chartGPU
// //
chartArea1.Name = "ChartArea1"; chartArea4.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea1); chartGPU.ChartAreas.Add(chartArea4);
chartGPU.Dock = DockStyle.Fill; chartGPU.Dock = DockStyle.Fill;
chartGPU.Location = new Point(2, 506); chartGPU.Location = new Point(2, 340);
chartGPU.Margin = new Padding(2, 10, 2, 10); chartGPU.Margin = new Padding(2, 10, 2, 10);
chartGPU.Name = "chartGPU"; chartGPU.Name = "chartGPU";
chartGPU.Size = new Size(760, 476); chartGPU.Size = new Size(760, 310);
chartGPU.TabIndex = 17; chartGPU.TabIndex = 17;
chartGPU.Text = "chart1"; chartGPU.Text = "chartGPU";
title1.Name = "Title1"; title4.Name = "Title1";
chartGPU.Titles.Add(title1); chartGPU.Titles.Add(title4);
// //
// chartCPU // chartCPU
// //
chartArea2.Name = "ChartArea1"; chartArea5.Name = "ChartArea1";
chartCPU.ChartAreas.Add(chartArea2); chartCPU.ChartAreas.Add(chartArea5);
chartCPU.Dock = DockStyle.Fill; chartCPU.Dock = DockStyle.Fill;
chartCPU.Location = new Point(2, 10); chartCPU.Location = new Point(2, 10);
chartCPU.Margin = new Padding(2, 10, 2, 10); chartCPU.Margin = new Padding(2, 10, 2, 10);
chartCPU.Name = "chartCPU"; chartCPU.Name = "chartCPU";
chartCPU.Size = new Size(760, 476); chartCPU.Size = new Size(760, 310);
chartCPU.TabIndex = 14; chartCPU.TabIndex = 14;
chartCPU.Text = "chartCPU"; chartCPU.Text = "chartCPU";
title2.Name = "Title1"; title5.Name = "Title1";
chartCPU.Titles.Add(title2); chartCPU.Titles.Add(title5);
//
// chartMid
//
chartArea6.Name = "ChartArea3";
chartMid.ChartAreas.Add(chartArea6);
chartMid.Dock = DockStyle.Fill;
chartMid.Location = new Point(2, 670);
chartMid.Margin = new Padding(2, 10, 2, 10);
chartMid.Name = "chartMid";
chartMid.Size = new Size(760, 312);
chartMid.TabIndex = 14;
chartMid.Text = "chartMid";
title6.Name = "Title3";
chartMid.Titles.Add(title6);
chartMid.Visible = false;
// //
// labelFans // labelFans
// //
@@ -197,17 +213,19 @@ namespace GHelper
labelFans.TabIndex = 28; labelFans.TabIndex = 28;
labelFans.Text = "Fan Curves"; labelFans.Text = "Fan Curves";
// //
// checkAuto // checkApplyFans
// //
checkAuto.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; checkApplyFans.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkAuto.AutoSize = true; checkApplyFans.AutoSize = true;
checkAuto.Location = new Point(377, 1086); checkApplyFans.BackColor = SystemColors.ControlLight;
checkAuto.Margin = new Padding(4, 2, 4, 2); checkApplyFans.Location = new Point(449, 1084);
checkAuto.Name = "checkAuto"; checkApplyFans.Margin = new Padding(4, 2, 4, 2);
checkAuto.Size = new Size(165, 36); checkApplyFans.Name = "checkApplyFans";
checkAuto.TabIndex = 17; checkApplyFans.Padding = new Padding(15, 5, 15, 5);
checkAuto.Text = "Auto Apply"; checkApplyFans.Size = new Size(339, 46);
checkAuto.UseVisualStyleBackColor = true; checkApplyFans.TabIndex = 17;
checkApplyFans.Text = "Apply Custom Fan Curve";
checkApplyFans.UseVisualStyleBackColor = false;
// //
// buttonReset // buttonReset
// //
@@ -215,41 +233,24 @@ namespace GHelper
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonReset.BackColor = SystemColors.ControlLight; buttonReset.BackColor = SystemColors.ControlLight;
buttonReset.BorderColor = Color.Transparent; buttonReset.BorderColor = Color.Transparent;
buttonReset.BorderRadius = 2;
buttonReset.FlatStyle = FlatStyle.Flat; buttonReset.FlatStyle = FlatStyle.Flat;
buttonReset.Location = new Point(30, 1081); buttonReset.Location = new Point(30, 1084);
buttonReset.Margin = new Padding(4, 2, 4, 2); buttonReset.Margin = new Padding(4, 2, 4, 2);
buttonReset.Name = "buttonReset"; buttonReset.Name = "buttonReset";
buttonReset.Secondary = true; buttonReset.Secondary = true;
buttonReset.Size = new Size(232, 44); buttonReset.Size = new Size(232, 50);
buttonReset.TabIndex = 15; buttonReset.TabIndex = 15;
buttonReset.Text = "Factory Defaults"; buttonReset.Text = "Factory Defaults";
buttonReset.UseVisualStyleBackColor = false; buttonReset.UseVisualStyleBackColor = false;
// //
// buttonApply
//
buttonApply.Activated = false;
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonApply.BackColor = SystemColors.ControlLight;
buttonApply.BorderColor = Color.Transparent;
buttonApply.FlatStyle = FlatStyle.Flat;
buttonApply.Location = new Point(542, 1081);
buttonApply.Margin = new Padding(4, 2, 4, 2);
buttonApply.Name = "buttonApply";
buttonApply.Secondary = true;
buttonApply.Size = new Size(248, 44);
buttonApply.TabIndex = 14;
buttonApply.Text = "Apply Fan Curve";
buttonApply.UseVisualStyleBackColor = false;
//
// panelPower // panelPower
// //
panelPower.Controls.Add(pictureBox1); panelPower.Controls.Add(pictureBox1);
panelPower.Controls.Add(labelPowerLimits); panelPower.Controls.Add(labelPowerLimits);
panelPower.Controls.Add(checkApplyPower); panelPower.Controls.Add(checkApplyPower);
panelPower.Controls.Add(buttonApplyPower);
panelPower.Controls.Add(panelCPU); panelPower.Controls.Add(panelCPU);
panelPower.Controls.Add(panelTotal); panelPower.Controls.Add(panelTotal);
panelPower.Controls.Add(labelApplied);
panelPower.Controls.Add(pictureFine); panelPower.Controls.Add(pictureFine);
panelPower.Controls.Add(labelInfo); panelPower.Controls.Add(labelInfo);
panelPower.Dock = DockStyle.Left; panelPower.Dock = DockStyle.Left;
@@ -287,36 +288,22 @@ namespace GHelper
// //
checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
checkApplyPower.AutoSize = true; checkApplyPower.AutoSize = true;
checkApplyPower.Location = new Point(27, 1039); checkApplyPower.BackColor = SystemColors.ControlLight;
checkApplyPower.Location = new Point(20, 1086);
checkApplyPower.Margin = new Padding(4, 2, 4, 2); checkApplyPower.Margin = new Padding(4, 2, 4, 2);
checkApplyPower.Name = "checkApplyPower"; checkApplyPower.Name = "checkApplyPower";
checkApplyPower.Size = new Size(165, 36); checkApplyPower.Padding = new Padding(15, 5, 15, 5);
checkApplyPower.Size = new Size(277, 46);
checkApplyPower.TabIndex = 25; checkApplyPower.TabIndex = 25;
checkApplyPower.Text = "Auto Apply"; checkApplyPower.Text = "Apply Power Limits";
checkApplyPower.UseVisualStyleBackColor = true; checkApplyPower.UseVisualStyleBackColor = false;
//
// buttonApplyPower
//
buttonApplyPower.Activated = false;
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonApplyPower.BackColor = SystemColors.ControlLight;
buttonApplyPower.BorderColor = Color.Transparent;
buttonApplyPower.FlatStyle = FlatStyle.Flat;
buttonApplyPower.Location = new Point(20, 1081);
buttonApplyPower.Margin = new Padding(4, 2, 4, 2);
buttonApplyPower.Name = "buttonApplyPower";
buttonApplyPower.Secondary = true;
buttonApplyPower.Size = new Size(324, 44);
buttonApplyPower.TabIndex = 24;
buttonApplyPower.Text = "Apply Power Limits";
buttonApplyPower.UseVisualStyleBackColor = false;
// //
// panelCPU // panelCPU
// //
panelCPU.Controls.Add(labelCPU); panelCPU.Controls.Add(labelCPU);
panelCPU.Controls.Add(label2); panelCPU.Controls.Add(label2);
panelCPU.Controls.Add(trackCPU); panelCPU.Controls.Add(trackCPU);
panelCPU.Location = new Point(184, 93); panelCPU.Location = new Point(184, 72);
panelCPU.Margin = new Padding(4); panelCPU.Margin = new Padding(4);
panelCPU.Name = "panelCPU"; panelCPU.Name = "panelCPU";
panelCPU.Size = new Size(160, 510); panelCPU.Size = new Size(160, 510);
@@ -324,12 +311,11 @@ namespace GHelper
// //
// labelCPU // labelCPU
// //
labelCPU.AutoSize = true;
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelCPU.Location = new Point(44, 40); labelCPU.Location = new Point(13, 40);
labelCPU.Margin = new Padding(4, 0, 4, 0); labelCPU.Margin = new Padding(4, 0, 4, 0);
labelCPU.Name = "labelCPU"; labelCPU.Name = "labelCPU";
labelCPU.Size = new Size(61, 32); labelCPU.Size = new Size(120, 32);
labelCPU.TabIndex = 13; labelCPU.TabIndex = 13;
labelCPU.Text = "CPU"; labelCPU.Text = "CPU";
labelCPU.TextAlign = ContentAlignment.MiddleCenter; labelCPU.TextAlign = ContentAlignment.MiddleCenter;
@@ -350,7 +336,7 @@ namespace GHelper
trackCPU.Location = new Point(48, 88); trackCPU.Location = new Point(48, 88);
trackCPU.Margin = new Padding(4, 2, 4, 2); trackCPU.Margin = new Padding(4, 2, 4, 2);
trackCPU.Maximum = 85; trackCPU.Maximum = 85;
trackCPU.Minimum = 15; trackCPU.Minimum = 5;
trackCPU.Name = "trackCPU"; trackCPU.Name = "trackCPU";
trackCPU.Orientation = Orientation.Vertical; trackCPU.Orientation = Orientation.Vertical;
trackCPU.Size = new Size(90, 416); trackCPU.Size = new Size(90, 416);
@@ -363,7 +349,7 @@ namespace GHelper
panelTotal.Controls.Add(labelTotal); panelTotal.Controls.Add(labelTotal);
panelTotal.Controls.Add(label1); panelTotal.Controls.Add(label1);
panelTotal.Controls.Add(trackTotal); panelTotal.Controls.Add(trackTotal);
panelTotal.Location = new Point(16, 93); panelTotal.Location = new Point(16, 72);
panelTotal.Margin = new Padding(4); panelTotal.Margin = new Padding(4);
panelTotal.Name = "panelTotal"; panelTotal.Name = "panelTotal";
panelTotal.Size = new Size(160, 512); panelTotal.Size = new Size(160, 512);
@@ -371,33 +357,32 @@ namespace GHelper
// //
// labelTotal // labelTotal
// //
labelTotal.AutoSize = true;
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelTotal.Location = new Point(46, 40); labelTotal.Location = new Point(16, 40);
labelTotal.Margin = new Padding(4, 0, 4, 0); labelTotal.Margin = new Padding(4, 0, 4, 0);
labelTotal.Name = "labelTotal"; labelTotal.Name = "labelTotal";
labelTotal.Size = new Size(70, 32); labelTotal.Size = new Size(122, 32);
labelTotal.TabIndex = 12; labelTotal.TabIndex = 12;
labelTotal.Text = "Total"; labelTotal.Text = "Platform";
labelTotal.TextAlign = ContentAlignment.MiddleCenter; labelTotal.TextAlign = ContentAlignment.MiddleCenter;
// //
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(48, 8); label1.Location = new Point(26, 8);
label1.Margin = new Padding(4, 0, 4, 0); label1.Margin = new Padding(4, 0, 4, 0);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(65, 32); label1.Size = new Size(104, 32);
label1.TabIndex = 11; label1.TabIndex = 11;
label1.Text = "Total"; label1.Text = "Platform";
label1.TextAlign = ContentAlignment.MiddleCenter; label1.TextAlign = ContentAlignment.MiddleCenter;
// //
// trackTotal // trackTotal
// //
trackTotal.Location = new Point(44, 88); trackTotal.Location = new Point(44, 88);
trackTotal.Margin = new Padding(4, 2, 4, 2); trackTotal.Margin = new Padding(4, 2, 4, 2);
trackTotal.Maximum = 150; trackTotal.Maximum = 180;
trackTotal.Minimum = 15; trackTotal.Minimum = 10;
trackTotal.Name = "trackTotal"; trackTotal.Name = "trackTotal";
trackTotal.Orientation = Orientation.Vertical; trackTotal.Orientation = Orientation.Vertical;
trackTotal.Size = new Size(90, 416); trackTotal.Size = new Size(90, 416);
@@ -406,17 +391,6 @@ namespace GHelper
trackTotal.TickStyle = TickStyle.TopLeft; trackTotal.TickStyle = TickStyle.TopLeft;
trackTotal.Value = 125; trackTotal.Value = 125;
// //
// labelApplied
//
labelApplied.AutoSize = true;
labelApplied.ForeColor = Color.Tomato;
labelApplied.Location = new Point(56, 54);
labelApplied.Margin = new Padding(4, 0, 4, 0);
labelApplied.Name = "labelApplied";
labelApplied.Size = new Size(143, 32);
labelApplied.TabIndex = 21;
labelApplied.Text = "Not Applied";
//
// pictureFine // pictureFine
// //
pictureFine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; pictureFine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
@@ -465,6 +439,7 @@ namespace GHelper
tableFanCharts.ResumeLayout(false); tableFanCharts.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)chartGPU).EndInit(); ((System.ComponentModel.ISupportInitialize)chartGPU).EndInit();
((System.ComponentModel.ISupportInitialize)chartCPU).EndInit(); ((System.ComponentModel.ISupportInitialize)chartCPU).EndInit();
((System.ComponentModel.ISupportInitialize)chartMid).EndInit();
panelPower.ResumeLayout(false); panelPower.ResumeLayout(false);
panelPower.PerformLayout(); panelPower.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
@@ -480,12 +455,10 @@ namespace GHelper
#endregion #endregion
private Panel panelFans; private Panel panelFans;
private CheckBox checkAuto; private RCheckBox checkApplyFans;
private RButton buttonReset; private RButton buttonReset;
private RButton buttonApply;
private Panel panelPower; private Panel panelPower;
private CheckBox checkApplyPower; private RCheckBox checkApplyPower;
private RButton buttonApplyPower;
private Panel panelCPU; private Panel panelCPU;
private Label labelCPU; private Label labelCPU;
private Label label2; private Label label2;
@@ -494,13 +467,13 @@ namespace GHelper
private Label labelTotal; private Label labelTotal;
private Label label1; private Label label1;
private TrackBar trackTotal; private TrackBar trackTotal;
private Label labelApplied;
private PictureBox pictureFine; private PictureBox pictureFine;
private Label labelInfo; private Label labelInfo;
private Label labelPowerLimits; private Label labelPowerLimits;
private TableLayoutPanel tableFanCharts; private TableLayoutPanel tableFanCharts;
private System.Windows.Forms.DataVisualization.Charting.Chart chartGPU; private System.Windows.Forms.DataVisualization.Charting.Chart chartGPU;
private System.Windows.Forms.DataVisualization.Charting.Chart chartCPU; private System.Windows.Forms.DataVisualization.Charting.Chart chartCPU;
private System.Windows.Forms.DataVisualization.Charting.Chart chartMid;
private Label labelFans; private Label labelFans;
private PictureBox picturePerf; private PictureBox picturePerf;
private PictureBox pictureBox1; private PictureBox pictureBox1;

View File

@@ -10,14 +10,77 @@ namespace GHelper
DataPoint curPoint = null; DataPoint curPoint = null;
Series seriesCPU; Series seriesCPU;
Series seriesGPU; Series seriesGPU;
Series seriesMid;
static int MinRPM, MaxRPM; static int MinRPM, MaxRPM;
public Fans()
{
InitializeComponent();
InitTheme();
MinRPM = 18;
MaxRPM = HardwareMonitor.GetFanMax();
labelTip.Visible = false;
labelTip.BackColor = Color.Transparent;
FormClosing += Fans_FormClosing;
seriesCPU = chartCPU.Series.Add("CPU");
seriesGPU = chartGPU.Series.Add("GPU");
seriesMid = chartMid.Series.Add("Mid");
seriesCPU.Color = colorStandard;
seriesGPU.Color = colorTurbo;
seriesMid.Color = colorEco;
chartCPU.MouseMove += ChartCPU_MouseMove;
chartCPU.MouseUp += ChartCPU_MouseUp;
chartGPU.MouseMove += ChartCPU_MouseMove;
chartGPU.MouseUp += ChartCPU_MouseUp;
chartMid.MouseMove += ChartCPU_MouseMove;
chartMid.MouseUp += ChartCPU_MouseUp;
buttonReset.Click += ButtonReset_Click;
trackTotal.Maximum = ASUSWmi.MaxTotal;
trackTotal.Minimum = ASUSWmi.MinTotal;
trackCPU.Maximum = ASUSWmi.MaxCPU;
trackCPU.Minimum = ASUSWmi.MinCPU;
trackCPU.Scroll += TrackPower_Scroll;
trackTotal.Scroll += TrackPower_Scroll;
trackCPU.MouseUp += TrackPower_MouseUp;
trackTotal.MouseUp += TrackPower_MouseUp;
checkApplyFans.Click += CheckApplyFans_Click;
checkApplyPower.Click += CheckApplyPower_Click;
//labelInfo.MaximumSize = new Size(280, 0);
labelInfo.Text = "Power Limits (PPT) is\nexperimental feature.\n\nUse carefully and\non your own risk!";
InitFans();
InitPower();
InitBoost();
comboBoost.SelectedValueChanged += ComboBoost_Changed;
Shown += Fans_Shown;
}
static string ChartPercToRPM(int percentage, string unit = "") static string ChartPercToRPM(int percentage, string unit = "")
{ {
if (percentage == 0) return "OFF"; if (percentage == 0) return "OFF";
return (200 * Math.Round((float)(MinRPM + (MaxRPM - MinRPM) * percentage * 0.01) / 200)).ToString() + unit; return (200 * Math.Round((float)(MinRPM * 100 + (MaxRPM - MinRPM) * percentage) / 200)).ToString() + unit;
} }
void SetChart(Chart chart, int device) void SetChart(Chart chart, int device)
@@ -27,6 +90,8 @@ namespace GHelper
if (device == 1) if (device == 1)
title = "GPU Fan Profile"; title = "GPU Fan Profile";
else if (device == 2)
title = "Middle Fan Profile";
else else
title = "CPU Fan Profile"; title = "CPU Fan Profile";
@@ -44,6 +109,11 @@ namespace GHelper
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F); chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = chartGrid;
chart.ChartAreas[0].AxisX.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.LineColor = chartGrid;
for (int i = 0; i <= 90; i += 10) for (int i = 0; i <= 90; i += 10)
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i)); chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
@@ -73,68 +143,10 @@ namespace GHelper
Left = Program.settingsForm.Left - Width - 5; Left = Program.settingsForm.Left - Width - 5;
} }
public Fans()
private void TrackPower_MouseUp(object? sender, MouseEventArgs e)
{ {
Program.settingsForm.AutoPower();
InitializeComponent();
InitTheme();
MinRPM = 1800;
if (Program.config.ContainsModel("401"))
MaxRPM = 7200;
else if (Program.config.ContainsModel("503"))
MaxRPM = 6800;
else
MaxRPM = 5800;
labelTip.Visible = false;
labelTip.BackColor = Color.Transparent;
FormClosing += Fans_FormClosing;
seriesCPU = chartCPU.Series.Add("CPU");
seriesGPU = chartGPU.Series.Add("GPU");
seriesCPU.Color = colorStandard;
seriesGPU.Color = colorTurbo;
chartCPU.MouseMove += ChartCPU_MouseMove;
chartCPU.MouseUp += ChartCPU_MouseUp;
chartGPU.MouseMove += ChartCPU_MouseMove;
chartGPU.MouseUp += ChartCPU_MouseUp;
buttonReset.Click += ButtonReset_Click;
buttonApply.Click += ButtonApply_Click;
trackTotal.Maximum = ASUSWmi.MaxTotal;
trackTotal.Minimum = ASUSWmi.MinTotal;
trackCPU.Maximum = ASUSWmi.MaxCPU;
trackCPU.Minimum = ASUSWmi.MinCPU;
trackCPU.Scroll += TrackCPU_Scroll;
trackTotal.Scroll += TrackTotal_Scroll;
buttonApplyPower.Click += ButtonApplyPower_Click;
checkAuto.Click += CheckAuto_Click;
checkApplyPower.Click += CheckApplyPower_Click;
//labelInfo.MaximumSize = new Size(280, 0);
labelInfo.Text = "Power Limits (PPT) is\nexperimental feature.\n\nUse carefully and\non your own risk!";
InitFans();
InitPower();
InitBoost();
comboBoost.SelectedIndexChanged += ComboBoost_Changed;
Shown += Fans_Shown;
} }
@@ -147,9 +159,11 @@ namespace GHelper
private void ComboBoost_Changed(object? sender, EventArgs e) private void ComboBoost_Changed(object? sender, EventArgs e)
{ {
if (sender is null) return; if (Program.config.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
ComboBox cmb = (ComboBox)sender; {
NativeMethods.SetCPUBoost(cmb.SelectedIndex); NativeMethods.SetCPUBoost(comboBoost.SelectedIndex);
Program.config.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
}
} }
private void CheckApplyPower_Click(object? sender, EventArgs e) private void CheckApplyPower_Click(object? sender, EventArgs e)
@@ -157,13 +171,38 @@ namespace GHelper
if (sender is null) return; if (sender is null) return;
CheckBox chk = (CheckBox)sender; CheckBox chk = (CheckBox)sender;
Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0); Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
if (chk.Checked)
{
Program.settingsForm.AutoPower();
}
else
{
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
Program.settingsForm.AutoFans();
}
} }
private void CheckAuto_Click(object? sender, EventArgs e) private void CheckApplyFans_Click(object? sender, EventArgs e)
{ {
if (sender is null) return; if (sender is null) return;
CheckBox chk = (CheckBox)sender; CheckBox chk = (CheckBox)sender;
Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0); Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
if (chk.Checked)
{
Program.settingsForm.AutoFans();
}
else
{
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
Program.settingsForm.AutoPower();
}
} }
private void Fans_FormClosing(object? sender, FormClosingEventArgs e) private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
@@ -175,11 +214,6 @@ namespace GHelper
} }
} }
private void ButtonApplyPower_Click(object? sender, EventArgs e)
{
Program.settingsForm.SetPower();
ApplyLabel(true);
}
public void InitPower(bool changed = false) public void InitPower(bool changed = false)
{ {
@@ -204,13 +238,11 @@ namespace GHelper
{ {
limit_total = trackTotal.Value; limit_total = trackTotal.Value;
limit_cpu = trackCPU.Value; limit_cpu = trackCPU.Value;
ApplyLabel(false);
} }
else else
{ {
limit_total = Program.config.getConfigPerf("limit_total"); limit_total = Program.config.getConfigPerf("limit_total");
limit_cpu = Program.config.getConfigPerf("limit_cpu"); limit_cpu = Program.config.getConfigPerf("limit_cpu");
ApplyLabel(apply);
} }
if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal; if (limit_total < 0) limit_total = ASUSWmi.DefaultTotal;
@@ -232,38 +264,36 @@ namespace GHelper
Program.config.setConfigPerf("limit_total", limit_total); Program.config.setConfigPerf("limit_total", limit_total);
Program.config.setConfigPerf("limit_cpu", limit_cpu); Program.config.setConfigPerf("limit_cpu", limit_cpu);
} }
private void TrackTotal_Scroll(object? sender, EventArgs e) private void TrackPower_Scroll(object? sender, EventArgs e)
{ {
InitPower(true); InitPower(true);
} }
private void TrackCPU_Scroll(object? sender, EventArgs e)
{
InitPower(true);
}
public void ApplyLabel(bool applied = false)
{
if (applied)
{
labelApplied.ForeColor = colorStandard;
labelApplied.Text = "Applied";
}
else
{
labelApplied.ForeColor = colorTurbo;
labelApplied.Text = "Not Applied";
}
}
public void InitFans() public void InitFans()
{ {
byte[] curve = Program.wmi.GetFanCurve(2);
if (curve.All(singleByte => singleByte == 0))
{
Program.config.setConfig("mid_fan", 0);
}
else
{
Program.config.setConfig("mid_fan", 1);
chartMid.Visible = true;
SetChart(chartMid, 2);
LoadProfile(seriesMid, 2);
}
SetChart(chartCPU, 0); SetChart(chartCPU, 0);
SetChart(chartGPU, 1); SetChart(chartGPU, 1);
@@ -272,7 +302,7 @@ namespace GHelper
int auto_apply = Program.config.getConfigPerf("auto_apply"); int auto_apply = Program.config.getConfigPerf("auto_apply");
checkAuto.Checked = (auto_apply == 1); checkApplyFans.Checked = (auto_apply == 1);
} }
@@ -307,7 +337,7 @@ namespace GHelper
} }
void ApplyProfile(Series series, int device) void SaveProfile(Series series, int device)
{ {
byte[] curve = new byte[16]; byte[] curve = new byte[16];
int i = 0; int i = 0;
@@ -319,38 +349,41 @@ namespace GHelper
} }
Program.config.setFanConfig(device, curve); Program.config.setFanConfig(device, curve);
Program.wmi.SetFanCurve(device, curve); //Program.wmi.SetFanCurve(device, curve);
} }
private void ButtonApply_Click(object? sender, EventArgs e)
{
ApplyProfile(seriesCPU, 0);
ApplyProfile(seriesGPU, 1);
}
private void ButtonReset_Click(object? sender, EventArgs e) private void ButtonReset_Click(object? sender, EventArgs e)
{ {
LoadProfile(seriesCPU, 0, 1); LoadProfile(seriesCPU, 0, 1);
LoadProfile(seriesGPU, 1, 1); LoadProfile(seriesGPU, 1, 1);
if (Program.config.getConfig("mid_fan") == 1)
LoadProfile(seriesMid, 2, 1);
checkAuto.Checked = false; checkApplyFans.Checked = false;
checkApplyPower.Checked = false; checkApplyPower.Checked = false;
Program.config.setConfigPerf("auto_apply", 0); Program.config.setConfigPerf("auto_apply", 0);
Program.config.setConfigPerf("auto_apply_power", 0); Program.config.setConfigPerf("auto_apply_power", 0);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode")); Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
ApplyLabel(false);
} }
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e) private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
{ {
curPoint = null; curPoint = null;
labelTip.Visible = false; labelTip.Visible = false;
SaveProfile(seriesCPU, 0);
SaveProfile(seriesGPU, 1);
if (Program.config.getConfig("mid_fan") == 1)
SaveProfile(seriesMid, 2);
Program.settingsForm.AutoFans();
} }
private void ChartCPU_MouseMove(object? sender, MouseEventArgs e) private void ChartCPU_MouseMove(object? sender, MouseEventArgs e)

View File

@@ -16,7 +16,23 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.33</AssemblyVersion> <AssemblyVersion>0.49</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DebugType>none</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -48,7 +64,7 @@
<PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" /> <PackageReference Include="NvAPIWrapper.Net" Version="0.8.1.101" />
<PackageReference Include="System.Management" Version="7.0.0" /> <PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="TaskScheduler" Version="2.10.1" /> <PackageReference Include="TaskScheduler" Version="2.10.1" />
<PackageReference Include="WinForms.DataVisualization" Version="1.7.0" /> <PackageReference Include="WinForms.DataVisualization" Version="1.8.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -73,6 +73,24 @@ public class AmdGpuTemperatureProvider : IGpuTemperatureProvider {
return temperatureSensor.Value; return temperatureSensor.Value;
} }
public int? GetGpuUse()
{
if (!IsValid)
return null;
if (Adl2.NativeMethods.ADL2_New_QueryPMLogData_Get(_adlContextHandle, _internalDiscreteAdapter.AdapterIndex, out ADLPMLogDataOutput adlpmLogDataOutput) != Adl2.ADL_SUCCESS)
return null;
ADLSingleSensorData gpuUsage = adlpmLogDataOutput.Sensors[(int)ADLSensorType.PMLOG_INFO_ACTIVITY_GFX];
if (gpuUsage.Supported == 0)
return null;
return gpuUsage.Value;
}
private void ReleaseUnmanagedResources() { private void ReleaseUnmanagedResources() {
if (_adlContextHandle != IntPtr.Zero) { if (_adlContextHandle != IntPtr.Zero) {
Adl2.NativeMethods.ADL2_Main_Control_Destroy(_adlContextHandle); Adl2.NativeMethods.ADL2_Main_Control_Destroy(_adlContextHandle);

View File

@@ -3,4 +3,5 @@
public interface IGpuTemperatureProvider : IDisposable { public interface IGpuTemperatureProvider : IDisposable {
bool IsValid { get; } bool IsValid { get; }
int? GetCurrentTemperature(); int? GetCurrentTemperature();
int? GetGpuUse();
} }

View File

@@ -1,42 +1,68 @@
using NvAPIWrapper.GPU; using NvAPIWrapper.GPU;
using NvAPIWrapper.Native; using NvAPIWrapper.Native;
using NvAPIWrapper.Native.Exceptions;
using NvAPIWrapper.Native.GPU; using NvAPIWrapper.Native.GPU;
using NvAPIWrapper.Native.Interfaces.GPU; using NvAPIWrapper.Native.Interfaces.GPU;
namespace GHelper.Gpu; namespace GHelper.Gpu;
public class NvidiaGpuTemperatureProvider : IGpuTemperatureProvider { public class NvidiaGpuTemperatureProvider : IGpuTemperatureProvider
{
private readonly PhysicalGPU? _internalGpu; private readonly PhysicalGPU? _internalGpu;
public NvidiaGpuTemperatureProvider() { public NvidiaGpuTemperatureProvider()
{
_internalGpu = GetInternalDiscreteGpu(); _internalGpu = GetInternalDiscreteGpu();
} }
public bool IsValid => _internalGpu != null; public bool IsValid => _internalGpu != null;
public int? GetCurrentTemperature() { public int? GetCurrentTemperature()
{
if (!IsValid) if (!IsValid)
return null; return null;
PhysicalGPU internalGpu = _internalGpu!; PhysicalGPU internalGpu = _internalGpu!;
IThermalSensor? gpuSensor = IThermalSensor? gpuSensor =
GPUApi.GetThermalSettings(internalGpu.Handle).Sensors GPUApi.GetThermalSettings(internalGpu.Handle).Sensors
.FirstOrDefault(s => s.Target == ThermalSettingsTarget.GPU); .FirstOrDefault(s => s.Target == ThermalSettingsTarget.GPU);
return gpuSensor?.CurrentTemperature; return gpuSensor?.CurrentTemperature;
} }
public void Dispose() { public void Dispose()
{
} }
private static PhysicalGPU? GetInternalDiscreteGpu() { private static PhysicalGPU? GetInternalDiscreteGpu()
try { {
try
{
return PhysicalGPU return PhysicalGPU
.GetPhysicalGPUs() .GetPhysicalGPUs()
.FirstOrDefault(gpu => gpu.SystemType == SystemType.Laptop); .FirstOrDefault(gpu => gpu.SystemType == SystemType.Laptop);
} catch { }
catch
{
return null; return null;
} }
} }
public int? GetGpuUse()
{
if (!IsValid)
return null;
PhysicalGPU internalGpu = _internalGpu!;
IUtilizationDomainInfo? gpuUsage = GPUApi.GetUsages(internalGpu.Handle).GPU;
if (gpuUsage == null)
return null;
return
(int)gpuUsage?.Percentage;
}
} }

View File

@@ -1,5 +1,7 @@
using System.Diagnostics; using GHelper;
using GHelper.Gpu; using GHelper.Gpu;
using System.Diagnostics;
using System.Management;
public static class HardwareMonitor public static class HardwareMonitor
{ {
@@ -9,20 +11,101 @@ public static class HardwareMonitor
public static float? batteryDischarge = -1; public static float? batteryDischarge = -1;
public static int? gpuTemp = null; public static int? gpuTemp = null;
public static string? cpuFan;
public static string? gpuFan;
public static string? midFan;
//public static List<int> gpuUsage = new List<int>();
public static int? gpuUse;
public static int GetFanMax()
{
int max = 58;
if (Program.config.ContainsModel("401")) max = 72;
else if (Program.config.ContainsModel("503")) max = 68;
return Math.Max(max, Program.config.getConfig("fan_max"));
}
public static void SetFanMax(int fan)
{
Program.config.setConfig("fan_max", fan);
}
private static string FormatFan(int fan)
{
// fix for old models
if (fan < 0)
{
fan += 65536;
if (fan <= 0 || fan > 100) return null; //nothing reasonable
}
int fanMax = GetFanMax();
if (fan > fanMax) SetFanMax(fan);
if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM";
else
return " Fan: " + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
}
private static int GetGpuUse()
{
try
{
int? gpuUse = GpuTemperatureProvider?.GetGpuUse();
if (gpuUse is not null) return (int)gpuUse;
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
return 0;
}
public static void ReadSensors() public static void ReadSensors()
{ {
cpuTemp = -1;
batteryDischarge = -1; batteryDischarge = -1;
gpuTemp = -1;
gpuUse = -1;
try cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan));
cpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_CPU);
if (cpuTemp < 0) try
{ {
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true); var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
cpuTemp = ct.NextValue() - 273; cpuTemp = ct.NextValue() - 273;
ct.Dispose(); ct.Dispose();
} catch
{
Logger.WriteLine("Failed reading CPU temp");
} }
catch
{
Debug.WriteLine("Failed reading CPU temp");
}
try
{
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
}
catch (Exception ex)
{
gpuTemp = -1;
Debug.WriteLine("Failed reading GPU temp");
Debug.WriteLine(ex.ToString());
}
if (gpuTemp is null || gpuTemp < 0)
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
/*
gpuUsage.Add(GetGpuUse());
if (gpuUsage.Count > 3) gpuUsage.RemoveAt(0);
*/
try try
{ {
@@ -30,34 +113,35 @@ public static class HardwareMonitor
batteryDischarge = cb.NextValue() / 1000; batteryDischarge = cb.NextValue() / 1000;
cb.Dispose(); cb.Dispose();
} catch
{
Logger.WriteLine("Failed reading Battery discharge");
} }
catch
try
{ {
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature(); Debug.WriteLine("Failed reading Battery discharge");
} catch (Exception ex) {
gpuTemp = null;
Logger.WriteLine("Failed reading GPU temp");
Logger.WriteLine(ex.ToString());
} }
} }
public static void RecreateGpuTemperatureProviderWithRetry() { public static bool IsUsedGPU(int threshold = 50)
RecreateGpuTemperatureProvider(); {
return (GetGpuUse() > threshold);
}
public static void RecreateGpuTemperatureProviderWithDelay()
{
// Re-enabling the discrete GPU takes a bit of time, // Re-enabling the discrete GPU takes a bit of time,
// so a simple workaround is to refresh again after that happens // so a simple workaround is to refresh again after that happens
Task.Run(async () => { Task.Run(async () =>
await Task.Delay(TimeSpan.FromSeconds(3)); {
await Task.Delay(TimeSpan.FromSeconds(5));
RecreateGpuTemperatureProvider(); RecreateGpuTemperatureProvider();
}); });
} }
public static void RecreateGpuTemperatureProvider() { public static void RecreateGpuTemperatureProvider()
{
try try
{ {
GpuTemperatureProvider?.Dispose(); GpuTemperatureProvider?.Dispose();
@@ -84,11 +168,8 @@ public static class HardwareMonitor
GpuTemperatureProvider = null; GpuTemperatureProvider = null;
} }
catch (Exception ex) catch (Exception ex)
{
}
finally
{ {
Logger.WriteLine($"GpuTemperatureProvider: {GpuTemperatureProvider?.GetType().Name}"); Debug.WriteLine(ex.ToString());
} }
} }
} }

204
app/Keyboard.Designer.cs generated
View File

@@ -31,16 +31,29 @@ namespace GHelper
private void InitializeComponent() private void InitializeComponent()
{ {
groupBox1 = new GroupBox(); groupBox1 = new GroupBox();
textFNF4 = new TextBox();
comboFNF4 = new RComboBox();
labelFNF4 = new Label();
textM4 = new TextBox(); textM4 = new TextBox();
textM3 = new TextBox(); textM3 = new TextBox();
comboM4 = new RComboBox(); comboM4 = new RComboBox();
labelM4 = new Label(); labelM4 = new Label();
comboM3 = new RComboBox(); comboM3 = new RComboBox();
labelM3 = new Label(); labelM3 = new Label();
textFNF4 = new TextBox(); groupLight = new GroupBox();
comboFNF4 = new RComboBox(); labelSpeed = new Label();
labelFNF4 = new Label(); comboKeyboardSpeed = new RComboBox();
checkShutdown = new CheckBox();
checkSleep = new CheckBox();
checkBoot = new CheckBox();
checkAwake = new CheckBox();
groupOther = new GroupBox();
checkKeyboardAuto = new CheckBox();
checkTopmost = new CheckBox();
checkNoOverdrive = new CheckBox();
groupBox1.SuspendLayout(); groupBox1.SuspendLayout();
groupLight.SuspendLayout();
groupOther.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// groupBox1 // groupBox1
@@ -57,11 +70,36 @@ namespace GHelper
groupBox1.Dock = DockStyle.Top; groupBox1.Dock = DockStyle.Top;
groupBox1.Location = new Point(10, 10); groupBox1.Location = new Point(10, 10);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(751, 242); groupBox1.Size = new Size(756, 242);
groupBox1.TabIndex = 0; groupBox1.TabIndex = 0;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Key Bindings"; groupBox1.Text = "Key Bindings";
// //
// textFNF4
//
textFNF4.Location = new Point(411, 176);
textFNF4.Name = "textFNF4";
textFNF4.PlaceholderText = "action";
textFNF4.Size = new Size(320, 39);
textFNF4.TabIndex = 8;
//
// comboFNF4
//
comboFNF4.FormattingEnabled = true;
comboFNF4.Location = new Point(93, 175);
comboFNF4.Name = "comboFNF4";
comboFNF4.Size = new Size(312, 40);
comboFNF4.TabIndex = 7;
//
// labelFNF4
//
labelFNF4.AutoSize = true;
labelFNF4.Location = new Point(2, 178);
labelFNF4.Name = "labelFNF4";
labelFNF4.Size = new Size(90, 32);
labelFNF4.TabIndex = 6;
labelFNF4.Text = "FN+F4:";
//
// textM4 // textM4
// //
textM4.Location = new Point(411, 113); textM4.Location = new Point(411, 113);
@@ -114,36 +152,137 @@ namespace GHelper
labelM3.TabIndex = 0; labelM3.TabIndex = 0;
labelM3.Text = "M3:"; labelM3.Text = "M3:";
// //
// textFNF4 // groupLight
// //
textFNF4.Location = new Point(411, 176); groupLight.Controls.Add(labelSpeed);
textFNF4.Name = "textFNF4"; groupLight.Controls.Add(comboKeyboardSpeed);
textFNF4.PlaceholderText = "action"; groupLight.Controls.Add(checkShutdown);
textFNF4.Size = new Size(320, 39); groupLight.Controls.Add(checkSleep);
textFNF4.TabIndex = 8; groupLight.Controls.Add(checkBoot);
groupLight.Controls.Add(checkAwake);
groupLight.Dock = DockStyle.Top;
groupLight.Location = new Point(10, 252);
groupLight.Name = "groupLight";
groupLight.Size = new Size(756, 304);
groupLight.TabIndex = 1;
groupLight.TabStop = false;
groupLight.Text = "Keyboard Backlight";
// //
// comboFNF4 // labelSpeed
// //
comboFNF4.FormattingEnabled = true; labelSpeed.AutoSize = true;
comboFNF4.Location = new Point(93, 175); labelSpeed.Location = new Point(25, 237);
comboFNF4.Name = "comboFNF4"; labelSpeed.Name = "labelSpeed";
comboFNF4.Size = new Size(312, 40); labelSpeed.Size = new Size(198, 32);
comboFNF4.TabIndex = 7; labelSpeed.TabIndex = 40;
labelSpeed.Text = "Animation Speed";
// //
// labelFNF4 // comboKeyboardSpeed
// //
labelFNF4.AutoSize = true; comboKeyboardSpeed.BorderColor = Color.White;
labelFNF4.Location = new Point(2, 178); comboKeyboardSpeed.ButtonColor = SystemColors.ControlLight;
labelFNF4.Name = "labelFNF4"; comboKeyboardSpeed.FlatStyle = FlatStyle.Flat;
labelFNF4.Size = new Size(90, 32); comboKeyboardSpeed.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
labelFNF4.TabIndex = 6; comboKeyboardSpeed.FormattingEnabled = true;
labelFNF4.Text = "FN+F4:"; comboKeyboardSpeed.ItemHeight = 32;
comboKeyboardSpeed.Items.AddRange(new object[] { "Slow", "Normal", "Fast" });
comboKeyboardSpeed.Location = new Point(230, 234);
comboKeyboardSpeed.Margin = new Padding(4, 10, 4, 8);
comboKeyboardSpeed.Name = "comboKeyboardSpeed";
comboKeyboardSpeed.Size = new Size(291, 40);
comboKeyboardSpeed.TabIndex = 39;
comboKeyboardSpeed.TabStop = false;
//
// checkShutdown
//
checkShutdown.AutoSize = true;
checkShutdown.Location = new Point(25, 185);
checkShutdown.Name = "checkShutdown";
checkShutdown.Size = new Size(154, 36);
checkShutdown.TabIndex = 3;
checkShutdown.Text = "Shutdown";
checkShutdown.UseVisualStyleBackColor = true;
//
// checkSleep
//
checkSleep.AutoSize = true;
checkSleep.Location = new Point(25, 143);
checkSleep.Name = "checkSleep";
checkSleep.Size = new Size(105, 36);
checkSleep.TabIndex = 2;
checkSleep.Text = "Sleep";
checkSleep.UseVisualStyleBackColor = true;
//
// checkBoot
//
checkBoot.AutoSize = true;
checkBoot.Location = new Point(25, 101);
checkBoot.Name = "checkBoot";
checkBoot.Size = new Size(96, 36);
checkBoot.TabIndex = 1;
checkBoot.Text = "Boot";
checkBoot.UseVisualStyleBackColor = true;
//
// checkAwake
//
checkAwake.AutoSize = true;
checkAwake.Location = new Point(25, 59);
checkAwake.Name = "checkAwake";
checkAwake.Size = new Size(115, 36);
checkAwake.TabIndex = 0;
checkAwake.Text = "Awake";
checkAwake.UseVisualStyleBackColor = true;
//
// groupOther
//
groupOther.Controls.Add(checkNoOverdrive);
groupOther.Controls.Add(checkKeyboardAuto);
groupOther.Controls.Add(checkTopmost);
groupOther.Dock = DockStyle.Top;
groupOther.Location = new Point(10, 556);
groupOther.Name = "groupOther";
groupOther.Size = new Size(756, 225);
groupOther.TabIndex = 2;
groupOther.TabStop = false;
groupOther.Text = "Other";
//
// checkKeyboardAuto
//
checkKeyboardAuto.AutoSize = true;
checkKeyboardAuto.Location = new Point(25, 51);
checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36);
checkKeyboardAuto.TabIndex = 2;
checkKeyboardAuto.Text = "Lower backlight brightness on battery and back when plugged";
checkKeyboardAuto.UseVisualStyleBackColor = true;
//
// checkTopmost
//
checkTopmost.AutoSize = true;
checkTopmost.Location = new Point(25, 104);
checkTopmost.Name = "checkTopmost";
checkTopmost.Size = new Size(390, 36);
checkTopmost.TabIndex = 1;
checkTopmost.Text = "Keep app window always on top";
checkTopmost.UseVisualStyleBackColor = true;
//
// checkNoOverdrive
//
checkNoOverdrive.AutoSize = true;
checkNoOverdrive.Location = new Point(25, 156);
checkNoOverdrive.Name = "checkNoOverdrive";
checkNoOverdrive.Size = new Size(307, 36);
checkNoOverdrive.TabIndex = 3;
checkNoOverdrive.Text = "Disable screen overdrive";
checkNoOverdrive.UseVisualStyleBackColor = true;
// //
// Keyboard // Keyboard
// //
AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(771, 858); ClientSize = new Size(776, 858);
Controls.Add(groupOther);
Controls.Add(groupLight);
Controls.Add(groupBox1); Controls.Add(groupBox1);
FormBorderStyle = FormBorderStyle.FixedSingle; FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false; MaximizeBox = false;
@@ -153,9 +292,13 @@ namespace GHelper
Padding = new Padding(10); Padding = new Padding(10);
ShowIcon = false; ShowIcon = false;
ShowInTaskbar = false; ShowInTaskbar = false;
Text = "Keyboard"; Text = "Extra Settings";
groupBox1.ResumeLayout(false); groupBox1.ResumeLayout(false);
groupBox1.PerformLayout(); groupBox1.PerformLayout();
groupLight.ResumeLayout(false);
groupLight.PerformLayout();
groupOther.ResumeLayout(false);
groupOther.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
} }
@@ -171,5 +314,16 @@ namespace GHelper
private TextBox textFNF4; private TextBox textFNF4;
private RComboBox comboFNF4; private RComboBox comboFNF4;
private Label labelFNF4; private Label labelFNF4;
private GroupBox groupLight;
private CheckBox checkSleep;
private CheckBox checkBoot;
private CheckBox checkAwake;
private CheckBox checkShutdown;
private Label labelSpeed;
private RComboBox comboKeyboardSpeed;
private GroupBox groupOther;
private CheckBox checkTopmost;
private CheckBox checkKeyboardAuto;
private CheckBox checkNoOverdrive;
} }
} }

View File

@@ -1,4 +1,5 @@
using CustomControls; using CustomControls;
using Microsoft.Win32;
namespace GHelper namespace GHelper
{ {
@@ -60,6 +61,76 @@ namespace GHelper
SetKeyCombo(comboFNF4, textFNF4, "fnf4"); SetKeyCombo(comboFNF4, textFNF4, "fnf4");
Shown += Keyboard_Shown; Shown += Keyboard_Shown;
comboKeyboardSpeed.DropDownStyle = ComboBoxStyle.DropDownList;
comboKeyboardSpeed.DataSource = new BindingSource(Aura.GetSpeeds(), null);
comboKeyboardSpeed.DisplayMember = "Value";
comboKeyboardSpeed.ValueMember = "Key";
comboKeyboardSpeed.SelectedValue = Aura.Speed;
comboKeyboardSpeed.SelectedValueChanged += ComboKeyboardSpeed_SelectedValueChanged;
checkAwake.Checked = !(Program.config.getConfig("keyboard_awake") == 0);
checkBoot.Checked = !(Program.config.getConfig("keyboard_boot") == 0);
checkSleep.Checked = !(Program.config.getConfig("keyboard_sleep") == 0);
checkShutdown.Checked = !(Program.config.getConfig("keyboard_shutdown") == 0);
checkAwake.CheckedChanged += CheckPower_CheckedChanged;
checkBoot.CheckedChanged += CheckPower_CheckedChanged;
checkSleep.CheckedChanged += CheckPower_CheckedChanged;
checkShutdown.CheckedChanged += CheckPower_CheckedChanged;
checkTopmost.Checked = (Program.config.getConfig("topmost") == 1);
checkTopmost.CheckedChanged += CheckTopmost_CheckedChanged; ;
checkKeyboardAuto.Checked = (Program.config.getConfig("keyboard_auto") == 1);
checkKeyboardAuto.CheckedChanged += CheckKeyboardAuto_CheckedChanged;
checkNoOverdrive.Checked = (Program.config.getConfig("no_overdrive") == 1);
checkNoOverdrive.CheckedChanged += CheckNoOverdrive_CheckedChanged;
}
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
Program.settingsForm.AutoScreen(true);
}
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
/*
RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\ASUS\\ASUS System Control Interface\\AsusOptimization\\ASUS Keyboard Hotkeys", true);
if (myKey != null)
{
myKey.SetValue("TurnOffKeybdLight", 30, RegistryValueKind.DWord);
myKey.Close();
}
*/
}
private void CheckTopmost_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("topmost", (checkTopmost.Checked ? 1 : 0));
Program.settingsForm.TopMost = checkTopmost.Checked;
}
private void CheckPower_CheckedChanged(object? sender, EventArgs e)
{
Program.config.setConfig("keyboard_awake", (checkAwake.Checked ? 1 : 0));
Program.config.setConfig("keyboard_boot", (checkBoot.Checked ? 1 : 0));
Program.config.setConfig("keyboard_sleep", (checkSleep.Checked ? 1 : 0));
Program.config.setConfig("keyboard_shutdown", (checkShutdown.Checked ? 1 : 0));
Aura.ApplyAuraPower(checkAwake.Checked, checkBoot.Checked, checkSleep.Checked, checkShutdown.Checked);
}
private void ComboKeyboardSpeed_SelectedValueChanged(object? sender, EventArgs e)
{
Program.config.setConfig("aura_speed", (int)comboKeyboardSpeed.SelectedValue);
Program.settingsForm.SetAura();
} }

View File

@@ -5,6 +5,49 @@ using static Tools.ScreenInterrogatory;
namespace Tools namespace Tools
{ {
public class KeyHandler
{
public const int NOMOD = 0x0000;
public const int ALT = 0x0001;
public const int CTRL = 0x0002;
public const int SHIFT = 0x0004;
public const int WIN = 0x0008;
public const int WM_HOTKEY_MSG_ID = 0x0312;
[DllImport("user32.dll")]
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
[DllImport("user32.dll")]
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
private int modifier;
private int key;
private IntPtr hWnd;
private int id;
public KeyHandler(int modifier, Keys key, nint handle)
{
this.modifier = modifier;
this.key = (int)key;
this.hWnd = handle;
id = this.GetHashCode();
}
public override int GetHashCode()
{
return modifier ^ key ^ hWnd.ToInt32();
}
public bool Register()
{
return RegisterHotKey(hWnd, id, modifier, key);
}
public bool Unregiser()
{
return UnregisterHotKey(hWnd, id);
}
}
public static class ScreenInterrogatory public static class ScreenInterrogatory
{ {
public const int ERROR_SUCCESS = 0; public const int ERROR_SUCCESS = 0;
@@ -588,7 +631,7 @@ public class NativeMethods
return laptopScreen; return laptopScreen;
} }
public static int GetRefreshRate() public static int GetRefreshRate(bool max = false)
{ {
DEVMODE dm = CreateDevmode(); DEVMODE dm = CreateDevmode();
@@ -598,10 +641,23 @@ public class NativeMethods
if (laptopScreen is null) if (laptopScreen is null)
return -1; return -1;
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) if (max)
{ {
frequency = dm.dmDisplayFrequency; int i = 0;
while (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, i, ref dm))
{
if (dm.dmDisplayFrequency > frequency) frequency = dm.dmDisplayFrequency;
i++;
}
} }
else
{
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
{
frequency = dm.dmDisplayFrequency;
}
}
return frequency; return frequency;
} }
@@ -618,6 +674,7 @@ public class NativeMethods
{ {
dm.dmDisplayFrequency = frequency; dm.dmDisplayFrequency = frequency;
int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero); int iRet = NativeMethods.ChangeDisplaySettingsEx(laptopScreen, ref dm, IntPtr.Zero, DisplaySettingsFlags.CDS_UPDATEREGISTRY, IntPtr.Zero);
Logger.WriteLine("Screen = " + frequency.ToString() + "Hz : " + (iRet == 0 ? "OK" : iRet));
return iRet; return iRet;
} }
@@ -671,6 +728,7 @@ public class NativeMethods
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
*/ */
Logger.WriteLine("Boost " + boost);
} }
public static void SetPowerScheme(int mode) public static void SetPowerScheme(int mode)

View File

@@ -1,15 +1,12 @@
using Microsoft.Win32; using Microsoft.Win32;
using System.Diagnostics; using System.Diagnostics;
using System.Management; using System.Management;
using System.Reflection; using Tools;
using System.Text.Json;
namespace GHelper namespace GHelper
{ {
static class Program static class Program
{ {
public static NotifyIcon trayIcon = new NotifyIcon public static NotifyIcon trayIcon = new NotifyIcon
{ {
Text = "G-Helper", Text = "G-Helper",
@@ -17,21 +14,30 @@ namespace GHelper
Visible = true Visible = true
}; };
public static ASUSWmi wmi; public static ASUSWmi? wmi;
public static AppConfig config = new AppConfig(); public static AppConfig config = new AppConfig();
public static SettingsForm settingsForm = new SettingsForm(); public static SettingsForm settingsForm = new SettingsForm();
public static ToastForm toast = new ToastForm(); public static ToastForm toast = new ToastForm();
private static IntPtr unRegPowerNotify; public static IntPtr unRegPowerNotify;
private static IntPtr ds;
private static long lastAuto; private static long lastAuto;
private static long lastTheme; private static long lastTheme;
private static PowerLineStatus isPlugged = PowerLineStatus.Unknown;
// The main entry point for the application // The main entry point for the application
public static void Main() public static void Main()
{ {
if (Process.GetProcesses().Count(p => p.ProcessName == "GHelper") > 1)
{
MessageBox.Show("G-Helper is already running. Check system tray for an icon.", "App already running", MessageBoxButtons.OK);
Application.Exit();
return;
}
try try
{ {
wmi = new ASUSWmi(); wmi = new ASUSWmi();
@@ -49,36 +55,46 @@ namespace GHelper
} }
SystemEvents.UserPreferenceChanged += new Logger.WriteLine("------------");
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged); Logger.WriteLine("App launched: " + config.GetModel());
Application.EnableVisualStyles(); Application.EnableVisualStyles();
ds = settingsForm.Handle; var ds = settingsForm.Handle;
trayIcon.MouseClick += TrayIcon_MouseClick; ; trayIcon.MouseClick += TrayIcon_MouseClick;
wmi.SubscribeToEvents(WatcherEventArrived); wmi.SubscribeToEvents(WatcherEventArrived);
settingsForm.InitGPUMode();
settingsForm.InitAura(); settingsForm.InitAura();
settingsForm.InitMatrix(); settingsForm.InitMatrix();
settingsForm.SetStartupCheck(Startup.IsScheduled()); settingsForm.SetStartupCheck(Startup.IsScheduled());
SetAutoModes(); SetAutoModes();
HardwareMonitor.RecreateGpuTemperatureProvider(); HardwareMonitor.RecreateGpuTemperatureProvider();
// Subscribing for system power change events
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
// Subscribing for monitor power on events // Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid(); var settingGuid = new NativeMethods.PowerSettingGuid();
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
// Subscribing for system power change events // CTRL + SHIFT + F5 to cycle profiles
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; var ghk = new KeyHandler(KeyHandler.SHIFT | KeyHandler.CTRL, Keys.F5, ds);
ghk.Register();
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\'))
{
SettingsToggle();
}
CheckForUpdates();
Application.Run(); Application.Run();
} }
@@ -86,88 +102,59 @@ namespace GHelper
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTheme) < 2000) return; if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastTheme) < 2000) return;
lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds();
switch (e.Category) switch (e.Category)
{ {
case UserPreferenceCategory.General: case UserPreferenceCategory.General:
Debug.WriteLine("Theme Changed"); bool changed = settingsForm.InitTheme();
Thread.Sleep(500); if (changed)
settingsForm.InitTheme(false); {
Debug.WriteLine("Theme Changed");
lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds();
}
if (settingsForm.fans is not null && settingsForm.fans.Text != "") if (settingsForm.fans is not null && settingsForm.fans.Text != "")
settingsForm.fans.InitTheme(false); settingsForm.fans.InitTheme();
if (settingsForm.keyb is not null && settingsForm.keyb.Text != "") if (settingsForm.keyb is not null && settingsForm.keyb.Text != "")
settingsForm.keyb.InitTheme(false); settingsForm.keyb.InitTheme();
break; break;
} }
} }
static async void CheckForUpdates()
public static void SetAutoModes()
{ {
var assembly = Assembly.GetExecutingAssembly().GetName().Version.ToString(); if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
settingsForm.SetVersionLabel("Version: " + assembly);
try
{
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App");
var json = await httpClient.GetStringAsync("https://api.github.com/repos/seerge/g-helper/releases/latest");
var config = JsonSerializer.Deserialize<JsonElement>(json);
var tag = config.GetProperty("tag_name").ToString().Replace("v", "");
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();
var gitVersion = new Version(tag);
var appVersion = new Version(assembly);
var result = gitVersion.CompareTo(appVersion);
if (result > 0)
{
settingsForm.SetVersionLabel("Download Update: " + tag, url);
}
}
}
catch
{
Logger.WriteLine("Failed to get update");
}
}
public static void SetAutoModes(bool wait = false)
{
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 1000) return;
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds(); lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus; isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
Logger.WriteLine("AutoSetting for " + isPlugged.ToString()); Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit")); settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
settingsForm.AutoPerformance();
settingsForm.AutoPerformance(isPlugged); bool switched = settingsForm.AutoGPUMode();
// waiting a bit before turning off dGPU if (!switched)
// if (wait && isPlugged != PowerLineStatus.Online) Thread.Sleep(3000); {
settingsForm.InitGPUMode();
settingsForm.AutoScreen();
}
bool switched = settingsForm.AutoGPUMode(isPlugged); settingsForm.AutoKeyboard();
if (!switched) settingsForm.AutoScreen(isPlugged); settingsForm.SetMatrix();
settingsForm.SetMatrix(isPlugged);
} }
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{ {
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
Logger.WriteLine("Windows - Power Mode Changed"); Logger.WriteLine("Windows - Power Mode Changed");
SetAutoModes(true); SetAutoModes();
} }
@@ -183,7 +170,7 @@ namespace GHelper
} }
catch catch
{ {
Logger.WriteLine("Failed to run " + fileName); Logger.WriteLine("Failed to run " + fileName);
} }

240
app/Settings.Designer.cs generated
View File

@@ -35,16 +35,17 @@ namespace GHelper
checkMatrix = new CheckBox(); checkMatrix = new CheckBox();
tableLayoutMatrix = new TableLayoutPanel(); tableLayoutMatrix = new TableLayoutPanel();
comboMatrix = new RComboBox(); comboMatrix = new RComboBox();
buttonMatrix = new RButton();
comboMatrixRunning = new RComboBox(); comboMatrixRunning = new RComboBox();
buttonMatrix = new RButton();
pictureMatrix = new PictureBox(); pictureMatrix = new PictureBox();
labelMatrix = new Label(); labelMatrix = new Label();
panelBattery = new Panel(); panelBattery = new Panel();
sliderBattery = new WinFormsSliderBar.Slider();
labelModel = new Label();
labelVersion = new Label(); labelVersion = new Label();
labelBattery = new Label(); labelBattery = new Label();
pictureBattery = new PictureBox(); pictureBattery = new PictureBox();
labelBatteryTitle = new Label(); labelBatteryTitle = new Label();
trackBattery = new TrackBar();
panelFooter = new Panel(); panelFooter = new Panel();
buttonQuit = new RButton(); buttonQuit = new RButton();
checkStartup = new CheckBox(); checkStartup = new CheckBox();
@@ -68,30 +69,30 @@ namespace GHelper
buttonOptimized = new RButton(); buttonOptimized = new RButton();
buttonUltimate = new RButton(); buttonUltimate = new RButton();
panelScreen = new Panel(); panelScreen = new Panel();
labelMidFan = new Label();
labelTipScreen = new Label(); labelTipScreen = new Label();
tableScreen = new TableLayoutPanel(); tableScreen = new TableLayoutPanel();
buttonScreenAuto = new RButton(); buttonScreenAuto = new RButton();
button60Hz = new RButton(); button60Hz = new RButton();
button120Hz = new RButton(); button120Hz = new RButton();
buttonMiniled = new RButton();
pictureScreen = new PictureBox(); pictureScreen = new PictureBox();
labelSreen = new Label(); labelSreen = new Label();
panelKeyboard = new Panel(); panelKeyboard = new Panel();
tableLayoutKeyboard = new TableLayoutPanel(); tableLayoutKeyboard = new TableLayoutPanel();
buttonKeyboard = new RButton();
comboKeyboard = new RComboBox(); comboKeyboard = new RComboBox();
panelColor = new Panel(); panelColor = new Panel();
pictureColor2 = new PictureBox(); pictureColor2 = new PictureBox();
pictureColor = new PictureBox(); pictureColor = new PictureBox();
buttonKeyboardColor = new RButton(); buttonKeyboardColor = new RButton();
buttonKeyboard = new RButton();
pictureKeyboard = new PictureBox(); pictureKeyboard = new PictureBox();
labelKeyboard = new Label(); labelKeyboard = new Label();
buttonMiniled = new RButton();
panelMatrix.SuspendLayout(); panelMatrix.SuspendLayout();
tableLayoutMatrix.SuspendLayout(); tableLayoutMatrix.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
panelBattery.SuspendLayout(); panelBattery.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit();
((System.ComponentModel.ISupportInitialize)trackBattery).BeginInit();
panelFooter.SuspendLayout(); panelFooter.SuspendLayout();
panelPerformance.SuspendLayout(); panelPerformance.SuspendLayout();
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit(); ((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
@@ -143,26 +144,26 @@ namespace GHelper
tableLayoutMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; tableLayoutMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutMatrix.AutoSize = true; tableLayoutMatrix.AutoSize = true;
tableLayoutMatrix.AutoSizeMode = AutoSizeMode.GrowAndShrink; tableLayoutMatrix.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutMatrix.ColumnCount = 4; tableLayoutMatrix.ColumnCount = 3;
tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutMatrix.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutMatrix.Controls.Add(comboMatrix, 0, 0); tableLayoutMatrix.Controls.Add(comboMatrix, 0, 0);
tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0);
tableLayoutMatrix.Controls.Add(comboMatrixRunning, 1, 0); tableLayoutMatrix.Controls.Add(comboMatrixRunning, 1, 0);
tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0);
tableLayoutMatrix.Location = new Point(16, 52); tableLayoutMatrix.Location = new Point(16, 52);
tableLayoutMatrix.Margin = new Padding(8); tableLayoutMatrix.Margin = new Padding(8);
tableLayoutMatrix.Name = "tableLayoutMatrix"; tableLayoutMatrix.Name = "tableLayoutMatrix";
tableLayoutMatrix.RowCount = 1; tableLayoutMatrix.RowCount = 1;
tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutMatrix.Size = new Size(772, 60); tableLayoutMatrix.Size = new Size(771, 60);
tableLayoutMatrix.TabIndex = 43; tableLayoutMatrix.TabIndex = 43;
// //
// comboMatrix // comboMatrix
// //
comboMatrix.BorderColor = Color.White; comboMatrix.BorderColor = Color.White;
comboMatrix.ButtonColor = SystemColors.ControlLight; comboMatrix.ButtonColor = Color.FromArgb(255, 255, 255);
comboMatrix.Dock = DockStyle.Top; comboMatrix.Dock = DockStyle.Top;
comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrix.FormattingEnabled = true; comboMatrix.FormattingEnabled = true;
@@ -171,43 +172,44 @@ namespace GHelper
comboMatrix.Location = new Point(4, 10); comboMatrix.Location = new Point(4, 10);
comboMatrix.Margin = new Padding(4, 10, 4, 8); comboMatrix.Margin = new Padding(4, 10, 4, 8);
comboMatrix.Name = "comboMatrix"; comboMatrix.Name = "comboMatrix";
comboMatrix.Size = new Size(185, 40); comboMatrix.Size = new Size(249, 40);
comboMatrix.TabIndex = 41; comboMatrix.TabIndex = 41;
comboMatrix.TabStop = false; comboMatrix.TabStop = false;
// //
// comboMatrixRunning
//
comboMatrixRunning.BorderColor = Color.White;
comboMatrixRunning.ButtonColor = Color.FromArgb(255, 255, 255);
comboMatrixRunning.Dock = DockStyle.Top;
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrixRunning.FormattingEnabled = true;
comboMatrixRunning.ItemHeight = 32;
comboMatrixRunning.Items.AddRange(new object[] { "Binary Banner", "Rog Logo", "Picture", "Clock" });
comboMatrixRunning.Location = new Point(261, 10);
comboMatrixRunning.Margin = new Padding(4, 10, 4, 8);
comboMatrixRunning.Name = "comboMatrixRunning";
comboMatrixRunning.Size = new Size(249, 40);
comboMatrixRunning.TabIndex = 42;
comboMatrixRunning.TabStop = false;
//
// buttonMatrix // buttonMatrix
// //
buttonMatrix.Activated = false; buttonMatrix.Activated = false;
buttonMatrix.BackColor = SystemColors.ControlLight; buttonMatrix.BackColor = SystemColors.ControlLight;
buttonMatrix.BorderColor = Color.Transparent; buttonMatrix.BorderColor = Color.Transparent;
buttonMatrix.BorderRadius = 2;
buttonMatrix.Dock = DockStyle.Top; buttonMatrix.Dock = DockStyle.Top;
buttonMatrix.FlatAppearance.BorderSize = 0; buttonMatrix.FlatAppearance.BorderSize = 0;
buttonMatrix.FlatStyle = FlatStyle.Flat; buttonMatrix.FlatStyle = FlatStyle.Flat;
buttonMatrix.Location = new Point(390, 8); buttonMatrix.Location = new Point(518, 8);
buttonMatrix.Margin = new Padding(4, 8, 4, 8); buttonMatrix.Margin = new Padding(4, 8, 4, 8);
buttonMatrix.Name = "buttonMatrix"; buttonMatrix.Name = "buttonMatrix";
buttonMatrix.Secondary = true; buttonMatrix.Secondary = true;
buttonMatrix.Size = new Size(185, 44); buttonMatrix.Size = new Size(249, 44);
buttonMatrix.TabIndex = 43; buttonMatrix.TabIndex = 43;
buttonMatrix.Text = "Picture / Gif"; buttonMatrix.Text = "Picture / Gif";
buttonMatrix.UseVisualStyleBackColor = false; buttonMatrix.UseVisualStyleBackColor = false;
// //
// comboMatrixRunning
//
comboMatrixRunning.BorderColor = Color.White;
comboMatrixRunning.ButtonColor = SystemColors.ControlLight;
comboMatrixRunning.Dock = DockStyle.Top;
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrixRunning.FormattingEnabled = true;
comboMatrixRunning.ItemHeight = 32;
comboMatrixRunning.Items.AddRange(new object[] { "Binary Banner", "Rog Logo", "Picture" });
comboMatrixRunning.Location = new Point(197, 10);
comboMatrixRunning.Margin = new Padding(4, 10, 4, 8);
comboMatrixRunning.Name = "comboMatrixRunning";
comboMatrixRunning.Size = new Size(185, 40);
comboMatrixRunning.TabIndex = 42;
comboMatrixRunning.TabStop = false;
//
// pictureMatrix // pictureMatrix
// //
pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_desktop_48; pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_desktop_48;
@@ -234,25 +236,49 @@ namespace GHelper
// //
panelBattery.AutoSize = true; panelBattery.AutoSize = true;
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelBattery.Controls.Add(sliderBattery);
panelBattery.Controls.Add(labelModel);
panelBattery.Controls.Add(labelVersion); panelBattery.Controls.Add(labelVersion);
panelBattery.Controls.Add(labelBattery); panelBattery.Controls.Add(labelBattery);
panelBattery.Controls.Add(pictureBattery); panelBattery.Controls.Add(pictureBattery);
panelBattery.Controls.Add(labelBatteryTitle); panelBattery.Controls.Add(labelBatteryTitle);
panelBattery.Controls.Add(trackBattery);
panelBattery.Dock = DockStyle.Top; panelBattery.Dock = DockStyle.Top;
panelBattery.Location = new Point(10, 926); panelBattery.Location = new Point(10, 926);
panelBattery.Margin = new Padding(8); panelBattery.Margin = new Padding(8);
panelBattery.Name = "panelBattery"; panelBattery.Name = "panelBattery";
panelBattery.Padding = new Padding(0, 0, 0, 12); panelBattery.Padding = new Padding(0, 0, 0, 12);
panelBattery.Size = new Size(810, 158); panelBattery.Size = new Size(810, 163);
panelBattery.TabIndex = 34; panelBattery.TabIndex = 34;
// //
// sliderBattery
//
sliderBattery.Location = new Point(16, 70);
sliderBattery.Max = 100;
sliderBattery.Min = 50;
sliderBattery.Name = "sliderBattery";
sliderBattery.Size = new Size(772, 40);
sliderBattery.TabIndex = 39;
sliderBattery.Text = "sliderBattery";
sliderBattery.Value = 80;
//
// labelModel
//
labelModel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelModel.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
labelModel.ForeColor = SystemColors.ControlDark;
labelModel.Location = new Point(291, 119);
labelModel.Margin = new Padding(8, 0, 8, 0);
labelModel.Name = "labelModel";
labelModel.Size = new Size(492, 32);
labelModel.TabIndex = 38;
labelModel.TextAlign = ContentAlignment.TopRight;
//
// labelVersion // labelVersion
// //
labelVersion.AutoSize = true; labelVersion.AutoSize = true;
labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point); labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point);
labelVersion.ForeColor = SystemColors.ControlDark; labelVersion.ForeColor = SystemColors.ControlDark;
labelVersion.Location = new Point(25, 109); labelVersion.Location = new Point(25, 119);
labelVersion.Margin = new Padding(8, 0, 8, 0); labelVersion.Margin = new Padding(8, 0, 8, 0);
labelVersion.Name = "labelVersion"; labelVersion.Name = "labelVersion";
labelVersion.Size = new Size(44, 32); labelVersion.Size = new Size(44, 32);
@@ -291,22 +317,6 @@ namespace GHelper
labelBatteryTitle.TabIndex = 34; labelBatteryTitle.TabIndex = 34;
labelBatteryTitle.Text = "Battery Charge Limit"; labelBatteryTitle.Text = "Battery Charge Limit";
// //
// trackBattery
//
trackBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
trackBattery.LargeChange = 10;
trackBattery.Location = new Point(20, 52);
trackBattery.Margin = new Padding(8, 4, 8, 4);
trackBattery.Maximum = 100;
trackBattery.Minimum = 50;
trackBattery.Name = "trackBattery";
trackBattery.Size = new Size(766, 90);
trackBattery.SmallChange = 5;
trackBattery.TabIndex = 33;
trackBattery.TickFrequency = 10;
trackBattery.TickStyle = TickStyle.TopLeft;
trackBattery.Value = 100;
//
// panelFooter // panelFooter
// //
panelFooter.AutoSize = true; panelFooter.AutoSize = true;
@@ -314,7 +324,7 @@ namespace GHelper
panelFooter.Controls.Add(buttonQuit); panelFooter.Controls.Add(buttonQuit);
panelFooter.Controls.Add(checkStartup); panelFooter.Controls.Add(checkStartup);
panelFooter.Dock = DockStyle.Top; panelFooter.Dock = DockStyle.Top;
panelFooter.Location = new Point(10, 1084); panelFooter.Location = new Point(10, 1089);
panelFooter.Margin = new Padding(8); panelFooter.Margin = new Padding(8);
panelFooter.Name = "panelFooter"; panelFooter.Name = "panelFooter";
panelFooter.Padding = new Padding(0, 0, 0, 10); panelFooter.Padding = new Padding(0, 0, 0, 10);
@@ -327,12 +337,13 @@ namespace GHelper
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right; buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonQuit.BackColor = SystemColors.ControlLight; buttonQuit.BackColor = SystemColors.ControlLight;
buttonQuit.BorderColor = Color.Transparent; buttonQuit.BorderColor = Color.Transparent;
buttonQuit.BorderRadius = 2;
buttonQuit.FlatStyle = FlatStyle.Flat; buttonQuit.FlatStyle = FlatStyle.Flat;
buttonQuit.Location = new Point(578, 16); buttonQuit.Location = new Point(599, 16);
buttonQuit.Margin = new Padding(8, 4, 8, 4); buttonQuit.Margin = new Padding(8, 4, 8, 4);
buttonQuit.Name = "buttonQuit"; buttonQuit.Name = "buttonQuit";
buttonQuit.Secondary = true; buttonQuit.Secondary = true;
buttonQuit.Size = new Size(208, 44); buttonQuit.Size = new Size(185, 44);
buttonQuit.TabIndex = 18; buttonQuit.TabIndex = 18;
buttonQuit.Text = "Quit"; buttonQuit.Text = "Quit";
buttonQuit.UseVisualStyleBackColor = false; buttonQuit.UseVisualStyleBackColor = false;
@@ -390,6 +401,7 @@ namespace GHelper
// labelCPUFan // labelCPUFan
// //
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right; labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelCPUFan.Cursor = Cursors.Hand;
labelCPUFan.Location = new Point(384, 15); labelCPUFan.Location = new Point(384, 15);
labelCPUFan.Margin = new Padding(8, 0, 8, 0); labelCPUFan.Margin = new Padding(8, 0, 8, 0);
labelCPUFan.Name = "labelCPUFan"; labelCPUFan.Name = "labelCPUFan";
@@ -426,6 +438,7 @@ namespace GHelper
buttonSilent.BackColor = SystemColors.ControlLightLight; buttonSilent.BackColor = SystemColors.ControlLightLight;
buttonSilent.BackgroundImageLayout = ImageLayout.None; buttonSilent.BackgroundImageLayout = ImageLayout.None;
buttonSilent.BorderColor = Color.Transparent; buttonSilent.BorderColor = Color.Transparent;
buttonSilent.BorderRadius = 5;
buttonSilent.CausesValidation = false; buttonSilent.CausesValidation = false;
buttonSilent.Dock = DockStyle.Fill; buttonSilent.Dock = DockStyle.Fill;
buttonSilent.FlatAppearance.BorderSize = 0; buttonSilent.FlatAppearance.BorderSize = 0;
@@ -448,6 +461,7 @@ namespace GHelper
buttonBalanced.Activated = false; buttonBalanced.Activated = false;
buttonBalanced.BackColor = SystemColors.ControlLightLight; buttonBalanced.BackColor = SystemColors.ControlLightLight;
buttonBalanced.BorderColor = Color.Transparent; buttonBalanced.BorderColor = Color.Transparent;
buttonBalanced.BorderRadius = 5;
buttonBalanced.Dock = DockStyle.Fill; buttonBalanced.Dock = DockStyle.Fill;
buttonBalanced.FlatAppearance.BorderSize = 0; buttonBalanced.FlatAppearance.BorderSize = 0;
buttonBalanced.FlatStyle = FlatStyle.Flat; buttonBalanced.FlatStyle = FlatStyle.Flat;
@@ -469,6 +483,7 @@ namespace GHelper
buttonTurbo.Activated = false; buttonTurbo.Activated = false;
buttonTurbo.BackColor = SystemColors.ControlLightLight; buttonTurbo.BackColor = SystemColors.ControlLightLight;
buttonTurbo.BorderColor = Color.Transparent; buttonTurbo.BorderColor = Color.Transparent;
buttonTurbo.BorderRadius = 5;
buttonTurbo.Dock = DockStyle.Fill; buttonTurbo.Dock = DockStyle.Fill;
buttonTurbo.FlatAppearance.BorderSize = 0; buttonTurbo.FlatAppearance.BorderSize = 0;
buttonTurbo.FlatStyle = FlatStyle.Flat; buttonTurbo.FlatStyle = FlatStyle.Flat;
@@ -490,6 +505,7 @@ namespace GHelper
buttonFans.Activated = false; buttonFans.Activated = false;
buttonFans.BackColor = SystemColors.ControlLight; buttonFans.BackColor = SystemColors.ControlLight;
buttonFans.BorderColor = Color.Transparent; buttonFans.BorderColor = Color.Transparent;
buttonFans.BorderRadius = 5;
buttonFans.Dock = DockStyle.Fill; buttonFans.Dock = DockStyle.Fill;
buttonFans.FlatAppearance.BorderSize = 0; buttonFans.FlatAppearance.BorderSize = 0;
buttonFans.FlatStyle = FlatStyle.Flat; buttonFans.FlatStyle = FlatStyle.Flat;
@@ -592,6 +608,7 @@ namespace GHelper
buttonEco.Activated = false; buttonEco.Activated = false;
buttonEco.BackColor = SystemColors.ControlLightLight; buttonEco.BackColor = SystemColors.ControlLightLight;
buttonEco.BorderColor = Color.Transparent; buttonEco.BorderColor = Color.Transparent;
buttonEco.BorderRadius = 5;
buttonEco.CausesValidation = false; buttonEco.CausesValidation = false;
buttonEco.Dock = DockStyle.Top; buttonEco.Dock = DockStyle.Top;
buttonEco.FlatAppearance.BorderSize = 0; buttonEco.FlatAppearance.BorderSize = 0;
@@ -614,6 +631,7 @@ namespace GHelper
buttonStandard.Activated = false; buttonStandard.Activated = false;
buttonStandard.BackColor = SystemColors.ControlLightLight; buttonStandard.BackColor = SystemColors.ControlLightLight;
buttonStandard.BorderColor = Color.Transparent; buttonStandard.BorderColor = Color.Transparent;
buttonStandard.BorderRadius = 5;
buttonStandard.Dock = DockStyle.Top; buttonStandard.Dock = DockStyle.Top;
buttonStandard.FlatAppearance.BorderSize = 0; buttonStandard.FlatAppearance.BorderSize = 0;
buttonStandard.FlatStyle = FlatStyle.Flat; buttonStandard.FlatStyle = FlatStyle.Flat;
@@ -635,6 +653,7 @@ namespace GHelper
buttonOptimized.Activated = false; buttonOptimized.Activated = false;
buttonOptimized.BackColor = SystemColors.ControlLightLight; buttonOptimized.BackColor = SystemColors.ControlLightLight;
buttonOptimized.BorderColor = Color.Transparent; buttonOptimized.BorderColor = Color.Transparent;
buttonOptimized.BorderRadius = 5;
buttonOptimized.Dock = DockStyle.Top; buttonOptimized.Dock = DockStyle.Top;
buttonOptimized.FlatAppearance.BorderSize = 0; buttonOptimized.FlatAppearance.BorderSize = 0;
buttonOptimized.FlatStyle = FlatStyle.Flat; buttonOptimized.FlatStyle = FlatStyle.Flat;
@@ -656,6 +675,7 @@ namespace GHelper
buttonUltimate.Activated = false; buttonUltimate.Activated = false;
buttonUltimate.BackColor = SystemColors.ControlLightLight; buttonUltimate.BackColor = SystemColors.ControlLightLight;
buttonUltimate.BorderColor = Color.Transparent; buttonUltimate.BorderColor = Color.Transparent;
buttonUltimate.BorderRadius = 5;
buttonUltimate.Dock = DockStyle.Top; buttonUltimate.Dock = DockStyle.Top;
buttonUltimate.FlatAppearance.BorderSize = 0; buttonUltimate.FlatAppearance.BorderSize = 0;
buttonUltimate.FlatStyle = FlatStyle.Flat; buttonUltimate.FlatStyle = FlatStyle.Flat;
@@ -676,6 +696,7 @@ namespace GHelper
// //
panelScreen.AutoSize = true; panelScreen.AutoSize = true;
panelScreen.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelScreen.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelScreen.Controls.Add(labelMidFan);
panelScreen.Controls.Add(labelTipScreen); panelScreen.Controls.Add(labelTipScreen);
panelScreen.Controls.Add(tableScreen); panelScreen.Controls.Add(tableScreen);
panelScreen.Controls.Add(pictureScreen); panelScreen.Controls.Add(pictureScreen);
@@ -688,6 +709,17 @@ namespace GHelper
panelScreen.Size = new Size(810, 181); panelScreen.Size = new Size(810, 181);
panelScreen.TabIndex = 38; panelScreen.TabIndex = 38;
// //
// labelMidFan
//
labelMidFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelMidFan.Location = new Point(488, 13);
labelMidFan.Margin = new Padding(8, 0, 8, 0);
labelMidFan.Name = "labelMidFan";
labelMidFan.Size = new Size(296, 34);
labelMidFan.TabIndex = 25;
labelMidFan.Text = " ";
labelMidFan.TextAlign = ContentAlignment.TopRight;
//
// labelTipScreen // labelTipScreen
// //
labelTipScreen.ForeColor = SystemColors.GrayText; labelTipScreen.ForeColor = SystemColors.GrayText;
@@ -711,7 +743,6 @@ namespace GHelper
tableScreen.Controls.Add(button60Hz, 1, 0); tableScreen.Controls.Add(button60Hz, 1, 0);
tableScreen.Controls.Add(button120Hz, 2, 0); tableScreen.Controls.Add(button120Hz, 2, 0);
tableScreen.Controls.Add(buttonMiniled, 3, 0); tableScreen.Controls.Add(buttonMiniled, 3, 0);
tableScreen.Location = new Point(16, 51); tableScreen.Location = new Point(16, 51);
tableScreen.Margin = new Padding(8, 4, 8, 4); tableScreen.Margin = new Padding(8, 4, 8, 4);
tableScreen.Name = "tableScreen"; tableScreen.Name = "tableScreen";
@@ -725,6 +756,7 @@ namespace GHelper
buttonScreenAuto.Activated = false; buttonScreenAuto.Activated = false;
buttonScreenAuto.BackColor = SystemColors.ControlLightLight; buttonScreenAuto.BackColor = SystemColors.ControlLightLight;
buttonScreenAuto.BorderColor = Color.Transparent; buttonScreenAuto.BorderColor = Color.Transparent;
buttonScreenAuto.BorderRadius = 5;
buttonScreenAuto.Dock = DockStyle.Fill; buttonScreenAuto.Dock = DockStyle.Fill;
buttonScreenAuto.FlatAppearance.BorderSize = 0; buttonScreenAuto.FlatAppearance.BorderSize = 0;
buttonScreenAuto.FlatStyle = FlatStyle.Flat; buttonScreenAuto.FlatStyle = FlatStyle.Flat;
@@ -743,6 +775,7 @@ namespace GHelper
button60Hz.Activated = false; button60Hz.Activated = false;
button60Hz.BackColor = SystemColors.ControlLightLight; button60Hz.BackColor = SystemColors.ControlLightLight;
button60Hz.BorderColor = Color.Transparent; button60Hz.BorderColor = Color.Transparent;
button60Hz.BorderRadius = 5;
button60Hz.CausesValidation = false; button60Hz.CausesValidation = false;
button60Hz.Dock = DockStyle.Fill; button60Hz.Dock = DockStyle.Fill;
button60Hz.FlatAppearance.BorderSize = 0; button60Hz.FlatAppearance.BorderSize = 0;
@@ -762,6 +795,7 @@ namespace GHelper
button120Hz.Activated = false; button120Hz.Activated = false;
button120Hz.BackColor = SystemColors.ControlLightLight; button120Hz.BackColor = SystemColors.ControlLightLight;
button120Hz.BorderColor = Color.Transparent; button120Hz.BorderColor = Color.Transparent;
button120Hz.BorderRadius = 5;
button120Hz.Dock = DockStyle.Fill; button120Hz.Dock = DockStyle.Fill;
button120Hz.FlatAppearance.BorderSize = 0; button120Hz.FlatAppearance.BorderSize = 0;
button120Hz.FlatStyle = FlatStyle.Flat; button120Hz.FlatStyle = FlatStyle.Flat;
@@ -775,6 +809,26 @@ namespace GHelper
button120Hz.Text = "120Hz + OD"; button120Hz.Text = "120Hz + OD";
button120Hz.UseVisualStyleBackColor = false; button120Hz.UseVisualStyleBackColor = false;
// //
// buttonMiniled
//
buttonMiniled.Activated = false;
buttonMiniled.BackColor = SystemColors.ControlLightLight;
buttonMiniled.BorderColor = Color.Transparent;
buttonMiniled.BorderRadius = 5;
buttonMiniled.CausesValidation = false;
buttonMiniled.Dock = DockStyle.Fill;
buttonMiniled.FlatAppearance.BorderSize = 0;
buttonMiniled.FlatStyle = FlatStyle.Flat;
buttonMiniled.ForeColor = SystemColors.ControlText;
buttonMiniled.Location = new Point(583, 4);
buttonMiniled.Margin = new Padding(4);
buttonMiniled.Name = "buttonMiniled";
buttonMiniled.Secondary = false;
buttonMiniled.Size = new Size(185, 72);
buttonMiniled.TabIndex = 3;
buttonMiniled.Text = "Multizone";
buttonMiniled.UseVisualStyleBackColor = false;
//
// pictureScreen // pictureScreen
// //
pictureScreen.BackgroundImage = (Image)resources.GetObject("pictureScreen.BackgroundImage"); pictureScreen.BackgroundImage = (Image)resources.GetObject("pictureScreen.BackgroundImage");
@@ -817,53 +871,36 @@ namespace GHelper
tableLayoutKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; tableLayoutKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutKeyboard.AutoSize = true; tableLayoutKeyboard.AutoSize = true;
tableLayoutKeyboard.AutoSizeMode = AutoSizeMode.GrowAndShrink; tableLayoutKeyboard.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableLayoutKeyboard.ColumnCount = 4; tableLayoutKeyboard.ColumnCount = 3;
tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableLayoutKeyboard.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutKeyboard.Controls.Add(buttonKeyboard, 2, 0);
tableLayoutKeyboard.Controls.Add(comboKeyboard, 0, 0); tableLayoutKeyboard.Controls.Add(comboKeyboard, 0, 0);
tableLayoutKeyboard.Controls.Add(panelColor, 1, 0); tableLayoutKeyboard.Controls.Add(panelColor, 1, 0);
tableLayoutKeyboard.Controls.Add(buttonKeyboard, 2, 0);
tableLayoutKeyboard.Location = new Point(16, 50); tableLayoutKeyboard.Location = new Point(16, 50);
tableLayoutKeyboard.Margin = new Padding(8); tableLayoutKeyboard.Margin = new Padding(8);
tableLayoutKeyboard.Name = "tableLayoutKeyboard"; tableLayoutKeyboard.Name = "tableLayoutKeyboard";
tableLayoutKeyboard.RowCount = 1; tableLayoutKeyboard.RowCount = 1;
tableLayoutKeyboard.RowStyles.Add(new RowStyle(SizeType.Percent, 100F)); tableLayoutKeyboard.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
tableLayoutKeyboard.Size = new Size(772, 60); tableLayoutKeyboard.Size = new Size(771, 60);
tableLayoutKeyboard.TabIndex = 39; tableLayoutKeyboard.TabIndex = 39;
// //
// buttonKeyboard
//
buttonKeyboard.Activated = false;
buttonKeyboard.BackColor = SystemColors.ControlLight;
buttonKeyboard.BorderColor = Color.Transparent;
buttonKeyboard.Dock = DockStyle.Top;
buttonKeyboard.FlatAppearance.BorderSize = 0;
buttonKeyboard.FlatStyle = FlatStyle.Flat;
buttonKeyboard.Location = new Point(390, 8);
buttonKeyboard.Margin = new Padding(4, 8, 4, 8);
buttonKeyboard.Name = "buttonKeyboard";
buttonKeyboard.Secondary = true;
buttonKeyboard.Size = new Size(185, 44);
buttonKeyboard.TabIndex = 37;
buttonKeyboard.Text = "Extra";
buttonKeyboard.UseVisualStyleBackColor = false;
//
// comboKeyboard // comboKeyboard
// //
comboKeyboard.BorderColor = Color.White; comboKeyboard.BorderColor = Color.White;
comboKeyboard.ButtonColor = SystemColors.ControlLight; comboKeyboard.ButtonColor = Color.FromArgb(255, 255, 255);
comboKeyboard.Dock = DockStyle.Top; comboKeyboard.Dock = DockStyle.Top;
comboKeyboard.FlatStyle = FlatStyle.Flat; comboKeyboard.FlatStyle = FlatStyle.Flat;
comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point); comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboKeyboard.FormattingEnabled = true; comboKeyboard.FormattingEnabled = true;
comboKeyboard.ItemHeight = 32; comboKeyboard.ItemHeight = 32;
comboKeyboard.Items.AddRange(new object[] { "Static", "Breathe", "Strobe", "Rainbow", "Dingding" }); comboKeyboard.Items.AddRange(new object[] { "Static", "Breathe", "Rainbow", "Strobe" });
comboKeyboard.Location = new Point(4, 10); comboKeyboard.Location = new Point(4, 10);
comboKeyboard.Margin = new Padding(4, 10, 4, 8); comboKeyboard.Margin = new Padding(4, 10, 4, 8);
comboKeyboard.Name = "comboKeyboard"; comboKeyboard.Name = "comboKeyboard";
comboKeyboard.Size = new Size(185, 40); comboKeyboard.Size = new Size(249, 40);
comboKeyboard.TabIndex = 35; comboKeyboard.TabIndex = 35;
comboKeyboard.TabStop = false; comboKeyboard.TabStop = false;
// //
@@ -874,16 +911,16 @@ namespace GHelper
panelColor.Controls.Add(pictureColor); panelColor.Controls.Add(pictureColor);
panelColor.Controls.Add(buttonKeyboardColor); panelColor.Controls.Add(buttonKeyboardColor);
panelColor.Dock = DockStyle.Fill; panelColor.Dock = DockStyle.Fill;
panelColor.Location = new Point(197, 8); panelColor.Location = new Point(261, 8);
panelColor.Margin = new Padding(4, 8, 4, 8); panelColor.Margin = new Padding(4, 8, 4, 8);
panelColor.Name = "panelColor"; panelColor.Name = "panelColor";
panelColor.Size = new Size(185, 44); panelColor.Size = new Size(249, 44);
panelColor.TabIndex = 36; panelColor.TabIndex = 36;
// //
// pictureColor2 // pictureColor2
// //
pictureColor2.Anchor = AnchorStyles.Top | AnchorStyles.Right; pictureColor2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pictureColor2.Location = new Point(123, 12); pictureColor2.Location = new Point(188, 12);
pictureColor2.Margin = new Padding(8); pictureColor2.Margin = new Padding(8);
pictureColor2.Name = "pictureColor2"; pictureColor2.Name = "pictureColor2";
pictureColor2.Size = new Size(20, 20); pictureColor2.Size = new Size(20, 20);
@@ -893,7 +930,7 @@ namespace GHelper
// pictureColor // pictureColor
// //
pictureColor.Anchor = AnchorStyles.Top | AnchorStyles.Right; pictureColor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pictureColor.Location = new Point(151, 12); pictureColor.Location = new Point(215, 12);
pictureColor.Margin = new Padding(8); pictureColor.Margin = new Padding(8);
pictureColor.Name = "pictureColor"; pictureColor.Name = "pictureColor";
pictureColor.Size = new Size(20, 20); pictureColor.Size = new Size(20, 20);
@@ -905,6 +942,7 @@ namespace GHelper
buttonKeyboardColor.Activated = false; buttonKeyboardColor.Activated = false;
buttonKeyboardColor.BackColor = SystemColors.ButtonHighlight; buttonKeyboardColor.BackColor = SystemColors.ButtonHighlight;
buttonKeyboardColor.BorderColor = Color.Transparent; buttonKeyboardColor.BorderColor = Color.Transparent;
buttonKeyboardColor.BorderRadius = 2;
buttonKeyboardColor.Dock = DockStyle.Top; buttonKeyboardColor.Dock = DockStyle.Top;
buttonKeyboardColor.FlatStyle = FlatStyle.Flat; buttonKeyboardColor.FlatStyle = FlatStyle.Flat;
buttonKeyboardColor.ForeColor = SystemColors.ControlText; buttonKeyboardColor.ForeColor = SystemColors.ControlText;
@@ -912,11 +950,29 @@ namespace GHelper
buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8); buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8);
buttonKeyboardColor.Name = "buttonKeyboardColor"; buttonKeyboardColor.Name = "buttonKeyboardColor";
buttonKeyboardColor.Secondary = false; buttonKeyboardColor.Secondary = false;
buttonKeyboardColor.Size = new Size(185, 44); buttonKeyboardColor.Size = new Size(249, 44);
buttonKeyboardColor.TabIndex = 39; buttonKeyboardColor.TabIndex = 39;
buttonKeyboardColor.Text = "Color "; buttonKeyboardColor.Text = "Color";
buttonKeyboardColor.UseVisualStyleBackColor = false; buttonKeyboardColor.UseVisualStyleBackColor = false;
// //
// buttonKeyboard
//
buttonKeyboard.Activated = false;
buttonKeyboard.BackColor = SystemColors.ControlLight;
buttonKeyboard.BorderColor = Color.Transparent;
buttonKeyboard.BorderRadius = 2;
buttonKeyboard.Dock = DockStyle.Top;
buttonKeyboard.FlatAppearance.BorderSize = 0;
buttonKeyboard.FlatStyle = FlatStyle.Flat;
buttonKeyboard.Location = new Point(518, 8);
buttonKeyboard.Margin = new Padding(4, 8, 4, 8);
buttonKeyboard.Name = "buttonKeyboard";
buttonKeyboard.Secondary = true;
buttonKeyboard.Size = new Size(249, 44);
buttonKeyboard.TabIndex = 37;
buttonKeyboard.Text = "Extra";
buttonKeyboard.UseVisualStyleBackColor = false;
//
// pictureKeyboard // pictureKeyboard
// //
pictureKeyboard.BackgroundImage = Properties.Resources.icons8_keyboard_48; pictureKeyboard.BackgroundImage = Properties.Resources.icons8_keyboard_48;
@@ -939,25 +995,6 @@ namespace GHelper
labelKeyboard.TabIndex = 32; labelKeyboard.TabIndex = 32;
labelKeyboard.Text = "Laptop Keyboard"; labelKeyboard.Text = "Laptop Keyboard";
// //
// buttonMiniled
//
buttonMiniled.Activated = false;
buttonMiniled.BackColor = SystemColors.ControlLightLight;
buttonMiniled.BorderColor = Color.Transparent;
buttonMiniled.CausesValidation = false;
buttonMiniled.Dock = DockStyle.Fill;
buttonMiniled.FlatAppearance.BorderSize = 0;
buttonMiniled.FlatStyle = FlatStyle.Flat;
buttonMiniled.ForeColor = SystemColors.ControlText;
buttonMiniled.Location = new Point(197, 4);
buttonMiniled.Margin = new Padding(4);
buttonMiniled.Name = "buttonMiniled";
buttonMiniled.Secondary = false;
buttonMiniled.Size = new Size(185, 72);
buttonMiniled.TabIndex = 3;
buttonMiniled.Text = "Miniled";
buttonMiniled.UseVisualStyleBackColor = false;
//
// SettingsForm // SettingsForm
// //
AutoScaleDimensions = new SizeF(192F, 192F); AutoScaleDimensions = new SizeF(192F, 192F);
@@ -990,7 +1027,6 @@ namespace GHelper
panelBattery.ResumeLayout(false); panelBattery.ResumeLayout(false);
panelBattery.PerformLayout(); panelBattery.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBattery).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBattery).EndInit();
((System.ComponentModel.ISupportInitialize)trackBattery).EndInit();
panelFooter.ResumeLayout(false); panelFooter.ResumeLayout(false);
panelFooter.PerformLayout(); panelFooter.PerformLayout();
panelPerformance.ResumeLayout(false); panelPerformance.ResumeLayout(false);
@@ -1026,7 +1062,6 @@ namespace GHelper
private Label labelBattery; private Label labelBattery;
private PictureBox pictureBattery; private PictureBox pictureBattery;
private Label labelBatteryTitle; private Label labelBatteryTitle;
private TrackBar trackBattery;
private Panel panelFooter; private Panel panelFooter;
private RButton buttonQuit; private RButton buttonQuit;
private CheckBox checkStartup; private CheckBox checkStartup;
@@ -1073,5 +1108,8 @@ namespace GHelper
private RButton buttonKeyboard; private RButton buttonKeyboard;
private RButton buttonKeyboardColor; private RButton buttonKeyboardColor;
private RButton buttonFans; private RButton buttonFans;
private Label labelMidFan;
private Label labelModel;
private WinFormsSliderBar.Slider sliderBattery;
} }
} }

View File

@@ -2,7 +2,10 @@
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Reflection;
using System.Text.Json;
using System.Timers; using System.Timers;
using Tools;
namespace GHelper namespace GHelper
{ {
@@ -10,7 +13,9 @@ namespace GHelper
public partial class SettingsForm : RForm public partial class SettingsForm : RForm
{ {
static System.Timers.Timer aTimer = default!; public static System.Timers.Timer aTimer = default!;
public static Point trayPoint;
static System.Timers.Timer matrixTimer = default!; static System.Timers.Timer matrixTimer = default!;
public string versionUrl = "http://github.com/seerge/g-helper/releases"; public string versionUrl = "http://github.com/seerge/g-helper/releases";
@@ -21,11 +26,15 @@ namespace GHelper
public Keyboard keyb; public Keyboard keyb;
static AnimeMatrixDevice mat; static AnimeMatrixDevice mat;
static long lastRefresh;
private bool customFans = false;
private int customPower = 0;
public SettingsForm() public SettingsForm()
{ {
InitializeComponent(); InitializeComponent();
InitTheme(); InitTheme(true);
FormClosing += SettingsForm_FormClosing; FormClosing += SettingsForm_FormClosing;
@@ -54,8 +63,6 @@ namespace GHelper
VisibleChanged += SettingsForm_VisibleChanged; VisibleChanged += SettingsForm_VisibleChanged;
trackBattery.Scroll += trackBatteryChange;
button60Hz.Click += Button60Hz_Click; button60Hz.Click += Button60Hz_Click;
button120Hz.Click += Button120Hz_Click; button120Hz.Click += Button120Hz_Click;
buttonScreenAuto.Click += ButtonScreenAuto_Click; buttonScreenAuto.Click += ButtonScreenAuto_Click;
@@ -63,10 +70,6 @@ namespace GHelper
buttonQuit.Click += ButtonQuit_Click; buttonQuit.Click += ButtonQuit_Click;
comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
comboKeyboard.SelectedIndex = 0;
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
buttonKeyboardColor.Click += ButtonKeyboardColor_Click; buttonKeyboardColor.Click += ButtonKeyboardColor_Click;
buttonFans.Click += ButtonFans_Click; buttonFans.Click += ButtonFans_Click;
@@ -114,16 +117,90 @@ namespace GHelper
button120Hz.MouseMove += Button120Hz_MouseHover; button120Hz.MouseMove += Button120Hz_MouseHover;
button120Hz.MouseLeave += ButtonScreen_MouseLeave; button120Hz.MouseLeave += ButtonScreen_MouseLeave;
//buttonStandard.Image = (Image)(new Bitmap(buttonStandard.Image, new Size(16, 16))); sliderBattery.ValueChanged += SliderBattery_ValueChanged;
Program.trayIcon.MouseMove += TrayIcon_MouseMove;
aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += OnTimedEvent;
SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
string model = Program.config.GetModel();
int trim = model.LastIndexOf("_");
if (trim > 0) model = model.Substring(0, trim);
labelModel.Text = model;
this.TopMost = Program.config.getConfig("topmost") == 1;
Task.Run(async () =>
{
await Task.Delay(TimeSpan.FromSeconds(1));
CheckForUpdatesAsync();
});
SetTimer();
} }
private void SliderBattery_ValueChanged(object? sender, EventArgs e)
{
SetBatteryChargeLimit(sliderBattery.Value);
}
public async void CheckForUpdatesAsync()
{
try
{
using (var httpClient = new HttpClient())
{
httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App");
var json = await httpClient.GetStringAsync("https://api.github.com/repos/seerge/g-helper/releases/latest");
var config = JsonSerializer.Deserialize<JsonElement>(json);
var tag = config.GetProperty("tag_name").ToString().Replace("v", "");
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();
var gitVersion = new Version(tag);
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
if (gitVersion.CompareTo(appVersion) > 0)
{
BeginInvoke(delegate
{
SetVersionLabel("Download Update: " + tag, url);
});
}
else
{
Debug.WriteLine("Latest version");
}
}
}
catch (Exception ex)
{
//Logger.WriteLine("Failed to check for updates:" + ex.Message);
}
}
private static void TrayIcon_MouseMove(object? sender, MouseEventArgs e)
{
Program.settingsForm.RefreshSensors();
}
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
{
Program.settingsForm.RefreshSensors();
}
private void Button120Hz_MouseHover(object? sender, EventArgs e) private void Button120Hz_MouseHover(object? sender, EventArgs e)
{ {
labelTipScreen.Text = "Max refresh rate + screen overdrive for lower latency"; labelTipScreen.Text = "Max refresh rate for lower latency";
} }
private void Button60Hz_MouseHover(object? sender, EventArgs e) private void Button60Hz_MouseHover(object? sender, EventArgs e)
@@ -171,18 +248,19 @@ namespace GHelper
{ {
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1); Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
VisualiseGPUMode(); VisualiseGPUMode();
AutoGPUMode(SystemInformation.PowerStatus.PowerLineStatus); AutoGPUMode();
} }
private void ButtonScreenAuto_Click(object? sender, EventArgs e) private void ButtonScreenAuto_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("screen_auto", 1); Program.config.setConfig("screen_auto", 1);
InitScreen(); InitScreen();
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus); AutoScreen();
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
{ {
switch (m.Msg) switch (m.Msg)
{ {
case NativeMethods.WM_POWERBROADCAST: case NativeMethods.WM_POWERBROADCAST:
@@ -193,13 +271,11 @@ namespace GHelper
{ {
case 0: case 0:
Logger.WriteLine("Monitor Power Off"); Logger.WriteLine("Monitor Power Off");
SetBatteryChargeLimit(Program.config.getConfig("charge_limit"));
break; break;
case 1: case 1:
Logger.WriteLine("Monitor Power On"); Logger.WriteLine("Monitor Power On");
Program.settingsForm.BeginInvoke(delegate Program.SetAutoModes();
{
Program.SetAutoModes();
});
break; break;
case 2: case 2:
Logger.WriteLine("Monitor Dimmed"); Logger.WriteLine("Monitor Dimmed");
@@ -208,17 +284,20 @@ namespace GHelper
} }
m.Result = (IntPtr)1; m.Result = (IntPtr)1;
break; break;
case KeyHandler.WM_HOTKEY_MSG_ID:
CyclePerformanceMode();
break;
} }
base.WndProc(ref m); base.WndProc(ref m);
} }
public void SetVersionLabel(string label, string url = null) void SetVersionLabel(string label, string url = null)
{ {
labelVersion.Text = label; labelVersion.Text = label;
if (url is not null) if (url is not null)
{ {
versionUrl = url; this.versionUrl = url;
labelVersion.ForeColor = Color.Red; labelVersion.ForeColor = Color.Red;
} }
} }
@@ -252,8 +331,9 @@ namespace GHelper
Program.config.setConfig("matrix_auto", check.Checked ? 1 : 0); Program.config.setConfig("matrix_auto", check.Checked ? 1 : 0);
} }
private static void StartMatrixTimer() private static void StartMatrixTimer(int interval = 100)
{ {
matrixTimer.Interval = interval;
matrixTimer.Enabled = true; matrixTimer.Enabled = true;
} }
@@ -265,14 +345,23 @@ namespace GHelper
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e) private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
{ {
if (mat is null) return; if (mat is null) return;
mat.PresentNextFrame();
switch (Program.config.getConfig("matrix_running"))
{
case 2:
mat.PresentNextFrame();
break;
case 3:
mat.PresentClock();
break;
}
} }
void SetMatrixPicture(string fileName) void SetMatrixPicture(string fileName)
{ {
if (mat is null) return; if (mat is null) return;
StopMatrixTimer(); StopMatrixTimer();
Image image; Image image;
@@ -315,8 +404,6 @@ namespace GHelper
mat.GenerateFrame(image); mat.GenerateFrame(image);
mat.Present(); mat.Present();
} }
} }
@@ -342,6 +429,8 @@ namespace GHelper
if (fileName is not null) if (fileName is not null)
{ {
Program.config.setConfig("matrix_picture", fileName); Program.config.setConfig("matrix_picture", fileName);
Program.config.setConfig("matrix_running", 2);
SetMatrixPicture(fileName); SetMatrixPicture(fileName);
BeginInvoke(delegate BeginInvoke(delegate
{ {
@@ -365,7 +454,7 @@ namespace GHelper
SetMatrix(); SetMatrix();
} }
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online) public void SetMatrix()
{ {
if (mat is null) return; if (mat is null) return;
@@ -388,7 +477,7 @@ namespace GHelper
mat.SetProvider(); mat.SetProvider();
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online)) if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
{ {
mat.SetDisplayState(false); mat.SetDisplayState(false);
} }
@@ -397,16 +486,22 @@ namespace GHelper
mat.SetDisplayState(true); mat.SetDisplayState(true);
mat.SetBrightness((BrightnessMode)brightness); mat.SetBrightness((BrightnessMode)brightness);
if (running == 2) switch (running)
{ {
string fileName = Program.config.getConfigString("matrix_picture"); case 2:
SetMatrixPicture(fileName); SetMatrixPicture(Program.config.getConfigString("matrix_picture"));
} break;
else case 3:
{ mat.SetBuiltInAnimation(false);
mat.SetBuiltInAnimation(true, animation); StartMatrixTimer(1000);
break;
default:
mat.SetBuiltInAnimation(true, animation);
break;
} }
//mat.SetBrightness((BrightnessMode)brightness);
} }
} }
@@ -416,19 +511,20 @@ namespace GHelper
private void LabelCPUFan_Click(object? sender, EventArgs e) private void LabelCPUFan_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1); Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
RefreshSensors(); RefreshSensors(true);
} }
private void PictureColor2_Click(object? sender, EventArgs e) private void PictureColor2_Click(object? sender, EventArgs e)
{ {
ColorDialog colorDlg = new ColorDialog(); ColorDialog colorDlg = new ColorDialog();
colorDlg.AllowFullOpen = false; colorDlg.AllowFullOpen = true;
colorDlg.Color = pictureColor2.BackColor; colorDlg.Color = pictureColor2.BackColor;
if (colorDlg.ShowDialog() == DialogResult.OK) if (colorDlg.ShowDialog() == DialogResult.OK)
{ {
SetAuraColor(color2: colorDlg.Color); Program.config.setConfig("aura_color2", colorDlg.Color.ToArgb());
SetAura();
} }
} }
@@ -473,45 +569,34 @@ namespace GHelper
private void ButtonKeyboardColor_Click(object? sender, EventArgs e) private void ButtonKeyboardColor_Click(object? sender, EventArgs e)
{ {
if (sender is null)
return;
Button but = (Button)sender;
ColorDialog colorDlg = new ColorDialog(); ColorDialog colorDlg = new ColorDialog();
colorDlg.AllowFullOpen = false; colorDlg.AllowFullOpen = true;
colorDlg.Color = pictureColor.BackColor; colorDlg.Color = pictureColor.BackColor;
if (colorDlg.ShowDialog() == DialogResult.OK) if (colorDlg.ShowDialog() == DialogResult.OK)
{ {
SetAuraColor(color1: colorDlg.Color); Program.config.setConfig("aura_color", colorDlg.Color.ToArgb());
SetAura();
} }
} }
public void InitAura() public void InitAura()
{ {
int mode = Program.config.getConfig("aura_mode"); Aura.Mode = Program.config.getConfig("aura_mode");
int colorCode = Program.config.getConfig("aura_color"); Aura.Speed = Program.config.getConfig("aura_speed");
int colorCode2 = Program.config.getConfig("aura_color2"); Aura.SetColor(Program.config.getConfig("aura_color"));
Aura.SetColor2(Program.config.getConfig("aura_color2"));
int speed = Program.config.getConfig("aura_speed"); comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
comboKeyboard.DataSource = new BindingSource(Aura.GetModes(), null);
comboKeyboard.DisplayMember = "Value";
comboKeyboard.ValueMember = "Key";
comboKeyboard.SelectedValue = Aura.Mode;
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
Color color = Color.FromArgb(255, 255, 255); pictureColor.BackColor = Aura.Color1;
Color color2 = Color.FromArgb(0, 0, 0); pictureColor2.BackColor = Aura.Color2;
pictureColor2.Visible = Aura.HasSecondColor();
if (mode == -1)
mode = 0;
if (colorCode != -1)
color = Color.FromArgb(colorCode);
if (colorCode2 != -1)
color2 = Color.FromArgb(colorCode2);
SetAuraColor(color, color2, false);
SetAuraMode(mode, false);
Aura.Mode = mode;
} }
public void InitMatrix() public void InitMatrix()
@@ -532,7 +617,7 @@ namespace GHelper
int brightness = Program.config.getConfig("matrix_brightness"); int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running"); int running = Program.config.getConfig("matrix_running");
comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count-1) : 0; comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count - 1) : 0;
comboMatrixRunning.SelectedIndex = (running != -1) ? Math.Min(running, comboMatrixRunning.Items.Count - 1) : 0; comboMatrixRunning.SelectedIndex = (running != -1) ? Math.Min(running, comboMatrixRunning.Items.Count - 1) : 0;
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1); checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
@@ -541,67 +626,36 @@ namespace GHelper
} }
public void SetAuraColor(Color? color1 = null, Color? color2 = null, bool apply = true) public void SetAura()
{ {
Aura.Mode = Program.config.getConfig("aura_mode");
if (color1 is not null) Aura.Speed = Program.config.getConfig("aura_speed");
{ Aura.SetColor(Program.config.getConfig("aura_color"));
Aura.Color1 = (Color)color1; Aura.SetColor2(Program.config.getConfig("aura_color2"));
Program.config.setConfig("aura_color", Aura.Color1.ToArgb());
}
if (color2 is not null)
{
Aura.Color2 = (Color)color2;
Program.config.setConfig("aura_color2", Aura.Color2.ToArgb());
}
if (apply)
Aura.ApplyAura();
pictureColor.BackColor = Aura.Color1; pictureColor.BackColor = Aura.Color1;
pictureColor2.BackColor = Aura.Color2; pictureColor2.BackColor = Aura.Color2;
} pictureColor2.Visible = Aura.HasSecondColor();
public void SetAuraMode(int mode = 0, bool apply = true) Aura.ApplyAura();
{
//Debug.WriteLine(mode);
if (mode > 4) mode = 0;
pictureColor2.Visible = (mode == Aura.Breathe);
if (Aura.Mode == mode) return; // same mode
Aura.Mode = mode;
Program.config.setConfig("aura_mode", mode);
comboKeyboard.SelectedValueChanged -= ComboKeyboard_SelectedValueChanged;
comboKeyboard.SelectedIndex = mode;
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
if (apply)
Aura.ApplyAura();
} }
public void CycleAuraMode() public void CycleAuraMode()
{ {
SetAuraMode(Program.config.getConfig("aura_mode") + 1); if (comboKeyboard.SelectedIndex < comboKeyboard.Items.Count - 1)
comboKeyboard.SelectedIndex += 1;
else
comboKeyboard.SelectedIndex = 0;
} }
private void ComboKeyboard_SelectedValueChanged(object? sender, EventArgs e) private void ComboKeyboard_SelectedValueChanged(object? sender, EventArgs e)
{ {
if (sender is null) Program.config.setConfig("aura_mode", (int)comboKeyboard.SelectedValue);
return; SetAura();
ComboBox cmb = (ComboBox)sender;
SetAuraMode(cmb.SelectedIndex);
} }
private void Button120Hz_Click(object? sender, EventArgs e) private void Button120Hz_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("screen_auto", 0); Program.config.setConfig("screen_auto", 0);
@@ -632,22 +686,24 @@ namespace GHelper
if (frequency >= 1000) if (frequency >= 1000)
{ {
frequency = Program.config.getConfig("max_frequency"); frequency = NativeMethods.GetRefreshRate(true);
if (frequency <= 60) frequency = 120;
} }
if (frequency > 0) if (frequency > 0)
{ {
NativeMethods.SetRefreshRate(frequency); NativeMethods.SetRefreshRate(frequency);
Logger.WriteLine("Screen " + frequency.ToString() + "Hz");
} }
if (overdrive >= 0) if (overdrive >= 0)
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive); {
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive, "ScreenOverdrive");
}
if (miniled >= 0) if (miniled >= 0)
{ {
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled); Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled, "Miniled");
Debug.WriteLine("Miniled " + miniled); Debug.WriteLine("Miniled " + miniled);
} }
@@ -659,9 +715,10 @@ namespace GHelper
{ {
int frequency = NativeMethods.GetRefreshRate(); int frequency = NativeMethods.GetRefreshRate();
int maxFrequency = Program.config.getConfig("max_frequency"); int maxFrequency = NativeMethods.GetRefreshRate(true);
bool screenAuto = (Program.config.getConfig("screen_auto") == 1); bool screenAuto = (Program.config.getConfig("screen_auto") == 1);
bool overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive); int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled); int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
@@ -689,25 +746,22 @@ namespace GHelper
{ {
button60Hz.Activated = true; button60Hz.Activated = true;
} }
else else if (frequency > 60)
{ {
if (frequency > 60)
maxFrequency = frequency;
Program.config.setConfig("max_frequency", maxFrequency);
button120Hz.Activated = true; button120Hz.Activated = true;
} }
if (maxFrequency > 60) if (maxFrequency > 60)
{ {
button120Hz.Text = maxFrequency.ToString() + "Hz + OD"; button120Hz.Text = maxFrequency.ToString() + "Hz" + (overdriveSetting ? " + OD" : "");
} }
if (miniled >= 0) if (miniled >= 0)
{ {
buttonMiniled.Activated = (miniled == 1); buttonMiniled.Activated = (miniled == 1);
Program.config.setConfig("miniled", miniled); Program.config.setConfig("miniled", miniled);
} else }
else
{ {
buttonMiniled.Visible = false; buttonMiniled.Visible = false;
} }
@@ -747,28 +801,12 @@ namespace GHelper
SetGPUMode(ASUSWmi.GPUModeEco); SetGPUMode(ASUSWmi.GPUModeEco);
} }
private static void SetTimer()
{
aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += OnTimedEvent;
aTimer.AutoReset = true;
aTimer.Enabled = false;
}
private void RefreshSensors(bool force = false)
private static string FormatFan(int fan)
{
if (Program.config.getConfig("fan_rpm") == 1)
return " Fan: " + (fan * 100).ToString() + "RPM";
else
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm
}
private static void RefreshSensors()
{ {
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)); if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
string gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan)); lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();
string cpuTemp = ""; string cpuTemp = "";
string gpuTemp = ""; string gpuTemp = "";
@@ -777,29 +815,33 @@ namespace GHelper
HardwareMonitor.ReadSensors(); HardwareMonitor.ReadSensors();
if (HardwareMonitor.cpuTemp > 0) if (HardwareMonitor.cpuTemp > 0)
cpuTemp = ": " + Math.Round((decimal)HardwareMonitor.cpuTemp).ToString() + "°C - "; cpuTemp = ": " + Math.Round((decimal)HardwareMonitor.cpuTemp).ToString() + "°C ";
if (HardwareMonitor.batteryDischarge > 0) if (HardwareMonitor.batteryDischarge > 0)
battery = "Discharging: " + Math.Round((decimal)HardwareMonitor.batteryDischarge, 1).ToString() + "W"; battery = "Discharging: " + Math.Round((decimal)HardwareMonitor.batteryDischarge, 1).ToString() + "W";
if (HardwareMonitor.gpuTemp != null) if (HardwareMonitor.gpuTemp > 0)
{ {
gpuTemp = $": {HardwareMonitor.gpuTemp}°C - "; gpuTemp = $": {HardwareMonitor.gpuTemp}°C ";
} }
Program.settingsForm.BeginInvoke(delegate Program.settingsForm.BeginInvoke(delegate
{ {
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + cpuFan; labelCPUFan.Text = "CPU" + cpuTemp + HardwareMonitor.cpuFan;
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan; labelGPUFan.Text = "GPU" + gpuTemp + HardwareMonitor.gpuFan;
Program.settingsForm.labelBattery.Text = battery; if (HardwareMonitor.midFan is not null)
labelMidFan.Text = "Mid" + HardwareMonitor.midFan;
labelBattery.Text = battery;
}); });
Program.trayIcon.Text = "CPU" + cpuTemp + HardwareMonitor.cpuFan + "\n"
+ "GPU" + gpuTemp + HardwareMonitor.gpuFan +
((battery.Length > 0) ? ("\n" + battery) : "");
} }
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
{
RefreshSensors();
aTimer.Interval = 2000;
}
private void SettingsForm_VisibleChanged(object? sender, EventArgs e) private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
{ {
@@ -811,10 +853,7 @@ namespace GHelper
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height; this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
this.Activate(); this.Activate();
aTimer.Interval = 300;
aTimer.Enabled = true; aTimer.Enabled = true;
//RefreshSensors();
} }
else else
{ {
@@ -822,6 +861,12 @@ namespace GHelper
} }
} }
private void SetPerformanceLabel()
{
labelPerf.Text = "Performance Mode" + (customFans?"+":"") + ((customPower > 0) ? " "+customPower+"W" : "");
}
public void SetPower() public void SetPower()
{ {
int limit_total = Program.config.getConfigPerf("limit_total"); int limit_total = Program.config.getConfigPerf("limit_total");
@@ -834,43 +879,80 @@ namespace GHelper
if (limit_cpu < ASUSWmi.MinCPU) return; if (limit_cpu < ASUSWmi.MinCPU) return;
if (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0) if (Program.wmi.DeviceGet(ASUSWmi.PPT_TotalA0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total); {
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total, "PowerLimit A");
customPower = limit_total;
}
if (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0) if (Program.wmi.DeviceGet(ASUSWmi.PPT_CPUB0) >= 0)
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu); {
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu, "PowerLimit B");
Logger.WriteLine("PowerLimits " + limit_total.ToString() + ", " + limit_cpu.ToString()); customPower = limit_cpu;
}
Program.settingsForm.BeginInvoke(SetPerformanceLabel);
} }
public void AutoFansAndPower() public void AutoFans()
{ {
customFans = false;
if (Program.config.getConfigPerf("auto_apply") == 1) if (Program.config.getConfigPerf("auto_apply") == 1)
{ {
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0)); int cpuResult = Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1)); int gpuResult = Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
if (Program.config.getConfig("mid_fan") == 1)
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));
if (cpuResult != 1 || gpuResult != 1) // something went wrong, resetting to default profile
{
int mode = Program.config.getConfig("performance_mode");
Logger.WriteLine("Driver rejected fan curve, resetting mode to " + mode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, mode, "PerformanceMode");
}
else customFans = true;
} }
Program.settingsForm.BeginInvoke(SetPerformanceLabel);
}
public void AutoPower(int delay = 0)
{
customPower = 0;
if (Program.config.getConfigPerf("auto_apply_power") == 1) if (Program.config.getConfigPerf("auto_apply_power") == 1)
{ {
var timer = new System.Timers.Timer(1000); if (delay > 0)
timer.Elapsed += delegate {
var timer = new System.Timers.Timer(1000);
timer.Elapsed += delegate
{
timer.Stop();
timer.Dispose();
SetPower();
};
timer.Start();
}
else
{ {
timer.Stop();
timer.Dispose();
SetPower(); SetPower();
}; }
timer.Start();
} }
} }
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
public void SetPerformanceMode(int PerformanceMode = -1, bool notify = false)
{ {
if (PerformanceMode < 0)
PerformanceMode = Program.config.getConfig("performance_mode");
buttonSilent.Activated = false; buttonSilent.Activated = false;
buttonBalanced.Activated = false; buttonBalanced.Activated = false;
@@ -897,8 +979,7 @@ namespace GHelper
Program.config.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode); Program.config.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
Program.config.setConfig("performance_mode", PerformanceMode); Program.config.setConfig("performance_mode", PerformanceMode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode); Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode, "PerformanceMode");
Logger.WriteLine("PerfMode " + perfName + " " + PerformanceMode);
if (notify && (oldMode != PerformanceMode)) if (notify && (oldMode != PerformanceMode))
{ {
@@ -912,7 +993,13 @@ namespace GHelper
} }
} }
AutoFansAndPower(); AutoFans();
AutoPower(1000);
if (Program.config.getConfigPerf("auto_boost") != -1)
{
NativeMethods.SetCPUBoost(Program.config.getConfigPerf("auto_boost"));
}
NativeMethods.SetPowerScheme(PerformanceMode); NativeMethods.SetPowerScheme(PerformanceMode);
@@ -925,20 +1012,42 @@ namespace GHelper
{ {
fans.InitFans(); fans.InitFans();
fans.InitPower(); fans.InitPower();
fans.InitBoost();
} }
} }
public void CyclePerformanceMode() public void CyclePerformanceMode()
{ {
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true); int mode = Program.config.getConfig("performance_mode");
if (Control.ModifierKeys == Keys.Shift)
mode = (mode == 0) ? 2 : mode - 1;
else
mode++;
SetPerformanceMode(mode, true);
} }
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
public void AutoKeyboard()
{ {
if (Program.config.getConfig("keyboard_auto") != 1) return;
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
Aura.ApplyBrightness(3);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
else
Aura.ApplyBrightness(0);
//Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
}
public void AutoPerformance()
{
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
int mode = Program.config.getConfig("performance_" + (int)Plugged); int mode = Program.config.getConfig("performance_" + (int)Plugged);
if (mode != -1) if (mode != -1)
SetPerformanceMode(mode, true); SetPerformanceMode(mode, true);
@@ -947,11 +1056,11 @@ namespace GHelper
} }
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online) public void AutoScreen(bool force = false)
{ {
if (Program.config.getConfig("screen_auto") != 1) return; if (!force && Program.config.getConfig("screen_auto") != 1) return;
if (Plugged == PowerLineStatus.Online) if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
SetScreen(1000, 1); SetScreen(1000, 1);
else else
SetScreen(60, 0); SetScreen(60, 0);
@@ -959,11 +1068,17 @@ namespace GHelper
} }
public bool AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online) public bool AutoGPUMode()
{ {
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1; bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
if (!GpuAuto) return false; bool ForceGPU = Program.config.ContainsModel("503");
int GpuMode = Program.config.getConfig("gpu_mode");
if (!GpuAuto && !ForceGPU) return false;
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco); int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux); int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
@@ -972,16 +1087,25 @@ namespace GHelper
return false; return false;
else else
{ {
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged if (eco == 1)
{ if ((GpuAuto && Plugged == PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeStandard))
SetEcoGPU(0); {
return true; SetEcoGPU(0);
} return true;
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged }
{ if (eco == 0)
SetEcoGPU(1); if ((GpuAuto && Plugged != PowerLineStatus.Online) || (ForceGPU && GpuMode == ASUSWmi.GPUModeEco))
return true; {
}
if (HardwareMonitor.IsUsedGPU())
{
DialogResult dialogResult = MessageBox.Show("Your dGPU seem to be in heavy use, disable it?", "Eco Mode", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.No) return false;
}
SetEcoGPU(1);
return true;
}
} }
return false; return false;
@@ -993,20 +1117,13 @@ namespace GHelper
if (!ultimate) if (!ultimate)
{ {
tableGPU.Controls.Remove(buttonUltimate); tableGPU.Controls.Remove(buttonUltimate);
/*
* buttonFans.Image = null;
buttonFans.Height = 44;
*/
tablePerf.ColumnCount = 0; tablePerf.ColumnCount = 0;
tableGPU.ColumnCount = 0; tableGPU.ColumnCount = 0;
tableScreen.ColumnCount = 0; tableScreen.ColumnCount = 0;
} }
tableLayoutKeyboard.ColumnCount = 0; //tableLayoutMatrix.ColumnCount = 0;
tableLayoutMatrix.ColumnCount = 0;
} }
@@ -1017,6 +1134,9 @@ namespace GHelper
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco); int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux); int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
Logger.WriteLine("Eco flag : " + eco);
Logger.WriteLine("Mux flag : " + mux);
int GpuMode; int GpuMode;
if (mux == 0) if (mux == 0)
@@ -1056,7 +1176,7 @@ namespace GHelper
labelGPU.Text = "GPU Mode: Changing ..."; labelGPU.Text = "GPU Mode: Changing ...";
new Thread(() => Thread t = new Thread(() =>
{ {
Thread.CurrentThread.IsBackground = true; Thread.CurrentThread.IsBackground = true;
@@ -1067,18 +1187,17 @@ namespace GHelper
foreach (var process in Process.GetProcessesByName(kill)) process.Kill(); foreach (var process in Process.GetProcessesByName(kill)) process.Kill();
} }
Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco); Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco, "GPUEco");
Program.settingsForm.BeginInvoke(delegate Program.settingsForm.BeginInvoke(delegate
{ {
InitGPUMode();
HardwareMonitor.RecreateGpuTemperatureProviderWithRetry();
Thread.Sleep(500); Thread.Sleep(500);
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus); InitGPUMode();
AutoScreen();
}); });
}) });
{
}.Start(); t.Start();
} }
@@ -1102,7 +1221,7 @@ namespace GHelper
DialogResult dialogResult = MessageBox.Show("Switching off Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Switching off Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 1); Program.wmi.DeviceSet(ASUSWmi.GPUMux, 1, "GPUMux");
restart = true; restart = true;
changed = true; changed = true;
} }
@@ -1112,7 +1231,7 @@ namespace GHelper
DialogResult dialogResult = MessageBox.Show("Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo); DialogResult dialogResult = MessageBox.Show("Ultimate Mode requires restart", "Reboot now?", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes) if (dialogResult == DialogResult.Yes)
{ {
Program.wmi.DeviceSet(ASUSWmi.GPUMux, 0); Program.wmi.DeviceSet(ASUSWmi.GPUMux, 0, "GPUMux");
restart = true; restart = true;
changed = true; changed = true;
} }
@@ -1134,7 +1253,6 @@ namespace GHelper
if (changed) if (changed)
{ {
Program.config.setConfig("gpu_mode", GPUMode); Program.config.setConfig("gpu_mode", GPUMode);
HardwareMonitor.RecreateGpuTemperatureProviderWithRetry();
} }
if (restart) if (restart)
@@ -1224,21 +1342,16 @@ namespace GHelper
if (limit < 40 || limit > 100) return; if (limit < 40 || limit > 100) return;
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%"; //Debug.WriteLine(limit);
trackBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
sliderBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit, "BatteryLimit");
Program.config.setConfig("charge_limit", limit); Program.config.setConfig("charge_limit", limit);
} }
private void trackBatteryChange(object? sender, EventArgs e)
{
if (sender is null) return;
TrackBar bar = (TrackBar)sender;
SetBatteryChargeLimit(bar.Value);
}
} }

168
app/Slider.cs Normal file
View File

@@ -0,0 +1,168 @@
using System.Drawing.Drawing2D;
namespace WinFormsSliderBar
{
public static class GraphicsExtensions
{
public static void DrawCircle(this Graphics g, Pen pen,
float centerX, float centerY, float radius)
{
g.DrawEllipse(pen, centerX - radius, centerY - radius,
radius + radius, radius + radius);
}
public static void FillCircle(this Graphics g, Brush brush,
float centerX, float centerY, float radius)
{
g.FillEllipse(brush, centerX - radius, centerY - radius,
radius + radius, radius + radius);
}
}
public class Slider : Control
{
private float _radius;
private PointF _thumbPos;
private SizeF _barSize;
private PointF _barPos;
private int _step = 5;
public Color accentColor = Color.FromArgb(255, 58, 174, 239);
public Color borderColor = Color.White;
public event EventHandler ValueChanged;
public Slider()
{
// This reduces flicker
DoubleBuffered = true;
}
private int _min = 0;
public int Min
{
get => _min;
set
{
_min = value;
RecalculateParameters();
}
}
private int _max = 100;
public int Max
{
get => _max;
set
{
_max = value;
RecalculateParameters();
}
}
private int _value = 50;
public int Value
{
get => _value;
set
{
value = (int)Math.Round(value / (float)_step) * _step;
if (_value != value)
{
_value = value;
ValueChanged?.Invoke(this, EventArgs.Empty);
RecalculateParameters();
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Brush brushAccent = new SolidBrush(accentColor);
Brush brushEmpty = new SolidBrush(Color.Gray);
Brush brushBorder = new SolidBrush(borderColor);
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
e.Graphics.FillRectangle(brushEmpty,
_barPos.X, _barPos.Y, _barSize.Width, _barSize.Height);
e.Graphics.FillRectangle(brushAccent,
_barPos.X, _barPos.Y, _thumbPos.X - _barPos.X, _barSize.Height);
e.Graphics.FillCircle(brushBorder, _thumbPos.X, _thumbPos.Y, _radius);
e.Graphics.FillCircle(brushAccent, _thumbPos.X, _thumbPos.Y, 0.7f * _radius);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
RecalculateParameters();
}
private void RecalculateParameters()
{
_radius = 0.4F * ClientSize.Height;
_barSize = new SizeF(ClientSize.Width - 4 * _radius, ClientSize.Height * 0.15F);
_barPos = new PointF(_radius, (ClientSize.Height - _barSize.Height) / 2);
_thumbPos = new PointF(
_barSize.Width / (Max - Min) * (Value - Min) + _barPos.X,
_barPos.Y + 0.5f * _barSize.Height);
Invalidate();
}
bool _moving = false;
SizeF _delta;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
// Difference between tumb and mouse position.
_delta = new SizeF(e.Location.X - _thumbPos.X, e.Location.Y - _thumbPos.Y);
if (_delta.Width * _delta.Width + _delta.Height * _delta.Height <= _radius * _radius)
{
// Clicking inside thumb.
_moving = true;
}
_calculateValue(e);
}
private void _calculateValue(MouseEventArgs e)
{
float thumbX = e.Location.X; // - _delta.Width;
if (thumbX < _barPos.X)
{
thumbX = _barPos.X;
}
else if (thumbX > _barPos.X + _barSize.Width)
{
thumbX = _barPos.X + _barSize.Width;
}
Value = (int)Math.Round(Min + (thumbX - _barPos.X) * (Max - Min) / _barSize.Width);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (_moving)
{
_calculateValue(e);
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
base.OnMouseUp(e);
_moving = false;
}
}
}

View File

@@ -22,31 +22,43 @@ public class Startup
var userId = WindowsIdentity.GetCurrent().Name; var userId = WindowsIdentity.GetCurrent().Name;
TaskDefinition td = TaskService.Instance.NewTask(); using (TaskDefinition td = TaskService.Instance.NewTask())
td.RegistrationInfo.Description = "GHelper Auto Start";
td.Triggers.Add(new LogonTrigger { UserId = userId });
td.Actions.Add(strExeFilePath);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
{ {
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td); td.RegistrationInfo.Description = "G-Helper Auto Start";
} catch (Exception e) td.Triggers.Add(new LogonTrigger { UserId = userId });
{ td.Actions.Add(strExeFilePath);
MessageBox.Show(e.ToString(), "Scheduler Error", MessageBoxButtons.OK);
td.Settings.StopIfGoingOnBatteries = false;
td.Settings.DisallowStartIfOnBatteries = false;
td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
Debug.WriteLine(strExeFilePath);
Debug.WriteLine(userId);
try
{
TaskService.Instance.RootFolder.RegisterTaskDefinition(taskName, td);
}
catch (Exception e)
{
MessageBox.Show("Can't create a start up task. Try running Task Scheduler by hand and manually deleting GHelper task if it exists there.", "Scheduler Error", MessageBoxButtons.OK);
}
} }
} }
public static void UnSchedule() public static void UnSchedule()
{ {
TaskService taskService = new TaskService(); using (TaskService taskService = new TaskService())
taskService.RootFolder.DeleteTask(taskName); {
try
{
taskService.RootFolder.DeleteTask(taskName);
}
catch (Exception e)
{
MessageBox.Show("Can't remove task. Try running Task Scheduler by hand and manually deleting GHelper task if it exists there.", "Scheduler Error", MessageBoxButtons.OK);
}
}
} }
} }

19
bloat.bat Normal file
View File

@@ -0,0 +1,19 @@
sc config AsusAppService start= auto
sc config ASUSLinkNear start= auto
sc config ASUSLinkRemote start= auto
sc config ASUSSoftwareManager start= auto
sc config ASUSSwitch start= auto
sc config ASUSSystemAnalysis start= auto
sc config ASUSSystemDiagnosis start= auto
sc config ArmouryCrateControlInterface start= auto
sc START AsusAppService
sc START ASUSLinkNear
sc START ASUSLinkRemote
sc START ASUSSoftwareManager
sc START ASUSSwitch
sc START ASUSSystemAnalysis
sc START ASUSSystemDiagnosis
sc START ArmouryCrateControlInterface
set /p asd="Hit enter to finish"

View File

@@ -7,11 +7,13 @@ sc STOP ASUSSystemAnalysis
sc STOP ASUSSystemDiagnosis sc STOP ASUSSystemDiagnosis
sc STOP ArmouryCrateControlInterface sc STOP ArmouryCrateControlInterface
sc DELETE AsusAppService sc config AsusAppService start= disabled
sc DELETE ASUSLinkNear sc config ASUSLinkNear start= disabled
sc DELETE ASUSLinkRemote sc config ASUSLinkRemote start= disabled
sc DELETE ASUSSoftwareManager sc config ASUSSoftwareManager start= disabled
sc DELETE ASUSSwitch sc config ASUSSwitch start= disabled
sc DELETE ASUSSystemAnalysis sc config ASUSSystemAnalysis start= disabled
sc DELETE ASUSSystemDiagnosis sc config ASUSSystemDiagnosis start= disabled
sc DELETE ArmouryCrateControlInterface sc config ArmouryCrateControlInterface start= disabled
set /p asd="Hit enter to finish"

View File

@@ -1,73 +1,103 @@
# [G-Helper (GHelper)](https://github.com/seerge/g-helper) # G-Helper (GHelper)
[![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/seerge/g-helper/stargazers/) [![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star)](https://GitHub.com/seerge/g-helper/stargazers/)
## Open source Armoury Crate alternative for Asus ROG Zephyrus G14, G15, Flow X13, Flow X16, and other models ## Lightweight Armoury Crate alternative for Asus laptops
### Control tool for ROG Zephyrus G14, G15, Flow X13, Flow X16, TUF, Strix, Scar and other models
A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services. A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services.
### :gift: Main advantages ## :gift: Main advantages
1. Seamless and automatic GPU switching (without asking you to close all apps, etc) 1. Seamless and automatic GPU switching (without asking you to close all apps, etc)
2. All performance modes can be fully customized (with fan curves and PPTs) 2. All performance modes can be fully customized (with fan curves and PPTs)
3. Very lightweight and consumes almost no resources, doesn't install any services. Just a single exe to run 3. Very lightweight and consumes almost no resources, doesn't install any services. Just a single exe to run
4. Simple and clean native UI with easy access to all settings
5. Doesn't need administrator privileges to run!
### [:floppy_disk: Download latest release](https://github.com/seerge/g-helper/releases/latest/download/GHelper.zip) ## [:floppy_disk: Download App](https://github.com/seerge/g-helper/releases/latest/download/GHelper.zip)
If you like this app, please [star :star: it on Github](https://github.com/seerge/g-helper) and spread a word about it! If you like this app, please [star :star: it on Github](https://github.com/seerge/g-helper) and spread a word about it!
![Screenshot](https://raw.githubusercontent.com/seerge/g-helper/main/docs/screenshot.png) _If you post about the app - please include a link. Thanks._
![Screenshot 2023-03-30 115149](https://user-images.githubusercontent.com/5920850/228799078-bc93148f-6580-4319-b9e6-fbde4d246cd2.png)
### :zap: Main features ### :zap: Main features
1. Built-in **Performance modes**: Silent - Balanced - Turbo (with default fan curves) 1. **Performance modes**: Silent - Balanced - Turbo (built-in, with default fan curves)
2. **GPU modes**: Eco - Standard - Ultimate - Optimized 2. **GPU modes**: Eco - Standard - Ultimate - Optimized
3. Laptop screen refresh rate 60hz or 120hz (144hz, etc depending on the model) with display overdrive (OD) 3. Laptop screen refresh rate 60hz or 120hz (144hz, etc) with display overdrive (OD) and miniled multizone switch
4. Default and custom fan profiles for every performance mode 4. Custom fan curve editor, power limits (PPT) and turbo boost selection for every performance mode
5. Power limits (PPT) for every performance mode 5. Anime matrix control thanks to [Starlight](https://github.com/vddCore/Starlight) + some tweaks from my side including animated GIFs
6. CPU turbo boost mode 6. Keyboard backlit animation and colors (including sleep animation and support for TUF models)
7. Keyboard backlit animation and colors 7. Custom bindings for M3, M4 keys and FN+F5 (performance mode) FN+F4 (keyboard animation modes)
8. Anime matrix control thanks to [Starlight](https://github.com/vddCore/Starlight) + some tweaks from my side (including animated GIFs) 8. Monitor CPU / GPU temperature, fan speeds and battery discharge rate
9. FN+F5 cycles performance modes, FN+F4 cycles keyboard animation modes 9. Battery charge limit to preserve battery health
10. Keybindings for M3 and M4 keys
11. Battery charge limit to preserve battery health
12. Monitor CPU / GPU temperature, fan speeds and battery discharge rate
### :apple: Automatic switching of modes when on battery or plugged in ### :gear: Automatic switching when on battery or plugged in
- Performance modes (app remembers last mode used on battery or when plugged) - Performance modes (app remembers last mode used on battery or when plugged)
- Optimized GPU mode - disables dGPU on battery and enables when plugged - Optimized GPU mode - disables dGPU on battery and enables when plugged
- Auto Screen refresh rate (60hz on battery, 120+ hz when plugged) - Auto Screen refresh rate (60hz on battery, 120+ hz when plugged)
- Keyboard backlight can be turned off on battery
To keep auto switching and hotkeys working the app needs to stay in running in the tray. It doesn't consume any resources. To keep auto switching and hotkeys working the app needs to stay running in the tray. It doesn't consume any resources.
### :rocket: Performance Modes ### :rocket: Performance Modes
Modes are **same** as in Armory Crate (as they are stored in bios), including default fan curves Modes are **same** as in Armoury Crate as they are stored in bios including default fan curves
1. Silent (minimal or no fans, 70W PPT total, up to 45W PPT to CPU) + Best power efficiency setting in windows 1. Silent (minimal or no fans, 70W PPT total, up to 45W PPT to CPU) + Best power efficiency setting in windows
2. Balanced (balanced fans, 100W PPT total, up to 45W PPT to CPU) + Balanced setting in windows 2. Balanced (balanced fans, 100W PPT total, up to 45W PPT to CPU) + Balanced setting in windows
3. Turbo (intense fans, 125W PPT total, up to 80W PPT to CPU) + Best performance setting in windows 3. Turbo (intense fans, 125W PPT total, up to 80W PPT to CPU) + Best performance setting in windows
PPTs are shown for G14 2022, for other models PPTs will be different as they are set in bios. _PPTs are shown for G14 2022, for other models PPTs will be different as they are set in bios._
![Screenshot 2023-04-06 142234](https://user-images.githubusercontent.com/5920850/230377635-7032a480-3a94-4e35-9468-d8911e3e55ec.png)
### :video_game: GPU Modes ### :video_game: GPU Modes
1. Eco mode : only low power integrated GPU enabled, iGPU drives built in display 1. Eco mode : only low power integrated GPU enabled, iGPU drives built in display
2. Standard mode (Windows Hybrid) : iGPU and dGPU enabled, iGPU drives built in display 2. Standard mode (MS Hybrid) : iGPU and dGPU enabled, iGPU drives built in display
3. Ultimate mode: iGPU and dGPU enabled, but dGPU drives built in display (supported only on G14 2022 model) 3. Ultimate mode: iGPU and dGPU enabled, but dGPU drives built in display (supported only on G14 2022 model)
4. Optimized (formely existed as a checkbox): disables dGPU on battery (Eco) and enables when plugged (Standard) 4. Optimized: disables dGPU on battery (Eco) and enables when plugged (Standard)
### :question: FAQ ## :question: FAQ
#### How do I stop Armory Crate install popup appearing every time I press M4 / Rog key? ### How do I stop the Armory Crate install popup appearing every time I press the M4 / Rog key?
Go to BIOS (F2 on boot), open Advanced Settings (F8) and disable "Armory Control Intrerface" Go to BIOS (F2 on boot), open Advanced Settings and disable "Armory Control Interface".
If it still appears - delete or move somewhere following file ``C:\Windows\System32\ASUSACCI\ArmouryCrateKeyControl.exe``
#### Why Ultimate GPU mode is not available on my laptop? ### Why is Ultimate GPU mode not available on my laptop?
Ultimate mode is supported (by hardware) only on G14 2022 (and possibly other models from 2022+) Ultimate mode is supported (by hardware) only on G14 2022 (and possibly other models from 2022+)
#### App doesn't start / or crashes, what should I do ? ### I can't set Eco mode (disable dGPU) on my G14 2020
Unfortunately 2020 model doesn't support that on hardware level
### Should I apply custom PPTs and fan profiles?
You don't have to, it's purely optional. From my experience built in (in bios) performance modes work well. Limit your power or apply custom fan curves only if you have issues. As soon as you click Apply in the fan + power section bios will be considering the fan profile as "custom"! (no matter if you modified it or not)
### How does G-helper control my fan speeds?
It doesn't. Your bios does (same as in case with armoury). What G-helper can do - is (optionally) set a custom fan profile to current performance mode consisting of 8 pairs of temperature + fan speed % via same endpoint armoury seem to use.
### How do I change fan % to fan RPM?
Click on them
### I don't see a GPU temperature in G-helper
Most probably either you are using Eco / Optimized mode and your dGPU is simply off, or your windows has put the dGPU into sleep (to preserve power). In this situations G-helper won't be able to reach your GPU and get readings
### It says, that app is already running
Please check system tray for a (G) icon. By default windows is keen to hide all icons, so you may need to click ^ to see them all. I would advise to right click on Task Bar select Task Bar Settings -> Other System Tray icons -> Mark G-Helper to be always ON.
### App doesn't start / or crashes, what should I do ?
Open "Event Viewer" from start menu, go to Windows Logs -> Application and check for recent Errors mentioning G-Helper. If you see one - please post a [new issue](https://github.com/seerge/g-helper/issues) with all details from this error. Open "Event Viewer" from start menu, go to Windows Logs -> Application and check for recent Errors mentioning G-Helper. If you see one - please post a [new issue](https://github.com/seerge/g-helper/issues) with all details from this error.
### Can I use MyASUS app along with G-Helper?
Sure, you can! The only problem is that MyASUS may override the battery charge limit that you set before. My advice in such a situation would be to set the same limit (i.e. 80%) in both MyASUS and G-Helper.
### How do I uninstall G-helper?
G-helper is a single exe, and it doesn't install anything in the system. To remove it - you can simply delete exe :) If you have applied any custom fan profiles or PPTs - before removing I would recommend selecting your favorite performance mode (for example balanced) and clicking "Factory defaults" under Fans + Power.
---------------------------- ----------------------------
### How to install ### How to install
@@ -76,15 +106,17 @@ Open "Event Viewer" from start menu, go to Windows Logs -> Application and check
2. Unzip to a folder of your choice 2. Unzip to a folder of your choice
3. Run **GHelper.exe** 3. Run **GHelper.exe**
### Dependencies ### Dependencies & Requirements
- App requires [.NET7](https://dotnet.microsoft.com/en-us/download) to be installed. Most probably you already have it. Otherwise you can [download it](https://dotnet.microsoft.com/en-us/download). - Microsoft [.NET7](https://dotnet.microsoft.com/en-us/download). Most probably you already have it. Otherwise you can [download it](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-7.0.202-windows-x64-installer) from the official website.
- I recommend keeping "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working. If you have (or had) MyASUS app installed, that service is most probably still up and running even after MyASUS uninstalls. It's part of [Asus System Control Interface](https://www.asus.com/support/FAQ/1047338/). You can install it, and later disable / remove unnecessary services by running [this bat file](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat) as admin. - [Asus System Control Interface](https://dlcdnets.asus.com/pub/ASUS/nb/Image/CustomComponent/ASUSSystemControlInterfaceV3/ASUSSystemControlInterfaceV3.exe). If you have or had MyASUS app installed this "driver" probably still in place (even after MyASUS uninstalls). Alternatively - you can download and install it
- It's not recommended to use an app in combination with Armory Crate, cause they adjust the same settings. You can [uninstall it using it's own uninstall tool](https://dlcdnets.asus.com/pub/ASUS/mb/14Utilities/Armoury_Crate_Uninstall_Tool.zip?model=armoury%20crate). Just in case, you can always install it back later. - Optionally(!) you can disable / remove unnecessary services by running [this debloat bat file](https://raw.githubusercontent.com/seerge/g-helper/main/debloat.bat) as admin. To restore services - run [this bloat bat file](https://raw.githubusercontent.com/seerge/g-helper/main/bloat.bat) instead.
Note: Doesn't need administrator privileges to run! - I recommend keeping "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working.
- It's not recommended to use an app in combination with Armoury Crate services, because they adjust the same settings. You can [uninstall it using it's own uninstall tool](https://dlcdnets.asus.com/pub/ASUS/mb/14Utilities/Armoury_Crate_Uninstall_Tool.zip?model=armoury%20crate). Just in case, you can always install it back later.
------------------------------- -------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB