Compare commits

...

17 Commits
v0.39 ... v0.42

Author SHA1 Message Date
seerge
8af8823ee4 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-29 12:19:02 +02:00
seerge
ec0a1b710e New slider 2023-03-29 12:19:00 +02:00
Serge
2ac2e84161 Update README.md 2023-03-28 22:09:06 +02:00
seerge
14dc1741f7 New battery slider 2023-03-28 20:11:30 +02:00
seerge
fbed195194 - 2023-03-28 16:35:20 +02:00
seerge
0d002edf65 Animatrix fix for 2020/2021 models 2023-03-28 16:05:24 +02:00
seerge
28a17562a8 CPU boost per mode 2023-03-28 14:19:51 +02:00
seerge
583cb677d0 Added option to disable screen overdrive 2023-03-27 15:21:52 +02:00
seerge
1888fe7bd9 Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-27 14:28:31 +02:00
seerge
089b339e61 Minor tweaks 2023-03-27 14:28:28 +02:00
Serge
cab4a04339 Update README.md 2023-03-27 13:02:14 +02:00
seerge
7ab3b450cd Merge branch 'main' of https://github.com/seerge/g-helper 2023-03-26 19:31:43 +02:00
seerge
ea2dc7b75d Animatrix tweaks 2023-03-26 19:31:41 +02:00
Serge
ccd69a8628 Update README.md 2023-03-26 14:40:12 +02:00
Serge
c1d23159a0 Update debloat.bat 2023-03-26 14:17:53 +02:00
Serge
1c865624e6 Update debloat.bat 2023-03-26 14:06:13 +02:00
seerge
4853c09c2c Added model name, and custom fan+ in profile names 2023-03-25 20:28:27 +01:00
17 changed files with 608 additions and 242 deletions

View File

@@ -1,6 +1,4 @@
using GHelper; using System.Management;
using System.Diagnostics;
using System.Management;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
public class ASUSWmi public class ASUSWmi
@@ -12,6 +10,10 @@ public class ASUSWmi
const uint DSTS = 0x53545344; const uint DSTS = 0x53545344;
const uint DEVS = 0x53564544; const uint DEVS = 0x53564544;
public const uint UniversalControl = 0x00100021;
public const int KB_Light_Up = 0xc4;
public const int KB_Light_Down = 0xc5;
public const uint CPU_Fan = 0x00110013; public const uint CPU_Fan = 0x00110013;
public const uint GPU_Fan = 0x00110014; public const uint GPU_Fan = 0x00110014;
public const uint Mid_Fan = 0x00110031; public const uint Mid_Fan = 0x00110031;
@@ -253,28 +255,22 @@ public class ASUSWmi
} }
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) public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{ {
uint flags; int state = 0xbd;
uint cmd = 1;
flags = 0; if (boot) state = state | ASUS_WMI_KEYBOARD_POWER_BOOT;
if (boot) if (awake) state = state | ASUS_WMI_KEYBOARD_POWER_AWAKE;
flags |= (1 << 1); if (sleep) state = state | ASUS_WMI_KEYBOARD_POWER_SLEEP;
if (awake) if (shutdown) state = state | ASUS_WMI_KEYBOARD_POWER_SHUTDOWN;
flags |= (1 << 3);
if (sleep)
flags |= (1 << 5);
if (shutdown)
flags |= (1 << 7);
byte[] state = new byte[12]; state = state | 0x01 << 8;
state[0] = 0xbd;
state[1] = (byte)((cmd != 0) ? (1 << 2) : 0);
state[2] = (byte)flags;
DeviceSet(TUF_KB, state); DeviceSet(TUF_KB_STATE, state);
Debug.WriteLine(BitConverter.ToString(state));
} }
public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler) public void SubscribeToEvents(Action<object, EventArrivedEventArgs> EventHandler)

View File

