mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84a3f01267 | ||
|
|
f9488fbf2f | ||
|
|
43d2ed656a | ||
|
|
e9fa181d4e | ||
|
|
58aa838e51 | ||
|
|
96c85f69fe | ||
|
|
8f215dafab | ||
|
|
b3636fd447 | ||
|
|
ed579f25d6 | ||
|
|
6a71a64c96 | ||
|
|
ac69f1317e | ||
|
|
4b38d380b5 | ||
|
|
9a2f9afe5b | ||
|
|
ce9ec1b6df | ||
|
|
e68282050b | ||
|
|
6b8f61fab4 | ||
|
|
f59070cb96 | ||
|
|
f47a00fde2 | ||
|
|
b15c15974e | ||
|
|
b5c47de3f2 |
26
ASUSWmi.cs
26
ASUSWmi.cs
@@ -1,6 +1,6 @@
|
||||
using System.Management;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Diagnostics;
|
||||
|
||||
public class ASUSWmi
|
||||
{
|
||||
@@ -25,6 +25,13 @@ public class ASUSWmi
|
||||
public const uint DevsCPUFanCurve = 0x00110024;
|
||||
public const uint DevsGPUFanCurve = 0x00110025;
|
||||
|
||||
public const int PPT_TotalA0 = 0x001200A0;
|
||||
public const int PPT_TotalA1 = 0x001200A1;
|
||||
|
||||
public const int PPT_CPUB0 = 0x001200B0;
|
||||
public const int PPT_CPUB1 = 0x001200B1;
|
||||
public const int PPT_CPUA2 = 0x001200A2;
|
||||
|
||||
public const int PerformanceBalanced = 0;
|
||||
public const int PerformanceTurbo = 1;
|
||||
public const int PerformanceSilent = 2;
|
||||
@@ -162,9 +169,14 @@ public class ASUSWmi
|
||||
public void SetFanCurve(int device, byte[] curve)
|
||||
{
|
||||
|
||||
if (device == 1)
|
||||
if (curve.Length != 16) return;
|
||||
if (curve.All(singleByte => singleByte == 0)) return;
|
||||
|
||||
Debug.WriteLine(BitConverter.ToString(curve));
|
||||
|
||||
if (device == 1)
|
||||
DeviceSet(DevsGPUFanCurve, curve);
|
||||
else
|
||||
else
|
||||
DeviceSet(DevsCPUFanCurve, curve);
|
||||
}
|
||||
|
||||
@@ -175,14 +187,14 @@ public class ASUSWmi
|
||||
// because it's asus, and modes are swapped here
|
||||
switch (mode)
|
||||
{
|
||||
case 1:fan_mode = 2; break;
|
||||
case 1: fan_mode = 2; break;
|
||||
case 2: fan_mode = 1; break;
|
||||
default: fan_mode = 0; break;
|
||||
}
|
||||
|
||||
if (device == 1)
|
||||
if (device == 1)
|
||||
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
|
||||
else
|
||||
else
|
||||
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
|
||||
|
||||
}
|
||||
|
||||
230
AnimeMatrix/AnimeMatrixDevice.cs
Normal file
230
AnimeMatrix/AnimeMatrixDevice.cs
Normal file
@@ -0,0 +1,230 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
||||
|
||||
using System.Text;
|
||||
using Starlight.Communication;
|
||||
|
||||
namespace Starlight.AnimeMatrix
|
||||
{
|
||||
|
||||
public class BuiltInAnimation
|
||||
{
|
||||
public enum Startup
|
||||
{
|
||||
GlitchConstruction,
|
||||
StaticEmergence
|
||||
}
|
||||
|
||||
public enum Shutdown
|
||||
{
|
||||
GlitchOut,
|
||||
SeeYa
|
||||
}
|
||||
|
||||
public enum Sleeping
|
||||
{
|
||||
BannerSwipe,
|
||||
Starfield
|
||||
}
|
||||
|
||||
public enum Running
|
||||
{
|
||||
BinaryBannerScroll,
|
||||
RogLogoGlitch
|
||||
}
|
||||
|
||||
public byte AsByte { get; }
|
||||
|
||||
public BuiltInAnimation(
|
||||
Running running,
|
||||
Sleeping sleeping,
|
||||
Shutdown shutdown,
|
||||
Startup startup
|
||||
)
|
||||
{
|
||||
AsByte |= (byte)(((int)running & 0x01) << 0);
|
||||
AsByte |= (byte)(((int)sleeping & 0x01) << 1);
|
||||
AsByte |= (byte)(((int)shutdown & 0x01) << 2);
|
||||
AsByte |= (byte)(((int)startup & 0x01) << 3);
|
||||
}
|
||||
}
|
||||
|
||||
internal class AnimeMatrixPacket : Packet
|
||||
{
|
||||
public AnimeMatrixPacket(byte[] command)
|
||||
: base(0x5E, 640, command)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public enum BrightnessMode : byte
|
||||
{
|
||||
Off = 0,
|
||||
Dim = 1,
|
||||
Medium = 2,
|
||||
Full = 3
|
||||
}
|
||||
|
||||
|
||||
public class AnimeMatrixDevice : Device
|
||||
{
|
||||
private const int UpdatePageLength = 0x0278;
|
||||
|
||||
public int LedCount => 1450;
|
||||
public int Rows => 61;
|
||||
|
||||
private readonly byte[] _displayBuffer = new byte[UpdatePageLength * 3];
|
||||
|
||||
public AnimeMatrixDevice()
|
||||
: base(0x0B05, 0x193B, 640)
|
||||
{
|
||||
}
|
||||
|
||||
public void SendRaw(params byte[] data)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(data));
|
||||
}
|
||||
|
||||
|
||||
public int EmptyColumns(int row)
|
||||
{
|
||||
return (int)Math.Ceiling(Math.Max(0, row - 11) / 2.0);
|
||||
}
|
||||
public int Columns(int row)
|
||||
{
|
||||
EnsureRowInRange(row);
|
||||
return 34 - EmptyColumns(row);
|
||||
}
|
||||
|
||||
public int RowToLinearAddress(int row)
|
||||
{
|
||||
EnsureRowInRange(row);
|
||||
|
||||
var ret = 0;
|
||||
|
||||
if (row > 0)
|
||||
{
|
||||
for (var i = 0; i < row; i++)
|
||||
ret += Columns(i);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void WakeUp()
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(Encoding.ASCII.GetBytes("ASUS Tech.Inc.")));
|
||||
}
|
||||
|
||||
public void SetLedLinear(int address, byte value)
|
||||
{
|
||||
EnsureAddressableLed(address);
|
||||
_displayBuffer[address] = value;
|
||||
}
|
||||
|
||||
public void SetLedLinearImmediate(int address, byte value)
|
||||
{
|
||||
EnsureAddressableLed(address);
|
||||
_displayBuffer[address] = value;
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(address + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)0x0001))
|
||||
.AppendData(value)
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||
}
|
||||
|
||||
public void SetLedPlanar(int x, int y, byte value)
|
||||
{
|
||||
EnsureRowInRange(y);
|
||||
var ledsInRow = Columns(y);
|
||||
var start = RowToLinearAddress(y) - EmptyColumns(y);
|
||||
|
||||
if (x > EmptyColumns(y))
|
||||
SetLedLinear(start + x, value);
|
||||
}
|
||||
|
||||
public void Clear(bool present = false)
|
||||
{
|
||||
for (var i = 0; i < _displayBuffer.Length; i++)
|
||||
_displayBuffer[i] = 0;
|
||||
|
||||
if (present)
|
||||
Present();
|
||||
}
|
||||
|
||||
public void Present()
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 0 + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
||||
.AppendData(_displayBuffer[(UpdatePageLength * 0)..(UpdatePageLength * 1)])
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 1 + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)UpdatePageLength))
|
||||
.AppendData(_displayBuffer[(UpdatePageLength * 1)..(UpdatePageLength * 2)])
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x02)
|
||||
.AppendData(BitConverter.GetBytes((ushort)(UpdatePageLength * 2 + 1)))
|
||||
.AppendData(BitConverter.GetBytes((ushort)(LedCount - UpdatePageLength * 2)))
|
||||
.AppendData(
|
||||
_displayBuffer[(UpdatePageLength * 2)..(UpdatePageLength * 2 + (LedCount - UpdatePageLength * 2))])
|
||||
);
|
||||
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x03));
|
||||
}
|
||||
|
||||
public void SetDisplayState(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC3, 0x01)
|
||||
.AppendData(0x00));
|
||||
}
|
||||
else
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC3, 0x01)
|
||||
.AppendData(0x80));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBrightness(BrightnessMode mode)
|
||||
{
|
||||
Set(Packet<AnimeMatrixPacket>(0xC0, 0x04)
|
||||
.AppendData((byte)mode)
|
||||
);
|
||||
}
|
||||
|
||||
public void SetBuiltInAnimation(bool enable)
|
||||
{
|
||||
var enabled = enable ? (byte)0x00 : (byte)0x80;
|
||||
Set(Packet<AnimeMatrixPacket>(0xC4, 0x01, enabled));
|
||||
}
|
||||
|
||||
public void SetBuiltInAnimation(bool enable, BuiltInAnimation animation)
|
||||
{
|
||||
SetBuiltInAnimation(enable);
|
||||
Set(Packet<AnimeMatrixPacket>(0xC5, animation.AsByte));
|
||||
}
|
||||
|
||||
private void EnsureRowInRange(int row)
|
||||
{
|
||||
if (row < 0 || row >= Rows)
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Y-coordinate should fall in range of [0, {Rows - 1}].");
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureAddressableLed(int address)
|
||||
{
|
||||
if (address < 0 || address >= LedCount)
|
||||
{
|
||||
throw new IndexOutOfRangeException($"Linear LED address must be in range of [0, {LedCount - 1}].");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
143
AppConfig.cs
Normal file
143
AppConfig.cs
Normal file
@@ -0,0 +1,143 @@
|
||||
using System.Text.Json;
|
||||
public class AppConfig
|
||||
{
|
||||
|
||||
public string appPath;
|
||||
string configFile;
|
||||
|
||||
public Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public AppConfig()
|
||||
{
|
||||
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
configFile = appPath + "\\config.json";
|
||||
|
||||
if (!System.IO.Directory.Exists(appPath))
|
||||
System.IO.Directory.CreateDirectory(appPath);
|
||||
|
||||
if (File.Exists(configFile))
|
||||
{
|
||||
string text = File.ReadAllText(configFile);
|
||||
try
|
||||
{
|
||||
config = JsonSerializer.Deserialize<Dictionary<string, object>>(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initConfig()
|
||||
{
|
||||
config = new Dictionary<string, object>();
|
||||
config["performance_mode"] = 0;
|
||||
string jsonString = JsonSerializer.Serialize(config);
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public int getConfig(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return int.Parse(config[name].ToString());
|
||||
else return -1;
|
||||
}
|
||||
|
||||
public string getConfigString(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return config[name].ToString();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public void setConfig(string name, int value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public void setConfig(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public string getParamName(int device, string paramName = "fan_profile")
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
string name;
|
||||
|
||||
if (device == 1)
|
||||
name = "gpu";
|
||||
else
|
||||
name = "cpu";
|
||||
|
||||
return paramName + "_" + name + "_" + mode;
|
||||
}
|
||||
|
||||
public byte[] getFanConfig(int device)
|
||||
{
|
||||
string curveString = getConfigString(getParamName(device));
|
||||
byte[] curve = { };
|
||||
|
||||
if (curveString is not null)
|
||||
curve = StringToBytes(curveString);
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
public void setFanConfig(int device, byte[] curve)
|
||||
{
|
||||
string bitCurve = BitConverter.ToString(curve);
|
||||
setConfig(getParamName(device), bitCurve);
|
||||
}
|
||||
|
||||
|
||||
public static byte[] StringToBytes(string str)
|
||||
{
|
||||
String[] arr = str.Split('-');
|
||||
byte[] array = new byte[arr.Length];
|
||||
for (int i = 0; i < arr.Length; i++) array[i] = Convert.ToByte(arr[i], 16);
|
||||
return array;
|
||||
}
|
||||
|
||||
public byte[] getDefaultCurve(int device)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
byte[] curve;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
|
||||
else
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
|
||||
break;
|
||||
case 2:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
|
||||
else
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
|
||||
break;
|
||||
default:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
|
||||
else
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
|
||||
break;
|
||||
}
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
}
|
||||
16
Aura.cs
16
Aura.cs
@@ -10,7 +10,7 @@ public class Aura
|
||||
public const int Breathe = 1;
|
||||
public const int Strobe = 2;
|
||||
public const int Rainbow = 3;
|
||||
public const int Dingding = 10;
|
||||
public const int Dingding = 4;
|
||||
|
||||
public const int SpeedSlow = 0xe1;
|
||||
public const int SpeedMedium = 0xeb;
|
||||
@@ -47,6 +47,20 @@ public class Aura
|
||||
|
||||
HidDeviceList = HidDevices.Enumerate(0x0b05, deviceIds).ToArray();
|
||||
|
||||
if (Mode == Dingding)
|
||||
{
|
||||
Mode = 10;
|
||||
Speed = SpeedMedium;
|
||||
}
|
||||
else if (Mode == Rainbow)
|
||||
{
|
||||
Speed = SpeedMedium;
|
||||
}
|
||||
else
|
||||
{
|
||||
Speed = SpeedSlow;
|
||||
}
|
||||
|
||||
foreach (HidDevice device in HidDeviceList)
|
||||
{
|
||||
if (device.IsConnected)
|
||||
|
||||
33
Communication/Device.cs
Normal file
33
Communication/Device.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
||||
|
||||
|
||||
using Starlight.Communication.Platform;
|
||||
|
||||
namespace Starlight.Communication
|
||||
{
|
||||
public abstract class Device : IDisposable
|
||||
{
|
||||
private static UsbProvider _usbProvider;
|
||||
|
||||
protected Device(ushort vendorId, ushort productId, int maxFeatureReportLength)
|
||||
{
|
||||
_usbProvider = new WindowsUsbProvider(vendorId, productId, maxFeatureReportLength);
|
||||
}
|
||||
|
||||
protected T Packet<T>(params byte[] command) where T : Packet
|
||||
{
|
||||
return (T)Activator.CreateInstance(typeof(T), command)!;
|
||||
}
|
||||
|
||||
public void Set(Packet packet)
|
||||
=> _usbProvider?.Set(packet.Data);
|
||||
|
||||
public byte[] Get(Packet packet)
|
||||
=> _usbProvider?.Get(packet.Data);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_usbProvider?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
61
Communication/Packet.cs
Normal file
61
Communication/Packet.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
// Source thanks to https://github.com/vddCore/Starlight :)
|
||||
|
||||
using System.ComponentModel;
|
||||
using HidSharp;
|
||||
|
||||
namespace Starlight.Communication
|
||||
{
|
||||
public abstract class Packet
|
||||
{
|
||||
private int _currentDataIndex = 1;
|
||||
|
||||
public byte[] Data { get; }
|
||||
|
||||
internal Packet(byte reportId, int packetLength, params byte[] data)
|
||||
{
|
||||
if (packetLength < 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(packetLength),
|
||||
"Packet length must be at least 1."
|
||||
);
|
||||
}
|
||||
|
||||
Data = new byte[packetLength];
|
||||
Data[0] = reportId;
|
||||
|
||||
if (data.Length > 0)
|
||||
{
|
||||
if (_currentDataIndex >= Data.Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(
|
||||
nameof(data),
|
||||
"Your packet length does not allow for initial data to be appended."
|
||||
);
|
||||
}
|
||||
|
||||
AppendData(data);
|
||||
}
|
||||
}
|
||||
|
||||
public Packet AppendData(params byte[] data)
|
||||
=> AppendData(out _, data);
|
||||
|
||||
public Packet AppendData(out int bytesWritten, params byte[] data)
|
||||
{
|
||||
bytesWritten = 0;
|
||||
|
||||
for (var i = 0;
|
||||
i < data.Length && _currentDataIndex < Data.Length - 1;
|
||||
i++, bytesWritten++, _currentDataIndex++)
|
||||
{
|
||||
if (_currentDataIndex > Data.Length - 1)
|
||||
break;
|
||||
|
||||
Data[_currentDataIndex] = data[i];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Communication/Platform/UsbProvider.cs
Normal file
19
Communication/Platform/UsbProvider.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Starlight.Communication.Platform
|
||||
{
|
||||
internal abstract class UsbProvider : IDisposable
|
||||
{
|
||||
protected ushort VendorID { get; }
|
||||
protected ushort ProductID { get; }
|
||||
|
||||
protected UsbProvider(ushort vendorId, ushort productId)
|
||||
{
|
||||
VendorID = vendorId;
|
||||
ProductID = productId;
|
||||
}
|
||||
|
||||
public abstract void Set(byte[] data);
|
||||
public abstract byte[] Get(byte[] data);
|
||||
|
||||
public abstract void Dispose();
|
||||
}
|
||||
}
|
||||
79
Communication/Platform/WindowsUsbProvider.cs
Normal file
79
Communication/Platform/WindowsUsbProvider.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System.ComponentModel;
|
||||
using HidSharp;
|
||||
|
||||
namespace Starlight.Communication.Platform
|
||||
{
|
||||
internal class WindowsUsbProvider : UsbProvider
|
||||
{
|
||||
protected HidDevice HidDevice { get; }
|
||||
protected HidStream HidStream { get; }
|
||||
|
||||
public WindowsUsbProvider(ushort vendorId, ushort productId, int maxFeatureReportLength)
|
||||
: base(vendorId, productId)
|
||||
{
|
||||
try
|
||||
{
|
||||
HidDevice = DeviceList.Local
|
||||
.GetHidDevices(vendorId, productId)
|
||||
.First(x => x.GetMaxFeatureReportLength() == maxFeatureReportLength);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw new IOException("AniMe Matrix control device was not found on your machine.");
|
||||
}
|
||||
|
||||
var config = new OpenConfiguration();
|
||||
config.SetOption(OpenOption.Interruptible, true);
|
||||
config.SetOption(OpenOption.Exclusive, false);
|
||||
config.SetOption(OpenOption.Priority, 10);
|
||||
|
||||
HidStream = HidDevice.Open(config);
|
||||
}
|
||||
|
||||
public override void Set(byte[] data)
|
||||
{
|
||||
WrapException(() =>
|
||||
{
|
||||
HidStream.SetFeature(data);
|
||||
HidStream.Flush();
|
||||
});
|
||||
}
|
||||
|
||||
public override byte[] Get(byte[] data)
|
||||
{
|
||||
var outData = new byte[data.Length];
|
||||
Array.Copy(data, outData, data.Length);
|
||||
|
||||
WrapException(() =>
|
||||
{
|
||||
HidStream.GetFeature(outData);
|
||||
HidStream.Flush();
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
HidStream.Dispose();
|
||||
}
|
||||
|
||||
private void WrapException(Action action)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
if (e.InnerException is Win32Exception w32e)
|
||||
{
|
||||
if (w32e.NativeErrorCode != 0)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
190
Fans.Designer.cs
generated
190
Fans.Designer.cs
generated
@@ -34,23 +34,39 @@
|
||||
buttonApply = new Button();
|
||||
buttonReset = new Button();
|
||||
chartGPU = new System.Windows.Forms.DataVisualization.Charting.Chart();
|
||||
groupBox1 = new GroupBox();
|
||||
labelApplied = new Label();
|
||||
pictureFine = new PictureBox();
|
||||
labelInfo = new Label();
|
||||
labelCPU = new Label();
|
||||
labelTotal = new Label();
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
trackCPU = new TrackBar();
|
||||
trackTotal = new TrackBar();
|
||||
buttonApplyPower = new Button();
|
||||
checkAuto = new CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
|
||||
groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureFine).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackCPU).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackTotal).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// chartCPU
|
||||
//
|
||||
chartArea1.Name = "ChartArea1";
|
||||
chartCPU.ChartAreas.Add(chartArea1);
|
||||
chartCPU.Location = new Point(16, 13);
|
||||
chartCPU.Location = new Point(362, 30);
|
||||
chartCPU.Name = "chartCPU";
|
||||
chartCPU.Size = new Size(900, 480);
|
||||
chartCPU.Size = new Size(772, 464);
|
||||
chartCPU.TabIndex = 0;
|
||||
chartCPU.Text = "chartCPU";
|
||||
//
|
||||
// buttonApply
|
||||
//
|
||||
buttonApply.Location = new Point(661, 1016);
|
||||
buttonApply.Location = new Point(879, 1016);
|
||||
buttonApply.Name = "buttonApply";
|
||||
buttonApply.Size = new Size(254, 46);
|
||||
buttonApply.TabIndex = 1;
|
||||
@@ -59,7 +75,7 @@
|
||||
//
|
||||
// buttonReset
|
||||
//
|
||||
buttonReset.Location = new Point(16, 1016);
|
||||
buttonReset.Location = new Point(362, 1016);
|
||||
buttonReset.Name = "buttonReset";
|
||||
buttonReset.Size = new Size(254, 46);
|
||||
buttonReset.TabIndex = 2;
|
||||
@@ -70,17 +86,157 @@
|
||||
//
|
||||
chartArea2.Name = "ChartArea1";
|
||||
chartGPU.ChartAreas.Add(chartArea2);
|
||||
chartGPU.Location = new Point(16, 513);
|
||||
chartGPU.Location = new Point(362, 511);
|
||||
chartGPU.Name = "chartGPU";
|
||||
chartGPU.Size = new Size(900, 480);
|
||||
chartGPU.Size = new Size(772, 480);
|
||||
chartGPU.TabIndex = 3;
|
||||
chartGPU.Text = "chart1";
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(labelApplied);
|
||||
groupBox1.Controls.Add(pictureFine);
|
||||
groupBox1.Controls.Add(labelInfo);
|
||||
groupBox1.Controls.Add(labelCPU);
|
||||
groupBox1.Controls.Add(labelTotal);
|
||||
groupBox1.Controls.Add(label2);
|
||||
groupBox1.Controls.Add(label1);
|
||||
groupBox1.Controls.Add(trackCPU);
|
||||
groupBox1.Controls.Add(trackTotal);
|
||||
groupBox1.Location = new Point(12, 12);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Padding = new Padding(5);
|
||||
groupBox1.Size = new Size(330, 979);
|
||||
groupBox1.TabIndex = 4;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Power Limits (PPT)";
|
||||
//
|
||||
// labelApplied
|
||||
//
|
||||
labelApplied.AutoSize = true;
|
||||
labelApplied.ForeColor = Color.Tomato;
|
||||
labelApplied.Location = new Point(14, 39);
|
||||
labelApplied.Name = "labelApplied";
|
||||
labelApplied.Size = new Size(143, 32);
|
||||
labelApplied.TabIndex = 13;
|
||||
labelApplied.Text = "Not Applied";
|
||||
//
|
||||
// pictureFine
|
||||
//
|
||||
pictureFine.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
pictureFine.BackgroundImage = Properties.Resources.everything_is_fine_itsfine;
|
||||
pictureFine.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureFine.Location = new Point(9, 731);
|
||||
pictureFine.Name = "pictureFine";
|
||||
pictureFine.Size = new Size(311, 240);
|
||||
pictureFine.TabIndex = 12;
|
||||
pictureFine.TabStop = false;
|
||||
pictureFine.Visible = false;
|
||||
//
|
||||
// labelInfo
|
||||
//
|
||||
labelInfo.AutoSize = true;
|
||||
labelInfo.Dock = DockStyle.Bottom;
|
||||
labelInfo.Location = new Point(5, 942);
|
||||
labelInfo.Name = "labelInfo";
|
||||
labelInfo.Size = new Size(65, 32);
|
||||
labelInfo.TabIndex = 11;
|
||||
labelInfo.Text = "label";
|
||||
//
|
||||
// labelCPU
|
||||
//
|
||||
labelCPU.AutoSize = true;
|
||||
labelCPU.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelCPU.Location = new Point(197, 125);
|
||||
labelCPU.Name = "labelCPU";
|
||||
labelCPU.Size = new Size(61, 32);
|
||||
labelCPU.TabIndex = 10;
|
||||
labelCPU.Text = "CPU";
|
||||
labelCPU.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// labelTotal
|
||||
//
|
||||
labelTotal.AutoSize = true;
|
||||
labelTotal.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelTotal.Location = new Point(39, 125);
|
||||
labelTotal.Name = "labelTotal";
|
||||
labelTotal.Size = new Size(70, 32);
|
||||
labelTotal.TabIndex = 9;
|
||||
labelTotal.Text = "Total";
|
||||
labelTotal.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(200, 91);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 32);
|
||||
label2.TabIndex = 8;
|
||||
label2.Text = "CPU";
|
||||
label2.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(41, 91);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(65, 32);
|
||||
label1.TabIndex = 7;
|
||||
label1.Text = "Total";
|
||||
label1.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// trackCPU
|
||||
//
|
||||
trackCPU.Location = new Point(203, 178);
|
||||
trackCPU.Maximum = 85;
|
||||
trackCPU.Minimum = 15;
|
||||
trackCPU.Name = "trackCPU";
|
||||
trackCPU.Orientation = Orientation.Vertical;
|
||||
trackCPU.Size = new Size(90, 444);
|
||||
trackCPU.TabIndex = 6;
|
||||
trackCPU.TickFrequency = 5;
|
||||
trackCPU.Value = 80;
|
||||
//
|
||||
// trackTotal
|
||||
//
|
||||
trackTotal.Location = new Point(42, 178);
|
||||
trackTotal.Maximum = 150;
|
||||
trackTotal.Minimum = 15;
|
||||
trackTotal.Name = "trackTotal";
|
||||
trackTotal.Orientation = Orientation.Vertical;
|
||||
trackTotal.Size = new Size(90, 444);
|
||||
trackTotal.TabIndex = 5;
|
||||
trackTotal.TickFrequency = 5;
|
||||
trackTotal.TickStyle = TickStyle.TopLeft;
|
||||
trackTotal.Value = 125;
|
||||
//
|
||||
// buttonApplyPower
|
||||
//
|
||||
buttonApplyPower.Location = new Point(15, 1016);
|
||||
buttonApplyPower.Name = "buttonApplyPower";
|
||||
buttonApplyPower.Size = new Size(327, 46);
|
||||
buttonApplyPower.TabIndex = 11;
|
||||
buttonApplyPower.Text = "Apply Power Limits";
|
||||
buttonApplyPower.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkAuto
|
||||
//
|
||||
checkAuto.AutoSize = true;
|
||||
checkAuto.Location = new Point(708, 1022);
|
||||
checkAuto.Name = "checkAuto";
|
||||
checkAuto.Size = new Size(165, 36);
|
||||
checkAuto.TabIndex = 12;
|
||||
checkAuto.Text = "Auto Apply";
|
||||
checkAuto.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Fans
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(13F, 32F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(940, 1089);
|
||||
ClientSize = new Size(1154, 1089);
|
||||
Controls.Add(checkAuto);
|
||||
Controls.Add(buttonApplyPower);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(chartGPU);
|
||||
Controls.Add(buttonReset);
|
||||
Controls.Add(buttonApply);
|
||||
@@ -93,10 +249,16 @@
|
||||
ShowIcon = false;
|
||||
ShowInTaskbar = false;
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Fans";
|
||||
Text = "Fans and Power";
|
||||
((System.ComponentModel.ISupportInitialize)chartCPU).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartGPU).EndInit();
|
||||
groupBox1.ResumeLayout(false);
|
||||
groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureFine).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackCPU).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)trackTotal).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -105,5 +267,17 @@
|
||||
private Button buttonApply;
|
||||
private Button buttonReset;
|
||||
private System.Windows.Forms.DataVisualization.Charting.Chart chartGPU;
|
||||
private GroupBox groupBox1;
|
||||
private Label labelCPU;
|
||||
private Label labelTotal;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private TrackBar trackCPU;
|
||||
private TrackBar trackTotal;
|
||||
private Button buttonApplyPower;
|
||||
private Label labelInfo;
|
||||
private PictureBox pictureFine;
|
||||
private Label labelApplied;
|
||||
private CheckBox checkAuto;
|
||||
}
|
||||
}
|
||||
202
Fans.cs
202
Fans.cs
@@ -11,6 +11,14 @@ namespace GHelper
|
||||
Series seriesCPU;
|
||||
Series seriesGPU;
|
||||
|
||||
const int MaxTotal = 150;
|
||||
const int MinTotal = 15;
|
||||
const int DefaultTotal = 125;
|
||||
|
||||
const int MaxCPU = 90;
|
||||
const int MinCPU = 15;
|
||||
const int DefaultCPU = 80;
|
||||
|
||||
void SetChart(Chart chart, int device)
|
||||
{
|
||||
|
||||
@@ -35,10 +43,19 @@ namespace GHelper
|
||||
chart.ChartAreas[0].AxisX.Minimum = 10;
|
||||
chart.ChartAreas[0].AxisX.Maximum = 100;
|
||||
chart.ChartAreas[0].AxisX.Interval = 10;
|
||||
|
||||
chart.ChartAreas[0].AxisY.Minimum = 0;
|
||||
chart.ChartAreas[0].AxisY.Maximum = 100;
|
||||
|
||||
chart.ChartAreas[0].AxisX.Interval = 10;
|
||||
chart.ChartAreas[0].AxisY.LabelStyle.Font = new Font("Arial", 7F);
|
||||
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(-2, 2, "OFF");
|
||||
|
||||
for (int i = 1; i <= 9; i++)
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(i * 10 - 2, i * 10 + 2, (1800 + 400 * i).ToString());
|
||||
|
||||
chart.ChartAreas[0].AxisY.CustomLabels.Add(98, 102, "RPM");
|
||||
|
||||
chart.ChartAreas[0].AxisY.Interval = 10;
|
||||
|
||||
if (chart.Legends.Count > 0)
|
||||
@@ -57,14 +74,14 @@ namespace GHelper
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
FormClosing += Fans_FormClosing;
|
||||
|
||||
seriesCPU = chartCPU.Series.Add("CPU");
|
||||
seriesGPU = chartGPU.Series.Add("GPU");
|
||||
|
||||
seriesCPU.Color = Color.Blue;
|
||||
seriesGPU.Color = Color.Red;
|
||||
|
||||
LoadFans();
|
||||
|
||||
chartCPU.MouseMove += ChartCPU_MouseMove;
|
||||
chartCPU.MouseUp += ChartCPU_MouseUp;
|
||||
|
||||
@@ -74,10 +91,119 @@ namespace GHelper
|
||||
buttonReset.Click += ButtonReset_Click;
|
||||
buttonApply.Click += ButtonApply_Click;
|
||||
|
||||
trackTotal.Maximum = MaxTotal;
|
||||
trackTotal.Minimum = MinTotal;
|
||||
|
||||
trackCPU.Maximum = MaxCPU;
|
||||
trackCPU.Minimum = MinCPU;
|
||||
|
||||
trackCPU.Scroll += TrackCPU_Scroll;
|
||||
trackTotal.Scroll += TrackTotal_Scroll;
|
||||
|
||||
buttonApplyPower.Click += ButtonApplyPower_Click;
|
||||
|
||||
checkAuto.Click += CheckAuto_Click;
|
||||
|
||||
//labelInfo.MaximumSize = new Size(280, 0);
|
||||
labelInfo.Text = "Power Limits (PPT) is\nexperimental feature.\n\nValues will be applied\nonly after you click 'Apply'\nand reset after performance\nmode changes.\n\nUse carefully and\non your own risk!";
|
||||
|
||||
LoadFans();
|
||||
VisualisePower(true);
|
||||
|
||||
Shown += Fans_Shown;
|
||||
|
||||
}
|
||||
|
||||
private void CheckAuto_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is null)
|
||||
return;
|
||||
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
|
||||
Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), chk.Checked ? 1 : 0);
|
||||
}
|
||||
|
||||
private void Fans_FormClosing(object? sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (e.CloseReason == CloseReason.UserClosing)
|
||||
{
|
||||
e.Cancel = true;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonApplyPower_Click(object? sender, EventArgs e)
|
||||
{
|
||||
int limit_total = trackTotal.Value;
|
||||
int limit_cpu = trackCPU.Value;
|
||||
|
||||
Program.config.setConfig("limit_total", limit_total);
|
||||
Program.config.setConfig("limit_cpu", limit_cpu);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA0, limit_total);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_TotalA1, limit_total);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUB0, limit_cpu);
|
||||
Program.wmi.DeviceSet(ASUSWmi.PPT_CPUA2, limit_cpu);
|
||||
|
||||
labelApplied.ForeColor = Color.Blue;
|
||||
labelApplied.Text = "Applied";
|
||||
|
||||
}
|
||||
|
||||
public void VisualisePower(bool init = false)
|
||||
{
|
||||
|
||||
int limit_total;
|
||||
int limit_cpu;
|
||||
|
||||
if (init)
|
||||
{
|
||||
limit_total = Program.config.getConfig("limit_total");
|
||||
limit_cpu = Program.config.getConfig("limit_cpu");
|
||||
}
|
||||
else
|
||||
{
|
||||
limit_total = trackTotal.Value;
|
||||
limit_cpu = trackCPU.Value;
|
||||
}
|
||||
|
||||
if (limit_total < 0) limit_total = DefaultTotal;
|
||||
if (limit_total > MaxTotal) limit_total = MaxTotal;
|
||||
if (limit_total < MinTotal) limit_total = MinTotal;
|
||||
|
||||
if (limit_cpu < 0) limit_cpu = DefaultCPU;
|
||||
if (limit_cpu > MaxCPU) limit_cpu = MaxCPU;
|
||||
if (limit_cpu < MinCPU) limit_cpu = MinCPU;
|
||||
|
||||
if (limit_cpu > limit_total) limit_cpu = limit_total;
|
||||
|
||||
trackTotal.Value = limit_total;
|
||||
trackCPU.Value = limit_cpu;
|
||||
|
||||
labelTotal.Text = trackTotal.Value.ToString() + "W";
|
||||
labelCPU.Text = trackCPU.Value.ToString() + "W";
|
||||
|
||||
pictureFine.Visible = (limit_cpu > 85 || limit_total > 145);
|
||||
}
|
||||
|
||||
private void TrackTotal_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
VisualisePower();
|
||||
}
|
||||
|
||||
private void TrackCPU_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
VisualisePower();
|
||||
}
|
||||
|
||||
public void ResetApplyLabel()
|
||||
{
|
||||
labelApplied.ForeColor = Color.Red;
|
||||
labelApplied.Text = "Not Applied";
|
||||
}
|
||||
|
||||
public void LoadFans()
|
||||
{
|
||||
|
||||
@@ -87,28 +213,12 @@ namespace GHelper
|
||||
LoadProfile(seriesCPU, 0);
|
||||
LoadProfile(seriesGPU, 1);
|
||||
|
||||
int auto_apply = Program.config.getConfig("auto_apply_" + Program.config.getConfig("performance_mode"));
|
||||
|
||||
checkAuto.Checked = (auto_apply == 1);
|
||||
|
||||
}
|
||||
|
||||
byte[] StringToBytes(string str)
|
||||
{
|
||||
String[] arr = str.Split('-');
|
||||
byte[] array = new byte[arr.Length];
|
||||
for (int i = 0; i < arr.Length; i++) array[i] = Convert.ToByte(arr[i], 16);
|
||||
return array;
|
||||
}
|
||||
|
||||
string GetFanName(int device)
|
||||
{
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
string name;
|
||||
|
||||
if (device == 1)
|
||||
name = "gpu";
|
||||
else
|
||||
name = "cpu";
|
||||
|
||||
return "fan_profile_" + name + "_" + mode;
|
||||
}
|
||||
|
||||
void LoadProfile(Series series, int device, int def = 0)
|
||||
{
|
||||
@@ -120,42 +230,13 @@ namespace GHelper
|
||||
series.Points.Clear();
|
||||
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
string curveString = Program.config.getConfigString(GetFanName(device));
|
||||
byte[] curve = { };
|
||||
|
||||
if (curveString is not null)
|
||||
curve = StringToBytes(curveString);
|
||||
byte[] curve = Program.config.getFanConfig(device);
|
||||
|
||||
if (def == 1 || curve.Length != 16)
|
||||
curve = Program.wmi.GetFanCurve(device, mode);
|
||||
|
||||
if (curve.All(singleByte => singleByte == 0))
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 1:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-16-1F-26-2D-39-47-55-5F");
|
||||
else
|
||||
curve = StringToBytes("14-3F-44-48-4C-50-54-62-11-1A-22-29-34-43-51-5A");
|
||||
break;
|
||||
case 2:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-08-11-11-1D-1D-26-26-2D");
|
||||
else
|
||||
curve = StringToBytes("3C-41-42-46-47-4B-4C-62-03-0C-0C-16-16-22-22-29");
|
||||
break;
|
||||
default:
|
||||
if (device == 1)
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-0C-16-1D-1F-26-2D-34-4A");
|
||||
else
|
||||
curve = StringToBytes("3A-3D-40-44-48-4D-51-62-08-11-16-1A-22-29-30-45");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (curve.Length != 16 || curve.All(singleByte => singleByte == 0))
|
||||
curve = Program.config.getDefaultCurve(device);
|
||||
|
||||
//Debug.WriteLine(BitConverter.ToString(curve));
|
||||
|
||||
@@ -180,10 +261,7 @@ namespace GHelper
|
||||
i++;
|
||||
}
|
||||
|
||||
string bitCurve = BitConverter.ToString(curve);
|
||||
Debug.WriteLine(bitCurve);
|
||||
Program.config.setConfig(GetFanName(device), bitCurve);
|
||||
|
||||
Program.config.setFanConfig(device, curve);
|
||||
Program.wmi.SetFanCurve(device, curve);
|
||||
|
||||
}
|
||||
@@ -199,7 +277,13 @@ namespace GHelper
|
||||
{
|
||||
LoadProfile(seriesCPU, 0, 1);
|
||||
LoadProfile(seriesGPU, 1, 1);
|
||||
|
||||
checkAuto.Checked = false;
|
||||
Program.config.setConfig("auto_apply_" + Program.config.getConfig("performance_mode"), 0);
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, Program.config.getConfig("performance_mode"));
|
||||
|
||||
ResetApplyLabel();
|
||||
}
|
||||
|
||||
private void ChartCPU_MouseUp(object? sender, MouseEventArgs e)
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
<AssemblyName>GHelper</AssemblyName>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AssemblyVersion>0.9.9.0</AssemblyVersion>
|
||||
<AssemblyVersion>0.15</AssemblyVersion>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -37,9 +38,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="hidlibrary" Version="3.3.40" />
|
||||
<PackageReference Include="HidSharpCore" Version="1.2.1.1" />
|
||||
<PackageReference Include="System.Management" Version="7.0.0" />
|
||||
<PackageReference Include="TaskScheduler" Version="2.10.1" />
|
||||
<PackageReference Include="UToolKit" Version="1.1.0.1" />
|
||||
<PackageReference Include="WinForms.DataVisualization" Version="1.7.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
106
Program.cs
106
Program.cs
@@ -1,82 +1,7 @@
|
||||
using Microsoft.Win32;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Text.Json;
|
||||
|
||||
public class AppConfig
|
||||
{
|
||||
|
||||
string appPath;
|
||||
string configFile;
|
||||
|
||||
public Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public AppConfig()
|
||||
{
|
||||
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
configFile = appPath + "\\config.json";
|
||||
|
||||
if (!System.IO.Directory.Exists(appPath))
|
||||
System.IO.Directory.CreateDirectory(appPath);
|
||||
|
||||
if (File.Exists(configFile))
|
||||
{
|
||||
string text = File.ReadAllText(configFile);
|
||||
try
|
||||
{
|
||||
config = JsonSerializer.Deserialize<Dictionary<string, object>>(text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
initConfig();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initConfig()
|
||||
{
|
||||
config = new Dictionary<string, object>();
|
||||
config["performance_mode"] = 0;
|
||||
string jsonString = JsonSerializer.Serialize(config);
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public int getConfig(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return int.Parse(config[name].ToString());
|
||||
else return -1;
|
||||
}
|
||||
|
||||
public string getConfigString(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return config[name].ToString();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public void setConfig(string name, int value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public void setConfig(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
using Starlight.AnimeMatrix;
|
||||
|
||||
public class HardwareMonitor
|
||||
{
|
||||
@@ -137,17 +62,11 @@ namespace GHelper
|
||||
settingsForm.InitBoost();
|
||||
settingsForm.InitAura();
|
||||
|
||||
settingsForm.SetPerformanceMode(config.getConfig("performance_mode"));
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
|
||||
settingsForm.VisualiseGPUAuto(config.getConfig("gpu_auto"));
|
||||
settingsForm.VisualiseScreenAuto(config.getConfig("screen_auto"));
|
||||
|
||||
settingsForm.SetStartupCheck(Startup.IsScheduled());
|
||||
|
||||
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
|
||||
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
|
||||
settingsForm.AutoScreen(isPlugged ? 1 : 0);
|
||||
SetAutoModes();
|
||||
|
||||
SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
|
||||
|
||||
@@ -157,13 +76,18 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
private static void SetAutoModes()
|
||||
{
|
||||
PowerLineStatus isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
settingsForm.AutoGPUMode(isPlugged);
|
||||
settingsForm.AutoScreen(isPlugged);
|
||||
settingsForm.AutoPerformance(isPlugged);
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
}
|
||||
|
||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||
{
|
||||
bool isPlugged = (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online);
|
||||
settingsForm.AutoGPUMode(isPlugged ? 1 : 0);
|
||||
settingsForm.AutoScreen(isPlugged ? 1 : 0);
|
||||
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
SetAutoModes();
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +100,8 @@ namespace GHelper
|
||||
try
|
||||
{
|
||||
Process proc = Process.Start(start);
|
||||
} catch
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Failed to run " + fileName);
|
||||
}
|
||||
@@ -269,6 +194,9 @@ namespace GHelper
|
||||
settingsForm.Show();
|
||||
settingsForm.Activate();
|
||||
}
|
||||
|
||||
settingsForm.VisualiseGPUMode();
|
||||
|
||||
}
|
||||
|
||||
static void TrayIcon_MouseClick(object? sender, MouseEventArgs e)
|
||||
|
||||
20
Properties/Resources.Designer.cs
generated
20
Properties/Resources.Designer.cs
generated
@@ -70,6 +70,16 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap everything_is_fine_itsfine {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("everything-is-fine-itsfine", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@@ -110,6 +120,16 @@ namespace GHelper.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icons8_matrix_desktop_48 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icons8-matrix-desktop-48", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
||||
@@ -133,19 +133,25 @@
|
||||
<data name="icons8-speed-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="everything-is-fine-itsfine" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\everything-is-fine-itsfine.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-speed-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-speed-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-video-card-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-video-card-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-fan-head-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-fan-head-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-charging-battery-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-charging-battery-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-laptop-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-laptop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icons8-fan-head-96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-fan-head-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="icons8-matrix-desktop-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icons8-matrix-desktop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
16
README.md
16
README.md
@@ -2,23 +2,27 @@
|
||||
|
||||
A small utility that allows you do almost everyting you could do with Armory Crate but without extra bloat and unnecessary services.
|
||||
|
||||
### NEW! Experimental feature: **Set Power limits (PPT) - Total and CPU**.
|
||||
|
||||
1. Switch between default **Performance modes** - Silent / Balanced / Turbo and apply default fan curves
|
||||
2. Switch between Eco / Standard or Ultimate **GPU modes**
|
||||
3. Change laptop screen refresh rate - 60hz or your maximum (120hz, 144hz, etc depending on the model) with display overdrive (OD)
|
||||
4. View default fan profiles for every mode and apply custom ones
|
||||
4. View default fan profiles for every mode and **auto apply** custom ones
|
||||
5. Control keyboard backlit animation and colors
|
||||
6. Set battery charge limit to preserve battery
|
||||
7. Monitor CPU temperature, fan speeds and battery discharge rate
|
||||
8. **Automatically switch to Eco(iGPU)/60hz on battery** and back to Standard(GPU)/120hz modes when plugged
|
||||
9. Support for M4 key / FN+F5 to cycle through performance modes (with OSD notification) and FN+F4 to cycle through keeyboard animation modes
|
||||
10. Basic keybindings for M3 amd M4 keys
|
||||
10. Basic keybindings for M3 and M4 keys
|
||||
11. Turn cpu turbo boost on/off with one checkbox to keep temps cooler
|
||||
|
||||
Designed and developer for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.
|
||||
Designed and developed for Asus Zephyrus G14 2022 (with AMD Radeon iGPU and dGPU). But could and should potentially work for G14 of 2021 and 2020, G15, X FLOW, and other ROG models for relevant and supported features.
|
||||
|
||||
To keep autoswitching and hotkeys work app needs to stay in running in tray. It doesn't consume any resources.
|
||||
|
||||
I also recommend to keep "Asus Optimization Service" running , as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working. If you have (or had) MyASUS app installed, that service is most probably still up an running even after MyASUS uninstall.
|
||||
I also recommend to keep "Asus Optimization Service" running, as it keeps basic laptop hotkeys such as screen or keyboard brightness adjustment working. If you have (or had) MyASUS app installed, that service is most probably still up an running even after MyASUS uninstall.
|
||||
|
||||
It's part of [Asus System Controll Interface](https://www.asus.com/support/FAQ/1047338/). You can install it, and later disable / remove unnecesarily services by running [this bat file](https://raw.githubusercontent.com/seerge/g-helper/main/stop-asus-sv.bat ) as admin.
|
||||
|
||||
### [Download latest release](https://github.com/seerge/g-helper/releases)
|
||||
|
||||
@@ -40,10 +44,6 @@ PPTs are shown for G14 2022, for other models PPTs will be different as they are
|
||||
2. Standard mode (Windows Hybrid) : iGPU and dGPU enabled, iGPU drives built in display
|
||||
3. Ultimate mode: iGPU and dGPU enabled, but dGPU drives built in display (supported only on G14 2022 model)
|
||||
|
||||
## Things still missing
|
||||
|
||||
1. Anime matrix control
|
||||
|
||||
## How to install
|
||||
|
||||
1. Download latest release from https://github.com/seerge/g-helper/releases
|
||||
|
||||
BIN
Resources/everything-is-fine-itsfine.gif
Normal file
BIN
Resources/everything-is-fine-itsfine.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 220 KiB |
BIN
Resources/icons8-matrix-desktop-48.png
Normal file
BIN
Resources/icons8-matrix-desktop-48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 428 B |
188
Settings.Designer.cs
generated
188
Settings.Designer.cs
generated
@@ -56,7 +56,7 @@
|
||||
button60Hz = new Button();
|
||||
checkScreen = new CheckBox();
|
||||
checkBoost = new CheckBox();
|
||||
pictureBox1 = new PictureBox();
|
||||
pictureKeyboard = new PictureBox();
|
||||
label1 = new Label();
|
||||
comboKeyboard = new ComboBox();
|
||||
buttonKeyboardColor = new Button();
|
||||
@@ -66,6 +66,11 @@
|
||||
pictureColor = new PictureBox();
|
||||
pictureColor2 = new PictureBox();
|
||||
labelVersion = new Label();
|
||||
pictureMatrix = new PictureBox();
|
||||
labelMatrix = new Label();
|
||||
comboMatrix = new ComboBox();
|
||||
comboMatrixRunning = new ComboBox();
|
||||
buttonMatrix = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)trackBattery).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBattery).BeginInit();
|
||||
tableGPU.SuspendLayout();
|
||||
@@ -74,15 +79,16 @@
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureScreen).BeginInit();
|
||||
tableScreen.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureKeyboard).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureColor).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureColor2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureMatrix).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkStartup
|
||||
//
|
||||
checkStartup.AutoSize = true;
|
||||
checkStartup.Location = new Point(33, 1016);
|
||||
checkStartup.Location = new Point(35, 1138);
|
||||
checkStartup.Margin = new Padding(4, 2, 4, 2);
|
||||
checkStartup.Name = "checkStartup";
|
||||
checkStartup.Size = new Size(206, 36);
|
||||
@@ -95,12 +101,12 @@
|
||||
//
|
||||
trackBattery.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
trackBattery.LargeChange = 20;
|
||||
trackBattery.Location = new Point(20, 908);
|
||||
trackBattery.Location = new Point(22, 1030);
|
||||
trackBattery.Margin = new Padding(4, 2, 4, 2);
|
||||
trackBattery.Maximum = 100;
|
||||
trackBattery.Minimum = 50;
|
||||
trackBattery.Name = "trackBattery";
|
||||
trackBattery.Size = new Size(676, 90);
|
||||
trackBattery.Size = new Size(682, 90);
|
||||
trackBattery.SmallChange = 10;
|
||||
trackBattery.TabIndex = 3;
|
||||
trackBattery.TickFrequency = 10;
|
||||
@@ -111,7 +117,7 @@
|
||||
//
|
||||
labelBatteryTitle.AutoSize = true;
|
||||
labelBatteryTitle.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelBatteryTitle.Location = new Point(78, 870);
|
||||
labelBatteryTitle.Location = new Point(80, 992);
|
||||
labelBatteryTitle.Margin = new Padding(4, 0, 4, 0);
|
||||
labelBatteryTitle.Name = "labelBatteryTitle";
|
||||
labelBatteryTitle.Size = new Size(248, 32);
|
||||
@@ -122,7 +128,7 @@
|
||||
//
|
||||
pictureBattery.BackgroundImage = (Image)resources.GetObject("pictureBattery.BackgroundImage");
|
||||
pictureBattery.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureBattery.Location = new Point(36, 868);
|
||||
pictureBattery.Location = new Point(38, 990);
|
||||
pictureBattery.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureBattery.Name = "pictureBattery";
|
||||
pictureBattery.Size = new Size(36, 38);
|
||||
@@ -132,12 +138,12 @@
|
||||
// labelGPUFan
|
||||
//
|
||||
labelGPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelGPUFan.Location = new Point(410, 262);
|
||||
labelGPUFan.Location = new Point(344, 262);
|
||||
labelGPUFan.Margin = new Padding(4, 0, 4, 0);
|
||||
labelGPUFan.Name = "labelGPUFan";
|
||||
labelGPUFan.Size = new Size(276, 32);
|
||||
labelGPUFan.Size = new Size(348, 32);
|
||||
labelGPUFan.TabIndex = 8;
|
||||
labelGPUFan.Text = "GPU Fan : 0%";
|
||||
labelGPUFan.Text = " ";
|
||||
labelGPUFan.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// tableGPU
|
||||
@@ -155,7 +161,7 @@
|
||||
tableGPU.Name = "tableGPU";
|
||||
tableGPU.RowCount = 1;
|
||||
tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 108F));
|
||||
tableGPU.Size = new Size(676, 108);
|
||||
tableGPU.Size = new Size(682, 108);
|
||||
tableGPU.TabIndex = 7;
|
||||
//
|
||||
// buttonUltimate
|
||||
@@ -164,10 +170,10 @@
|
||||
buttonUltimate.Dock = DockStyle.Fill;
|
||||
buttonUltimate.FlatAppearance.BorderSize = 0;
|
||||
buttonUltimate.FlatStyle = FlatStyle.Flat;
|
||||
buttonUltimate.Location = new Point(458, 12);
|
||||
buttonUltimate.Location = new Point(462, 12);
|
||||
buttonUltimate.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonUltimate.Name = "buttonUltimate";
|
||||
buttonUltimate.Size = new Size(210, 84);
|
||||
buttonUltimate.Size = new Size(212, 84);
|
||||
buttonUltimate.TabIndex = 2;
|
||||
buttonUltimate.Text = "Ultimate";
|
||||
buttonUltimate.UseVisualStyleBackColor = false;
|
||||
@@ -178,10 +184,10 @@
|
||||
buttonStandard.Dock = DockStyle.Fill;
|
||||
buttonStandard.FlatAppearance.BorderSize = 0;
|
||||
buttonStandard.FlatStyle = FlatStyle.Flat;
|
||||
buttonStandard.Location = new Point(233, 12);
|
||||
buttonStandard.Location = new Point(235, 12);
|
||||
buttonStandard.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonStandard.Name = "buttonStandard";
|
||||
buttonStandard.Size = new Size(209, 84);
|
||||
buttonStandard.Size = new Size(211, 84);
|
||||
buttonStandard.TabIndex = 1;
|
||||
buttonStandard.Text = "Standard";
|
||||
buttonStandard.UseVisualStyleBackColor = false;
|
||||
@@ -196,7 +202,7 @@
|
||||
buttonEco.Location = new Point(8, 12);
|
||||
buttonEco.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonEco.Name = "buttonEco";
|
||||
buttonEco.Size = new Size(209, 84);
|
||||
buttonEco.Size = new Size(211, 84);
|
||||
buttonEco.TabIndex = 0;
|
||||
buttonEco.Text = "Eco";
|
||||
buttonEco.UseVisualStyleBackColor = false;
|
||||
@@ -226,12 +232,12 @@
|
||||
// labelCPUFan
|
||||
//
|
||||
labelCPUFan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelCPUFan.Location = new Point(410, 38);
|
||||
labelCPUFan.Location = new Point(326, 38);
|
||||
labelCPUFan.Margin = new Padding(4, 0, 4, 0);
|
||||
labelCPUFan.Name = "labelCPUFan";
|
||||
labelCPUFan.Size = new Size(276, 32);
|
||||
labelCPUFan.Size = new Size(366, 32);
|
||||
labelCPUFan.TabIndex = 12;
|
||||
labelCPUFan.Text = "CPU Fan : 0%";
|
||||
labelCPUFan.Text = " ";
|
||||
labelCPUFan.TextAlign = ContentAlignment.TopRight;
|
||||
//
|
||||
// tablePerf
|
||||
@@ -249,7 +255,7 @@
|
||||
tablePerf.Name = "tablePerf";
|
||||
tablePerf.RowCount = 1;
|
||||
tablePerf.RowStyles.Add(new RowStyle(SizeType.Absolute, 108F));
|
||||
tablePerf.Size = new Size(676, 108);
|
||||
tablePerf.Size = new Size(682, 108);
|
||||
tablePerf.TabIndex = 11;
|
||||
//
|
||||
// buttonTurbo
|
||||
@@ -259,10 +265,10 @@
|
||||
buttonTurbo.FlatAppearance.BorderColor = Color.FromArgb(192, 0, 0);
|
||||
buttonTurbo.FlatAppearance.BorderSize = 0;
|
||||
buttonTurbo.FlatStyle = FlatStyle.Flat;
|
||||
buttonTurbo.Location = new Point(458, 12);
|
||||
buttonTurbo.Location = new Point(462, 12);
|
||||
buttonTurbo.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonTurbo.Name = "buttonTurbo";
|
||||
buttonTurbo.Size = new Size(210, 84);
|
||||
buttonTurbo.Size = new Size(212, 84);
|
||||
buttonTurbo.TabIndex = 2;
|
||||
buttonTurbo.Text = "Turbo";
|
||||
buttonTurbo.UseVisualStyleBackColor = false;
|
||||
@@ -274,10 +280,10 @@
|
||||
buttonBalanced.FlatAppearance.BorderColor = Color.FromArgb(0, 0, 192);
|
||||
buttonBalanced.FlatAppearance.BorderSize = 0;
|
||||
buttonBalanced.FlatStyle = FlatStyle.Flat;
|
||||
buttonBalanced.Location = new Point(233, 12);
|
||||
buttonBalanced.Location = new Point(235, 12);
|
||||
buttonBalanced.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonBalanced.Name = "buttonBalanced";
|
||||
buttonBalanced.Size = new Size(209, 84);
|
||||
buttonBalanced.Size = new Size(211, 84);
|
||||
buttonBalanced.TabIndex = 1;
|
||||
buttonBalanced.Text = "Balanced";
|
||||
buttonBalanced.UseVisualStyleBackColor = false;
|
||||
@@ -293,7 +299,7 @@
|
||||
buttonSilent.Location = new Point(8, 12);
|
||||
buttonSilent.Margin = new Padding(8, 12, 8, 12);
|
||||
buttonSilent.Name = "buttonSilent";
|
||||
buttonSilent.Size = new Size(209, 84);
|
||||
buttonSilent.Size = new Size(211, 84);
|
||||
buttonSilent.TabIndex = 0;
|
||||
buttonSilent.Text = "Silent";
|
||||
buttonSilent.UseVisualStyleBackColor = false;
|
||||
@@ -338,7 +344,7 @@
|
||||
//
|
||||
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonQuit.BackColor = SystemColors.ButtonFace;
|
||||
buttonQuit.Location = new Point(576, 1008);
|
||||
buttonQuit.Location = new Point(584, 1130);
|
||||
buttonQuit.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonQuit.Name = "buttonQuit";
|
||||
buttonQuit.Size = new Size(120, 48);
|
||||
@@ -382,7 +388,7 @@
|
||||
tableScreen.Name = "tableScreen";
|
||||
tableScreen.RowCount = 1;
|
||||
tableScreen.RowStyles.Add(new RowStyle(SizeType.Absolute, 108F));
|
||||
tableScreen.Size = new Size(676, 108);
|
||||
tableScreen.Size = new Size(682, 108);
|
||||
tableScreen.TabIndex = 19;
|
||||
//
|
||||
// button120Hz
|
||||
@@ -392,10 +398,10 @@
|
||||
button120Hz.FlatAppearance.BorderColor = SystemColors.ActiveBorder;
|
||||
button120Hz.FlatAppearance.BorderSize = 0;
|
||||
button120Hz.FlatStyle = FlatStyle.Flat;
|
||||
button120Hz.Location = new Point(233, 12);
|
||||
button120Hz.Location = new Point(235, 12);
|
||||
button120Hz.Margin = new Padding(8, 12, 8, 12);
|
||||
button120Hz.Name = "button120Hz";
|
||||
button120Hz.Size = new Size(209, 84);
|
||||
button120Hz.Size = new Size(211, 84);
|
||||
button120Hz.TabIndex = 1;
|
||||
button120Hz.Text = "120Hz + OD";
|
||||
button120Hz.UseVisualStyleBackColor = false;
|
||||
@@ -412,7 +418,7 @@
|
||||
button60Hz.Location = new Point(8, 12);
|
||||
button60Hz.Margin = new Padding(8, 12, 8, 12);
|
||||
button60Hz.Name = "button60Hz";
|
||||
button60Hz.Size = new Size(209, 84);
|
||||
button60Hz.Size = new Size(211, 84);
|
||||
button60Hz.TabIndex = 0;
|
||||
button60Hz.Text = "60Hz";
|
||||
button60Hz.UseVisualStyleBackColor = false;
|
||||
@@ -441,16 +447,16 @@
|
||||
checkBoost.Text = "CPU Turbo Boost enabled";
|
||||
checkBoost.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// pictureBox1
|
||||
// pictureKeyboard
|
||||
//
|
||||
pictureBox1.BackgroundImage = Properties.Resources.icons8_keyboard_48;
|
||||
pictureBox1.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureBox1.Location = new Point(36, 724);
|
||||
pictureBox1.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(36, 36);
|
||||
pictureBox1.TabIndex = 23;
|
||||
pictureBox1.TabStop = false;
|
||||
pictureKeyboard.BackgroundImage = Properties.Resources.icons8_keyboard_48;
|
||||
pictureKeyboard.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureKeyboard.Location = new Point(36, 724);
|
||||
pictureKeyboard.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureKeyboard.Name = "pictureKeyboard";
|
||||
pictureKeyboard.Size = new Size(36, 36);
|
||||
pictureKeyboard.TabIndex = 23;
|
||||
pictureKeyboard.TabStop = false;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@@ -468,11 +474,11 @@
|
||||
comboKeyboard.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboKeyboard.FormattingEnabled = true;
|
||||
comboKeyboard.ItemHeight = 32;
|
||||
comboKeyboard.Items.AddRange(new object[] { "Static", "Breathe", "Strobe", "Rainbow" });
|
||||
comboKeyboard.Location = new Point(32, 778);
|
||||
comboKeyboard.Items.AddRange(new object[] { "Static", "Breathe", "Strobe", "Rainbow", "Dingding" });
|
||||
comboKeyboard.Location = new Point(30, 770);
|
||||
comboKeyboard.Margin = new Padding(0);
|
||||
comboKeyboard.Name = "comboKeyboard";
|
||||
comboKeyboard.Size = new Size(200, 40);
|
||||
comboKeyboard.Size = new Size(211, 40);
|
||||
comboKeyboard.TabIndex = 24;
|
||||
comboKeyboard.TabStop = false;
|
||||
//
|
||||
@@ -483,10 +489,10 @@
|
||||
buttonKeyboardColor.FlatAppearance.BorderColor = Color.Red;
|
||||
buttonKeyboardColor.FlatAppearance.BorderSize = 2;
|
||||
buttonKeyboardColor.ForeColor = SystemColors.ControlText;
|
||||
buttonKeyboardColor.Location = new Point(255, 774);
|
||||
buttonKeyboardColor.Location = new Point(257, 766);
|
||||
buttonKeyboardColor.Margin = new Padding(0);
|
||||
buttonKeyboardColor.Name = "buttonKeyboardColor";
|
||||
buttonKeyboardColor.Size = new Size(209, 48);
|
||||
buttonKeyboardColor.Size = new Size(211, 48);
|
||||
buttonKeyboardColor.TabIndex = 25;
|
||||
buttonKeyboardColor.Text = "Color ";
|
||||
buttonKeyboardColor.UseVisualStyleBackColor = false;
|
||||
@@ -494,7 +500,7 @@
|
||||
// labelBattery
|
||||
//
|
||||
labelBattery.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelBattery.Location = new Point(410, 868);
|
||||
labelBattery.Location = new Point(420, 991);
|
||||
labelBattery.Margin = new Padding(4, 0, 4, 0);
|
||||
labelBattery.Name = "labelBattery";
|
||||
labelBattery.Size = new Size(276, 32);
|
||||
@@ -507,12 +513,12 @@
|
||||
buttonFans.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonFans.BackColor = SystemColors.ButtonFace;
|
||||
buttonFans.FlatAppearance.BorderSize = 0;
|
||||
buttonFans.Location = new Point(480, 186);
|
||||
buttonFans.Location = new Point(486, 186);
|
||||
buttonFans.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonFans.Name = "buttonFans";
|
||||
buttonFans.Size = new Size(210, 48);
|
||||
buttonFans.TabIndex = 28;
|
||||
buttonFans.Text = "Fan Profile";
|
||||
buttonFans.Text = "Fans and Power";
|
||||
buttonFans.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// buttonKeyboard
|
||||
@@ -520,7 +526,7 @@
|
||||
buttonKeyboard.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonKeyboard.BackColor = SystemColors.ButtonFace;
|
||||
buttonKeyboard.FlatAppearance.BorderSize = 0;
|
||||
buttonKeyboard.Location = new Point(480, 773);
|
||||
buttonKeyboard.Location = new Point(486, 765);
|
||||
buttonKeyboard.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonKeyboard.Name = "buttonKeyboard";
|
||||
buttonKeyboard.Size = new Size(209, 48);
|
||||
@@ -530,7 +536,7 @@
|
||||
//
|
||||
// pictureColor
|
||||
//
|
||||
pictureColor.Location = new Point(431, 789);
|
||||
pictureColor.Location = new Point(431, 781);
|
||||
pictureColor.Name = "pictureColor";
|
||||
pictureColor.Size = new Size(20, 20);
|
||||
pictureColor.TabIndex = 30;
|
||||
@@ -538,7 +544,7 @@
|
||||
//
|
||||
// pictureColor2
|
||||
//
|
||||
pictureColor2.Location = new Point(405, 789);
|
||||
pictureColor2.Location = new Point(405, 781);
|
||||
pictureColor2.Name = "pictureColor2";
|
||||
pictureColor2.Size = new Size(20, 20);
|
||||
pictureColor2.TabIndex = 31;
|
||||
@@ -549,17 +555,83 @@
|
||||
labelVersion.AutoSize = true;
|
||||
labelVersion.Font = new Font("Segoe UI", 9F, FontStyle.Underline, GraphicsUnit.Point);
|
||||
labelVersion.ForeColor = SystemColors.ControlDark;
|
||||
labelVersion.Location = new Point(34, 966);
|
||||
labelVersion.Location = new Point(36, 1088);
|
||||
labelVersion.Name = "labelVersion";
|
||||
labelVersion.Size = new Size(44, 32);
|
||||
labelVersion.TabIndex = 32;
|
||||
labelVersion.Text = "v.0";
|
||||
//
|
||||
// pictureMatrix
|
||||
//
|
||||
pictureMatrix.BackgroundImage = Properties.Resources.icons8_matrix_desktop_48;
|
||||
pictureMatrix.BackgroundImageLayout = ImageLayout.Zoom;
|
||||
pictureMatrix.Location = new Point(36, 858);
|
||||
pictureMatrix.Margin = new Padding(4, 2, 4, 2);
|
||||
pictureMatrix.Name = "pictureMatrix";
|
||||
pictureMatrix.Size = new Size(36, 36);
|
||||
pictureMatrix.TabIndex = 34;
|
||||
pictureMatrix.TabStop = false;
|
||||
//
|
||||
// labelMatrix
|
||||
//
|
||||
labelMatrix.AutoSize = true;
|
||||
labelMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelMatrix.Location = new Point(78, 858);
|
||||
labelMatrix.Margin = new Padding(4, 0, 4, 0);
|
||||
labelMatrix.Name = "labelMatrix";
|
||||
labelMatrix.Size = new Size(170, 32);
|
||||
labelMatrix.TabIndex = 33;
|
||||
labelMatrix.Text = "Anime Matrix";
|
||||
//
|
||||
// comboMatrix
|
||||
//
|
||||
comboMatrix.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboMatrix.FormattingEnabled = true;
|
||||
comboMatrix.ItemHeight = 32;
|
||||
comboMatrix.Items.AddRange(new object[] { "Off", "Dim", "Medium", "Bright" });
|
||||
comboMatrix.Location = new Point(30, 910);
|
||||
comboMatrix.Margin = new Padding(0);
|
||||
comboMatrix.Name = "comboMatrix";
|
||||
comboMatrix.Size = new Size(211, 40);
|
||||
comboMatrix.TabIndex = 35;
|
||||
comboMatrix.TabStop = false;
|
||||
//
|
||||
// comboMatrixRunning
|
||||
//
|
||||
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||
comboMatrixRunning.FormattingEnabled = true;
|
||||
comboMatrixRunning.ItemHeight = 32;
|
||||
comboMatrixRunning.Items.AddRange(new object[] { "Binary Banner", "Rog Logo", "Picture" });
|
||||
comboMatrixRunning.Location = new Point(257, 910);
|
||||
comboMatrixRunning.Margin = new Padding(0);
|
||||
comboMatrixRunning.Name = "comboMatrixRunning";
|
||||
comboMatrixRunning.Size = new Size(211, 40);
|
||||
comboMatrixRunning.TabIndex = 36;
|
||||
comboMatrixRunning.TabStop = false;
|
||||
//
|
||||
// buttonMatrix
|
||||
//
|
||||
buttonMatrix.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonMatrix.BackColor = SystemColors.ButtonFace;
|
||||
buttonMatrix.FlatAppearance.BorderSize = 0;
|
||||
buttonMatrix.Location = new Point(486, 905);
|
||||
buttonMatrix.Margin = new Padding(4, 2, 4, 2);
|
||||
buttonMatrix.Name = "buttonMatrix";
|
||||
buttonMatrix.Size = new Size(209, 48);
|
||||
buttonMatrix.TabIndex = 37;
|
||||
buttonMatrix.Text = "Picture";
|
||||
buttonMatrix.UseVisualStyleBackColor = false;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(192F, 192F);
|
||||
AutoScaleMode = AutoScaleMode.Dpi;
|
||||
ClientSize = new Size(730, 1089);
|
||||
ClientSize = new Size(736, 1203);
|
||||
Controls.Add(buttonMatrix);
|
||||
Controls.Add(comboMatrixRunning);
|
||||
Controls.Add(comboMatrix);
|
||||
Controls.Add(pictureMatrix);
|
||||
Controls.Add(labelMatrix);
|
||||
Controls.Add(labelVersion);
|
||||
Controls.Add(pictureColor2);
|
||||
Controls.Add(pictureColor);
|
||||
@@ -568,7 +640,7 @@
|
||||
Controls.Add(labelBattery);
|
||||
Controls.Add(buttonKeyboardColor);
|
||||
Controls.Add(comboKeyboard);
|
||||
Controls.Add(pictureBox1);
|
||||
Controls.Add(pictureKeyboard);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(checkBoost);
|
||||
Controls.Add(checkScreen);
|
||||
@@ -608,9 +680,10 @@
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureScreen).EndInit();
|
||||
tableScreen.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureKeyboard).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureColor).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureColor2).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureMatrix).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@@ -643,7 +716,7 @@
|
||||
private Button button60Hz;
|
||||
private CheckBox checkScreen;
|
||||
private CheckBox checkBoost;
|
||||
private PictureBox pictureBox1;
|
||||
private PictureBox pictureKeyboard;
|
||||
private Label label1;
|
||||
private ComboBox comboKeyboard;
|
||||
private Button buttonKeyboardColor;
|
||||
@@ -653,5 +726,10 @@
|
||||
private PictureBox pictureColor;
|
||||
private PictureBox pictureColor2;
|
||||
private Label labelVersion;
|
||||
private PictureBox pictureMatrix;
|
||||
private Label labelMatrix;
|
||||
private ComboBox comboMatrix;
|
||||
private ComboBox comboMatrixRunning;
|
||||
private Button buttonMatrix;
|
||||
}
|
||||
}
|
||||
264
Settings.cs
264
Settings.cs
@@ -1,7 +1,10 @@
|
||||
using System.Diagnostics;
|
||||
using Starlight.AnimeMatrix;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Timers;
|
||||
using System.Windows.Forms.DataVisualization.Charting;
|
||||
using System.Drawing.Imaging;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Drawing;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
@@ -61,7 +64,6 @@ namespace GHelper
|
||||
|
||||
comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboKeyboard.SelectedIndex = 0;
|
||||
|
||||
comboKeyboard.SelectedValueChanged += ComboKeyboard_SelectedValueChanged;
|
||||
|
||||
buttonKeyboardColor.Click += ButtonKeyboardColor_Click;
|
||||
@@ -75,12 +77,165 @@ namespace GHelper
|
||||
labelVersion.Text = "Version " + Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
labelVersion.Click += LabelVersion_Click;
|
||||
|
||||
labelCPUFan.Click += LabelCPUFan_Click;
|
||||
labelGPUFan.Click += LabelCPUFan_Click;
|
||||
|
||||
|
||||
InitMatrix();
|
||||
|
||||
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboMatrix.SelectedValueChanged += ComboMatrix_SelectedValueChanged;
|
||||
comboMatrixRunning.SelectedValueChanged += ComboMatrixRunning_SelectedValueChanged;
|
||||
|
||||
buttonMatrix.Click += ButtonMatrix_Click;
|
||||
|
||||
|
||||
SetTimer();
|
||||
|
||||
}
|
||||
|
||||
void SetMatrixPicture(string fileName)
|
||||
{
|
||||
|
||||
int width = 34 * 3;
|
||||
int height = 61;
|
||||
float scale;
|
||||
|
||||
Bitmap image;
|
||||
|
||||
try
|
||||
{
|
||||
using (var bmpTemp = (Bitmap)Image.FromFile(fileName))
|
||||
{
|
||||
image = new Bitmap(bmpTemp);
|
||||
|
||||
Bitmap canvas = new Bitmap(width, height);
|
||||
|
||||
scale = Math.Min((float)width / (float)image.Width, (float)height / (float)image.Height);
|
||||
|
||||
var graph = Graphics.FromImage(canvas);
|
||||
var scaleWidth = (int)(image.Width * scale);
|
||||
var scaleHeight = (int)(image.Height * scale);
|
||||
|
||||
graph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
|
||||
graph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||
graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||||
|
||||
graph.DrawImage(image, ((int)width - scaleWidth), ((int)height - scaleHeight) / 2, scaleWidth, scaleHeight);
|
||||
|
||||
Bitmap bmp = new Bitmap(canvas, 34, 61);
|
||||
|
||||
var mat = new AnimeMatrixDevice();
|
||||
mat.SetBuiltInAnimation(false);
|
||||
|
||||
for (int y = 0; y < bmp.Height; y++)
|
||||
{
|
||||
for (int x = 0; x < bmp.Width; x++)
|
||||
{
|
||||
var pixel = bmp.GetPixel(x, y);
|
||||
byte color = (byte)((pixel.R + pixel.G + pixel.B) / 3);
|
||||
mat.SetLedPlanar(x, y, color);
|
||||
}
|
||||
}
|
||||
|
||||
mat.Present();
|
||||
mat.Dispose();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Error loading picture");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ButtonMatrix_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Thread t = new Thread((ThreadStart)(() =>
|
||||
{
|
||||
OpenFileDialog of = new OpenFileDialog();
|
||||
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png)|*.BMP;*.JPG;*.JPEG;*.PNG";
|
||||
if (of.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Program.config.setConfig("matrix_picture", of.FileName);
|
||||
SetMatrixPicture(of.FileName);
|
||||
BeginInvoke(delegate
|
||||
{
|
||||
comboMatrixRunning.SelectedIndex = 2;
|
||||
});
|
||||
}
|
||||
return;
|
||||
}));
|
||||
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
t.Join();
|
||||
}
|
||||
|
||||
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
SetAnimeMatrix();
|
||||
}
|
||||
|
||||
|
||||
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
SetAnimeMatrix();
|
||||
}
|
||||
|
||||
private void SetAnimeMatrix()
|
||||
{
|
||||
|
||||
int brightness = comboMatrix.SelectedIndex;
|
||||
int running = comboMatrixRunning.SelectedIndex;
|
||||
|
||||
var mat = new AnimeMatrixDevice();
|
||||
|
||||
BuiltInAnimation animation = new BuiltInAnimation(
|
||||
(BuiltInAnimation.Running)running,
|
||||
BuiltInAnimation.Sleeping.Starfield,
|
||||
BuiltInAnimation.Shutdown.SeeYa,
|
||||
BuiltInAnimation.Startup.StaticEmergence
|
||||
);
|
||||
|
||||
|
||||
if (brightness == 0)
|
||||
{
|
||||
mat.SetDisplayState(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.SetDisplayState(true);
|
||||
mat.SetBrightness((BrightnessMode)brightness);
|
||||
|
||||
if (running == 2)
|
||||
{
|
||||
string fileName = Program.config.getConfigString("matrix_picture");
|
||||
SetMatrixPicture(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
mat.SetBuiltInAnimation(true, animation);
|
||||
}
|
||||
}
|
||||
|
||||
mat.Dispose();
|
||||
|
||||
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void LabelCPUFan_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
|
||||
RefreshSensors();
|
||||
}
|
||||
|
||||
private void LabelVersion_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Process.Start(new ProcessStartInfo("http://github.com/seerge/g-helper/releases") { UseShellExecute = true });
|
||||
@@ -122,13 +277,19 @@ namespace GHelper
|
||||
if (fans == null || fans.Text == "")
|
||||
{
|
||||
fans = new Fans();
|
||||
fans.Show();
|
||||
Debug.WriteLine("Starting fans");
|
||||
}
|
||||
|
||||
if (fans.Visible)
|
||||
{
|
||||
fans.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
fans.Close();
|
||||
fans.Show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void ButtonKeyboardColor_Click(object? sender, EventArgs e)
|
||||
@@ -173,10 +334,18 @@ namespace GHelper
|
||||
SetAuraMode(mode, false);
|
||||
|
||||
Aura.Mode = mode;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void InitMatrix()
|
||||
{
|
||||
int brightness = Program.config.getConfig("matrix_brightness");
|
||||
int running = Program.config.getConfig("matrix_running");
|
||||
|
||||
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
|
||||
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
|
||||
}
|
||||
|
||||
|
||||
public void SetAuraColor(Color? color1 = null, Color? color2 = null, bool apply = true)
|
||||
{
|
||||
|
||||
@@ -205,14 +374,14 @@ namespace GHelper
|
||||
|
||||
//Debug.WriteLine(mode);
|
||||
|
||||
if (mode > 3) mode = 0;
|
||||
if (mode > 4) mode = 0;
|
||||
|
||||
pictureColor2.Visible = (mode == Aura.Breathe);
|
||||
|
||||
if (Aura.Mode == mode) return; // same mode
|
||||
|
||||
|
||||
Aura.Mode = mode;
|
||||
|
||||
Program.config.setConfig("aura_mode", mode);
|
||||
|
||||
comboKeyboard.SelectedValueChanged -= ComboKeyboard_SelectedValueChanged;
|
||||
@@ -397,10 +566,20 @@ namespace GHelper
|
||||
aTimer.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
private static string FormatFan(int fan)
|
||||
{
|
||||
if (Program.config.getConfig("fan_rpm") == 1)
|
||||
return " Fan: " + (fan * 100).ToString() + "RPM";
|
||||
else
|
||||
return " Fan: " + Math.Round(fan / 0.6).ToString() + "%"; // relatively to 6000 rpm
|
||||
}
|
||||
|
||||
private static void RefreshSensors()
|
||||
{
|
||||
string cpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan) / 0.6).ToString() + "%";
|
||||
string gpuFan = " Fan: " + Math.Round(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan) / 0.6).ToString() + "%";
|
||||
|
||||
string cpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.CPU_Fan));
|
||||
string gpuFan = FormatFan(Program.wmi.DeviceGet(ASUSWmi.GPU_Fan));
|
||||
|
||||
string cpuTemp = "";
|
||||
string gpuTemp = "";
|
||||
@@ -425,7 +604,7 @@ namespace GHelper
|
||||
private static void OnTimedEvent(Object? source, ElapsedEventArgs? e)
|
||||
{
|
||||
RefreshSensors();
|
||||
aTimer.Interval = 2000;
|
||||
aTimer.Interval = 1000;
|
||||
}
|
||||
|
||||
private void SettingsForm_VisibleChanged(object? sender, EventArgs e)
|
||||
@@ -438,7 +617,7 @@ namespace GHelper
|
||||
this.Top = Screen.FromControl(this).WorkingArea.Height - 10 - this.Height;
|
||||
this.Activate();
|
||||
|
||||
aTimer.Interval = 500;
|
||||
aTimer.Interval = 100;
|
||||
aTimer.Enabled = true;
|
||||
|
||||
}
|
||||
@@ -472,21 +651,25 @@ namespace GHelper
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int oldMode = Program.config.getConfig("performance_mode");
|
||||
Program.config.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
||||
Program.config.setConfig("performance_mode", PerformanceMode);
|
||||
try
|
||||
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||
|
||||
if (Program.config.getConfig("auto_apply_" + PerformanceMode) == 1)
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.PerformanceMode, PerformanceMode);
|
||||
}
|
||||
catch
|
||||
{
|
||||
labelPerf.Text = "Performance Mode: not supported";
|
||||
Program.wmi.SetFanCurve(0, Program.config.getFanConfig(0));
|
||||
Program.wmi.SetFanCurve(1, Program.config.getFanConfig(1));
|
||||
}
|
||||
|
||||
if (fans != null && fans.Text != "")
|
||||
{
|
||||
fans.LoadFans();
|
||||
fans.ResetApplyLabel();
|
||||
}
|
||||
|
||||
if (notify)
|
||||
if (notify && (oldMode != PerformanceMode))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -506,12 +689,22 @@ namespace GHelper
|
||||
SetPerformanceMode(Program.config.getConfig("performance_mode") + 1, true);
|
||||
}
|
||||
|
||||
public void AutoScreen(int Plugged = 1)
|
||||
public void AutoPerformance(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
||||
if (mode != -1)
|
||||
SetPerformanceMode(mode, true);
|
||||
else
|
||||
SetPerformanceMode(Program.config.getConfig("performance_mode"));
|
||||
}
|
||||
|
||||
|
||||
public void AutoScreen(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
int ScreenAuto = Program.config.getConfig("screen_auto");
|
||||
if (ScreenAuto != 1) return;
|
||||
|
||||
if (Plugged == 1)
|
||||
if (Plugged == PowerLineStatus.Online)
|
||||
SetScreen(1000, 1);
|
||||
else
|
||||
SetScreen(60, 0);
|
||||
@@ -520,7 +713,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
public void AutoGPUMode(int Plugged = 1)
|
||||
public void AutoGPUMode(PowerLineStatus Plugged = PowerLineStatus.Online)
|
||||
{
|
||||
|
||||
int GpuAuto = Program.config.getConfig("gpu_auto");
|
||||
@@ -534,12 +727,12 @@ namespace GHelper
|
||||
return;
|
||||
else
|
||||
{
|
||||
if (eco == 1 && Plugged == 1) // Eco going Standard on plugged
|
||||
if (eco == 1 && Plugged == PowerLineStatus.Online) // Eco going Standard on plugged
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 0);
|
||||
InitGPUMode();
|
||||
}
|
||||
else if (eco == 0 && Plugged == 0) // Standard going Eco on plugged
|
||||
else if (eco == 0 && Plugged != PowerLineStatus.Online) // Standard going Eco on plugged
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.GPUEco, 1);
|
||||
InitGPUMode();
|
||||
@@ -643,9 +836,14 @@ namespace GHelper
|
||||
checkScreen.Checked = (ScreenAuto == 1);
|
||||
}
|
||||
|
||||
public void VisualiseGPUMode(int GPUMode)
|
||||
public void VisualiseGPUMode(int GPUMode = -1)
|
||||
{
|
||||
|
||||
if (GPUMode == -1)
|
||||
{
|
||||
GPUMode = Program.config.getConfig("gpu_mode");
|
||||
}
|
||||
|
||||
buttonEco.FlatAppearance.BorderSize = buttonInactive;
|
||||
buttonStandard.FlatAppearance.BorderSize = buttonInactive;
|
||||
buttonUltimate.FlatAppearance.BorderSize = buttonInactive;
|
||||
@@ -717,18 +915,12 @@ namespace GHelper
|
||||
public void SetBatteryChargeLimit(int limit = 100)
|
||||
{
|
||||
|
||||
if (limit < 50 || limit > 100) limit = 100;
|
||||
if (limit < 40 || limit > 100) return;
|
||||
|
||||
labelBatteryTitle.Text = "Battery Charge Limit: " + limit.ToString() + "%";
|
||||
trackBattery.Value = limit;
|
||||
try
|
||||
{
|
||||
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Debug.WriteLine("Can't set battery charge limit");
|
||||
}
|
||||
Program.wmi.DeviceSet(ASUSWmi.BatteryLimit, limit);
|
||||
|
||||
Program.config.setConfig("charge_limit", limit);
|
||||
|
||||
}
|
||||
|
||||
11
Startup.cs
11
Startup.cs
@@ -10,17 +10,6 @@ public class Startup
|
||||
public static bool IsScheduled()
|
||||
{
|
||||
TaskService taskService = new TaskService();
|
||||
|
||||
// cleanup of OLD autorun
|
||||
try
|
||||
{
|
||||
taskService.RootFolder.DeleteTask("GSharpHelper");
|
||||
} catch
|
||||
{
|
||||
Debug.WriteLine("Not running as admin");
|
||||
}
|
||||
|
||||
|
||||
return (taskService.RootFolder.AllTasks.Any(t => t.Name == taskName));
|
||||
}
|
||||
|
||||
|
||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
15
stop-asus-sv.bat
Normal file
15
stop-asus-sv.bat
Normal file
@@ -0,0 +1,15 @@
|
||||
sc STOP AsusAppService
|
||||
sc STOP ASUSLinkNear
|
||||
sc STOP ASUSLinkRemote
|
||||
sc STOP ASUSSoftwareManager
|
||||
sc STOP ASUSSwitch
|
||||
sc STOP ASUSSystemAnalysis
|
||||
sc STOP ASUSSystemDiagnosis
|
||||
|
||||
sc DELETE AsusAppService
|
||||
sc DELETE ASUSLinkNear
|
||||
sc DELETE ASUSLinkRemote
|
||||
sc DELETE ASUSSoftwareManager
|
||||
sc DELETE ASUSSwitch
|
||||
sc DELETE ASUSSystemAnalysis
|
||||
sc DELETE ASUSSystemDiagnosis
|
||||
Reference in New Issue
Block a user