diff --git a/app/ASUSWmi.cs b/app/ASUSWmi.cs index 1d54f8f4..6d979da8 100644 --- a/app/ASUSWmi.cs +++ b/app/ASUSWmi.cs @@ -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) { - uint flags; - uint cmd = 1; + int state = 0xbd; - flags = 0; - if (boot) - flags |= (1 << 1); - if (awake) - flags |= (1 << 3); - if (sleep) - flags |= (1 << 5); - if (shutdown) - flags |= (1 << 7); + 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; - byte[] state = new byte[12]; - state[0] = 0xbd; - state[1] = (byte)((cmd != 0) ? (1 << 2) : 0); - state[2] = (byte)flags; + state = state | 0x01 << 8; - DeviceSet(TUF_KB, state); - Debug.WriteLine(BitConverter.ToString(state)); + DeviceSet(TUF_KB_STATE, state); } public void SubscribeToEvents(Action EventHandler) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 9ca09826..76f823cc 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -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)); } diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index e60ba996..5a1a3a3a 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -40,6 +40,7 @@ namespace GHelper pictureMatrix = new PictureBox(); labelMatrix = new Label(); panelBattery = new Panel(); + labelModel = new Label(); labelVersion = new Label(); labelBattery = new Label(); pictureBattery = new PictureBox(); @@ -236,6 +237,7 @@ namespace GHelper // panelBattery.AutoSize = true; panelBattery.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelBattery.Controls.Add(labelModel); panelBattery.Controls.Add(labelVersion); panelBattery.Controls.Add(labelBattery); panelBattery.Controls.Add(pictureBattery); @@ -246,15 +248,27 @@ namespace GHelper 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; // + // 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); @@ -316,7 +330,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); @@ -1103,5 +1117,6 @@ namespace GHelper private RButton buttonKeyboardColor; private RButton buttonFans; private Label labelMidFan; + private Label labelModel; } } \ No newline at end of file diff --git a/app/Settings.cs b/app/Settings.cs index 7ec60684..5ceba44b 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -121,18 +121,25 @@ namespace GHelper aTimer = new System.Timers.Timer(500); aTimer.Elapsed += OnTimedEvent; - SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version); - Thread t = new Thread(() => - { - CheckForUpdatesAsync(); - }); - t.Start(); - t.Join(); - // 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; + + 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 url = config.GetProperty("assets")[0].GetProperty("browser_download_url").ToString(); - Thread.Sleep(5000); - var gitVersion = new Version(tag); var appVersion = new Version(Assembly.GetExecutingAssembly().GetName().Version.ToString()); @@ -506,7 +511,7 @@ 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) @@ -808,10 +813,10 @@ namespace GHelper 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(); string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan)); @@ -902,6 +907,12 @@ 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)