@@ -2,7 +2,7 @@
using Starlight.Communication; using Starlight.Communication;
using System.Management; using System.Management;
using System.Runtime.CompilerServices; using System.Drawing.Drawing2D;
using System.Text; using System.Text;
namespace Starlight.AnimeMatrix namespace Starlight.AnimeMatrix
@@ -86,6 +86,7 @@ namespace Starlight.AnimeMatrix
//public int FullRows = 11; //public int FullRows = 11;
//public int FullEvenRows = -1; //public int FullEvenRows = -1;
public int dx = 0;
public int MaxColumns = 34; public int MaxColumns = 34;
private int frameIndex = 0; private int frameIndex = 0;
@@ -102,12 +103,14 @@ namespace Starlight.AnimeMatrix
_model = AnimeType.GA401; _model = AnimeType.GA401;
MaxColumns = 33; MaxColumns = 33;
dx = 1;
//FullRows = 7; //FullRows = 7;
//FullEvenRows = 3; //FullEvenRows = 3;
MaxRows = 55; MaxRows = 55;
LedCount = 1214; LedCount = 1245;
UpdatePageLength = 410; UpdatePageLength = 410;
} }
@@ -176,7 +179,8 @@ namespace Starlight.AnimeMatrix
if (y < 11) if (y < 11)
{ {
return 0; return 0;
} else }
else
{ {
return (y) / 2 - 5; return (y) / 2 - 5;
} }
@@ -211,7 +215,7 @@ namespace Starlight.AnimeMatrix
return 33; return 33;
case 1: case 1:
case 3: case 3:
return 35; // Some rows are padded return 35;
default: default:
return 36 - y / 2; return 36 - y / 2;
} }
@@ -257,7 +261,8 @@ namespace Starlight.AnimeMatrix
if (x >= FirstX(y) && x < Width(y)) if (x >= FirstX(y) && x < Width(y))
{ {
SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x, value); SetLedLinear(RowToLinearAddress(y) - FirstX(y) + x + dx, value);
//Debug.Write((RowToLinearAddress(y) - FirstX(y) + x + dx).ToString() + " ");
} }
} }
@@ -355,74 +360,75 @@ namespace Starlight.AnimeMatrix
public void PresentText(string text, float fontSize = 8F) public void PresentText(string text1, string text2 = "")
{ {
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows)) using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
{ {
using (Graphics g = Graphics.FromImage(bmp)) using (Graphics g = Graphics.FromImage(bmp))
{ {
using (Font font = new Font("Arial", fontSize)) g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
using (Font font = new Font("Arial", 12F))
{ {
SizeF textSize = g.MeasureString(text1, font);
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; g.DrawString(text1, font, Brushes.White, (MaxColumns*3 - textSize.Width)+3, -5);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
/*
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.DrawString(text, font, Brushes.White, 12, -2);
} }
if (text2.Length > 0)
using (Font font = new Font("Arial", 9F))
{
SizeF textSize = g.MeasureString(text2, font);
g.DrawString(text2, font, Brushes.White, (MaxColumns * 3 - textSize.Width)+1, 25);
}
} }
GenerateFrame(bmp); GenerateFrame(bmp, InterpolationMode.Bicubic);
Present(); 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 height = MaxRows;
int targetWidth = MaxColumns * 2;
float scale; float scale;
using (Bitmap canvas = new Bitmap(width, height)) using (Bitmap bmp = new Bitmap(targetWidth, height))
{ {
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height); scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
using (var graph = Graphics.FromImage(canvas)) using (var graph = Graphics.FromImage(bmp))
{ {
var scaleWidth = (int)(image.Width * scale); var scaleWidth = (float)(image.Width * scale);
var scaleHeight = (int)(image.Height * scale); var scaleHeight = (float)(image.Height * scale);
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; graph.InterpolationMode = interpolation;
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; graph.CompositingQuality = CompositingQuality.HighQuality;
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; graph.SmoothingMode = SmoothingMode.AntiAlias;
graph.DrawImage(image, ((int)width - scaleWidth), 0, scaleWidth, scaleHeight); graph.DrawImage(image, (float)Math.Round(targetWidth - scaleWidth * targetWidth / width), 0, (float)Math.Round(scaleWidth * targetWidth / width), scaleHeight);
} }
using (Bitmap bmp = new Bitmap(canvas, MaxColumns * 2, MaxRows)) for (int y = 0; y < bmp.Height; y++)
{ {
for (int y = 0; y < bmp.Height; y++) for (int x = 0; x < bmp.Width; x++)
{ if (x % 2 == (y+dx) % 2)
for (int x = 0; x < bmp.Width; x++) {
if (x % 2 == y % 2) var pixel = bmp.GetPixel(x, y);
{ var color = (pixel.R + pixel.G + pixel.B) / 3;
var pixel = bmp.GetPixel(x, y); if (color < 10) color = 0;
SetLedPlanar(x / 2, y, (byte)((pixel.R + pixel.G + pixel.B) / 3)); SetLedPlanar(x / 2, y, (byte)color);
} }
}
} }
} }
} }
private void EnsureRowInRange(int row) private void EnsureRowInRange(int row)

View File

@@ -40,8 +40,7 @@ public class AppConfig
} }
public string GetModel()
public bool ContainsModel(string contains)
{ {
if (_model is null) if (_model is null)
{ {
@@ -56,6 +55,12 @@ public class AppConfig
} }
} }
return _model;
}
public bool ContainsModel(string contains)
{
GetModel();
return (_model is not null && _model.Contains(contains)); return (_model is not null && _model.Contains(contains));
} }

View File

@@ -1,7 +1,5 @@
using HidLibrary; using HidLibrary;
using Microsoft.VisualBasic.ApplicationServices;
using System.Diagnostics; using System.Diagnostics;
using static Starlight.AnimeMatrix.BuiltInAnimation;
namespace GHelper namespace GHelper
{ {
@@ -36,7 +34,7 @@ namespace GHelper
{ {
a |= (uint)n; a |= (uint)n;
} }
return new byte[] {0x5d, 0xbd, 0x01, (byte)(a & 0xff), (byte)((a & 0xff00) >> 8), (byte)((a & 0xff0000) >> 16) }; 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) public static ushort BitOr(this AuraDev19b6 self, AuraDev19b6 rhs)
@@ -56,6 +54,7 @@ namespace GHelper
static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 }; static byte[] MESSAGE_SET = { 0x5d, 0xb5, 0, 0, 0 };
static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 }; static byte[] MESSAGE_APPLY = { 0x5d, 0xb4 };
static int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
private static int mode = 0; private static int mode = 0;
private static int speed = 1; private static int speed = 1;
@@ -145,6 +144,22 @@ namespace GHelper
} }
public static void ApplyBrightness(int brightness)
{
HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
byte[] msg = { 0x5a, 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) public static void ApplyAuraPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
{ {
@@ -176,10 +191,7 @@ namespace GHelper
public static void ApplyAura() public static void ApplyAura()
{ {
HidDevice[] HidDeviceList; HidDevice[] HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
int[] deviceIds = { 0x1854, 0x1869, 0x1866, 0x19b6, 0x1822, 0x1837, 0x1854, 0x184a, 0x183d, 0x8502, 0x1807, 0x17e0 };
HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
int _speed; int _speed;

View File

@@ -1,4 +1,5 @@
using CustomControls; using CustomControls;
using WinFormsSliderBar;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Windows.Forms.DataVisualization.Charting; using System.Windows.Forms.DataVisualization.Charting;
@@ -38,7 +39,7 @@ public static class ControlHelper
foreMain = SystemColors.ControlText; foreMain = SystemColors.ControlText;
foreAccent = Color.LightGray; foreAccent = Color.LightGray;
borderMain = Color.LightGray; borderMain = Color.LightGray;
buttonMain = Color.FromArgb(255, 230, 230, 230); buttonMain = Color.FromArgb(255, 250, 250, 250);
} }
container.BackColor = formBack; container.BackColor = formBack;
@@ -53,7 +54,7 @@ public static class ControlHelper
public static void Resize(RForm container, float baseScale = 2) public static void Resize(RForm container, float baseScale = 2)
{ {
_scale = GetDpiScale(container).Value / baseScale; _scale = GetDpiScale(container).Value / baseScale;
ResizeControls(container.Controls); if (Math.Abs(_scale - 1) > 0.2) ResizeControls(container.Controls);
} }
@@ -65,9 +66,11 @@ public static class ControlHelper
if (button != null && button.Image is not null) if (button != null && button.Image is not null)
button.Image = ResizeImage(button.Image); button.Image = ResizeImage(button.Image);
/*
var pictureBox = control as PictureBox; var pictureBox = control as PictureBox;
if (pictureBox != null && pictureBox.BackgroundImage is not null) if (pictureBox != null && pictureBox.BackgroundImage is not null)
pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage); pictureBox.BackgroundImage = ResizeImage(pictureBox.BackgroundImage);
*/
ResizeControls(control.Controls); ResizeControls(control.Controls);
} }
@@ -111,6 +114,11 @@ public static class ControlHelper
gb.ForeColor = foreMain; gb.ForeColor = foreMain;
} }
var sl = control as Slider;
if (sl != null)
{
sl.borderColor = buttonMain;
}
var chart = control as Chart; var chart = control as Chart;
if (chart != null) if (chart != null)

View File

@@ -1,5 +1,6 @@
using Microsoft.Win32; using Microsoft.Win32;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
@@ -30,9 +31,9 @@ namespace CustomControls
return (int)registryValueObject <= 0; return (int)registryValueObject <= 0;
} }
public void InitTheme(bool setDPI = true) public bool InitTheme(bool setDPI = false)
{ {
bool newDarkTheme = IsDarkTheme(); bool newDarkTheme = CheckSystemDarkModeStatus();
bool changed = (darkTheme != newDarkTheme); bool changed = (darkTheme != newDarkTheme);
darkTheme = newDarkTheme; darkTheme = newDarkTheme;
@@ -45,16 +46,13 @@ namespace CustomControls
ControlHelper.Adjust(this, darkTheme, changed); ControlHelper.Adjust(this, darkTheme, changed);
} }
return changed;
} }
} }
public class RTrackBar : TrackBar
{
}
public class RComboBox : ComboBox public class RComboBox : ComboBox
{ {
private Color borderColor = Color.Gray; private Color borderColor = Color.Gray;
@@ -71,6 +69,8 @@ namespace CustomControls
} }
} }
} }
private Color buttonColor = Color.FromArgb(255,230, 230, 230); private Color buttonColor = Color.FromArgb(255,230, 230, 230);
[DefaultValue(typeof(Color), "230, 230, 230")] [DefaultValue(typeof(Color), "230, 230, 230")]
public Color ButtonColor public Color ButtonColor

