mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added model name, and custom fan+ in profile names
This commit is contained in:
@@ -253,28 +253,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)
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
21
app/Settings.Designer.cs
generated
21
app/Settings.Designer.cs
generated
@@ -40,6 +40,7 @@ namespace GHelper
|
|||||||
pictureMatrix = new PictureBox();
|
pictureMatrix = new PictureBox();
|
||||||
labelMatrix = new Label();
|
labelMatrix = new Label();
|
||||||
panelBattery = new Panel();
|
panelBattery = new Panel();
|
||||||
|
labelModel = new Label();
|
||||||
labelVersion = new Label();
|
labelVersion = new Label();
|
||||||
labelBattery = new Label();
|
labelBattery = new Label();
|
||||||
pictureBattery = new PictureBox();
|
pictureBattery = new PictureBox();
|
||||||
@@ -236,6 +237,7 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
panelBattery.AutoSize = true;
|
panelBattery.AutoSize = true;
|
||||||
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
|
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);
|
||||||
@@ -246,15 +248,27 @@ namespace GHelper
|
|||||||
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;
|
||||||
//
|
//
|
||||||
|
// 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);
|
||||||
@@ -316,7 +330,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);
|
||||||
@@ -1103,5 +1117,6 @@ namespace GHelper
|
|||||||
private RButton buttonKeyboardColor;
|
private RButton buttonKeyboardColor;
|
||||||
private RButton buttonFans;
|
private RButton buttonFans;
|
||||||
private Label labelMidFan;
|
private Label labelMidFan;
|
||||||
|
private Label labelModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,18 +121,25 @@ namespace GHelper
|
|||||||
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;
|
||||||
|
|
||||||
|
Task.Run(async () =>
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||||
|
CheckForUpdatesAsync();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -156,8 +163,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());
|
||||||
|
|
||||||
@@ -506,7 +511,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)
|
||||||
@@ -808,10 +813,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 +907,12 @@ 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user