mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Minor tweaks
This commit is contained in:
@@ -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;
|
||||||
@@ -231,7 +233,7 @@ public class ASUSWmi
|
|||||||
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
|
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
|
||||||
case 2:
|
case 2:
|
||||||
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
|
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
|
||||||
default:
|
default:
|
||||||
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
|
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void PresentText(string text, float fontSize = 8F)
|
public void PresentText(string text, float fontSize = 8.5F)
|
||||||
{
|
{
|
||||||
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
|
using (Bitmap bmp = new Bitmap(MaxColumns * 3, MaxRows))
|
||||||
{
|
{
|
||||||
@@ -378,21 +378,22 @@ namespace Starlight.AnimeMatrix
|
|||||||
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
|
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
g.DrawString(text, font, Brushes.White, 12, -2);
|
g.DrawString(text, font, Brushes.White, 5, -2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GenerateFrame(bmp);
|
GenerateFrame(bmp, System.Drawing.Drawing2D.InterpolationMode.Bicubic);
|
||||||
Present();
|
Present();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateFrame(Image image)
|
public void GenerateFrame(Image image, System.Drawing.Drawing2D.InterpolationMode interpolation = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic)
|
||||||
{
|
{
|
||||||
|
|
||||||
int width = MaxColumns * 3;
|
int width = MaxColumns * 3;
|
||||||
int height = MaxRows;
|
int height = MaxRows;
|
||||||
|
|
||||||
int targetWidth = MaxColumns * 2;
|
int targetWidth = MaxColumns * 2;
|
||||||
|
|
||||||
float scale;
|
float scale;
|
||||||
@@ -403,14 +404,14 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
using (var graph = Graphics.FromImage(bmp))
|
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.Bilinear;
|
graph.InterpolationMode = interpolation;
|
||||||
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||||
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||||||
|
|
||||||
graph.DrawImage(image, (int)Math.Round(targetWidth - scaleWidth/1.5), 0, (int)Math.Round(scaleWidth/1.5), scaleHeight);
|
graph.DrawImage(image, (float)Math.Round(targetWidth - scaleWidth * targetWidth / width), 0, (float)Math.Round(scaleWidth * targetWidth / width), scaleHeight);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -420,12 +421,12 @@ namespace Starlight.AnimeMatrix
|
|||||||
if (x % 2 == y % 2)
|
if (x % 2 == y % 2)
|
||||||
{
|
{
|
||||||
var pixel = bmp.GetPixel(x, y);
|
var pixel = bmp.GetPixel(x, y);
|
||||||
SetLedPlanar(x / 2, y, (byte)((pixel.R + pixel.G + pixel.B) / 3));
|
var color = (pixel.R + pixel.G + pixel.B) / 3;
|
||||||
|
if (color < 10) color = 0;
|
||||||
|
SetLedPlanar(x / 2, y, (byte)color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnsureRowInRange(int row)
|
private void EnsureRowInRange(int row)
|
||||||
|
|||||||
30
app/Aura.cs
30
app/Aura.cs
@@ -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;
|
||||||
@@ -92,7 +91,7 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
if (GetModes().ContainsKey(value))
|
if (GetModes().ContainsKey(value))
|
||||||
mode = value;
|
mode = value;
|
||||||
else
|
else
|
||||||
mode = 0;
|
mode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
{
|
{
|
||||||
@@ -158,7 +173,7 @@ namespace GHelper
|
|||||||
if (shutdown) flags.Add(AuraDev19b6.ShutdownKeyb);
|
if (shutdown) flags.Add(AuraDev19b6.ShutdownKeyb);
|
||||||
|
|
||||||
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
|
byte[] msg = AuraDev19b6Extensions.ToBytes(flags.ToArray());
|
||||||
|
|
||||||
Debug.WriteLine(BitConverter.ToString(msg));
|
Debug.WriteLine(BitConverter.ToString(msg));
|
||||||
|
|
||||||
foreach (HidDevice device in HidDeviceList)
|
foreach (HidDevice device in HidDeviceList)
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
150
app/Keyboard.Designer.cs
generated
150
app/Keyboard.Designer.cs
generated
@@ -41,14 +41,18 @@ 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();
|
||||||
groupBox1.SuspendLayout();
|
groupBox1.SuspendLayout();
|
||||||
groupLight.SuspendLayout();
|
groupLight.SuspendLayout();
|
||||||
|
groupOther.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBox1
|
// groupBox1
|
||||||
@@ -65,7 +69,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 +162,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 +192,84 @@ 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(checkKeyboardAuto);
|
||||||
|
groupOther.Controls.Add(checkTopmost);
|
||||||
|
groupOther.Dock = DockStyle.Top;
|
||||||
|
groupOther.Location = new Point(10, 556);
|
||||||
|
groupOther.Name = "groupOther";
|
||||||
|
groupOther.Size = new Size(756, 167);
|
||||||
|
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;
|
||||||
//
|
//
|
||||||
// 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 +280,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 +309,8 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,8 +78,25 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -588,7 +588,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 +598,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ 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");
|
||||||
|
settingsForm.AutoKeyboard(SystemInformation.PowerStatus.PowerLineStatus);
|
||||||
SetAutoModes(true);
|
SetAutoModes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -133,6 +134,8 @@ namespace GHelper
|
|||||||
|
|
||||||
labelModel.Text = model;
|
labelModel.Text = model;
|
||||||
|
|
||||||
|
this.TopMost = Program.config.getConfig("topmost") == 1;
|
||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await Task.Delay(TimeSpan.FromSeconds(5));
|
await Task.Delay(TimeSpan.FromSeconds(5));
|
||||||
@@ -687,8 +690,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)
|
||||||
@@ -714,7 +716,7 @@ 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);
|
||||||
|
|
||||||
@@ -744,12 +746,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -999,6 +997,19 @@ namespace GHelper
|
|||||||
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
|
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void AutoKeyboard(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||||
|
{
|
||||||
|
if (Program.config.getConfig("keyboard_auto") != 1) return;
|
||||||
|
|
||||||
|
if (Plugged == PowerLineStatus.Online)
|
||||||
|
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Up);
|
||||||
|
else
|
||||||
|
Program.wmi.DeviceSet(ASUSWmi.UniversalControl, ASUSWmi.KB_Light_Down);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
|
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||||
{
|
{
|
||||||
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
||||||
|
|||||||
Reference in New Issue
Block a user