View File

@@ -146,7 +146,7 @@ namespace GHelper
InitPower(); InitPower();
InitBoost(); InitBoost();
comboBoost.SelectedIndexChanged += ComboBoost_Changed; comboBoost.SelectedValueChanged += ComboBoost_Changed;
Shown += Fans_Shown; Shown += Fans_Shown;
@@ -162,9 +162,11 @@ namespace GHelper
private void ComboBoost_Changed(object? sender, EventArgs e) private void ComboBoost_Changed(object? sender, EventArgs e)
{ {
if (sender is null) return; if (Program.config.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
ComboBox cmb = (ComboBox)sender; {
NativeMethods.SetCPUBoost(cmb.SelectedIndex); NativeMethods.SetCPUBoost(comboBoost.SelectedIndex);
Program.config.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
}
} }
private void CheckApplyPower_Click(object? sender, EventArgs e) private void CheckApplyPower_Click(object? sender, EventArgs e)

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.39</AssemblyVersion> <AssemblyVersion>0.42</AssemblyVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

163
app/Keyboard.Designer.cs generated
View File

@@ -41,14 +41,19 @@ namespace GHelper
comboM3 = new RComboBox(); comboM3 = new RComboBox();
labelM3 = new Label(); labelM3 = new Label();
groupLight = new GroupBox(); groupLight = new GroupBox();
checkAwake = new CheckBox();
checkBoot = new CheckBox();
checkSleep = new CheckBox();
checkShutdown = new CheckBox();
comboKeyboardSpeed = new RComboBox();
labelSpeed = new Label(); 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(); groupBox1.SuspendLayout();
groupLight.SuspendLayout(); groupLight.SuspendLayout();
groupOther.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// groupBox1 // groupBox1
@@ -65,7 +70,7 @@ namespace GHelper
groupBox1.Dock = DockStyle.Top; groupBox1.Dock = DockStyle.Top;
groupBox1.Location = new Point(10, 10); groupBox1.Location = new Point(10, 10);
groupBox1.Name = "groupBox1"; groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(751, 242); groupBox1.Size = new Size(756, 242);
groupBox1.TabIndex = 0; groupBox1.TabIndex = 0;
groupBox1.TabStop = false; groupBox1.TabStop = false;
groupBox1.Text = "Key Bindings"; groupBox1.Text = "Key Bindings";
@@ -158,50 +163,19 @@ namespace GHelper
groupLight.Dock = DockStyle.Top; groupLight.Dock = DockStyle.Top;
groupLight.Location = new Point(10, 252); groupLight.Location = new Point(10, 252);
groupLight.Name = "groupLight"; groupLight.Name = "groupLight";
groupLight.Size = new Size(751, 304); groupLight.Size = new Size(756, 304);
groupLight.TabIndex = 1; groupLight.TabIndex = 1;
groupLight.TabStop = false; groupLight.TabStop = false;
groupLight.Text = "Keyboard Backlight"; groupLight.Text = "Keyboard Backlight";
// //
// checkAwake // labelSpeed
// //
checkAwake.AutoSize = true; labelSpeed.AutoSize = true;
checkAwake.Location = new Point(25, 59); labelSpeed.Location = new Point(25, 237);
checkAwake.Name = "checkAwake"; labelSpeed.Name = "labelSpeed";
checkAwake.Size = new Size(115, 36); labelSpeed.Size = new Size(198, 32);
checkAwake.TabIndex = 0; labelSpeed.TabIndex = 40;
checkAwake.Text = "Awake"; labelSpeed.Text = "Animation Speed";
checkAwake.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;
//
// 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;
//
// 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;
// //
// comboKeyboardSpeed // comboKeyboardSpeed
// //
@@ -219,20 +193,95 @@ namespace GHelper
comboKeyboardSpeed.TabIndex = 39; comboKeyboardSpeed.TabIndex = 39;
comboKeyboardSpeed.TabStop = false; comboKeyboardSpeed.TabStop = false;
// //
// labelSpeed // checkShutdown
// //
labelSpeed.AutoSize = true; checkShutdown.AutoSize = true;
labelSpeed.Location = new Point(25, 237); checkShutdown.Location = new Point(25, 185);
labelSpeed.Name = "labelSpeed"; checkShutdown.Name = "checkShutdown";
labelSpeed.Size = new Size(198, 32); checkShutdown.Size = new Size(154, 36);
labelSpeed.TabIndex = 40; checkShutdown.TabIndex = 3;
labelSpeed.Text = "Animation Speed"; checkShutdown.Text = "Shutdown";
checkShutdown.UseVisualStyleBackColor = true;
//
// checkSleep
//
checkSleep.AutoSize = true;
checkSleep.Location = new Point(25, 143);
checkSleep.Name = "checkSleep";
checkSleep.Size = new Size(105, 36);
checkSleep.TabIndex = 2;
checkSleep.Text = "Sleep";
checkSleep.UseVisualStyleBackColor = true;
//
// checkBoot
//
checkBoot.AutoSize = true;
checkBoot.Location = new Point(25, 101);
checkBoot.Name = "checkBoot";
checkBoot.Size = new Size(96, 36);
checkBoot.TabIndex = 1;
checkBoot.Text = "Boot";
checkBoot.UseVisualStyleBackColor = true;
//
// checkAwake
//
checkAwake.AutoSize = true;
checkAwake.Location = new Point(25, 59);
checkAwake.Name = "checkAwake";
checkAwake.Size = new Size(115, 36);
checkAwake.TabIndex = 0;
checkAwake.Text = "Awake";
checkAwake.UseVisualStyleBackColor = true;
//
// groupOther
//
groupOther.Controls.Add(checkNoOverdrive);
groupOther.Controls.Add(checkKeyboardAuto);
groupOther.Controls.Add(checkTopmost);
groupOther.Dock = DockStyle.Top;
groupOther.Location = new Point(10, 556);
groupOther.Name = "groupOther";
groupOther.Size = new Size(756, 225);
groupOther.TabIndex = 2;
groupOther.TabStop = false;
groupOther.Text = "Other";
//
// checkKeyboardAuto
//
checkKeyboardAuto.AutoSize = true;
checkKeyboardAuto.Location = new Point(25, 51);
checkKeyboardAuto.Name = "checkKeyboardAuto";
checkKeyboardAuto.Size = new Size(712, 36);
checkKeyboardAuto.TabIndex = 2;
checkKeyboardAuto.Text = "Lower backlight brightness on battery and back when plugged";
checkKeyboardAuto.UseVisualStyleBackColor = true;
//
// checkTopmost
//
checkTopmost.AutoSize = true;
checkTopmost.Location = new Point(25, 104);
checkTopmost.Name = "checkTopmost";
checkTopmost.Size = new Size(390, 36);
checkTopmost.TabIndex = 1;
checkTopmost.Text = "Keep app window always on top";
checkTopmost.UseVisualStyleBackColor = true;
//
// checkNoOverdrive
//
checkNoOverdrive.AutoSize = true;
checkNoOverdrive.Location = new Point(25, 156);
checkNoOverdrive.Name = "checkNoOverdrive";
checkNoOverdrive.Size = new Size(307, 36);
checkNoOverdrive.TabIndex = 3;
checkNoOverdrive.Text = "Disable screen overdrive";
checkNoOverdrive.UseVisualStyleBackColor = true;
// //
// Keyboard // Keyboard
// //
AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(771, 858); ClientSize = new Size(776, 858);
Controls.Add(groupOther);
Controls.Add(groupLight); Controls.Add(groupLight);
Controls.Add(groupBox1); Controls.Add(groupBox1);
FormBorderStyle = FormBorderStyle.FixedSingle; FormBorderStyle = FormBorderStyle.FixedSingle;
@@ -243,11 +292,13 @@ namespace GHelper
Padding = new Padding(10); Padding = new Padding(10);
ShowIcon = false; ShowIcon = false;
ShowInTaskbar = false; ShowInTaskbar = false;
Text = "Keyboard"; Text = "Extra Settings";
groupBox1.ResumeLayout(false); groupBox1.ResumeLayout(false);
groupBox1.PerformLayout(); groupBox1.PerformLayout();
groupLight.ResumeLayout(false); groupLight.ResumeLayout(false);
groupLight.PerformLayout(); groupLight.PerformLayout();
groupOther.ResumeLayout(false);
groupOther.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
} }
@@ -270,5 +321,9 @@ namespace GHelper
private CheckBox checkShutdown; private CheckBox checkShutdown;
private Label labelSpeed; private Label labelSpeed;
private RComboBox comboKeyboardSpeed; private RComboBox comboKeyboardSpeed;
private GroupBox groupOther;
private CheckBox checkTopmost;
private CheckBox checkKeyboardAuto;
private CheckBox checkNoOverdrive;
} }
} }

