mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a7a7170676 | ||
|
|
1d43ca3ce4 | ||
|
|
ff7618f16f | ||
|
|
bb947bf8bf | ||
|
|
63092d8415 | ||
|
|
6fbce2f495 | ||
|
|
8d89a04608 | ||
|
|
0cbc48d526 | ||
|
|
81013ca0be | ||
|
|
af2509fc17 | ||
|
|
136b5b4f55 | ||
|
|
4e2abff942 | ||
|
|
2c8a11fc24 | ||
|
|
8af8823ee4 | ||
|
|
ec0a1b710e | ||
|
|
2ac2e84161 | ||
|
|
14dc1741f7 | ||
|
|
fbed195194 | ||
|
|
0d002edf65 | ||
|
|
28a17562a8 | ||
|
|
583cb677d0 | ||
|
|
1888fe7bd9 | ||
|
|
089b339e61 | ||
|
|
cab4a04339 | ||
|
|
7ab3b450cd | ||
|
|
ea2dc7b75d | ||
|
|
ccd69a8628 | ||
|
|
c1d23159a0 | ||
|
|
1c865624e6 | ||
|
|
4853c09c2c | ||
|
|
08704d6826 | ||
|
|
6edbcf5ecd | ||
|
|
7702dc8e38 | ||
|
|
94391358ef | ||
|
|
feecd193ac | ||
|
|
444f7c76f0 | ||
|
|
701423fa0e | ||
|
|
7b3a6d319b | ||
|
|
8bc9325b3f | ||
|
|
64195c5082 | ||
|
|
2297532323 | ||
|
|
daac8b0a45 | ||
|
|
f061e3f43a | ||
|
|
85e02549f1 | ||
|
|
9053764930 | ||
|
|
64871e5554 | ||
|
|
b1c778b30d | ||
|
|
6932bb1889 | ||
|
|
c90a342ce8 | ||
|
|
f223ca4a33 |
@@ -10,6 +10,10 @@ public class ASUSWmi
|
||||
const uint DSTS = 0x53545344;
|
||||
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 GPU_Fan = 0x00110014;
|
||||
public const uint Mid_Fan = 0x00110031;
|
||||
@@ -27,6 +31,10 @@ public class ASUSWmi
|
||||
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_EDCA1 = 0x001200A1; // CPU EDC
|
||||
public const int PPT_TDCA2 = 0x001200A2; // CPU TDC
|
||||
@@ -38,6 +46,9 @@ public class ASUSWmi
|
||||
public const int PPT_APUC1 = 0x001200C1;
|
||||
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 PerformanceTurbo = 1;
|
||||
public const int PerformanceSilent = 2;
|
||||
@@ -146,21 +157,21 @@ public class ASUSWmi
|
||||
|
||||
}
|
||||
|
||||
public void DeviceSet(uint DeviceID, int Status)
|
||||
public byte[] DeviceSet(uint DeviceID, int Status)
|
||||
{
|
||||
byte[] args = new byte[8];
|
||||
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
||||
BitConverter.GetBytes((uint)Status).CopyTo(args, 4);
|
||||
CallMethod(DEVS, args);
|
||||
return CallMethod(DEVS, args);
|
||||
}
|
||||
|
||||
|
||||
public void DeviceSet(uint DeviceID, byte[] Params)
|
||||
public byte[] DeviceSet(uint DeviceID, byte[] Params)
|
||||
{
|
||||
byte[] args = new byte[4 + Params.Length];
|
||||
BitConverter.GetBytes((uint)DeviceID).CopyTo(args, 0);
|
||||
Params.CopyTo(args, 4);
|
||||
CallMethod(DEVS, args);
|
||||
return CallMethod(DEVS, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -226,12 +237,46 @@ public class ASUSWmi
|
||||
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
|
||||
case 2:
|
||||
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
|
||||
default:
|
||||
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);
|
||||
//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);
|
||||
}
|
||||
|
||||
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)
|
||||
{
|
||||
ManagementEventWatcher watcher = new ManagementEventWatcher();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
|
||||
|
||||
using Starlight.Communication;
|
||||
using System.Drawing;
|
||||
using System.Management;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
|
||||
namespace Starlight.AnimeMatrix
|
||||
@@ -57,6 +57,14 @@ namespace Starlight.AnimeMatrix
|
||||
}
|
||||
}
|
||||
|
||||
public enum AnimeType
|
||||
{
|
||||
GA401,
|
||||
GA402
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum BrightnessMode : byte
|
||||
{
|
||||
Off = 0,
|
||||
@@ -75,29 +83,38 @@ namespace Starlight.AnimeMatrix
|
||||
List<byte[]> frames = new List<byte[]>();
|
||||
|
||||
public int MaxRows = 61;
|
||||
public int FullRows = 11;
|
||||
public int FullEvenRows = -1;
|
||||
//public int FullRows = 11;
|
||||
//public int FullEvenRows = -1;
|
||||
|
||||
public int dx = 0;
|
||||
public int MaxColumns = 34;
|
||||
|
||||
private int frameIndex = 0;
|
||||
|
||||
private static AnimeType _model = AnimeType.GA402;
|
||||
|
||||
public AnimeMatrixDevice()
|
||||
: base(0x0B05, 0x193B, 640)
|
||||
{
|
||||
string model = GetModel();
|
||||
if (model.Contains("401"))
|
||||
{
|
||||
MaxColumns = 33;
|
||||
|
||||
FullRows = 7;
|
||||
FullEvenRows = 6;
|
||||
_model = AnimeType.GA401;
|
||||
|
||||
MaxColumns = 33;
|
||||
dx = 1;
|
||||
|
||||
//FullRows = 7;
|
||||
//FullEvenRows = 3;
|
||||
|
||||
MaxRows = 55;
|
||||
LedCount = 1214;
|
||||
LedCount = 1245;
|
||||
|
||||
UpdatePageLength = 410;
|
||||
}
|
||||
|
||||
|
||||
_displayBuffer = new byte[LedCount];
|
||||
|
||||
}
|
||||
@@ -145,6 +162,71 @@ namespace Starlight.AnimeMatrix
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
return (int)Math.Ceiling(Math.Max(0, row - FullRows) / 2.0);
|
||||
@@ -152,22 +234,38 @@ namespace Starlight.AnimeMatrix
|
||||
|
||||
public int XEnd(int row)
|
||||
{
|
||||
if (row <= FullEvenRows && row % 2 == 0) return MaxColumns - 1;
|
||||
if (row <= FullEvenRows)
|
||||
{
|
||||
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);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
for (var i = 0; i < row; i++)
|
||||
ret += XEnd(i) - XStart(i);
|
||||
for (var i = 0; i < y; i++)
|
||||
ret += Pitch(i);
|
||||
|
||||
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()
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")));
|
||||
@@ -193,17 +291,7 @@ namespace Starlight.AnimeMatrix
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||
}
|
||||
|
||||
public int SetLedPlanar(int x, int y, byte value)
|
||||
{
|
||||
EnsureRowInRange(y);
|
||||
var start = RowToLinearAddress(y) - XStart(y);
|
||||
if (x >= XStart(y) && x < XEnd(y))
|
||||
{
|
||||
SetLedLinear(start + x, value);
|
||||
return start + x;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
public void Clear(bool present = false)
|
||||
{
|
||||
@@ -270,79 +358,77 @@ namespace Starlight.AnimeMatrix
|
||||
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte));
|
||||
}
|
||||
|
||||
static int GetColor(Bitmap bmp, int x, int y)
|
||||
|
||||
|
||||
public void PresentText(string text1, string text2 = "")
|
||||
{
|
||||
var pixel = bmp.GetPixel(Math.Max(0, Math.Min(bmp.Width - 1, x)), Math.Max(0, Math.Min(bmp.Height - 1, y)));
|
||||
return (Math.Min((pixel.R + pixel.G + pixel.B) / 3, 255));
|
||||
}
|
||||
|
||||
|
||||
public void PresentText(string text, int fontSize = 8)
|
||||
{
|
||||
int width = MaxColumns * 3;
|
||||
int height = MaxRows;
|
||||
|
||||
Bitmap bmp = new Bitmap(width, height);
|
||||
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
|
||||
{
|
||||
using (Font font = new Font("Arial", fontSize))
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
|
||||
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
SizeF textSize = g.MeasureString(text, font);
|
||||
|
||||
/*
|
||||
g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
|
||||
g.RotateTransform(33);
|
||||
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
|
||||
*/
|
||||
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
|
||||
using (Font font = new Font("Arial", 12F))
|
||||
{
|
||||
SizeF textSize = g.MeasureString(text1, font);
|
||||
g.DrawString(text1, font, Brushes.White, (MaxColumns*3 - textSize.Width)+3, -5);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
g.DrawString(text, font, Brushes.White, bmp.Width - textSize.Width + 5, 0);
|
||||
}
|
||||
|
||||
GenerateFrame(bmp, InterpolationMode.Bicubic);
|
||||
Present();
|
||||
}
|
||||
|
||||
GenerateFrame(bmp);
|
||||
Present();
|
||||
|
||||
}
|
||||
|
||||
public void GenerateFrame(Image image)
|
||||
public void GenerateFrame(Image image, InterpolationMode interpolation = InterpolationMode.HighQualityBicubic)
|
||||
{
|
||||
|
||||
int width = MaxColumns * 3;
|
||||
int width = MaxColumns/2 * 6;
|
||||
int height = MaxRows;
|
||||
|
||||
int targetWidth = MaxColumns * 2;
|
||||
|
||||
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++)
|
||||
using (Bitmap bmp = new Bitmap(targetWidth, height))
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
|
||||
|
||||
using (var graph = Graphics.FromImage(bmp))
|
||||
{
|
||||
if (x % 2 == y % 2)
|
||||
{
|
||||
var color = GetColor(bmp, x, y);
|
||||
SetLedPlanar(x / 2, y, (byte)color);
|
||||
}
|
||||
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)
|
||||
|
||||
@@ -40,8 +40,7 @@ public class AppConfig
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool ContainsModel(string contains)
|
||||
public string GetModel()
|
||||
{
|
||||
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));
|
||||
|
||||
}
|
||||
@@ -103,6 +108,8 @@ public class AppConfig
|
||||
|
||||
if (device == 1)
|
||||
name = "gpu";
|
||||
else if (device == 2)
|
||||
name = "mid";
|
||||
else
|
||||
name = "cpu";
|
||||
|
||||
|
||||
284
app/Aura.cs
284
app/Aura.cs
@@ -1,78 +1,242 @@
|
||||
using HidLibrary;
|
||||
using System.Diagnostics;
|
||||
|
||||
public class Aura
|
||||
namespace GHelper
|
||||
{
|
||||
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0,0,0 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4};
|
||||
|
||||
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)
|
||||
[Flags]
|
||||
public enum AuraDev19b6 : uint
|
||||
{
|
||||
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;
|
||||
BootLogo = 1,
|
||||
BootKeyb = 1 << 1,
|
||||
AwakeLogo = 1 << 2,
|
||||
AwakeKeyb = 1 << 3,
|
||||
SleepLogo = 1 << 4,
|
||||
SleepKeyb = 1 << 5,
|
||||
ShutdownLogo = 1 << 6,
|
||||
ShutdownKeyb = 1 << 7,
|
||||
BootBar = 1u << (7 + 2),
|
||||
AwakeBar = 1u << (7 + 3),
|
||||
SleepBar = 1u << (7 + 4),
|
||||
ShutdownBar = 1u << (7 + 5),
|
||||
BootLid = 1u << (15 + 1),
|
||||
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;
|
||||
int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
|
||||
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 };
|
||||
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
|
||||
|
||||
HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
||||
static int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
|
||||
|
||||
if (Mode == Dingding)
|
||||
{
|
||||
Mode = 10;
|
||||
Speed = SpeedMedium;
|
||||
}
|
||||
else if (Mode == Rainbow)
|
||||
{
|
||||
Speed = SpeedMedium;
|
||||
}
|
||||
else
|
||||
{
|
||||
Speed = SpeedSlow;
|
||||
}
|
||||
private static int mode = 0;
|
||||
private static int speed = 1;
|
||||
public static Color Color1 = Color.White;
|
||||
public static Color Color2 = Color.Black;
|
||||
|
||||
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();
|
||||
byte[] msg = AuraMessage(Mode, Color1, Color2, Speed);
|
||||
device.Write(msg);
|
||||
device.Write(MESSAGE_SET);
|
||||
device.Write(MESSAGE_APPLY);
|
||||
device.CloseDevice();
|
||||
{ 0, "Slow" },
|
||||
{ 1, "Normal" },
|
||||
{ 2, "Fast" }
|
||||
};
|
||||
}
|
||||
|
||||
static Dictionary<int, string> _modes = new Dictionary<int, string>
|
||||
{
|
||||
{ 0, "Static" },
|
||||
{ 1, "Breathe" },
|
||||
{ 2, "Color Cycle" },
|
||||
{ 3, "Rainbow" },
|
||||
{ 10, "Strobe" },
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
Program.wmi.TUFKeyboardRGB(Mode, Color1, _speed);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using CustomControls;
|
||||
using WinFormsSliderBar;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
|
||||
@@ -6,7 +7,8 @@ public static class ControlHelper
|
||||
{
|
||||
|
||||
static bool _invert = false;
|
||||
static bool _resize = false;
|
||||
static bool _darkTheme = false;
|
||||
|
||||
|
||||
static float _scale = 1;
|
||||
|
||||
@@ -20,11 +22,13 @@ public static class ControlHelper
|
||||
public static void Adjust(RForm container, bool darkTheme = false, bool invert = false)
|
||||
{
|
||||
|
||||
_darkTheme = darkTheme;
|
||||
|
||||
if (darkTheme)
|
||||
{
|
||||
formBack = Color.FromArgb(255, 35, 35, 35);
|
||||
backMain = Color.FromArgb(255, 50, 50, 50);
|
||||
foreMain = Color.White;
|
||||
foreMain = Color.FromArgb(255, 240, 240, 240);
|
||||
foreAccent = Color.FromArgb(255, 100, 100, 100);
|
||||
borderMain = Color.FromArgb(255, 50, 50, 50);
|
||||
buttonMain = Color.FromArgb(255, 80, 80, 80);
|
||||
@@ -36,7 +40,7 @@ public static class ControlHelper
|
||||
foreMain = SystemColors.ControlText;
|
||||
foreAccent = Color.LightGray;
|
||||
borderMain = Color.LightGray;
|
||||
buttonMain = Color.FromArgb(255, 230, 230, 230);
|
||||
buttonMain = Color.FromArgb(255, 250, 250, 250);
|
||||
}
|
||||
|
||||
container.BackColor = formBack;
|
||||
@@ -51,7 +55,7 @@ public static class ControlHelper
|
||||
public static void Resize(RForm container, float baseScale = 2)
|
||||
{
|
||||
_scale = GetDpiScale(container).Value / baseScale;
|
||||
ResizeControls(container.Controls);
|
||||
if (Math.Abs(_scale - 1) > 0.2) ResizeControls(container.Controls);
|
||||
|
||||
}
|
||||
|
||||
@@ -63,9 +67,11 @@ public static class ControlHelper
|
||||
if (button != null && button.Image is not null)
|
||||
button.Image = ResizeImage(button.Image);
|
||||
|
||||
/*
|
||||
var pictureBox = control as PictureBox;
|
||||
if (pictureBox != null && pictureBox.BackgroundImage is not null)
|
||||
pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage);
|
||||
*/
|
||||
|
||||
ResizeControls(control.Controls);
|
||||
}
|
||||
@@ -93,7 +99,7 @@ public static class ControlHelper
|
||||
if (pictureBox != null && pictureBox.BackgroundImage is not null)
|
||||
pictureBox.BackgroundImage = AdjustImage(pictureBox.BackgroundImage);
|
||||
|
||||
|
||||
|
||||
var combo = control as RComboBox;
|
||||
if (combo != null)
|
||||
{
|
||||
@@ -109,14 +115,17 @@ public static class ControlHelper
|
||||
gb.ForeColor = foreMain;
|
||||
}
|
||||
|
||||
var sl = control as Slider;
|
||||
if (sl != null)
|
||||
{
|
||||
sl.borderColor = buttonMain;
|
||||
}
|
||||
|
||||
var chart = control as Chart;
|
||||
if (chart != null)
|
||||
{
|
||||
chart.BackColor = backMain;
|
||||
chart.ChartAreas[0].BackColor = backMain;
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;
|
||||
|
||||
chart.ChartAreas[0].AxisX.TitleForeColor = foreMain;
|
||||
chart.ChartAreas[0].AxisY.TitleForeColor = foreMain;
|
||||
@@ -127,6 +136,8 @@ public static class ControlHelper
|
||||
chart.ChartAreas[0].AxisX.MajorTickMark.LineColor = foreMain;
|
||||
chart.ChartAreas[0].AxisY.MajorTickMark.LineColor = foreMain;
|
||||
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisX.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisY.LineColor = foreAccent;
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Win32;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
@@ -30,9 +31,9 @@ namespace CustomControls
|
||||
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);
|
||||
darkTheme = newDarkTheme;
|
||||
|
||||
@@ -45,16 +46,13 @@ namespace CustomControls
|
||||
ControlHelper.Adjust(this, darkTheme, changed);
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public class RTrackBar : TrackBar
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class RComboBox : ComboBox
|
||||
{
|
||||
private Color borderColor = Color.Gray;
|
||||
@@ -71,6 +69,8 @@ namespace CustomControls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Color buttonColor = Color.FromArgb(255,230, 230, 230);
|
||||
[DefaultValue(typeof(Color), "230, 230, 230")]
|
||||
public Color ButtonColor
|
||||
|
||||
20
app/Fans.Designer.cs
generated
20
app/Fans.Designer.cs
generated
@@ -259,7 +259,7 @@ namespace GHelper
|
||||
buttonApply.Secondary = true;
|
||||
buttonApply.Size = new Size(248, 44);
|
||||
buttonApply.TabIndex = 14;
|
||||
buttonApply.Text = "Apply Fan Curve";
|
||||
buttonApply.Text = "Apply Custom Curve";
|
||||
buttonApply.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// panelPower
|
||||
@@ -346,12 +346,11 @@ namespace GHelper
|
||||
//
|
||||
// labelCPU
|
||||
//
|
||||
labelCPU.AutoSize = true;
|
||||
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.Name = "labelCPU";
|
||||
labelCPU.Size = new Size(61, 32);
|
||||
labelCPU.Size = new Size(120, 32);
|
||||
labelCPU.TabIndex = 13;
|
||||
labelCPU.Text = "CPU";
|
||||
labelCPU.TextAlign = ContentAlignment.MiddleCenter;
|
||||
@@ -393,25 +392,24 @@ namespace GHelper
|
||||
//
|
||||
// labelTotal
|
||||
//
|
||||
labelTotal.AutoSize = true;
|
||||
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.Name = "labelTotal";
|
||||
labelTotal.Size = new Size(70, 32);
|
||||
labelTotal.Size = new Size(122, 32);
|
||||
labelTotal.TabIndex = 12;
|
||||
labelTotal.Text = "Total";
|
||||
labelTotal.Text = "Platform";
|
||||
labelTotal.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(48, 8);
|
||||
label1.Location = new Point(26, 8);
|
||||
label1.Margin = new Padding(4, 0, 4, 0);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(65, 32);
|
||||
label1.Size = new Size(104, 32);
|
||||
label1.TabIndex = 11;
|
||||
label1.Text = "Total";
|
||||
label1.Text = "Platform";
|
||||
label1.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// trackTotal
|
||||
|
||||
29
app/Fans.cs
29
app/Fans.cs
@@ -18,7 +18,7 @@ namespace GHelper
|
||||
{
|
||||
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)
|
||||
@@ -47,6 +47,13 @@ namespace GHelper
|
||||
|
||||
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
|
||||
|
||||
var foreAccent = Color.FromArgb(255, 100, 100, 100);
|
||||
|
||||
chart.ChartAreas[0].AxisX.MajorGrid.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisY.MajorGrid.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisX.LineColor = foreAccent;
|
||||
chart.ChartAreas[0].AxisY.LineColor = foreAccent;
|
||||
|
||||
for (int i = 0; i <= 90; i += 10)
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i));
|
||||
|
||||
@@ -82,14 +89,8 @@ namespace GHelper
|
||||
InitializeComponent();
|
||||
InitTheme();
|
||||
|
||||
MinRPM = 1800;
|
||||
|
||||
if (Program.config.ContainsModel("401"))
|
||||
MaxRPM = 7200;
|
||||
else if (Program.config.ContainsModel("503"))
|
||||
MaxRPM = 6800;
|
||||
else
|
||||
MaxRPM = 5800;
|
||||
MinRPM = 18;
|
||||
MaxRPM = HardwareMonitor.GetFanMax();
|
||||
|
||||
|
||||
|
||||
@@ -139,7 +140,7 @@ namespace GHelper
|
||||
InitPower();
|
||||
InitBoost();
|
||||
|
||||
comboBoost.SelectedIndexChanged += ComboBoost_Changed;
|
||||
comboBoost.SelectedValueChanged += ComboBoost_Changed;
|
||||
|
||||
Shown += Fans_Shown;
|
||||
|
||||
@@ -155,9 +156,11 @@ namespace GHelper
|
||||
|
||||
private void ComboBoost_Changed(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null) return;
|
||||
ComboBox cmb = (ComboBox)sender;
|
||||
NativeMethods.SetCPUBoost(cmb.SelectedIndex);
|
||||
if (Program.config.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
|
||||
{
|
||||
NativeMethods.SetCPUBoost(comboBoost.SelectedIndex);
|
||||
Program.config.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckApplyPower_Click(object? sender, EventArgs e)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>0.36</AssemblyVersion>
|
||||
<AssemblyVersion>0.43</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using GHelper;
|
||||
using GHelper.Gpu;
|
||||
|
||||
public static class HardwareMonitor
|
||||
@@ -9,12 +10,53 @@ public static class HardwareMonitor
|
||||
public static float? batteryDischarge = -1;
|
||||
public static int? gpuTemp = null;
|
||||
|
||||
public static string? cpuFan;
|
||||
public static string? gpuFan;
|
||||
public static string? midFan;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
public static void ReadSensors()
|
||||
{
|
||||
cpuTemp = -1;
|
||||
batteryDischarge = -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);
|
||||
gpuTemp = Program.wmi.DeviceGet(ASUSWmi.Temp_GPU);
|
||||
|
||||
if (cpuTemp < 0) try
|
||||
{
|
||||
var ct = new PerformanceCounter("Thermal Zone Information", "Temperature", @"\_TZ.THRM", true);
|
||||
cpuTemp = ct.NextValue() - 273;
|
||||
@@ -24,37 +66,42 @@ public static class HardwareMonitor
|
||||
Logger.WriteLine("Failed reading CPU temp");
|
||||
}
|
||||
|
||||
if (gpuTemp < 0) try
|
||||
{
|
||||
if (GpuTemperatureProvider is null) RecreateGpuTemperatureProvider();
|
||||
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
gpuTemp = null;
|
||||
Logger.WriteLine("Failed reading GPU temp");
|
||||
Logger.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var cb = new PerformanceCounter("Power Meter", "Power", "Power Meter (0)", true);
|
||||
batteryDischarge = cb.NextValue() / 1000;
|
||||
cb.Dispose();
|
||||
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.WriteLine("Failed reading Battery discharge");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
gpuTemp = GpuTemperatureProvider?.GetCurrentTemperature();
|
||||
} catch (Exception ex) {
|
||||
gpuTemp = null;
|
||||
Logger.WriteLine("Failed reading GPU temp");
|
||||
Logger.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void RecreateGpuTemperatureProviderWithRetry() {
|
||||
RecreateGpuTemperatureProvider();
|
||||
public static void RecreateGpuTemperatureProviderWithDelay() {
|
||||
|
||||
// Re-enabling the discrete GPU takes a bit of time,
|
||||
// so a simple workaround is to refresh again after that happens
|
||||
Task.Run(async () => {
|
||||
await Task.Delay(TimeSpan.FromSeconds(3));
|
||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||
RecreateGpuTemperatureProvider();
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void RecreateGpuTemperatureProvider() {
|
||||
@@ -85,6 +132,7 @@ public static class HardwareMonitor
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine(ex.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
204
app/Keyboard.Designer.cs
generated
204
app/Keyboard.Designer.cs
generated
@@ -31,16 +31,29 @@ namespace GHelper
|
||||
private void InitializeComponent()
|
||||
{
|
||||
groupBox1 = new GroupBox();
|
||||
textFNF4 = new TextBox();
|
||||
comboFNF4 = new RComboBox();
|
||||
labelFNF4 = new Label();
|
||||
textM4 = new TextBox();
|
||||
textM3 = new TextBox();
|
||||
comboM4 = new RComboBox();
|
||||
labelM4 = new Label();
|
||||
comboM3 = new RComboBox();
|
||||
labelM3 = new Label();
|
||||
textFNF4 = new TextBox();
|
||||
comboFNF4 = new RComboBox();
|
||||
labelFNF4 = new Label();
|
||||
groupLight = new GroupBox();
|
||||
labelSpeed = 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();
|
||||
groupLight.SuspendLayout();
|
||||
groupOther.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// groupBox1
|
||||
@@ -57,11 +70,36 @@ namespace GHelper
|
||||
groupBox1.Dock = DockStyle.Top;
|
||||
groupBox1.Location = new Point(10, 10);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(751, 242);
|
||||
groupBox1.Size = new Size(756, 242);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
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.Location = new Point(411, 113);
|
||||
@@ -114,36 +152,137 @@ namespace GHelper
|
||||
labelM3.TabIndex = 0;
|
||||
labelM3.Text = "M3:";
|
||||
//
|
||||
// textFNF4
|
||||
// groupLight
|
||||
//
|
||||
textFNF4.Location = new Point(411, 176);
|
||||
textFNF4.Name = "textFNF4";
|
||||
textFNF4.PlaceholderText = "action";
|
||||
textFNF4.Size = new Size(320, 39);
|
||||
textFNF4.TabIndex = 8;
|
||||
groupLight.Controls.Add(labelSpeed);
|
||||
groupLight.Controls.Add(comboKeyboardSpeed);
|
||||
groupLight.Controls.Add(checkShutdown);
|
||||
groupLight.Controls.Add(checkSleep);
|
||||
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;
|
||||
comboFNF4.Location = new Point(93, 175);
|
||||
comboFNF4.Name = "comboFNF4";
|
||||
comboFNF4.Size = new Size(312, 40);
|
||||
comboFNF4.TabIndex = 7;
|
||||
labelSpeed.AutoSize = true;
|
||||
labelSpeed.Location = new Point(25, 237);
|
||||
labelSpeed.Name = "labelSpeed";
|
||||
labelSpeed.Size = new Size(198, 32);
|
||||
labelSpeed.TabIndex = 40;
|
||||
labelSpeed.Text = "Animation Speed";
|
||||
//
|
||||
// labelFNF4
|
||||
// comboKeyboardSpeed
|
||||
//
|
||||
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:";
|
||||
comboKeyboardSpeed.BorderColor = Color.White;
|
||||
comboKeyboardSpeed.ButtonColor = SystemColors.ControlLight;
|
||||
comboKeyboardSpeed.FlatStyle = FlatStyle.Flat;
|
||||
comboKeyboardSpeed.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboKeyboardSpeed.FormattingEnabled = true;
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(771, 858);
|
||||
ClientSize = new Size(776, 858);
|
||||
Controls.Add(groupOther);
|
||||
Controls.Add(groupLight);
|
||||
Controls.Add(groupBox1);
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
@@ -153,9 +292,13 @@ namespace GHelper
|
||||
Padding = new Padding(10);
|
||||
ShowIcon = false;
|
||||
ShowInTaskbar = false;
|
||||
Text = "Keyboard";
|
||||
Text = "Extra Settings";
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
groupLight.ResumeLayout(false);
|
||||
groupLight.PerformLayout();
|
||||
groupOther.ResumeLayout(false);
|
||||
groupOther.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@@ -171,5 +314,16 @@ namespace GHelper
|
||||
private TextBox textFNF4;
|
||||
private RComboBox comboFNF4;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,66 @@ namespace GHelper
|
||||
SetKeyCombo(comboFNF4, textFNF4, "fnf4");
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Xml.Linq;
|
||||
using static Tools.ScreenInterrogatory;
|
||||
|
||||
namespace Tools
|
||||
@@ -588,7 +590,7 @@ public class NativeMethods
|
||||
return laptopScreen;
|
||||
}
|
||||
|
||||
public static int GetRefreshRate()
|
||||
public static int GetRefreshRate(bool max = false)
|
||||
{
|
||||
DEVMODE dm = CreateDevmode();
|
||||
|
||||
@@ -598,11 +600,23 @@ public class NativeMethods
|
||||
if (laptopScreen is null)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -671,6 +685,7 @@ public class NativeMethods
|
||||
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
|
||||
*/
|
||||
|
||||
Logger.WriteLine("Boost " + boost);
|
||||
}
|
||||
|
||||
public static void SetPowerScheme(int mode)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
@@ -23,15 +21,24 @@ namespace GHelper
|
||||
public static SettingsForm settingsForm = new SettingsForm();
|
||||
public static ToastForm toast = new ToastForm();
|
||||
|
||||
private static IntPtr unRegPowerNotify;
|
||||
private static IntPtr ds;
|
||||
public static IntPtr unRegPowerNotify;
|
||||
|
||||
private static long lastAuto;
|
||||
private static long lastTheme;
|
||||
private static PowerLineStatus isPlugged = PowerLineStatus.Unknown;
|
||||
|
||||
// The main entry point for the application
|
||||
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
|
||||
{
|
||||
wmi = new ASUSWmi();
|
||||
@@ -49,14 +56,12 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
SystemEvents.UserPreferenceChanged += new
|
||||
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
|
||||
ds = settingsForm.Handle;
|
||||
var ds = settingsForm.Handle;
|
||||
|
||||
trayIcon.MouseClick += TrayIcon_MouseClick; ;
|
||||
trayIcon.MouseClick += TrayIcon_MouseClick;
|
||||
|
||||
wmi.SubscribeToEvents(WatcherEventArrived);
|
||||
|
||||
@@ -67,16 +72,11 @@ namespace GHelper
|
||||
settingsForm.SetStartupCheck(Startup.IsScheduled());
|
||||
|
||||
SetAutoModes();
|
||||
HardwareMonitor.RecreateGpuTemperatureProvider();
|
||||
|
||||
// Subscribing for monitor power on events
|
||||
var settingGuid = new NativeMethods.PowerSettingGuid();
|
||||
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
// Subscribing for system power change events
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
|
||||
CheckForUpdates();
|
||||
|
||||
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\'))
|
||||
{
|
||||
@@ -99,82 +99,46 @@ namespace GHelper
|
||||
{
|
||||
case UserPreferenceCategory.General:
|
||||
Debug.WriteLine("Theme Changed");
|
||||
Thread.Sleep(500);
|
||||
settingsForm.InitTheme(false);
|
||||
Thread.Sleep(1000);
|
||||
settingsForm.InitTheme();
|
||||
|
||||
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 != "")
|
||||
settingsForm.keyb.InitTheme(false);
|
||||
settingsForm.keyb.InitTheme();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static async void CheckForUpdates()
|
||||
|
||||
public static void SetAutoModes()
|
||||
{
|
||||
|
||||
var assembly = Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
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;
|
||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
|
||||
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
||||
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
|
||||
isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
|
||||
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
settingsForm.AutoPerformance();
|
||||
|
||||
settingsForm.AutoPerformance(isPlugged);
|
||||
bool switched = settingsForm.AutoGPUMode();
|
||||
if (!switched) settingsForm.AutoScreen();
|
||||
|
||||
// waiting a bit before turning off dGPU
|
||||
// if (wait && isPlugged != PowerLineStatus.Online) Thread.Sleep(3000);
|
||||
|
||||
bool switched = settingsForm.AutoGPUMode(isPlugged);
|
||||
if (!switched) settingsForm.AutoScreen(isPlugged);
|
||||
|
||||
settingsForm.SetMatrix(isPlugged);
|
||||
settingsForm.SetMatrix();
|
||||
}
|
||||
|
||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
|
||||
|
||||
Logger.WriteLine("Windows - Power Mode Changed");
|
||||
SetAutoModes(true);
|
||||
settingsForm.AutoKeyboard();
|
||||
SetAutoModes();
|
||||
}
|
||||
|
||||
|
||||
|
||||
167
app/Settings.Designer.cs
generated
167
app/Settings.Designer.cs
generated
@@ -35,16 +35,17 @@ namespace GHelper
|
||||
checkMatrix = new CheckBox();
|
||||
tableLayoutMatrix = new TableLayoutPanel();
|
||||
comboMatrix = new RComboBox();
|
||||
buttonMatrix = new RButton();
|
||||
comboMatrixRunning = new RComboBox();
|
||||
buttonMatrix = new RButton();
|
||||
pictureMatrix = new PictureBox();
|
||||
labelMatrix = new Label();
|
||||
panelBattery = new Panel();
|
||||
sliderBattery = new WinFormsSliderBar.Slider();
|
||||
labelModel = new Label();
|
||||
labelVersion = new Label();
|
||||
labelBattery = new Label();
|
||||
pictureBattery = new PictureBox();
|
||||
labelBatteryTitle = new Label();
|
||||
trackBattery = new TrackBar();
|
||||
panelFooter = new Panel();
|
||||
buttonQuit = new RButton();
|
||||
checkStartup = new CheckBox();
|
||||
@@ -79,12 +80,12 @@ namespace GHelper
|
||||
labelSreen = new Label();
|
||||
panelKeyboard = new Panel();
|
||||
tableLayoutKeyboard = new TableLayoutPanel();
|
||||
buttonKeyboard = new RButton();
|
||||
comboKeyboard = new RComboBox();
|
||||
panelColor = new Panel();
|
||||
pictureColor2 = new PictureBox();
|
||||
pictureColor = new PictureBox();
|
||||
buttonKeyboardColor = new RButton();
|
||||
buttonKeyboard = new RButton();
|
||||
pictureKeyboard = new PictureBox();
|
||||
labelKeyboard = new Label();
|
||||
panelMatrix.SuspendLayout();
|
||||
@@ -92,7 +93,6 @@ namespace GHelper
|
||||
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
|
||||
panelBattery.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackBattery).BeginInit();
|
||||
panelFooter.SuspendLayout();
|
||||
panelPerformance.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
|
||||
@@ -144,20 +144,20 @@ namespace GHelper
|
||||
tableLayoutMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
tableLayoutMatrix.AutoSize = true;
|
||||
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.Controls.Add(comboMatrix, 0, 0);
|
||||
tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0);
|
||||
tableLayoutMatrix.Controls.Add(comboMatrixRunning, 1, 0);
|
||||
tableLayoutMatrix.Controls.Add(buttonMatrix, 2, 0);
|
||||
tableLayoutMatrix.Location = new Point(16, 52);
|
||||
tableLayoutMatrix.Margin = new Padding(8);
|
||||
tableLayoutMatrix.Name = "tableLayoutMatrix";
|
||||
tableLayoutMatrix.RowCount = 1;
|
||||
tableLayoutMatrix.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tableLayoutMatrix.Size = new Size(772, 60);
|
||||
tableLayoutMatrix.Size = new Size(771, 60);
|
||||
tableLayoutMatrix.TabIndex = 43;
|
||||
//
|
||||
// comboMatrix
|
||||
@@ -172,28 +172,10 @@ namespace GHelper
|
||||
comboMatrix.Location = new Point(4, 10);
|
||||
comboMatrix.Margin = new Padding(4, 10, 4, 8);
|
||||
comboMatrix.Name = "comboMatrix";
|
||||
comboMatrix.Size = new Size(185, 40);
|
||||
comboMatrix.Size = new Size(249, 40);
|
||||
comboMatrix.TabIndex = 41;
|
||||
comboMatrix.TabStop = false;
|
||||
//
|
||||
// buttonMatrix
|
||||
//
|
||||
buttonMatrix.Activated = false;
|
||||
buttonMatrix.BackColor = Color.FromArgb(230, 230, 230);
|
||||
buttonMatrix.BorderColor = Color.Transparent;
|
||||
buttonMatrix.BorderRadius = 2;
|
||||
buttonMatrix.Dock = DockStyle.Top;
|
||||
buttonMatrix.FlatAppearance.BorderSize = 0;
|
||||
buttonMatrix.FlatStyle = FlatStyle.Flat;
|
||||
buttonMatrix.Location = new Point(390, 8);
|
||||
buttonMatrix.Margin = new Padding(4, 8, 4, 8);
|
||||
buttonMatrix.Name = "buttonMatrix";
|
||||
buttonMatrix.Secondary = true;
|
||||
buttonMatrix.Size = new Size(185, 44);
|
||||
buttonMatrix.TabIndex = 43;
|
||||
buttonMatrix.Text = "Picture / Gif";
|
||||
buttonMatrix.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// comboMatrixRunning
|
||||
//
|
||||
comboMatrixRunning.BorderColor = Color.White;
|
||||
@@ -203,13 +185,31 @@ namespace GHelper
|
||||
comboMatrixRunning.FormattingEnabled = true;
|
||||
comboMatrixRunning.ItemHeight = 32;
|
||||
comboMatrixRunning.Items.AddRange(new object[] { "Binary Banner", "Rog Logo", "Picture", "Clock" });
|
||||
comboMatrixRunning.Location = new Point(197, 10);
|
||||
comboMatrixRunning.Location = new Point(261, 10);
|
||||
comboMatrixRunning.Margin = new Padding(4, 10, 4, 8);
|
||||
comboMatrixRunning.Name = "comboMatrixRunning";
|
||||
comboMatrixRunning.Size = new Size(185, 40);
|
||||
comboMatrixRunning.Size = new Size(249, 40);
|
||||
comboMatrixRunning.TabIndex = 42;
|
||||
comboMatrixRunning.TabStop = false;
|
||||
//
|
||||
// buttonMatrix
|
||||
//
|
||||
buttonMatrix.Activated = false;
|
||||
buttonMatrix.BackColor = Color.FromArgb(230, 230, 230);
|
||||
buttonMatrix.BorderColor = Color.Transparent;
|
||||
buttonMatrix.BorderRadius = 2;
|
||||
buttonMatrix.Dock = DockStyle.Top;
|
||||
buttonMatrix.FlatAppearance.BorderSize = 0;
|
||||
buttonMatrix.FlatStyle = FlatStyle.Flat;
|
||||
buttonMatrix.Location = new Point(518, 8);
|
||||
buttonMatrix.Margin = new Padding(4, 8, 4, 8);
|
||||
buttonMatrix.Name = "buttonMatrix";
|
||||
buttonMatrix.Secondary = true;
|
||||
buttonMatrix.Size = new Size(249, 44);
|
||||
buttonMatrix.TabIndex = 43;
|
||||
buttonMatrix.Text = "Picture / Gif";
|
||||
buttonMatrix.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// pictureMatrix
|
||||
//
|
||||
pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_desktop_48;
|
||||
@@ -236,25 +236,49 @@ namespace GHelper
|
||||
//
|
||||
panelBattery.AutoSize = true;
|
||||
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
panelBattery.Controls.Add(sliderBattery);
|
||||
panelBattery.Controls.Add(labelModel);
|
||||
panelBattery.Controls.Add(labelVersion);
|
||||
panelBattery.Controls.Add(labelBattery);
|
||||
panelBattery.Controls.Add(pictureBattery);
|
||||
panelBattery.Controls.Add(labelBatteryTitle);
|
||||
panelBattery.Controls.Add(trackBattery);
|
||||
panelBattery.Dock = DockStyle.Top;
|
||||
panelBattery.Location = new Point(10, 926);
|
||||
panelBattery.Margin = new Padding(8);
|
||||
panelBattery.Name = "panelBattery";
|
||||
panelBattery.Padding = new Padding(0, 0, 0, 12);
|
||||
panelBattery.Size = new Size(810, 158);
|
||||
panelBattery.Size = new Size(810, 163);
|
||||
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.AutoSize = true;
|
||||
labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point);
|
||||
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.Name = "labelVersion";
|
||||
labelVersion.Size = new Size(44, 32);
|
||||
@@ -293,22 +317,6 @@ namespace GHelper
|
||||
labelBatteryTitle.TabIndex = 34;
|
||||
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.AutoSize = true;
|
||||
@@ -316,7 +324,7 @@ namespace GHelper
|
||||
panelFooter.Controls.Add(buttonQuit);
|
||||
panelFooter.Controls.Add(checkStartup);
|
||||
panelFooter.Dock = DockStyle.Top;
|
||||
panelFooter.Location = new Point(10, 1084);
|
||||
panelFooter.Location = new Point(10, 1089);
|
||||
panelFooter.Margin = new Padding(8);
|
||||
panelFooter.Name = "panelFooter";
|
||||
panelFooter.Padding = new Padding(0, 0, 0, 10);
|
||||
@@ -393,6 +401,7 @@ namespace GHelper
|
||||
// labelCPUFan
|
||||
//
|
||||
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelCPUFan.Cursor = Cursors.Hand;
|
||||
labelCPUFan.Location = new Point(384, 15);
|
||||
labelCPUFan.Margin = new Padding(8, 0, 8, 0);
|
||||
labelCPUFan.Name = "labelCPUFan";
|
||||
@@ -862,40 +871,22 @@ namespace GHelper
|
||||
tableLayoutKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
tableLayoutKeyboard.AutoSize = true;
|
||||
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.Controls.Add(buttonKeyboard, 2, 0);
|
||||
tableLayoutKeyboard.Controls.Add(comboKeyboard, 0, 0);
|
||||
tableLayoutKeyboard.Controls.Add(panelColor, 1, 0);
|
||||
tableLayoutKeyboard.Controls.Add(buttonKeyboard, 2, 0);
|
||||
tableLayoutKeyboard.Location = new Point(16, 50);
|
||||
tableLayoutKeyboard.Margin = new Padding(8);
|
||||
tableLayoutKeyboard.Name = "tableLayoutKeyboard";
|
||||
tableLayoutKeyboard.RowCount = 1;
|
||||
tableLayoutKeyboard.RowStyles.Add(new RowStyle(SizeType.Percent, 100F));
|
||||
tableLayoutKeyboard.Size = new Size(772, 60);
|
||||
tableLayoutKeyboard.Size = new Size(771, 60);
|
||||
tableLayoutKeyboard.TabIndex = 39;
|
||||
//
|
||||
// buttonKeyboard
|
||||
//
|
||||
buttonKeyboard.Activated = false;
|
||||
buttonKeyboard.BackColor = Color.FromArgb(230, 230, 230);
|
||||
buttonKeyboard.BorderColor = Color.Transparent;
|
||||
buttonKeyboard.BorderRadius = 2;
|
||||
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.BorderColor = Color.White;
|
||||
@@ -905,11 +896,11 @@ namespace GHelper
|
||||
comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboKeyboard.FormattingEnabled = true;
|
||||
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.Margin = new Padding(4, 10, 4, 8);
|
||||
comboKeyboard.Name = "comboKeyboard";
|
||||
comboKeyboard.Size = new Size(185, 40);
|
||||
comboKeyboard.Size = new Size(249, 40);
|
||||
comboKeyboard.TabIndex = 35;
|
||||
comboKeyboard.TabStop = false;
|
||||
//
|
||||
@@ -920,16 +911,16 @@ namespace GHelper
|
||||
panelColor.Controls.Add(pictureColor);
|
||||
panelColor.Controls.Add(buttonKeyboardColor);
|
||||
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.Name = "panelColor";
|
||||
panelColor.Size = new Size(185, 44);
|
||||
panelColor.Size = new Size(249, 44);
|
||||
panelColor.TabIndex = 36;
|
||||
//
|
||||
// pictureColor2
|
||||
//
|
||||
pictureColor2.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
pictureColor2.Location = new Point(123, 12);
|
||||
pictureColor2.Location = new Point(188, 12);
|
||||
pictureColor2.Margin = new Padding(8);
|
||||
pictureColor2.Name = "pictureColor2";
|
||||
pictureColor2.Size = new Size(20, 20);
|
||||
@@ -939,7 +930,7 @@ namespace GHelper
|
||||
// pictureColor
|
||||
//
|
||||
pictureColor.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
pictureColor.Location = new Point(151, 12);
|
||||
pictureColor.Location = new Point(215, 12);
|
||||
pictureColor.Margin = new Padding(8);
|
||||
pictureColor.Name = "pictureColor";
|
||||
pictureColor.Size = new Size(20, 20);
|
||||
@@ -959,11 +950,29 @@ namespace GHelper
|
||||
buttonKeyboardColor.Margin = new Padding(4, 8, 4, 8);
|
||||
buttonKeyboardColor.Name = "buttonKeyboardColor";
|
||||
buttonKeyboardColor.Secondary = false;
|
||||
buttonKeyboardColor.Size = new Size(185, 44);
|
||||
buttonKeyboardColor.Size = new Size(249, 44);
|
||||
buttonKeyboardColor.TabIndex = 39;
|
||||
buttonKeyboardColor.Text = "Color ";
|
||||
buttonKeyboardColor.Text = "Color";
|
||||
buttonKeyboardColor.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// buttonKeyboard
|
||||
//
|
||||
buttonKeyboard.Activated = false;
|
||||
buttonKeyboard.BackColor = Color.FromArgb(230, 230, 230);
|
||||
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.BackgroundImage = Properties.Resources.icons8_keyboard_48;
|
||||
@@ -1018,7 +1027,6 @@ namespace GHelper
|
||||
panelBattery.ResumeLayout(false);
|
||||
panelBattery.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBattery).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackBattery).EndInit();
|
||||
panelFooter.ResumeLayout(false);
|
||||
panelFooter.PerformLayout();
|
||||
panelPerformance.ResumeLayout(false);
|
||||
@@ -1054,7 +1062,6 @@ namespace GHelper
|
||||
private Label labelBattery;
|
||||
private PictureBox pictureBattery;
|
||||
private Label labelBatteryTitle;
|
||||
private TrackBar trackBattery;
|
||||
private Panel panelFooter;
|
||||
private RButton buttonQuit;
|
||||
private CheckBox checkStartup;
|
||||
@@ -1102,5 +1109,7 @@ namespace GHelper
|
||||
private RButton buttonKeyboardColor;
|
||||
private RButton buttonFans;
|
||||
private Label labelMidFan;
|
||||
private Label labelModel;
|
||||
private WinFormsSliderBar.Slider sliderBattery;
|
||||
}
|
||||
}
|
||||
401
app/Settings.cs
401
app/Settings.cs
@@ -2,6 +2,9 @@
|
||||
using Starlight.AnimeMatrix;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Timers;
|
||||
|
||||
namespace GHelper
|
||||
@@ -10,7 +13,9 @@ namespace GHelper
|
||||
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!;
|
||||
|
||||
public string versionUrl = "http://github.com/seerge/g-helper/releases";
|
||||
@@ -21,12 +26,13 @@ namespace GHelper
|
||||
public Keyboard keyb;
|
||||
|
||||
static AnimeMatrixDevice mat;
|
||||
static int matrixMode = 0;
|
||||
static int matrixTick = 0;
|
||||
static long lastRefresh;
|
||||
|
||||
public SettingsForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitTheme();
|
||||
InitTheme(true);
|
||||
|
||||
FormClosing += SettingsForm_FormClosing;
|
||||
|
||||
@@ -55,8 +61,6 @@ namespace GHelper
|
||||
|
||||
VisibleChanged += SettingsForm_VisibleChanged;
|
||||
|
||||
trackBattery.Scroll += trackBatteryChange;
|
||||
|
||||
button60Hz.Click += Button60Hz_Click;
|
||||
button120Hz.Click += Button120Hz_Click;
|
||||
buttonScreenAuto.Click += ButtonScreenAuto_Click;
|
||||
@@ -64,10 +68,6 @@ namespace GHelper
|
||||
|
||||
buttonQuit.Click += ButtonQuit_Click;
|
||||
|
||||
comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboKeyboard.SelectedIndex = 0;
|
||||
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
|
||||
|
||||
buttonKeyboardColor.Click += ButtonKeyboardColor_Click;
|
||||
|
||||
buttonFans.Click += ButtonFans_Click;
|
||||
@@ -115,16 +115,94 @@ namespace GHelper
|
||||
button120Hz.MouseMove += Button120Hz_MouseHover;
|
||||
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;
|
||||
|
||||
// Subscribing for monitor power on events
|
||||
var settingGuid = new NativeMethods.PowerSettingGuid();
|
||||
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
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)
|
||||
{
|
||||
RefreshSensors();
|
||||
}
|
||||
|
||||
|
||||
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
|
||||
{
|
||||
RefreshSensors();
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -172,18 +250,19 @@ namespace GHelper
|
||||
{
|
||||
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
|
||||
VisualiseGPUMode();
|
||||
AutoGPUMode(SystemInformation.PowerStatus.PowerLineStatus);
|
||||
AutoGPUMode();
|
||||
}
|
||||
|
||||
private void ButtonScreenAuto_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 1);
|
||||
InitScreen();
|
||||
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus);
|
||||
AutoScreen();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
|
||||
switch (m.Msg)
|
||||
{
|
||||
case NativeMethods.WM_POWERBROADCAST:
|
||||
@@ -194,6 +273,7 @@ namespace GHelper
|
||||
{
|
||||
case 0:
|
||||
Logger.WriteLine("Monitor Power Off");
|
||||
SetBatteryChargeLimit(Program.config.getConfig("charge_limit"));
|
||||
break;
|
||||
case 1:
|
||||
Logger.WriteLine("Monitor Power On");
|
||||
@@ -214,12 +294,12 @@ namespace GHelper
|
||||
}
|
||||
|
||||
|
||||
public void SetVersionLabel(string label, string url = null)
|
||||
void SetVersionLabel(string label, string url = null)
|
||||
{
|
||||
labelVersion.Text = label;
|
||||
if (url is not null)
|
||||
{
|
||||
versionUrl = url;
|
||||
this.versionUrl = url;
|
||||
labelVersion.ForeColor = Color.Red;
|
||||
}
|
||||
}
|
||||
@@ -253,8 +333,9 @@ namespace GHelper
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -273,7 +354,29 @@ namespace GHelper
|
||||
mat.PresentNextFrame();
|
||||
break;
|
||||
case 3:
|
||||
mat.PresentText(DateTime.Now.ToString("H:mm:ss"));
|
||||
string format1, format2;
|
||||
if (CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern.Contains("H"))
|
||||
{
|
||||
format1 = "H:mm";
|
||||
format2 = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
format1 = "h:mm";
|
||||
format2 = "tt";
|
||||
}
|
||||
|
||||
if (matrixTick > 0)
|
||||
{
|
||||
format1 = format1.Replace(":", " ");
|
||||
matrixTick = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
matrixTick++;
|
||||
}
|
||||
|
||||
mat.PresentText(DateTime.Now.ToString(format1), DateTime.Now.ToString(format2));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -350,6 +453,8 @@ namespace GHelper
|
||||
if (fileName is not null)
|
||||
{
|
||||
Program.config.setConfig("matrix_picture", fileName);
|
||||
Program.config.setConfig("matrix_running", 2);
|
||||
|
||||
SetMatrixPicture(fileName);
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
@@ -373,7 +478,7 @@ namespace GHelper
|
||||
SetMatrix();
|
||||
}
|
||||
|
||||
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
public void SetMatrix()
|
||||
{
|
||||
|
||||
if (mat is null) return;
|
||||
@@ -396,7 +501,7 @@ namespace GHelper
|
||||
|
||||
mat.SetProvider();
|
||||
|
||||
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online))
|
||||
if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
|
||||
{
|
||||
mat.SetDisplayState(false);
|
||||
}
|
||||
@@ -408,12 +513,11 @@ namespace GHelper
|
||||
switch (running)
|
||||
{
|
||||
case 2:
|
||||
string fileName = Program.config.getConfigString("matrix_picture");
|
||||
SetMatrixPicture(fileName);
|
||||
SetMatrixPicture(Program.config.getConfigString("matrix_picture"));
|
||||
break;
|
||||
case 3:
|
||||
mat.SetBuiltInAnimation(false);
|
||||
StartMatrixTimer();
|
||||
StartMatrixTimer(1000);
|
||||
break;
|
||||
default:
|
||||
mat.SetBuiltInAnimation(true, animation);
|
||||
@@ -421,6 +525,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
//mat.SetBrightness((BrightnessMode)brightness);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -430,19 +535,20 @@ namespace GHelper
|
||||
private void LabelCPUFan_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
|
||||
RefreshSensors();
|
||||
RefreshSensors(true);
|
||||
}
|
||||
|
||||
private void PictureColor2_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
ColorDialog colorDlg = new ColorDialog();
|
||||
colorDlg.AllowFullOpen = false;
|
||||
colorDlg.AllowFullOpen = true;
|
||||
colorDlg.Color = pictureColor2.BackColor;
|
||||
|
||||
if (colorDlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SetAuraColor(color2: colorDlg.Color);
|
||||
Program.config.setConfig("aura_color2", colorDlg.Color.ToArgb());
|
||||
SetAura();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,45 +593,34 @@ namespace GHelper
|
||||
private void ButtonKeyboardColor_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
Button but = (Button)sender;
|
||||
|
||||
ColorDialog colorDlg = new ColorDialog();
|
||||
colorDlg.AllowFullOpen = false;
|
||||
colorDlg.AllowFullOpen = true;
|
||||
colorDlg.Color = pictureColor.BackColor;
|
||||
|
||||
if (colorDlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
SetAuraColor(color1: colorDlg.Color);
|
||||
Program.config.setConfig("aura_color", colorDlg.Color.ToArgb());
|
||||
SetAura();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitAura()
|
||||
{
|
||||
int mode = Program.config.getConfig("aura_mode");
|
||||
int colorCode = Program.config.getConfig("aura_color");
|
||||
int colorCode2 = Program.config.getConfig("aura_color2");
|
||||
Aura.Mode = Program.config.getConfig("aura_mode");
|
||||
Aura.Speed = Program.config.getConfig("aura_speed");
|
||||
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);
|
||||
Color color2 = Color.FromArgb(0, 0, 0);
|
||||
|
||||
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;
|
||||
pictureColor.BackColor = Aura.Color1;
|
||||
pictureColor2.BackColor = Aura.Color2;
|
||||
pictureColor2.Visible = Aura.HasSecondColor();
|
||||
}
|
||||
|
||||
public void InitMatrix()
|
||||
@@ -555,67 +650,36 @@ namespace GHelper
|
||||
}
|
||||
|
||||
|
||||
public void SetAuraColor(Color? color1 = null, Color? color2 = null, bool apply = true)
|
||||
public void SetAura()
|
||||
{
|
||||
|
||||
if (color1 is not null)
|
||||
{
|
||||
Aura.Color1 = (Color)color1;
|
||||
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();
|
||||
Aura.Mode = Program.config.getConfig("aura_mode");
|
||||
Aura.Speed = Program.config.getConfig("aura_speed");
|
||||
Aura.SetColor(Program.config.getConfig("aura_color"));
|
||||
Aura.SetColor2(Program.config.getConfig("aura_color2"));
|
||||
|
||||
pictureColor.BackColor = Aura.Color1;
|
||||
pictureColor2.BackColor = Aura.Color2;
|
||||
}
|
||||
pictureColor2.Visible = Aura.HasSecondColor();
|
||||
|
||||
public void SetAuraMode(int mode = 0, bool apply = true)
|
||||
{
|
||||
|
||||
//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();
|
||||
Aura.ApplyAura();
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
ComboBox cmb = (ComboBox)sender;
|
||||
SetAuraMode(cmb.SelectedIndex);
|
||||
Program.config.setConfig("aura_mode", (int)comboKeyboard.SelectedValue);
|
||||
SetAura();
|
||||
}
|
||||
|
||||
|
||||
private void Button120Hz_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 0);
|
||||
@@ -646,8 +710,7 @@ namespace GHelper
|
||||
|
||||
if (frequency >= 1000)
|
||||
{
|
||||
frequency = Program.config.getConfig("max_frequency");
|
||||
if (frequency <= 60) frequency = 120;
|
||||
frequency = NativeMethods.GetRefreshRate(true);
|
||||
}
|
||||
|
||||
if (frequency > 0)
|
||||
@@ -657,8 +720,12 @@ namespace GHelper
|
||||
}
|
||||
|
||||
if (overdrive >= 0)
|
||||
{
|
||||
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
|
||||
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
|
||||
|
||||
}
|
||||
|
||||
if (miniled >= 0)
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled);
|
||||
@@ -673,11 +740,13 @@ namespace GHelper
|
||||
{
|
||||
|
||||
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 overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
|
||||
|
||||
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
|
||||
|
||||
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
|
||||
|
||||
bool screenEnabled = (frequency >= 0);
|
||||
@@ -703,18 +772,14 @@ namespace GHelper
|
||||
{
|
||||
button60Hz.Activated = true;
|
||||
}
|
||||
else
|
||||
else if (frequency > 60)
|
||||
{
|
||||
if (frequency > 60)
|
||||
maxFrequency = frequency;
|
||||
|
||||
Program.config.setConfig("max_frequency", maxFrequency);
|
||||
button120Hz.Activated = true;
|
||||
}
|
||||
|
||||
if (maxFrequency > 60)
|
||||
{
|
||||
button120Hz.Text = maxFrequency.ToString() + "Hz + OD";
|
||||
button120Hz.Text = maxFrequency.ToString() + "Hz" + (overdriveSetting ? " + OD" : "");
|
||||
}
|
||||
|
||||
if (miniled >= 0)
|
||||
@@ -762,31 +827,12 @@ namespace GHelper
|
||||
SetGPUMode(ASUSWmi.GPUModeEco);
|
||||
}
|
||||
|
||||
private static void SetTimer()
|
||||
{
|
||||
aTimer = new System.Timers.Timer(500);
|
||||
aTimer.Elapsed += OnTimedEvent;
|
||||
aTimer.AutoReset = true;
|
||||
aTimer.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
private static string FormatFan(int fan)
|
||||
{
|
||||
if (fan < 0) return null;
|
||||
|
||||
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()
|
||||
private static void RefreshSensors(bool force = false)
|
||||
{
|
||||
|
||||
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
|
||||
string gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
|
||||
string midFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.Mid_Fan));
|
||||
if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
|
||||
lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
|
||||
string cpuTemp = "";
|
||||
string gpuTemp = "";
|
||||
@@ -807,18 +853,20 @@ namespace GHelper
|
||||
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + cpuFan;
|
||||
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + gpuFan;
|
||||
if (midFan is not null) Program.settingsForm.labelMidFan.Text = "Mid" + midFan;
|
||||
Program.settingsForm.labelCPUFan.Text = "CPU" + cpuTemp + HardwareMonitor.cpuFan;
|
||||
Program.settingsForm.labelGPUFan.Text = "GPU" + gpuTemp + HardwareMonitor.gpuFan;
|
||||
if (HardwareMonitor.midFan is not null)
|
||||
Program.settingsForm.labelMidFan.Text = "Mid" + HardwareMonitor.midFan;
|
||||
|
||||
Program.settingsForm.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)
|
||||
{
|
||||
@@ -830,7 +878,7 @@ namespace GHelper
|
||||
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
||||
this.Activate();
|
||||
|
||||
aTimer.Interval = 300;
|
||||
//aTimer.Interval = 300;
|
||||
aTimer.Enabled = true;
|
||||
|
||||
//RefreshSensors();
|
||||
@@ -874,6 +922,13 @@ namespace GHelper
|
||||
|
||||
if (Program.config.getConfig("mid_fan") == 1)
|
||||
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2));
|
||||
|
||||
labelPerf.Text = "Performance Mode+";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
labelPerf.Text = "Performance Mode";
|
||||
}
|
||||
|
||||
if (Program.config.getConfigPerf("auto_apply_power") == 1)
|
||||
@@ -888,6 +943,10 @@ namespace GHelper
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
if (Program.config.getConfigPerf("auto_boost") != -1)
|
||||
{
|
||||
NativeMethods.SetCPUBoost(Program.config.getConfigPerf("auto_boost"));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
|
||||
@@ -947,6 +1006,7 @@ namespace GHelper
|
||||
{
|
||||
fans.InitFans();
|
||||
fans.InitPower();
|
||||
fans.InitBoost();
|
||||
}
|
||||
|
||||
|
||||
@@ -959,8 +1019,25 @@ namespace GHelper
|
||||
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, 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);
|
||||
if (mode != -1)
|
||||
SetPerformanceMode(mode, true);
|
||||
@@ -969,11 +1046,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);
|
||||
else
|
||||
SetScreen(60, 0);
|
||||
@@ -981,9 +1058,11 @@ 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;
|
||||
if (!GpuAuto) return false;
|
||||
|
||||
@@ -1021,8 +1100,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
tableLayoutKeyboard.ColumnCount = 0;
|
||||
tableLayoutMatrix.ColumnCount = 0;
|
||||
//tableLayoutMatrix.ColumnCount = 0;
|
||||
|
||||
|
||||
}
|
||||
@@ -1033,6 +1111,9 @@ namespace GHelper
|
||||
int eco = Program.wmi.DeviceGet(ASUSWmi.GPUEco);
|
||||
int mux = Program.wmi.DeviceGet(ASUSWmi.GPUMux);
|
||||
|
||||
//Logger.WriteLine("Eco flag : " + eco);
|
||||
//Logger.WriteLine("Mux flag : " + mux);
|
||||
|
||||
int GpuMode;
|
||||
|
||||
if (mux == 0)
|
||||
@@ -1072,7 +1153,7 @@ namespace GHelper
|
||||
|
||||
labelGPU.Text = "GPU Mode: Changing ...";
|
||||
|
||||
new Thread(() =>
|
||||
Thread t = new Thread(() =>
|
||||
{
|
||||
Thread.CurrentThread.IsBackground = true;
|
||||
|
||||
@@ -1084,17 +1165,17 @@ namespace GHelper
|
||||
}
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.GPUEco, eco);
|
||||
Logger.WriteLine("Setting Eco mode: " + eco);
|
||||
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
InitGPUMode();
|
||||
HardwareMonitor.RecreateGpuTemperatureProviderWithRetry();
|
||||
Thread.Sleep(500);
|
||||
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus);
|
||||
InitGPUMode();
|
||||
AutoScreen();
|
||||
});
|
||||
})
|
||||
{
|
||||
});
|
||||
|
||||
}.Start();
|
||||
t.Start();
|
||||
|
||||
}
|
||||
|
||||
@@ -1150,7 +1231,6 @@ namespace GHelper
|
||||
if (changed)
|
||||
{
|
||||
Program.config.setConfig("gpu_mode", GPUMode);
|
||||
HardwareMonitor.RecreateGpuTemperatureProviderWithRetry();
|
||||
}
|
||||
|
||||
if (restart)
|
||||
@@ -1240,21 +1320,16 @@ namespace GHelper
|
||||
|
||||
if (limit < 40 || limit > 100) return;
|
||||
|
||||
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
|
||||
trackBattery.Value = limit;
|
||||
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
|
||||
//Debug.WriteLine(limit);
|
||||
|
||||
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
|
||||
sliderBattery.Value = limit;
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, 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
168
app/Slider.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
debloat.bat
18
debloat.bat
@@ -7,11 +7,13 @@ sc STOP ASUSSystemAnalysis
|
||||
sc STOP ASUSSystemDiagnosis
|
||||
sc STOP ArmouryCrateControlInterface
|
||||
|
||||
sc DELETE AsusAppService
|
||||
sc DELETE ASUSLinkNear
|
||||
sc DELETE ASUSLinkRemote
|
||||
sc DELETE ASUSSoftwareManager
|
||||
sc DELETE ASUSSwitch
|
||||
sc DELETE ASUSSystemAnalysis
|
||||
sc DELETE ASUSSystemDiagnosis
|
||||
sc DELETE ArmouryCrateControlInterface
|
||||
sc config AsusAppService start= disabled
|
||||
sc config ASUSLinkNear start= disabled
|
||||
sc config ASUSLinkRemote start= disabled
|
||||
sc config ASUSSoftwareManager start= disabled
|
||||
sc config ASUSSwitch start= disabled
|
||||
sc config ASUSSystemAnalysis start= disabled
|
||||
sc config ASUSSystemDiagnosis start= disabled
|
||||
sc config ArmouryCrateControlInterface start= disabled
|
||||
|
||||
set /p asd="Hit enter to finish"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# [G-Helper (GHelper)](https://github.com/seerge/g-helper)
|
||||
# [G-Helper](https://github.com/seerge/g-helper)
|
||||
|
||||
[](https://GitHub.com/seerge/g-helper/releases/) [](https://GitHub.com/seerge/g-helper/releases/) [](https://GitHub.com/seerge/g-helper/stargazers/)
|
||||
[](https://GitHub.com/seerge/g-helper/releases/) [](https://GitHub.com/seerge/g-helper/releases/) [](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
|
||||
## Open source Armoury Crate alternative for Asus laptops such as ROG Zephyrus G14, G15, Flow X13, Flow X16, TUF 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.
|
||||
|
||||
@@ -11,12 +11,15 @@ A small utility that allows you to do almost everything you could do with Armour
|
||||
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)
|
||||
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
|
||||
|
||||
### [:floppy_disk: Download latest release](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 post about app - please include a link. Thanks.
|
||||
|
||||

|
||||
|
||||
### :zap: Main features
|
||||
|
||||
@@ -44,6 +47,8 @@ To keep auto switching and hotkeys working the app needs to stay in running in t
|
||||
|
||||
Modes are **same** as in Armory 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
|
||||
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
|
||||
@@ -55,19 +60,38 @@ PPTs are shown for G14 2022, for other models PPTs will be different as they are
|
||||
1. Eco mode : only low power integrated GPU 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)
|
||||
4. Optimized (formely existed as a checkbox): disables dGPU on battery (Eco) and enables when plugged (Standard)
|
||||
4. Optimized (formerly existed as a checkbox): 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?
|
||||
Go to BIOS (F2 on boot), open Advanced Settings and disable "Armory Control Intrerface"
|
||||
### How do I stop Armory Crate install popup appearing every time I press M4 / Rog key?
|
||||
Go to BIOS (F2 on boot), open Advanced Settings and disable "Armory Control Interface".
|
||||
If it still appears - delete or move somwhere following file ``C:\Windows\System32\ASUSACCI\ArmouryCrateKeyControl.exe``
|
||||
|
||||
#### Why Ultimate GPU mode is not available on my laptop?
|
||||
### Why Ultimate GPU mode is not available on my laptop?
|
||||
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 sooon as you click Apply in fan + power section bios will be considering 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 dGPU into sleep (to preserve power). In this situations G-helper won't be able to reach your GPU and get readings
|
||||
|
||||
### 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.
|
||||
|
||||
### 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
|
||||
@@ -82,7 +106,7 @@ Open "Event Viewer" from start menu, go to Windows Logs -> Application and check
|
||||
|
||||
- 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.
|
||||
|
||||
- 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.
|
||||
- It's not recommended to use an app in combination with Armoury 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.
|
||||
|
||||
Note: Doesn't need administrator privileges to run!
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 1.3 MiB |
Reference in New Issue
Block a user