Compare commits

...

5 Commits

Author SHA1 Message Date
seerge
43c6def162 Update checker 2023-03-09 20:54:32 +01:00
seerge
306697f026 Added possible fix for bios unsetting ppts after wake up 2023-03-09 16:03:39 +01:00
seerge
c5a32cc9d5 Moved turbo boost checkbox to Fans and Power window 2023-03-09 14:10:13 +01:00
seerge
51acd9a612 Fix for startup checkbox 2023-03-09 11:28:02 +01:00
seerge
457a37049c - 2023-03-08 22:51:33 +01:00
8 changed files with 265 additions and 122 deletions

View File

@@ -1,6 +1,7 @@
// Source thanks to https://github.com/vddCore/Starlight :) // Source thanks to https://github.com/vddCore/Starlight :)
using Starlight.Communication.Platform; using Starlight.Communication.Platform;
using System.Configuration;
namespace Starlight.Communication namespace Starlight.Communication
{ {
@@ -8,9 +9,21 @@ namespace Starlight.Communication
{ {
private static UsbProvider _usbProvider; private static UsbProvider _usbProvider;
private static ushort _vendorId;
private static ushort _productId;
private static int _maxFeatureReportLength;
protected Device(ushort vendorId, ushort productId, int maxFeatureReportLength) protected Device(ushort vendorId, ushort productId, int maxFeatureReportLength)
{ {
_usbProvider = new WindowsUsbProvider(vendorId, productId, maxFeatureReportLength); _vendorId = vendorId;
_productId = productId;
_maxFeatureReportLength = maxFeatureReportLength;
SetProvider();
}
public void SetProvider()
{
_usbProvider = new WindowsUsbProvider(_vendorId, _productId, _maxFeatureReportLength);
} }
protected T Packet<T>(params byte[] command) where T : Packet protected T Packet<T>(params byte[] command) where T : Packet

56
Fans.Designer.cs generated
View File

@@ -28,9 +28,11 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea5 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea6 = new System.Windows.Forms.DataVisualization.Charting.ChartArea(); System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea2 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
panelFans = new Panel(); panelFans = new Panel();
checkBoost = new CheckBox();
labelFans = new Label();
checkAuto = new CheckBox(); checkAuto = new CheckBox();
chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart(); chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
buttonReset = new Button(); buttonReset = new Button();
@@ -64,6 +66,9 @@
// //
// panelFans // panelFans
// //
panelFans.AutoSize = true;
panelFans.Controls.Add(checkBoost);
panelFans.Controls.Add(labelFans);
panelFans.Controls.Add(checkAuto); panelFans.Controls.Add(checkAuto);
panelFans.Controls.Add(chartGPU); panelFans.Controls.Add(chartGPU);
panelFans.Controls.Add(buttonReset); panelFans.Controls.Add(buttonReset);
@@ -72,17 +77,39 @@
panelFans.Dock = DockStyle.Left; panelFans.Dock = DockStyle.Left;
panelFans.Location = new Point(363, 0); panelFans.Location = new Point(363, 0);
panelFans.Margin = new Padding(10); panelFans.Margin = new Padding(10);
panelFans.MinimumSize = new Size(868, 1089); panelFans.MinimumSize = new Size(872, 1089);
panelFans.Name = "panelFans"; panelFans.Name = "panelFans";
panelFans.Padding = new Padding(10); panelFans.Padding = new Padding(10);
panelFans.Size = new Size(872, 1089); panelFans.Size = new Size(872, 1089);
panelFans.TabIndex = 12; panelFans.TabIndex = 12;
// //
// checkBoost
//
checkBoost.AutoSize = true;
checkBoost.ForeColor = SystemColors.ControlText;
checkBoost.Location = new Point(512, 15);
checkBoost.Margin = new Padding(4, 2, 4, 2);
checkBoost.Name = "checkBoost";
checkBoost.Size = new Size(320, 36);
checkBoost.TabIndex = 35;
checkBoost.Text = "CPU Turbo Boost enabled";
checkBoost.UseVisualStyleBackColor = true;
//
// labelFans
//
labelFans.AutoSize = true;
labelFans.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelFans.Location = new Point(24, 15);
labelFans.Name = "labelFans";
labelFans.Size = new Size(138, 32);
labelFans.TabIndex = 28;
labelFans.Text = "Fan Curves";
//
// checkAuto // checkAuto
// //
checkAuto.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; checkAuto.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkAuto.AutoSize = true; checkAuto.AutoSize = true;
checkAuto.Location = new Point(584, 981); checkAuto.Location = new Point(411, 1030);
checkAuto.Margin = new Padding(4, 2, 4, 2); checkAuto.Margin = new Padding(4, 2, 4, 2);
checkAuto.Name = "checkAuto"; checkAuto.Name = "checkAuto";
checkAuto.Size = new Size(165, 36); checkAuto.Size = new Size(165, 36);
@@ -93,9 +120,9 @@
// chartGPU // chartGPU
// //
chartGPU.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; chartGPU.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
chartArea5.Name = "ChartArea1"; chartArea1.Name = "ChartArea1";
chartGPU.ChartAreas.Add(chartArea5); chartGPU.ChartAreas.Add(chartArea1);
chartGPU.Location = new Point(22, 502); chartGPU.Location = new Point(22, 547);
chartGPU.Margin = new Padding(4, 2, 4, 2); chartGPU.Margin = new Padding(4, 2, 4, 2);
chartGPU.Name = "chartGPU"; chartGPU.Name = "chartGPU";
chartGPU.Size = new Size(810, 460); chartGPU.Size = new Size(810, 460);
@@ -127,9 +154,9 @@
// chartCPU // chartCPU
// //
chartCPU.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; chartCPU.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
chartArea6.Name = "ChartArea1"; chartArea2.Name = "ChartArea1";
chartCPU.ChartAreas.Add(chartArea6); chartCPU.ChartAreas.Add(chartArea2);
chartCPU.Location = new Point(22, 21); chartCPU.Location = new Point(22, 66);
chartCPU.Margin = new Padding(10); chartCPU.Margin = new Padding(10);
chartCPU.Name = "chartCPU"; chartCPU.Name = "chartCPU";
chartCPU.Size = new Size(810, 460); chartCPU.Size = new Size(810, 460);
@@ -166,7 +193,7 @@
// //
checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; checkApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
checkApplyPower.AutoSize = true; checkApplyPower.AutoSize = true;
checkApplyPower.Location = new Point(17, 981); checkApplyPower.Location = new Point(21, 982);
checkApplyPower.Margin = new Padding(4, 2, 4, 2); checkApplyPower.Margin = new Padding(4, 2, 4, 2);
checkApplyPower.Name = "checkApplyPower"; checkApplyPower.Name = "checkApplyPower";
checkApplyPower.Size = new Size(165, 36); checkApplyPower.Size = new Size(165, 36);
@@ -294,7 +321,7 @@
pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
pictureFine.BackgroundImageLayout = ImageLayout.Zoom; pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
pictureFine.Image = Properties.Resources.everything_is_fine_itsfine; pictureFine.Image = Properties.Resources.everything_is_fine_itsfine;
pictureFine.Location = new Point(17, 694); pictureFine.Location = new Point(17, 671);
pictureFine.Margin = new Padding(4, 2, 4, 2); pictureFine.Margin = new Padding(4, 2, 4, 2);
pictureFine.Name = "pictureFine"; pictureFine.Name = "pictureFine";
pictureFine.Size = new Size(327, 254); pictureFine.Size = new Size(327, 254);
@@ -308,7 +335,7 @@
labelInfo.Location = new Point(17, 603); labelInfo.Location = new Point(17, 603);
labelInfo.Margin = new Padding(4, 0, 4, 0); labelInfo.Margin = new Padding(4, 0, 4, 0);
labelInfo.Name = "labelInfo"; labelInfo.Name = "labelInfo";
labelInfo.Size = new Size(327, 371); labelInfo.Size = new Size(327, 330);
labelInfo.TabIndex = 19; labelInfo.TabIndex = 19;
labelInfo.Text = "label"; labelInfo.Text = "label";
// //
@@ -345,6 +372,7 @@
((System.ComponentModel.ISupportInitialize)trackTotal).EndInit(); ((System.ComponentModel.ISupportInitialize)trackTotal).EndInit();
((System.ComponentModel.ISupportInitialize)pictureFine).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureFine).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@@ -369,5 +397,7 @@
private PictureBox pictureFine; private PictureBox pictureFine;
private Label labelInfo; private Label labelInfo;
private Label labelPowerLimits; private Label labelPowerLimits;
private Label labelFans;
private CheckBox checkBoost;
} }
} }