View File

@@ -78,8 +78,33 @@ namespace GHelper
checkSleep.CheckedChanged += CheckPower_CheckedChanged; checkSleep.CheckedChanged += CheckPower_CheckedChanged;
checkShutdown.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) private void CheckPower_CheckedChanged(object? sender, EventArgs e)
{ {

View File

@@ -1,6 +1,8 @@
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Xml.Linq;
using static Tools.ScreenInterrogatory; using static Tools.ScreenInterrogatory;
namespace Tools namespace Tools
@@ -588,7 +590,7 @@ public class NativeMethods
return laptopScreen; return laptopScreen;
} }
public static int GetRefreshRate() public static int GetRefreshRate(bool max = false)
{ {
DEVMODE dm = CreateDevmode(); DEVMODE dm = CreateDevmode();
@@ -598,11 +600,23 @@ public class NativeMethods
if (laptopScreen is null) if (laptopScreen is null)
return -1; return -1;
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm)) if (max)
{ {
frequency = dm.dmDisplayFrequency; int i = 0;
while (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, i, ref dm))
{
if (dm.dmDisplayFrequency > frequency) frequency = dm.dmDisplayFrequency;
i++;
}
} else
{
if (0 != NativeMethods.EnumDisplaySettingsEx(laptopScreen, NativeMethods.ENUM_CURRENT_SETTINGS, ref dm))
{
frequency = dm.dmDisplayFrequency;
}
} }
return frequency; return frequency;
} }
@@ -671,6 +685,7 @@ public class NativeMethods
PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid); PowerSetActiveScheme(IntPtr.Zero, activeSchemeGuid);
*/ */
Logger.WriteLine("Boost " + boost);
} }
public static void SetPowerScheme(int mode) public static void SetPowerScheme(int mode)

View File

@@ -1,8 +1,6 @@
using Microsoft.Win32; using Microsoft.Win32;
using System.Diagnostics; using System.Diagnostics;
using System.Management; using System.Management;
using System.Reflection;
using System.Text.Json;
namespace GHelper namespace GHelper
{ {
@@ -32,6 +30,15 @@ namespace GHelper
// The main entry point for the application // The main entry point for the application
public static void Main() public static void Main()
{ {
if (Process.GetProcesses().Count(p => p.ProcessName == "GHelper") > 1)
{
MessageBox.Show("G-Helper is already running. Check system tray for an icon.", "App already running", MessageBoxButtons.OK);
Application.Exit();
return;
}
try try
{ {
wmi = new ASUSWmi(); wmi = new ASUSWmi();
@@ -52,8 +59,7 @@ namespace GHelper
Application.EnableVisualStyles(); Application.EnableVisualStyles();
SystemEvents.UserPreferenceChanged += new SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);
var ds = settingsForm.Handle; var ds = settingsForm.Handle;
@@ -97,13 +103,13 @@ namespace GHelper
case UserPreferenceCategory.General: case UserPreferenceCategory.General:
Debug.WriteLine("Theme Changed"); Debug.WriteLine("Theme Changed");
Thread.Sleep(1000); Thread.Sleep(1000);
settingsForm.InitTheme(false); settingsForm.InitTheme();
if (settingsForm.fans is not null && settingsForm.fans.Text != "") if (settingsForm.fans is not null && settingsForm.fans.Text != "")
settingsForm.fans.InitTheme(false); settingsForm.fans.InitTheme();
if (settingsForm.keyb is not null && settingsForm.keyb.Text != "") if (settingsForm.keyb is not null && settingsForm.keyb.Text != "")
settingsForm.keyb.InitTheme(false); settingsForm.keyb.InitTheme();
break; break;
} }
@@ -111,27 +117,22 @@ namespace GHelper
public static void SetAutoModes(bool wait = false) public static void SetAutoModes()
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return; if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 2000) return;
lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds(); lastAuto = DateTimeOffset.Now.ToUnixTimeMilliseconds();
isPlugged = SystemInformation.PowerStatus.PowerLineStatus; isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
Logger.WriteLine("AutoSetting for " + isPlugged.ToString()); Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit")); settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
settingsForm.AutoPerformance();
settingsForm.AutoPerformance(isPlugged); bool switched = settingsForm.AutoGPUMode();
if (!switched) settingsForm.AutoScreen();
// waiting a bit before turning off dGPU settingsForm.SetMatrix();
// if (wait && isPlugged != PowerLineStatus.Online) Thread.Sleep(3000);
bool switched = settingsForm.AutoGPUMode(isPlugged);
if (!switched) settingsForm.AutoScreen(isPlugged);
settingsForm.SetMatrix(isPlugged);
} }
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e) private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
@@ -139,7 +140,8 @@ namespace GHelper
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return; if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
Logger.WriteLine("Windows - Power Mode Changed"); Logger.WriteLine("Windows - Power Mode Changed");
SetAutoModes(true); settingsForm.AutoKeyboard();
SetAutoModes();
} }

View File