24
Fans.cs
View File

@@ -22,7 +22,7 @@ namespace GHelper
title = "CPU Fan Profile"; title = "CPU Fan Profile";
if (Program.settingsForm.perfName.Length > 0) if (Program.settingsForm.perfName.Length > 0)
title += ": " + Program.settingsForm.perfName; labelFans.Text = "Fan Profiles: " + Program.settingsForm.perfName;
if (chart.Titles.Count > 0) if (chart.Titles.Count > 0)
chart.Titles[0].Text = title; chart.Titles[0].Text = title;
@@ -102,11 +102,33 @@ namespace GHelper
InitFans(); InitFans();
InitPower(); InitPower();
InitBoost();
checkBoost.Click += CheckBoost_Click;
Shown += Fans_Shown; Shown += Fans_Shown;
} }
public void InitBoost()
{
int boost = NativeMethods.GetCPUBoost();
checkBoost.Checked = (boost > 0);
}
private void CheckBoost_Click(object? sender, EventArgs e)
{
if (sender is null)
return;
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
NativeMethods.SetCPUBoost(2);
else
NativeMethods.SetCPUBoost(0);
}
private void CheckApplyPower_Click(object? sender, EventArgs e) private void CheckApplyPower_Click(object? sender, EventArgs e)
{ {
if (sender is null) return; if (sender is null) return;

View File

@@ -15,7 +15,7 @@
<AssemblyName>GHelper</AssemblyName> <AssemblyName>GHelper</AssemblyName>
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly> <ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AssemblyVersion>0.18.1</AssemblyVersion> <AssemblyVersion>0.21</AssemblyVersion>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>

View File

@@ -310,6 +310,7 @@ namespace Tools
public class NativeMethods public class NativeMethods
{ {
public const int KEYEVENTF_EXTENDEDKEY = 1; public const int KEYEVENTF_EXTENDEDKEY = 1;
public const int KEYEVENTF_KEYUP = 2; public const int KEYEVENTF_KEYUP = 2;

View File

@@ -1,6 +1,10 @@
using Microsoft.Win32; using Microsoft.Win32;
using System;
using System.Diagnostics; using System.Diagnostics;
using System.Management; using System.Management;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
public class HardwareMonitor public class HardwareMonitor
{ {
@@ -36,6 +40,32 @@ namespace GHelper
{ {
static class Program static class Program
{ {
// Native methods for sleep detection
[DllImport("Powrprof.dll", SetLastError = true)]
static extern uint PowerRegisterSuspendResumeNotification(uint flags, ref DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS receipient, ref IntPtr registrationHandle);
private const int WM_POWERBROADCAST = 536; // (0x218)
private const int PBT_APMPOWERSTATUSCHANGE = 10; // (0xA) - Power status has changed.
private const int PBT_APMRESUMEAUTOMATIC = 18; // (0x12) - Operation is resuming automatically from a low-power state.This message is sent every time the system resumes.
private const int PBT_APMRESUMESUSPEND = 7; // (0x7) - Operation is resuming from a low-power state.This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key.
private const int PBT_APMSUSPEND = 4; // (0x4) - System is suspending operation.
private const int PBT_POWERSETTINGCHANGE = 32787; // (0x8013) - A power setting change event has been received.
private const int DEVICE_NOTIFY_CALLBACK = 2;
[StructLayout(LayoutKind.Sequential)]
struct DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS
{
public DeviceNotifyCallbackRoutine Callback;
public IntPtr Context;
}
public delegate int DeviceNotifyCallbackRoutine(IntPtr context, int type, IntPtr setting);
//
public static NotifyIcon trayIcon = new NotifyIcon public static NotifyIcon trayIcon = new NotifyIcon
{ {
Text = "G-Helper", Text = "G-Helper",
@@ -75,7 +105,6 @@ namespace GHelper
wmi.SubscribeToEvents(WatcherEventArrived); wmi.SubscribeToEvents(WatcherEventArrived);
settingsForm.InitGPUMode(); settingsForm.InitGPUMode();
settingsForm.InitBoost();
settingsForm.InitAura(); settingsForm.InitAura();
settingsForm.InitMatrix(); settingsForm.InitMatrix();
@@ -85,14 +114,81 @@ namespace GHelper
SetAutoModes(); SetAutoModes();
IntPtr registrationHandle = new IntPtr();
DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS recipient = new DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS();
recipient.Callback = new DeviceNotifyCallbackRoutine(DeviceNotifyCallback);
recipient.Context = IntPtr.Zero;
IntPtr pRecipient = Marshal.AllocHGlobal(Marshal.SizeOf(recipient));
Marshal.StructureToPtr(recipient, pRecipient, false);
uint result = PowerRegisterSuspendResumeNotification(DEVICE_NOTIFY_CALLBACK, ref recipient, ref registrationHandle);
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
IntPtr ds = settingsForm.Handle; IntPtr ds = settingsForm.Handle;
CheckForUpdates();
Application.Run(); Application.Run();
} }
private static int DeviceNotifyCallback(IntPtr context, int type, IntPtr setting)
{
//Debug.WriteLine($"Power callback type: {type}");
switch (type)
{
case PBT_APMRESUMEAUTOMATIC:
settingsForm.BeginInvoke(delegate
{
// Setting "other" mode to prevent bios bugging with PPTs after wake up from sleep
wmi.DeviceSet(ASUSWmi.PerformanceMode, config.getConfig("performance_mode"));
Thread.Sleep(1000);
SetAutoModes();
});
break;
}
return 0;
}
static async void CheckForUpdates()
{
settingsForm.SetVersionLabel("Version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString());
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 assembly = Assembly.GetExecutingAssembly().GetName().Version.ToString();
var gitVersion = new Version(tag);
var appVersion = new Version();
var result = appVersion.CompareTo(gitVersion);
if (result > 0)
{
settingsForm.SetVersionLabel("Download Update: " + tag, url);
}
}
} catch {
Debug.WriteLine("Failed to get update");
}
}
private static void SetAutoModes() private static void SetAutoModes()
{ {
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus; PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
@@ -104,6 +200,7 @@ namespace GHelper
settingsForm.AutoScreen(isPlugged); settingsForm.AutoScreen(isPlugged);
settingsForm.AutoGPUMode(isPlugged); settingsForm.AutoGPUMode(isPlugged);
settingsForm.SetMatrix(isPlugged); settingsForm.SetMatrix(isPlugged);
} }

33
Settings.Designer.cs generated
View File

@@ -48,7 +48,6 @@
checkStartup = new CheckBox(); checkStartup = new CheckBox();
panelPerformance = new Panel(); panelPerformance = new Panel();
buttonFans = new Button(); buttonFans = new Button();
checkBoost = new CheckBox();
picturePerf = new PictureBox(); picturePerf = new PictureBox();
labelPerf = new Label(); labelPerf = new Label();
labelCPUFan = new Label(); labelCPUFan = new Label();
@@ -113,17 +112,17 @@
panelMatrix.Controls.Add(pictureMatrix); panelMatrix.Controls.Add(pictureMatrix);
panelMatrix.Controls.Add(labelMatrix); panelMatrix.Controls.Add(labelMatrix);
panelMatrix.Dock = DockStyle.Top; panelMatrix.Dock = DockStyle.Top;
panelMatrix.Location = new Point(16, 806); panelMatrix.Location = new Point(16, 814);
panelMatrix.Margin = new Padding(4); panelMatrix.Margin = new Padding(4);
panelMatrix.Name = "panelMatrix"; panelMatrix.Name = "panelMatrix";
panelMatrix.Size = new Size(722, 156); panelMatrix.Size = new Size(722, 180);
panelMatrix.TabIndex = 33; panelMatrix.TabIndex = 33;
// //
// checkMatrix // checkMatrix
// //
checkMatrix.AutoSize = true; checkMatrix.AutoSize = true;
checkMatrix.ForeColor = SystemColors.GrayText; checkMatrix.ForeColor = SystemColors.GrayText;
checkMatrix.Location = new Point(26, 112); checkMatrix.Location = new Point(28, 109);
checkMatrix.Margin = new Padding(4, 2, 4, 2); checkMatrix.Margin = new Padding(4, 2, 4, 2);
checkMatrix.Name = "checkMatrix"; checkMatrix.Name = "checkMatrix";
checkMatrix.Size = new Size(249, 36); checkMatrix.Size = new Size(249, 36);
@@ -159,7 +158,7 @@
buttonMatrix.Name = "buttonMatrix"; buttonMatrix.Name = "buttonMatrix";
buttonMatrix.Size = new Size(208, 42); buttonMatrix.Size = new Size(208, 42);
buttonMatrix.TabIndex = 43; buttonMatrix.TabIndex = 43;
buttonMatrix.Text = "Picture"; buttonMatrix.Text = "Picture / Gif";
buttonMatrix.UseVisualStyleBackColor = false; buttonMatrix.UseVisualStyleBackColor = false;
// //
// comboMatrixRunning // comboMatrixRunning
@@ -220,7 +219,7 @@
panelBattery.Controls.Add(labelBatteryTitle); panelBattery.Controls.Add(labelBatteryTitle);
panelBattery.Controls.Add(trackBattery); panelBattery.Controls.Add(trackBattery);
panelBattery.Dock = DockStyle.Top; panelBattery.Dock = DockStyle.Top;
panelBattery.Location = new Point(16, 962); panelBattery.Location = new Point(16, 994);
panelBattery.Margin = new Padding(4); panelBattery.Margin = new Padding(4);
panelBattery.Name = "panelBattery"; panelBattery.Name = "panelBattery";
panelBattery.Size = new Size(722, 148); panelBattery.Size = new Size(722, 148);
@@ -291,7 +290,7 @@
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(16, 1110); panelFooter.Location = new Point(16, 1142);
panelFooter.Margin = new Padding(4); panelFooter.Margin = new Padding(4);
panelFooter.Name = "panelFooter"; panelFooter.Name = "panelFooter";
panelFooter.Size = new Size(722, 64); panelFooter.Size = new Size(722, 64);
@@ -323,7 +322,6 @@
// panelPerformance // panelPerformance
// //
panelPerformance.Controls.Add(buttonFans); panelPerformance.Controls.Add(buttonFans);
panelPerformance.Controls.Add(checkBoost);
panelPerformance.Controls.Add(picturePerf); panelPerformance.Controls.Add(picturePerf);
panelPerformance.Controls.Add(labelPerf); panelPerformance.Controls.Add(labelPerf);
panelPerformance.Controls.Add(labelCPUFan); panelPerformance.Controls.Add(labelCPUFan);
@@ -348,18 +346,6 @@
buttonFans.Text = "Fans and Power"; buttonFans.Text = "Fans and Power";
buttonFans.UseVisualStyleBackColor = false; buttonFans.UseVisualStyleBackColor = false;
// //
// checkBoost
//
checkBoost.AutoSize = true;
checkBoost.ForeColor = SystemColors.GrayText;
checkBoost.Location = new Point(27, 154);
checkBoost.Margin = new Padding(4, 2, 4, 2);
checkBoost.Name = "checkBoost";
checkBoost.Size = new Size(320, 36);
checkBoost.TabIndex = 33;
checkBoost.Text = "CPU Turbo Boost enabled";
checkBoost.UseVisualStyleBackColor = true;
//
// picturePerf // picturePerf
// //
picturePerf.BackgroundImage = (Image)resources.GetObject("picturePerf.BackgroundImage"); picturePerf.BackgroundImage = (Image)resources.GetObject("picturePerf.BackgroundImage");
@@ -595,7 +581,7 @@
// //
checkScreen.AutoSize = true; checkScreen.AutoSize = true;
checkScreen.ForeColor = SystemColors.GrayText; checkScreen.ForeColor = SystemColors.GrayText;
checkScreen.Location = new Point(27, 154); checkScreen.Location = new Point(27, 153);
checkScreen.Margin = new Padding(4, 2, 4, 2); checkScreen.Margin = new Padding(4, 2, 4, 2);
checkScreen.Name = "checkScreen"; checkScreen.Name = "checkScreen";
checkScreen.Size = new Size(527, 36); checkScreen.Size = new Size(527, 36);
@@ -683,7 +669,7 @@
panelKeyboard.Location = new Point(16, 660); panelKeyboard.Location = new Point(16, 660);
panelKeyboard.Margin = new Padding(4); panelKeyboard.Margin = new Padding(4);
panelKeyboard.Name = "panelKeyboard"; panelKeyboard.Name = "panelKeyboard";
panelKeyboard.Size = new Size(722, 146); panelKeyboard.Size = new Size(722, 154);
panelKeyboard.TabIndex = 39; panelKeyboard.TabIndex = 39;
// //
// tableLayoutKeyboard // tableLayoutKeyboard
@@ -775,7 +761,7 @@
buttonKeyboardColor.Name = "buttonKeyboardColor"; buttonKeyboardColor.Name = "buttonKeyboardColor";
buttonKeyboardColor.Size = new Size(208, 42); buttonKeyboardColor.Size = new Size(208, 42);
buttonKeyboardColor.TabIndex = 39; buttonKeyboardColor.TabIndex = 39;
buttonKeyboardColor.Text = "Color "; buttonKeyboardColor.Text = "Color ";
buttonKeyboardColor.UseVisualStyleBackColor = false; buttonKeyboardColor.UseVisualStyleBackColor = false;
// //
// pictureKeyboard // pictureKeyboard
@@ -872,7 +858,6 @@
private CheckBox checkStartup; private CheckBox checkStartup;
private Panel panelPerformance; private Panel panelPerformance;
private Button buttonFans; private Button buttonFans;
private CheckBox checkBoost;
private PictureBox picturePerf; private PictureBox picturePerf;
private Label labelPerf; private Label labelPerf;
private Label labelCPUFan; private Label labelCPUFan;

View File

@@ -1,7 +1,6 @@
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Reflection;
using System.Timers; using System.Timers;
namespace GHelper namespace GHelper
@@ -20,14 +19,14 @@ namespace GHelper
static System.Timers.Timer aTimer = default!; static System.Timers.Timer aTimer = default!;
static System.Timers.Timer matrixTimer = default!; static System.Timers.Timer matrixTimer = default!;
public string versionUrl = "http://github.com/seerge/g-helper/releases";
public string perfName = "Balanced"; public string perfName = "Balanced";
Fans fans; Fans fans;
Keyboard keyb; Keyboard keyb;
static AnimeMatrixDevice mat; static AnimeMatrixDevice mat;
static bool matEnabled = false;
public SettingsForm() public SettingsForm()
{ {
@@ -61,7 +60,6 @@ namespace GHelper
buttonQuit.Click += ButtonQuit_Click; buttonQuit.Click += ButtonQuit_Click;
checkBoost.Click += CheckBoost_Click;
checkScreen.CheckedChanged += checkScreen_CheckedChanged; checkScreen.CheckedChanged += checkScreen_CheckedChanged;
@@ -77,9 +75,6 @@ namespace GHelper
pictureColor.Click += PictureColor_Click; pictureColor.Click += PictureColor_Click;
pictureColor2.Click += PictureColor2_Click; pictureColor2.Click += PictureColor2_Click;
labelVersion.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
labelVersion.Click += LabelVersion_Click;
labelCPUFan.Click += LabelCPUFan_Click; labelCPUFan.Click += LabelCPUFan_Click;
labelGPUFan.Click += LabelCPUFan_Click; labelGPUFan.Click += LabelCPUFan_Click;
@@ -93,12 +88,46 @@ namespace GHelper
buttonMatrix.Click += ButtonMatrix_Click; buttonMatrix.Click += ButtonMatrix_Click;
checkStartup.CheckedChanged += CheckStartup_CheckedChanged;
labelVersion.Click += LabelVersion_Click;
SetTimer(); SetTimer();
} }
public void SetVersionLabel(string label, string url = null)
{
labelVersion.Text = label;
if (url is not null)
{
versionUrl = url;
labelVersion.ForeColor = Color.Red;
}
}
private void LabelVersion_Click(object? sender, EventArgs e)
{
Process.Start(new ProcessStartInfo(versionUrl) { UseShellExecute = true });
}
private void CheckStartup_CheckedChanged(object? sender, EventArgs e)
{
if (sender is null) return;
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
{
Startup.Schedule();
}
else
{
Startup.UnSchedule();
}
}
private void CheckMatrix_CheckedChanged(object? sender, EventArgs e) private void CheckMatrix_CheckedChanged(object? sender, EventArgs e)
{ {
if (sender is null) return; if (sender is null) return;
@@ -240,6 +269,8 @@ namespace GHelper
StopMatrixTimer(); StopMatrixTimer();
mat.SetProvider();
if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online)) if (brightness == 0 || (auto && Plugged != PowerLineStatus.Online))
{ {
mat.SetDisplayState(false); mat.SetDisplayState(false);
@@ -258,6 +289,7 @@ namespace GHelper
{ {
mat.SetBuiltInAnimation(true, animation); mat.SetBuiltInAnimation(true, animation);
} }
} }
} }
@@ -270,11 +302,6 @@ namespace GHelper
RefreshSensors(); RefreshSensors();
} }
private void LabelVersion_Click(object? sender, EventArgs e)
{
Process.Start(new ProcessStartInfo("http://github.com/seerge/g-helper/releases") { UseShellExecute = true });
}
private void PictureColor2_Click(object? sender, EventArgs e) private void PictureColor2_Click(object? sender, EventArgs e)
{ {
@@ -373,36 +400,26 @@ namespace GHelper
public void InitMatrix() public void InitMatrix()
{ {
matrixTimer = new System.Timers.Timer();
matrixTimer.Enabled = false;
matrixTimer.Interval = 100;
try try
{ {
matEnabled = true;
mat = new AnimeMatrixDevice(); mat = new AnimeMatrixDevice();
matrixTimer = new System.Timers.Timer(100);
matrixTimer.Elapsed += MatrixTimer_Elapsed; matrixTimer.Elapsed += MatrixTimer_Elapsed;
} }
catch catch
{
matEnabled = false;
Debug.WriteLine("Anime Matrix not detected");
}
if (!matEnabled)
{ {
panelMatrix.Visible = false; panelMatrix.Visible = false;
return;
} }
else
{
int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running");
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0; int brightness = Program.config.getConfig("matrix_brightness");
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0; int running = Program.config.getConfig("matrix_running");
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
}
} }
@@ -468,19 +485,6 @@ namespace GHelper
SetAuraMode(cmb.SelectedIndex); SetAuraMode(cmb.SelectedIndex);
} }
private void CheckBoost_Click(object? sender, EventArgs e)
{
if (sender is null)
return;
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
NativeMethods.SetCPUBoost(2);
else
NativeMethods.SetCPUBoost(0);
}
private void Button120Hz_Click(object? sender, EventArgs e) private void Button120Hz_Click(object? sender, EventArgs e)
{ {
SetScreen(1000, 1); SetScreen(1000, 1);
@@ -523,13 +527,6 @@ namespace GHelper
InitScreen(); InitScreen();
} }
public void InitBoost()
{
int boost = NativeMethods.GetCPUBoost();
checkBoost.Checked = (boost > 0);
}
public void InitScreen() public void InitScreen()
{ {
@@ -702,12 +699,28 @@ namespace GHelper
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total); Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total); Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu); Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
Debug.WriteLine(limit_total.ToString() + ", " + limit_cpu.ToString()); Debug.WriteLine(limit_total.ToString() + ", " + limit_cpu.ToString());
} }
public void AutoFansAndPower()
{
if (Program.config.getConfigPerf("auto_apply") == 1)
{
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
}
if (Program.config.getConfigPerf("auto_apply_power") == 1)
{
SetPower();
}
}
public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false) public void SetPerformanceMode(int PerformanceMode = ASUSWmi.PerformanceBalanced, bool notify = false)
{ {
@@ -737,23 +750,7 @@ namespace GHelper
Program.config.setConfig("performance_mode", PerformanceMode); Program.config.setConfig("performance_mode", PerformanceMode);
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode); Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
Debug.WriteLine("Perf:" + PerformanceMode);
if (Program.config.getConfigPerf("auto_apply") == 1)
{
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
}
if (Program.config.getConfigPerf("auto_apply_power") == 1)
{
SetPower();
}
if (fans != null && fans.Text != "")
{
fans.InitFans();
fans.InitPower();
}
if (notify && (oldMode != PerformanceMode)) if (notify && (oldMode != PerformanceMode))
{ {
@@ -767,6 +764,16 @@ namespace GHelper
} }
} }
AutoFansAndPower();
if (fans != null && fans.Text != "")
{
fans.InitFans();
fans.InitPower();
}
} }
@@ -985,18 +992,6 @@ namespace GHelper
{ {
checkStartup.Checked = status; checkStartup.Checked = status;
} }
private void checkStartup_CheckedChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
if (chk.Checked)
{
Startup.Schedule();
}
else
{
Startup.UnSchedule();
}
}
public void SetBatteryChargeLimit(int limit) public void SetBatteryChargeLimit(int limit)
{ {