@@ -40,11 +40,12 @@ namespace GHelper
pictureMatrix = new PictureBox(); pictureMatrix = new PictureBox();
labelMatrix = new Label(); labelMatrix = new Label();
panelBattery = new Panel(); panelBattery = new Panel();
sliderBattery = new WinFormsSliderBar.Slider();
labelModel = new Label();
labelVersion = new Label(); labelVersion = new Label();
labelBattery = new Label(); labelBattery = new Label();
pictureBattery = new PictureBox(); pictureBattery = new PictureBox();
labelBatteryTitle = new Label(); labelBatteryTitle = new Label();
trackBattery = new TrackBar();
panelFooter = new Panel(); panelFooter = new Panel();
buttonQuit = new RButton(); buttonQuit = new RButton();
checkStartup = new CheckBox(); checkStartup = new CheckBox();
@@ -92,7 +93,6 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
panelBattery.SuspendLayout(); panelBattery.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit();
((System.ComponentModel.ISupportInitialize)trackBattery).BeginInit();
panelFooter.SuspendLayout(); panelFooter.SuspendLayout();
panelPerformance.SuspendLayout(); panelPerformance.SuspendLayout();
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit(); ((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
@@ -236,25 +236,49 @@ namespace GHelper
// //
panelBattery.AutoSize = true; panelBattery.AutoSize = true;
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink; panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
panelBattery.Controls.Add(sliderBattery);
panelBattery.Controls.Add(labelModel);
panelBattery.Controls.Add(labelVersion); panelBattery.Controls.Add(labelVersion);
panelBattery.Controls.Add(labelBattery); panelBattery.Controls.Add(labelBattery);
panelBattery.Controls.Add(pictureBattery); panelBattery.Controls.Add(pictureBattery);
panelBattery.Controls.Add(labelBatteryTitle); panelBattery.Controls.Add(labelBatteryTitle);
panelBattery.Controls.Add(trackBattery);
panelBattery.Dock = DockStyle.Top; panelBattery.Dock = DockStyle.Top;
panelBattery.Location = new Point(10, 926); panelBattery.Location = new Point(10, 926);
panelBattery.Margin = new Padding(8); panelBattery.Margin = new Padding(8);
panelBattery.Name = "panelBattery"; panelBattery.Name = "panelBattery";
panelBattery.Padding = new Padding(0, 0, 0, 12); panelBattery.Padding = new Padding(0, 0, 0, 12);
panelBattery.Size = new Size(810, 158); panelBattery.Size = new Size(810, 163);
panelBattery.TabIndex = 34; panelBattery.TabIndex = 34;
// //
// sliderBattery
//
sliderBattery.Location = new Point(16, 70);
sliderBattery.Max = 100;
sliderBattery.Min = 50;
sliderBattery.Name = "sliderBattery";
sliderBattery.Size = new Size(772, 40);
sliderBattery.TabIndex = 39;
sliderBattery.Text = "sliderBattery";
sliderBattery.Value = 80;
//
// labelModel
//
labelModel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelModel.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
labelModel.ForeColor = SystemColors.ControlDark;
labelModel.Location = new Point(291, 119);
labelModel.Margin = new Padding(8, 0, 8, 0);
labelModel.Name = "labelModel";
labelModel.Size = new Size(492, 32);
labelModel.TabIndex = 38;
labelModel.TextAlign = ContentAlignment.TopRight;
//
// labelVersion // labelVersion
// //
labelVersion.AutoSize = true; labelVersion.AutoSize = true;
labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point); labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point);
labelVersion.ForeColor = SystemColors.ControlDark; labelVersion.ForeColor = SystemColors.ControlDark;
labelVersion.Location = new Point(25, 109); labelVersion.Location = new Point(25, 119);
labelVersion.Margin = new Padding(8, 0, 8, 0); labelVersion.Margin = new Padding(8, 0, 8, 0);
labelVersion.Name = "labelVersion"; labelVersion.Name = "labelVersion";
labelVersion.Size = new Size(44, 32); labelVersion.Size = new Size(44, 32);
@@ -293,22 +317,6 @@ namespace GHelper
labelBatteryTitle.TabIndex = 34; labelBatteryTitle.TabIndex = 34;
labelBatteryTitle.Text = "Battery Charge Limit"; labelBatteryTitle.Text = "Battery Charge Limit";
// //
// trackBattery
//
trackBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
trackBattery.LargeChange = 10;
trackBattery.Location = new Point(20, 52);
trackBattery.Margin = new Padding(8, 4, 8, 4);
trackBattery.Maximum = 100;
trackBattery.Minimum = 50;
trackBattery.Name = "trackBattery";
trackBattery.Size = new Size(766, 90);
trackBattery.SmallChange = 5;
trackBattery.TabIndex = 33;
trackBattery.TickFrequency = 10;
trackBattery.TickStyle = TickStyle.TopLeft;
trackBattery.Value = 100;
//
// panelFooter // panelFooter
// //
panelFooter.AutoSize = true; panelFooter.AutoSize = true;
@@ -316,7 +324,7 @@ namespace GHelper
panelFooter.Controls.Add(buttonQuit); panelFooter.Controls.Add(buttonQuit);
panelFooter.Controls.Add(checkStartup); panelFooter.Controls.Add(checkStartup);
panelFooter.Dock = DockStyle.Top; panelFooter.Dock = DockStyle.Top;
panelFooter.Location = new Point(10, 1084); panelFooter.Location = new Point(10, 1089);
panelFooter.Margin = new Padding(8); panelFooter.Margin = new Padding(8);
panelFooter.Name = "panelFooter"; panelFooter.Name = "panelFooter";
panelFooter.Padding = new Padding(0, 0, 0, 10); panelFooter.Padding = new Padding(0, 0, 0, 10);
@@ -1019,7 +1027,6 @@ namespace GHelper
panelBattery.ResumeLayout(false); panelBattery.ResumeLayout(false);
panelBattery.PerformLayout(); panelBattery.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBattery).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBattery).EndInit();
((System.ComponentModel.ISupportInitialize)trackBattery).EndInit();
panelFooter.ResumeLayout(false); panelFooter.ResumeLayout(false);
panelFooter.PerformLayout(); panelFooter.PerformLayout();
panelPerformance.ResumeLayout(false); panelPerformance.ResumeLayout(false);
@@ -1055,7 +1062,6 @@ namespace GHelper
private Label labelBattery; private Label labelBattery;
private PictureBox pictureBattery; private PictureBox pictureBattery;
private Label labelBatteryTitle; private Label labelBatteryTitle;
private TrackBar trackBattery;
private Panel panelFooter; private Panel panelFooter;
private RButton buttonQuit; private RButton buttonQuit;
private CheckBox checkStartup; private CheckBox checkStartup;
@@ -1103,5 +1109,7 @@ namespace GHelper
private RButton buttonKeyboardColor; private RButton buttonKeyboardColor;
private RButton buttonFans; private RButton buttonFans;
private Label labelMidFan; private Label labelMidFan;
private Label labelModel;
private WinFormsSliderBar.Slider sliderBattery;
} }
} }

View File

@@ -2,6 +2,7 @@
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Text.Json; using System.Text.Json;
using System.Timers; using System.Timers;
@@ -25,12 +26,13 @@ namespace GHelper
public Keyboard keyb; public Keyboard keyb;
static AnimeMatrixDevice mat; static AnimeMatrixDevice mat;
static int matrixTick = 0;
static long lastRefresh; static long lastRefresh;
public SettingsForm() public SettingsForm()
{ {
InitializeComponent(); InitializeComponent();
InitTheme(); InitTheme(true);
FormClosing += SettingsForm_FormClosing; FormClosing += SettingsForm_FormClosing;
@@ -113,32 +115,38 @@ namespace GHelper
button120Hz.MouseMove += Button120Hz_MouseHover; button120Hz.MouseMove += Button120Hz_MouseHover;
button120Hz.MouseLeave += ButtonScreen_MouseLeave; button120Hz.MouseLeave += ButtonScreen_MouseLeave;
trackBattery.ValueChanged += TrackBattery_ValueChanged; sliderBattery.ValueChanged += SliderBattery_ValueChanged;
Program.trayIcon.MouseMove += TrayIcon_MouseMove; Program.trayIcon.MouseMove += TrayIcon_MouseMove;
//buttonStandard.Image = (Image)(new Bitmap(buttonStandard.Image, new Size(16, 16)));
aTimer = new System.Timers.Timer(500); aTimer = new System.Timers.Timer(500);
aTimer.Elapsed += OnTimedEvent; aTimer.Elapsed += OnTimedEvent;
SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version);
Thread t = new Thread(() =>
{
CheckForUpdatesAsync();
});
t.Start();
t.Join();
// Subscribing for monitor power on events // Subscribing for monitor power on events
var settingGuid = new NativeMethods.PowerSettingGuid(); var settingGuid = new NativeMethods.PowerSettingGuid();
Program.unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(Handle, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE); 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(5));
CheckForUpdatesAsync();
});
} }
private void SliderBattery_ValueChanged(object? sender, EventArgs e)
private void TrackBattery_ValueChanged(object? sender, EventArgs e)
{ {
SetBatteryChargeLimit(trackBattery.Value); SetBatteryChargeLimit(sliderBattery.Value);
} }
@@ -156,8 +164,6 @@ namespace GHelper
var tag = config.GetProperty("tag_name").ToString().Replace("v", ""); var tag = config.GetProperty("tag_name").ToString().Replace("v", "");
var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString(); var url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString();
Thread.Sleep(5000);
var gitVersion = new Version(tag); var gitVersion = new Version(tag);
var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString());
@@ -196,7 +202,7 @@ namespace GHelper
private void Button120Hz_MouseHover(object? sender, EventArgs e) private void Button120Hz_MouseHover(object? sender, EventArgs e)
{ {
labelTipScreen.Text = "Max refresh rate + screen overdrive for lower latency"; labelTipScreen.Text = "Max refresh rate for lower latency";
} }
private void Button60Hz_MouseHover(object? sender, EventArgs e) private void Button60Hz_MouseHover(object? sender, EventArgs e)
@@ -244,14 +250,14 @@ namespace GHelper
{ {
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1); Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
VisualiseGPUMode(); VisualiseGPUMode();
AutoGPUMode(SystemInformation.PowerStatus.PowerLineStatus); AutoGPUMode();
} }
private void ButtonScreenAuto_Click(object? sender, EventArgs e) private void ButtonScreenAuto_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("screen_auto", 1); Program.config.setConfig("screen_auto", 1);
InitScreen(); InitScreen();
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus); AutoScreen();
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
@@ -267,6 +273,7 @@ namespace GHelper
{ {
case 0: case 0:
Logger.WriteLine("Monitor Power Off"); Logger.WriteLine("Monitor Power Off");
SetBatteryChargeLimit(Program.config.getConfig("charge_limit"));
break; break;
case 1: case 1:
Logger.WriteLine("Monitor Power On"); Logger.WriteLine("Monitor Power On");
@@ -347,7 +354,29 @@ namespace GHelper
mat.PresentNextFrame(); mat.PresentNextFrame();
break; break;
case 3: 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; break;
} }
@@ -449,7 +478,7 @@ namespace GHelper
SetMatrix(); SetMatrix();
} }
public void SetMatrix(PowerLineStatus Plugged = PowerLineStatus.Online) public void SetMatrix()
{ {
if (mat is null) return; if (mat is null) return;
@@ -472,7 +501,7 @@ namespace GHelper
mat.SetProvider(); mat.SetProvider();
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online)) if (brightness == 0 || (auto && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online))
{ {
mat.SetDisplayState(false); mat.SetDisplayState(false);
} }
@@ -506,7 +535,7 @@ namespace GHelper
private void LabelCPUFan_Click(object? sender, EventArgs e) private void LabelCPUFan_Click(object? sender, EventArgs e)
{ {
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1); Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
RefreshSensors(); RefreshSensors(true);
} }
private void PictureColor2_Click(object? sender, EventArgs e) private void PictureColor2_Click(object? sender, EventArgs e)
@@ -681,8 +710,7 @@ namespace GHelper
if (frequency >= 1000) if (frequency >= 1000)
{ {
frequency = Program.config.getConfig("max_frequency"); frequency = NativeMethods.GetRefreshRate(true);
if (frequency <= 60) frequency = 120;
} }
if (frequency > 0) if (frequency > 0)
@@ -692,8 +720,12 @@ namespace GHelper
} }
if (overdrive >= 0) if (overdrive >= 0)
{
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive); Program.wmi.DeviceSet(ASUSWmi.ScreenOverdrive, overdrive);
}
if (miniled >= 0) if (miniled >= 0)
{ {
Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled); Program.wmi.DeviceSet(ASUSWmi.ScreenMiniled, miniled);
@@ -708,11 +740,13 @@ namespace GHelper
{ {
int frequency = NativeMethods.GetRefreshRate(); int frequency = NativeMethods.GetRefreshRate();
int maxFrequency = Program.config.getConfig("max_frequency"); int maxFrequency = NativeMethods.GetRefreshRate(true);
bool screenAuto = (Program.config.getConfig("screen_auto") == 1); bool screenAuto = (Program.config.getConfig("screen_auto") == 1);
bool overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive); int overdrive = Program.wmi.DeviceGet(ASUSWmi.ScreenOverdrive);
int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled); int miniled = Program.wmi.DeviceGet(ASUSWmi.ScreenMiniled);
bool screenEnabled = (frequency >= 0); bool screenEnabled = (frequency >= 0);
@@ -738,18 +772,14 @@ namespace GHelper
{ {
button60Hz.Activated = true; button60Hz.Activated = true;
} }
else else if (frequency > 60)
{ {
if (frequency > 60)
maxFrequency = frequency;
Program.config.setConfig("max_frequency", maxFrequency);
button120Hz.Activated = true; button120Hz.Activated = true;
} }
if (maxFrequency > 60) if (maxFrequency > 60)
{ {
button120Hz.Text = maxFrequency.ToString() + "Hz + OD"; button120Hz.Text = maxFrequency.ToString() + "Hz" + (overdriveSetting ? " + OD" : "");
} }
if (miniled >= 0) if (miniled >= 0)
@@ -808,10 +838,10 @@ namespace GHelper
return " Fan: " + Math.Min(Math.Round(fan / 0.6), 100).ToString() + "%"; // relatively to 6000 rpm 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)
{ {
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return; if (!force && Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastRefresh) < 2000) return;
lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds(); lastRefresh = DateTimeOffset.Now.ToUnixTimeMilliseconds();
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)); string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
@@ -902,6 +932,13 @@ namespace GHelper
if (Program.config.getConfig("mid_fan") == 1) if (Program.config.getConfig("mid_fan") == 1)
Program.wmi.SetFanCurve(2, Program.config.getFanConfig(2)); 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) if (Program.config.getConfigPerf("auto_apply_power") == 1)
@@ -916,6 +953,10 @@ namespace GHelper
timer.Start(); 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) public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
@@ -975,6 +1016,7 @@ namespace GHelper
{ {
fans.InitFans(); fans.InitFans();
fans.InitPower(); fans.InitPower();
fans.InitBoost();
} }
@@ -987,8 +1029,23 @@ namespace GHelper
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true); 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)
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
else
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
}
public void AutoPerformance()
{
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
int mode = Program.config.getConfig("performance_" + (int)Plugged); int mode = Program.config.getConfig("performance_" + (int)Plugged);
if (mode != -1) if (mode != -1)
SetPerformanceMode(mode, true); SetPerformanceMode(mode, true);
@@ -997,11 +1054,11 @@ namespace GHelper
} }
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online) public void AutoScreen(bool force = false)
{ {
if (Program.config.getConfig("screen_auto") != 1) return; if (!force && Program.config.getConfig("screen_auto") != 1) return;
if (Plugged == PowerLineStatus.Online) if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
SetScreen(1000, 1); SetScreen(1000, 1);
else else
SetScreen(60, 0); SetScreen(60, 0);
@@ -1009,9 +1066,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; bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
if (!GpuAuto) return false; if (!GpuAuto) return false;
@@ -1116,7 +1175,7 @@ namespace GHelper
InitGPUMode(); InitGPUMode();
HardwareMonitor.RecreateGpuTemperatureProviderWithDelay(); HardwareMonitor.RecreateGpuTemperatureProviderWithDelay();
Thread.Sleep(500); Thread.Sleep(500);
AutoScreen(SystemInformation.PowerStatus.PowerLineStatus); AutoScreen();
}); });
}); });
@@ -1265,8 +1324,10 @@ namespace GHelper
if (limit < 40 || limit > 100) return; if (limit < 40 || limit > 100) return;
//Debug.WriteLine(limit);
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%"; labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
trackBattery.Value = limit; sliderBattery.Value = limit;
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit); Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
Program.config.setConfig("charge_limit", limit); Program.config.setConfig("charge_limit", limit);

168
app/Slider.cs Normal file
View File

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

View File

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

View File

@@ -1,8 +1,8 @@
# [G-Helper (GHelper)](https://github.com/seerge/g-helper) # [G-Helper (GHelper)](https://github.com/seerge/g-helper)
[![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/seerge/g-helper/stargazers/) [![Github all releases](https://img.shields.io/github/downloads/seerge/g-helper/total.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub release](https://img.shields.io/github/release/seerge/g-helper.svg)](https://GitHub.com/seerge/g-helper/releases/) [![GitHub stars](https://img.shields.io/github/stars/seerge/g-helper.svg?style=social&label=Star)](https://GitHub.com/seerge/g-helper/stargazers/)
## Open source Armoury Crate alternative for Asus laptops such as 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. A small utility that allows you to do almost everything you could do with Armoury Crate but without extra bloat and unnecessary services.
@@ -61,7 +61,8 @@ PPTs are shown for G14 2022, for other models PPTs will be different as they are
## :question: FAQ ## :question: FAQ
### How do I stop Armory Crate install popup appearing every time I press M4 / Rog key? ### 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 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+) Ultimate mode is supported (by hardware) only on G14 2022 (and possibly other models from 2022+)