mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Refactoring
This commit is contained in:
@@ -41,10 +41,10 @@ namespace GHelper.AnimeMatrix
|
||||
|
||||
if (!IsValid) return;
|
||||
|
||||
int brightness = Program.config.getConfig("matrix_brightness");
|
||||
int running = Program.config.getConfig("matrix_running");
|
||||
int brightness = AppConfig.getConfig("matrix_brightness");
|
||||
int running = AppConfig.getConfig("matrix_running");
|
||||
|
||||
bool auto = Program.config.getConfig("matrix_auto") == 1;
|
||||
bool auto = AppConfig.getConfig("matrix_auto") == 1;
|
||||
|
||||
if (brightness < 0) brightness = 0;
|
||||
if (running < 0) running = 0;
|
||||
@@ -74,7 +74,7 @@ namespace GHelper.AnimeMatrix
|
||||
switch (running)
|
||||
{
|
||||
case 2:
|
||||
SetMatrixPicture(Program.config.getConfigString("matrix_picture"));
|
||||
SetMatrixPicture(AppConfig.getConfigString("matrix_picture"));
|
||||
break;
|
||||
case 3:
|
||||
StartMatrixTimer(1000);
|
||||
@@ -110,7 +110,7 @@ namespace GHelper.AnimeMatrix
|
||||
{
|
||||
if (!IsValid) return;
|
||||
|
||||
switch (Program.config.getConfig("matrix_running"))
|
||||
switch (AppConfig.getConfig("matrix_running"))
|
||||
{
|
||||
case 2:
|
||||
mat.PresentNextFrame();
|
||||
|
||||
@@ -2,20 +2,18 @@
|
||||
using System.Management;
|
||||
using System.Text.Json;
|
||||
|
||||
public class AppConfig
|
||||
public static class AppConfig
|
||||
{
|
||||
|
||||
public string appPath;
|
||||
string configFile;
|
||||
private static string configFile;
|
||||
private static string? _model;
|
||||
|
||||
string _model;
|
||||
private static Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public Dictionary<string, object> config = new Dictionary<string, object>();
|
||||
|
||||
public AppConfig()
|
||||
static AppConfig()
|
||||
{
|
||||
|
||||
appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
|
||||
configFile = appPath + "\\config.json";
|
||||
|
||||
if (!System.IO.Directory.Exists(appPath))
|
||||
@@ -41,7 +39,7 @@ public class AppConfig
|
||||
}
|
||||
|
||||
|
||||
public string GetModel()
|
||||
public static string GetModel()
|
||||
{
|
||||
if (_model is null)
|
||||
{
|
||||
@@ -58,14 +56,14 @@ public class AppConfig
|
||||
|
||||
return _model;
|
||||
}
|
||||
public bool ContainsModel(string contains)
|
||||
public static bool ContainsModel(string contains)
|
||||
{
|
||||
|
||||
GetModel();
|
||||
return (_model is not null && _model.Contains(contains));
|
||||
|
||||
}
|
||||
private void initConfig()
|
||||
private static void initConfig()
|
||||
{
|
||||
config = new Dictionary<string, object>();
|
||||
config["performance_mode"] = 0;
|
||||
@@ -73,26 +71,26 @@ public class AppConfig
|
||||
File.WriteAllText(configFile, jsonString);
|
||||
}
|
||||
|
||||
public int getConfig(string name, bool performance = false)
|
||||
public static int getConfig(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return int.Parse(config[name].ToString());
|
||||
else return -1;
|
||||
}
|
||||
|
||||
public bool isConfig(string name)
|
||||
public static bool isConfig(string name)
|
||||
{
|
||||
return getConfig(name) == 1;
|
||||
}
|
||||
|
||||
public string getConfigString(string name)
|
||||
public static string getConfigString(string name)
|
||||
{
|
||||
if (config.ContainsKey(name))
|
||||
return config[name].ToString();
|
||||
else return null;
|
||||
}
|
||||
|
||||
public void setConfig(string name, int value)
|
||||
public static void setConfig(string name, int value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
@@ -105,7 +103,7 @@ public class AppConfig
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfig(string name, string value)
|
||||
public static void setConfig(string name, string value)
|
||||
{
|
||||
config[name] = value;
|
||||
string jsonString = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
@@ -119,7 +117,7 @@ public class AppConfig
|
||||
}
|
||||
}
|
||||
|
||||
public string getParamName(AsusFan device, string paramName = "fan_profile")
|
||||
public static string getParamName(AsusFan device, string paramName = "fan_profile")
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
string name;
|
||||
@@ -144,7 +142,7 @@ public class AppConfig
|
||||
return paramName + "_" + name + "_" + mode;
|
||||
}
|
||||
|
||||
public byte[] getFanConfig(AsusFan device)
|
||||
public static byte[] getFanConfig(AsusFan device)
|
||||
{
|
||||
string curveString = getConfigString(getParamName(device));
|
||||
byte[] curve = { };
|
||||
@@ -155,7 +153,7 @@ public class AppConfig
|
||||
return curve;
|
||||
}
|
||||
|
||||
public void setFanConfig(AsusFan device, byte[] curve)
|
||||
public static void setFanConfig(AsusFan device, byte[] curve)
|
||||
{
|
||||
string bitCurve = BitConverter.ToString(curve);
|
||||
setConfig(getParamName(device), bitCurve);
|
||||
@@ -170,7 +168,7 @@ public class AppConfig
|
||||
return array;
|
||||
}
|
||||
|
||||
public byte[] getDefaultCurve(AsusFan device)
|
||||
public static byte[] getDefaultCurve(AsusFan device)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
byte[] curve;
|
||||
@@ -200,19 +198,19 @@ public class AppConfig
|
||||
return curve;
|
||||
}
|
||||
|
||||
public string getConfigPerfString(string name)
|
||||
public static string getConfigPerfString(string name)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
return getConfigString(name + "_" + mode);
|
||||
}
|
||||
|
||||
public int getConfigPerf(string name)
|
||||
public static int getConfigPerf(string name)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
return getConfig(name + "_" + mode);
|
||||
}
|
||||
|
||||
public void setConfigPerf(string name, int value)
|
||||
public static void setConfigPerf(string name, int value)
|
||||
{
|
||||
int mode = getConfig("performance_mode");
|
||||
setConfig(name + "_" + mode, value);
|
||||
|
||||
@@ -103,18 +103,18 @@ namespace GHelper
|
||||
|
||||
public static Dictionary<int, string> GetModes()
|
||||
{
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
{
|
||||
_modes.Remove(3);
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("401"))
|
||||
if (AppConfig.ContainsModel("401"))
|
||||
{
|
||||
_modes.Remove(2);
|
||||
_modes.Remove(3);
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("Strix") || Program.config.ContainsModel("Scar"))
|
||||
if (AppConfig.ContainsModel("Strix") || AppConfig.ContainsModel("Scar"))
|
||||
{
|
||||
return _modesStrix;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ namespace GHelper
|
||||
|
||||
public static bool HasSecondColor()
|
||||
{
|
||||
return (mode == 1 && !Program.config.ContainsModel("TUF"));
|
||||
return (mode == 1 && !AppConfig.ContainsModel("TUF"));
|
||||
}
|
||||
|
||||
public static int Speed
|
||||
@@ -197,7 +197,7 @@ namespace GHelper
|
||||
|
||||
Logger.WriteLine("Input Events " + input.DevicePath);
|
||||
|
||||
Task.Run(() =>
|
||||
var task = Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -254,7 +254,7 @@ namespace GHelper
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardBrightness(brightness);
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ namespace GHelper
|
||||
device.CloseDevice();
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardPower(
|
||||
flags.Contains(AuraDev19b6.AwakeKeyb),
|
||||
flags.Contains(AuraDev19b6.BootKeyb),
|
||||
@@ -288,12 +288,12 @@ namespace GHelper
|
||||
public static int SetXGM(byte[] msg)
|
||||
{
|
||||
|
||||
Debug.WriteLine("XGM Payload :" + BitConverter.ToString(msg));
|
||||
Logger.WriteLine("XGM Payload :" + BitConverter.ToString(msg));
|
||||
|
||||
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }))
|
||||
foreach (HidDevice device in GetHidDevices(new int[] { 0x1970 }, 0))
|
||||
{
|
||||
device.OpenDevice();
|
||||
Debug.WriteLine("XGM " + device.Attributes.ProductHexId + ":" + BitConverter.ToString(msg));
|
||||
Logger.WriteLine("XGM " + device.Attributes.ProductHexId + device.Capabilities.FeatureReportByteLength + ":" + BitConverter.ToString(msg));
|
||||
device.WriteFeatureData(msg);
|
||||
device.CloseDevice();
|
||||
return 1;
|
||||
@@ -364,7 +364,7 @@ namespace GHelper
|
||||
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + "|" + device.Capabilities.InputReportByteLength + device.Description + device.DevicePath + ":" + BitConverter.ToString(msg));
|
||||
}
|
||||
|
||||
if (Program.config.ContainsModel("TUF"))
|
||||
if (AppConfig.ContainsModel("TUF"))
|
||||
Program.acpi.TUFKeyboardRGB(Mode, Color1, _speed);
|
||||
|
||||
}
|
||||
|
||||
228
app/EventDispatcher.cs
Normal file
228
app/EventDispatcher.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using Microsoft.Win32;
|
||||
using NAudio.CoreAudioApi;
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using Tools;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
public class EventDispatcher
|
||||
{
|
||||
|
||||
private static bool isOptimizationRunning = OptimizationService.IsRunning();
|
||||
private static nint windowHandle;
|
||||
|
||||
public EventDispatcher(nint handle)
|
||||
{
|
||||
|
||||
windowHandle = handle;
|
||||
|
||||
Program.acpi.SubscribeToEvents(WatcherEventArrived);
|
||||
|
||||
if (!isOptimizationRunning) AsusUSB.RunListener(HandleEvent);
|
||||
|
||||
// CTRL + SHIFT + F5 to cycle profiles
|
||||
Keys keybind_profile = (AppConfig.getConfig("keybind_profile") != -1) ? (Keys)AppConfig.getConfig("keybind_profile") : Keys.F5;
|
||||
if (keybind_profile != 0)
|
||||
{
|
||||
KeyHandler ghk = new KeyHandler(KeyHandler.SHIFT | KeyHandler.CTRL, keybind_profile, windowHandle);
|
||||
ghk.Register();
|
||||
}
|
||||
|
||||
/*
|
||||
KeyHandler m1 = new KeyHandler(0, Keys.VolumeDown, ds);
|
||||
m1.Register();
|
||||
KeyHandler m2 = new KeyHandler(0, Keys.VolumeUp, ds);
|
||||
m2.Register();
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
static void CustomKey(string configKey = "m3")
|
||||
{
|
||||
string command = AppConfig.getConfigString(configKey + "_custom");
|
||||
int intKey;
|
||||
|
||||
try
|
||||
{
|
||||
intKey = Convert.ToInt32(command, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
intKey = -1;
|
||||
}
|
||||
|
||||
|
||||
if (intKey > 0)
|
||||
NativeMethods.KeyPress(intKey);
|
||||
else
|
||||
LaunchProcess(command);
|
||||
|
||||
}
|
||||
|
||||
static void KeyProcess(string name = "m3")
|
||||
{
|
||||
string action = AppConfig.getConfigString(name);
|
||||
|
||||
if (action is null || action.Length <= 1)
|
||||
{
|
||||
if (name == "m4")
|
||||
action = "ghelper";
|
||||
if (name == "fnf4")
|
||||
action = "aura";
|
||||
if (name == "m3" && !isOptimizationRunning)
|
||||
action = "micmute";
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "mute":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_VOLUME_MUTE);
|
||||
break;
|
||||
case "play":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_MEDIA_PLAY_PAUSE);
|
||||
break;
|
||||
case "screenshot":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_SNAPSHOT);
|
||||
break;
|
||||
case "screen":
|
||||
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
||||
break;
|
||||
case "miniled":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.ToogleMiniled);
|
||||
break;
|
||||
case "aura":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode);
|
||||
break;
|
||||
case "performance":
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CyclePerformanceMode);
|
||||
break;
|
||||
case "ghelper":
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
Program.SettingsToggle();
|
||||
});
|
||||
break;
|
||||
case "custom":
|
||||
CustomKey(name);
|
||||
break;
|
||||
case "micmute":
|
||||
using (var enumerator = new MMDeviceEnumerator())
|
||||
{
|
||||
var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
|
||||
bool muteStatus = !commDevice.AudioEndpointVolume.Mute;
|
||||
commDevice.AudioEndpointVolume.Mute = muteStatus;
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void TabletMode()
|
||||
{
|
||||
bool touchpadState, tabletState;
|
||||
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
|
||||
{
|
||||
touchpadState = (key?.GetValue("Enabled")?.ToString() == "1");
|
||||
}
|
||||
|
||||
tabletState = Program.acpi.DeviceGet(AsusACPI.TabletState) > 0;
|
||||
|
||||
Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState);
|
||||
|
||||
if ((tabletState && touchpadState) || (!tabletState && !touchpadState)) AsusUSB.TouchpadToggle();
|
||||
|
||||
}
|
||||
|
||||
static void HandleEvent(int EventID)
|
||||
{
|
||||
switch (EventID)
|
||||
{
|
||||
case 124: // M3
|
||||
KeyProcess("m3");
|
||||
return;
|
||||
case 56: // M4 / Rog button
|
||||
KeyProcess("m4");
|
||||
return;
|
||||
case 174: // FN+F5
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.CyclePerformanceMode);
|
||||
return;
|
||||
case 179: // FN+F4
|
||||
KeyProcess("fnf4");
|
||||
return;
|
||||
case 189: // Tablet mode
|
||||
TabletMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOptimizationRunning) return;
|
||||
|
||||
// Asus Optimization service Events
|
||||
|
||||
int brightness = AppConfig.getConfig("keyboard_brightness");
|
||||
|
||||
switch (EventID)
|
||||
{
|
||||
case 197: // FN+F2
|
||||
brightness = Math.Max(0, brightness - 1);
|
||||
AppConfig.setConfig("keyboard_brightness", brightness);
|
||||
AsusUSB.ApplyBrightness(brightness);
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Backlight", ToastIcon.BacklightDown);
|
||||
break;
|
||||
case 196: // FN+F3
|
||||
brightness = Math.Min(3, brightness + 1);
|
||||
AppConfig.setConfig("keyboard_brightness", brightness);
|
||||
AsusUSB.ApplyBrightness(brightness);
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Backlight", ToastIcon.BacklightUp);
|
||||
break;
|
||||
case 16: // FN+F7
|
||||
ScreenBrightness.Adjust(-10);
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Brightness", ToastIcon.BrightnessDown);
|
||||
break;
|
||||
case 32: // FN+F8
|
||||
ScreenBrightness.Adjust(+10);
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Brightness", ToastIcon.BrightnessUp);
|
||||
break;
|
||||
case 107: // FN+F10
|
||||
AsusUSB.TouchpadToggle();
|
||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, "Touchpad", ToastIcon.Touchpad);
|
||||
break;
|
||||
case 108: // FN+F11
|
||||
Application.SetSuspendState(PowerState.Suspend, true, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void LaunchProcess(string command = "")
|
||||
{
|
||||
string executable = command.Split(' ')[0];
|
||||
string arguments = command.Substring(executable.Length).Trim();
|
||||
|
||||
try
|
||||
{
|
||||
Process proc = Process.Start(executable, arguments);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.WriteLine("Failed to run " + command);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
if (e.NewEvent is null) return;
|
||||
int EventID = int.Parse(e.NewEvent["EventID"].ToString());
|
||||
Logger.WriteLine("WMI event " + EventID);
|
||||
HandleEvent(EventID);
|
||||
}
|
||||
}
|
||||
}
|
||||
110
app/Extra.cs
110
app/Extra.cs
@@ -39,7 +39,7 @@ namespace GHelper
|
||||
combo.DisplayMember = "Value";
|
||||
combo.ValueMember = "Key";
|
||||
|
||||
string action = Program.config.getConfigString(name);
|
||||
string action = AppConfig.getConfigString(name);
|
||||
|
||||
combo.SelectedValue = (action is not null) ? action : "";
|
||||
if (combo.SelectedValue is null) combo.SelectedValue = "";
|
||||
@@ -47,13 +47,13 @@ namespace GHelper
|
||||
combo.SelectedValueChanged += delegate
|
||||
{
|
||||
if (combo.SelectedValue is not null)
|
||||
Program.config.setConfig(name, combo.SelectedValue.ToString());
|
||||
AppConfig.setConfig(name, combo.SelectedValue.ToString());
|
||||
};
|
||||
|
||||
txbox.Text = Program.config.getConfigString(name + "_custom");
|
||||
txbox.Text = AppConfig.getConfigString(name + "_custom");
|
||||
txbox.TextChanged += delegate
|
||||
{
|
||||
Program.config.setConfig(name + "_custom", txbox.Text);
|
||||
AppConfig.setConfig(name + "_custom", txbox.Text);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,28 +103,28 @@ namespace GHelper
|
||||
comboKeyboardSpeed.SelectedValueChanged += ComboKeyboardSpeed_SelectedValueChanged;
|
||||
|
||||
// Keyboard
|
||||
checkAwake.Checked = !(Program.config.getConfig("keyboard_awake") == 0);
|
||||
checkBoot.Checked = !(Program.config.getConfig("keyboard_boot") == 0);
|
||||
checkSleep.Checked = !(Program.config.getConfig("keyboard_sleep") == 0);
|
||||
checkShutdown.Checked = !(Program.config.getConfig("keyboard_shutdown") == 0);
|
||||
checkAwake.Checked = !(AppConfig.getConfig("keyboard_awake") == 0);
|
||||
checkBoot.Checked = !(AppConfig.getConfig("keyboard_boot") == 0);
|
||||
checkSleep.Checked = !(AppConfig.getConfig("keyboard_sleep") == 0);
|
||||
checkShutdown.Checked = !(AppConfig.getConfig("keyboard_shutdown") == 0);
|
||||
|
||||
// Lightbar
|
||||
checkAwakeBar.Checked = !(Program.config.getConfig("keyboard_awake_bar") == 0);
|
||||
checkBootBar.Checked = !(Program.config.getConfig("keyboard_boot_bar") == 0);
|
||||
checkSleepBar.Checked = !(Program.config.getConfig("keyboard_sleep_bar") == 0);
|
||||
checkShutdownBar.Checked = !(Program.config.getConfig("keyboard_shutdown_bar") == 0);
|
||||
checkAwakeBar.Checked = !(AppConfig.getConfig("keyboard_awake_bar") == 0);
|
||||
checkBootBar.Checked = !(AppConfig.getConfig("keyboard_boot_bar") == 0);
|
||||
checkSleepBar.Checked = !(AppConfig.getConfig("keyboard_sleep_bar") == 0);
|
||||
checkShutdownBar.Checked = !(AppConfig.getConfig("keyboard_shutdown_bar") == 0);
|
||||
|
||||
// Lid
|
||||
checkAwakeLid.Checked = !(Program.config.getConfig("keyboard_awake_lid") == 0);
|
||||
checkBootLid.Checked = !(Program.config.getConfig("keyboard_boot_lid") == 0);
|
||||
checkSleepLid.Checked = !(Program.config.getConfig("keyboard_sleep_lid") == 0);
|
||||
checkShutdownLid.Checked = !(Program.config.getConfig("keyboard_shutdown_lid") == 0);
|
||||
checkAwakeLid.Checked = !(AppConfig.getConfig("keyboard_awake_lid") == 0);
|
||||
checkBootLid.Checked = !(AppConfig.getConfig("keyboard_boot_lid") == 0);
|
||||
checkSleepLid.Checked = !(AppConfig.getConfig("keyboard_sleep_lid") == 0);
|
||||
checkShutdownLid.Checked = !(AppConfig.getConfig("keyboard_shutdown_lid") == 0);
|
||||
|
||||
// Logo
|
||||
checkAwakeLogo.Checked = !(Program.config.getConfig("keyboard_awake_logo") == 0);
|
||||
checkBootLogo.Checked = !(Program.config.getConfig("keyboard_boot_logo") == 0);
|
||||
checkSleepLogo.Checked = !(Program.config.getConfig("keyboard_sleep_logo") == 0);
|
||||
checkShutdownLogo.Checked = !(Program.config.getConfig("keyboard_shutdown_logo") == 0);
|
||||
checkAwakeLogo.Checked = !(AppConfig.getConfig("keyboard_awake_logo") == 0);
|
||||
checkBootLogo.Checked = !(AppConfig.getConfig("keyboard_boot_logo") == 0);
|
||||
checkSleepLogo.Checked = !(AppConfig.getConfig("keyboard_sleep_logo") == 0);
|
||||
checkShutdownLogo.Checked = !(AppConfig.getConfig("keyboard_shutdown_logo") == 0);
|
||||
|
||||
checkAwake.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkBoot.CheckedChanged += CheckPower_CheckedChanged;
|
||||
@@ -146,7 +146,7 @@ namespace GHelper
|
||||
checkSleepLogo.CheckedChanged += CheckPower_CheckedChanged;
|
||||
checkShutdownLogo.CheckedChanged += CheckPower_CheckedChanged;
|
||||
|
||||
if (!Program.config.ContainsModel("Strix"))
|
||||
if (!AppConfig.ContainsModel("Strix"))
|
||||
{
|
||||
labelBacklightBar.Visible = false;
|
||||
checkAwakeBar.Visible = false;
|
||||
@@ -154,7 +154,7 @@ namespace GHelper
|
||||
checkSleepBar.Visible = false;
|
||||
checkShutdownBar.Visible = false;
|
||||
|
||||
if (!Program.config.ContainsModel("Z13"))
|
||||
if (!AppConfig.ContainsModel("Z13"))
|
||||
{
|
||||
labelBacklightLid.Visible = false;
|
||||
checkAwakeLid.Visible = false;
|
||||
@@ -170,32 +170,32 @@ namespace GHelper
|
||||
}
|
||||
}
|
||||
|
||||
checkTopmost.Checked = (Program.config.getConfig("topmost") == 1);
|
||||
checkTopmost.Checked = (AppConfig.getConfig("topmost") == 1);
|
||||
checkTopmost.CheckedChanged += CheckTopmost_CheckedChanged; ;
|
||||
|
||||
checkKeyboardAuto.Checked = (Program.config.getConfig("keyboard_auto") == 1);
|
||||
checkKeyboardAuto.Checked = (AppConfig.getConfig("keyboard_auto") == 1);
|
||||
checkKeyboardAuto.CheckedChanged += CheckKeyboardAuto_CheckedChanged;
|
||||
|
||||
checkNoOverdrive.Checked = (Program.config.getConfig("no_overdrive") == 1);
|
||||
checkNoOverdrive.Checked = (AppConfig.getConfig("no_overdrive") == 1);
|
||||
checkNoOverdrive.CheckedChanged += CheckNoOverdrive_CheckedChanged;
|
||||
|
||||
checkUSBC.Checked = (Program.config.getConfig("optimized_usbc") == 1);
|
||||
checkUSBC.Checked = (AppConfig.getConfig("optimized_usbc") == 1);
|
||||
checkUSBC.CheckedChanged += CheckUSBC_CheckedChanged;
|
||||
|
||||
checkAutoApplyWindowsPowerMode.Checked = (Program.config.getConfig("auto_apply_power_plan") != 0);
|
||||
checkAutoApplyWindowsPowerMode.Checked = (AppConfig.getConfig("auto_apply_power_plan") != 0);
|
||||
checkAutoApplyWindowsPowerMode.CheckedChanged += checkAutoApplyWindowsPowerMode_CheckedChanged;
|
||||
|
||||
int kb_brightness = Program.config.getConfig("keyboard_brightness");
|
||||
int kb_brightness = AppConfig.getConfig("keyboard_brightness");
|
||||
trackBrightness.Value = (kb_brightness >= 0 && kb_brightness <= 3) ? kb_brightness : 3;
|
||||
|
||||
pictureHelp.Click += PictureHelp_Click;
|
||||
trackBrightness.Scroll += TrackBrightness_Scroll;
|
||||
|
||||
panelXMG.Visible = (Program.acpi.DeviceGet(AsusACPI.GPUXGConnected) == 1);
|
||||
checkXMG.Checked = !(Program.config.getConfig("xmg_light") == 0);
|
||||
checkXMG.Checked = !(AppConfig.getConfig("xmg_light") == 0);
|
||||
checkXMG.CheckedChanged += CheckXMG_CheckedChanged;
|
||||
|
||||
int kb_timeout = Program.config.getConfig("keyboard_light_tiomeout");
|
||||
int kb_timeout = AppConfig.getConfig("keyboard_light_tiomeout");
|
||||
numericBacklightTime.Value = (kb_timeout >= 0) ? kb_timeout : 60;
|
||||
|
||||
numericBacklightTime.ValueChanged += NumericBacklightTime_ValueChanged;
|
||||
@@ -205,24 +205,24 @@ namespace GHelper
|
||||
private void NumericBacklightTime_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.RunAsAdmin("extra");
|
||||
Program.config.setConfig("keyboard_light_tiomeout", (int)numericBacklightTime.Value);
|
||||
AppConfig.setConfig("keyboard_light_tiomeout", (int)numericBacklightTime.Value);
|
||||
AsusUSB.SetBacklightOffDelay((int)numericBacklightTime.Value);
|
||||
}
|
||||
|
||||
private void CheckXMG_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("xmg_light", (checkXMG.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("xmg_light", (checkXMG.Checked ? 1 : 0));
|
||||
AsusUSB.ApplyXGMLight(checkXMG.Checked);
|
||||
}
|
||||
|
||||
private void CheckUSBC_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("optimized_usbc", (checkUSBC.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("optimized_usbc", (checkUSBC.Checked ? 1 : 0));
|
||||
}
|
||||
|
||||
private void TrackBrightness_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_brightness", trackBrightness.Value);
|
||||
AppConfig.setConfig("keyboard_brightness", trackBrightness.Value);
|
||||
AsusUSB.ApplyBrightness(trackBrightness.Value);
|
||||
}
|
||||
|
||||
@@ -233,42 +233,42 @@ namespace GHelper
|
||||
|
||||
private void CheckNoOverdrive_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("no_overdrive", (checkNoOverdrive.Checked ? 1 : 0));
|
||||
Program.settingsForm.AutoScreen(true);
|
||||
}
|
||||
|
||||
private void CheckKeyboardAuto_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_auto", (checkKeyboardAuto.Checked ? 1 : 0));
|
||||
}
|
||||
|
||||
private void CheckTopmost_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("topmost", (checkTopmost.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("topmost", (checkTopmost.Checked ? 1 : 0));
|
||||
Program.settingsForm.TopMost = checkTopmost.Checked;
|
||||
}
|
||||
|
||||
private void CheckPower_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("keyboard_awake", (checkAwake.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_boot", (checkBoot.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_sleep", (checkSleep.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_shutdown", (checkShutdown.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_awake", (checkAwake.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_boot", (checkBoot.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_sleep", (checkSleep.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_shutdown", (checkShutdown.Checked ? 1 : 0));
|
||||
|
||||
Program.config.setConfig("keyboard_awake_bar", (checkAwakeBar.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_boot_bar", (checkBootBar.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_sleep_bar", (checkSleepBar.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_shutdown_bar", (checkShutdownBar.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_awake_bar", (checkAwakeBar.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_boot_bar", (checkBootBar.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_sleep_bar", (checkSleepBar.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_shutdown_bar", (checkShutdownBar.Checked ? 1 : 0));
|
||||
|
||||
Program.config.setConfig("keyboard_awake_lid", (checkAwakeLid.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_boot_lid", (checkBootLid.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_sleep_lid", (checkSleepLid.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_shutdown_lid", (checkShutdownLid.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_awake_lid", (checkAwakeLid.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_boot_lid", (checkBootLid.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_sleep_lid", (checkSleepLid.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_shutdown_lid", (checkShutdownLid.Checked ? 1 : 0));
|
||||
|
||||
Program.config.setConfig("keyboard_awake_logo", (checkAwakeLogo.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_boot_logo", (checkBootLogo.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_sleep_logo", (checkSleepLogo.Checked ? 1 : 0));
|
||||
Program.config.setConfig("keyboard_shutdown_logo", (checkShutdownLogo.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_awake_logo", (checkAwakeLogo.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_boot_logo", (checkBootLogo.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_sleep_logo", (checkSleepLogo.Checked ? 1 : 0));
|
||||
AppConfig.setConfig("keyboard_shutdown_logo", (checkShutdownLogo.Checked ? 1 : 0));
|
||||
|
||||
List<AuraDev19b6> flags = new List<AuraDev19b6>();
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace GHelper
|
||||
|
||||
private void ComboKeyboardSpeed_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("aura_speed", (int)comboKeyboardSpeed.SelectedValue);
|
||||
AppConfig.setConfig("aura_speed", (int)comboKeyboardSpeed.SelectedValue);
|
||||
Program.settingsForm.SetAura();
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ namespace GHelper
|
||||
|
||||
private void checkAutoApplyWindowsPowerMode_CheckedChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("auto_apply_power_plan", checkAutoApplyWindowsPowerMode.Checked ? 1 : 0);
|
||||
AppConfig.setConfig("auto_apply_power_plan", checkAutoApplyWindowsPowerMode.Checked ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
73
app/Fans.Designer.cs
generated
73
app/Fans.Designer.cs
generated
@@ -44,8 +44,8 @@ namespace GHelper
|
||||
tableFanCharts = new TableLayoutPanel();
|
||||
chartGPU = new Chart();
|
||||
chartCPU = new Chart();
|
||||
chartMid = new Chart();
|
||||
chartXGM = new Chart();
|
||||
chartMid = new Chart();
|
||||
panelTitleFans = new Panel();
|
||||
labelBoost = new Label();
|
||||
comboBoost = new RComboBox();
|
||||
@@ -95,8 +95,8 @@ namespace GHelper
|
||||
tableFanCharts.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)chartGPU).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartCPU).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartMid).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartXGM).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartMid).BeginInit();
|
||||
panelTitleFans.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).BeginInit();
|
||||
panelApplyFans.SuspendLayout();
|
||||
@@ -159,10 +159,8 @@ namespace GHelper
|
||||
tableFanCharts.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
|
||||
tableFanCharts.Controls.Add(chartGPU, 0, 1);
|
||||
tableFanCharts.Controls.Add(chartCPU, 0, 0);
|
||||
|
||||
tableFanCharts.Controls.Add(chartXGM, 0, 2);
|
||||
tableFanCharts.Controls.Add(chartMid, 0, 2);
|
||||
|
||||
tableFanCharts.Dock = DockStyle.Fill;
|
||||
tableFanCharts.Location = new Point(0, 66);
|
||||
tableFanCharts.Margin = new Padding(4);
|
||||
@@ -181,10 +179,10 @@ namespace GHelper
|
||||
chartArea1.Name = "ChartArea1";
|
||||
chartGPU.ChartAreas.Add(chartArea1);
|
||||
chartGPU.Dock = DockStyle.Fill;
|
||||
chartGPU.Location = new Point(12, 342);
|
||||
chartGPU.Location = new Point(12, 259);
|
||||
chartGPU.Margin = new Padding(2, 10, 2, 10);
|
||||
chartGPU.Name = "chartGPU";
|
||||
chartGPU.Size = new Size(781, 312);
|
||||
chartGPU.Size = new Size(781, 229);
|
||||
chartGPU.TabIndex = 17;
|
||||
chartGPU.Text = "chartGPU";
|
||||
title1.Name = "Title1";
|
||||
@@ -198,41 +196,42 @@ namespace GHelper
|
||||
chartCPU.Location = new Point(12, 10);
|
||||
chartCPU.Margin = new Padding(2, 10, 2, 10);
|
||||
chartCPU.Name = "chartCPU";
|
||||
chartCPU.Size = new Size(781, 312);
|
||||
chartCPU.Size = new Size(781, 229);
|
||||
chartCPU.TabIndex = 14;
|
||||
chartCPU.Text = "chartCPU";
|
||||
title2.Name = "Title1";
|
||||
chartCPU.Titles.Add(title2);
|
||||
//
|
||||
// chartMid
|
||||
//
|
||||
chartArea3.Name = "ChartArea3";
|
||||
chartMid.ChartAreas.Add(chartArea3);
|
||||
chartMid.Dock = DockStyle.Fill;
|
||||
chartMid.Location = new Point(12, 674);
|
||||
chartMid.Margin = new Padding(2, 10, 2, 10);
|
||||
chartMid.Name = "chartMid";
|
||||
chartMid.Size = new Size(781, 313);
|
||||
chartMid.TabIndex = 14;
|
||||
chartMid.Text = "chartMid";
|
||||
title3.Name = "Title3";
|
||||
chartMid.Titles.Add(title3);
|
||||
chartMid.Visible = false;
|
||||
//
|
||||
// chartXGM
|
||||
//
|
||||
chartArea4.Name = "ChartAreaXGM";
|
||||
chartXGM.ChartAreas.Add(chartArea4);
|
||||
chartArea3.Name = "ChartAreaXGM";
|
||||
chartXGM.ChartAreas.Add(chartArea3);
|
||||
chartXGM.Dock = DockStyle.Fill;
|
||||
chartXGM.Location = new Point(12, 674);
|
||||
chartXGM.Location = new Point(12, 757);
|
||||
chartXGM.Margin = new Padding(2, 10, 2, 10);
|
||||
chartXGM.Name = "chartXGM";
|
||||
chartXGM.Size = new Size(781, 313);
|
||||
chartXGM.Size = new Size(781, 230);
|
||||
chartXGM.TabIndex = 14;
|
||||
chartXGM.Text = "chartXGM";
|
||||
title4.Name = "Title4";
|
||||
chartXGM.Titles.Add(title4);
|
||||
chartXGM.Visible = false; //
|
||||
title3.Name = "Title4";
|
||||
chartXGM.Titles.Add(title3);
|
||||
chartXGM.Visible = false;
|
||||
//
|
||||
// chartMid
|
||||
//
|
||||
chartArea4.Name = "ChartArea3";
|
||||
chartMid.ChartAreas.Add(chartArea4);
|
||||
chartMid.Dock = DockStyle.Fill;
|
||||
chartMid.Location = new Point(12, 508);
|
||||
chartMid.Margin = new Padding(2, 10, 2, 10);
|
||||
chartMid.Name = "chartMid";
|
||||
chartMid.Size = new Size(781, 229);
|
||||
chartMid.TabIndex = 14;
|
||||
chartMid.Text = "chartMid";
|
||||
title4.Name = "Title3";
|
||||
chartMid.Titles.Add(title4);
|
||||
chartMid.Visible = false;
|
||||
//
|
||||
// panelTitleFans
|
||||
//
|
||||
panelTitleFans.Controls.Add(labelBoost);
|
||||
@@ -248,9 +247,9 @@ namespace GHelper
|
||||
// labelBoost
|
||||
//
|
||||
labelBoost.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
labelBoost.Location = new Point(335, 20);
|
||||
labelBoost.Location = new Point(356, 20);
|
||||
labelBoost.Name = "labelBoost";
|
||||
labelBoost.Size = new Size(143, 32);
|
||||
labelBoost.Size = new Size(140, 32);
|
||||
labelBoost.TabIndex = 43;
|
||||
labelBoost.Text = "CPU Boost";
|
||||
labelBoost.TextAlign = ContentAlignment.MiddleRight;
|
||||
@@ -263,7 +262,7 @@ namespace GHelper
|
||||
comboBoost.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoost.FormattingEnabled = true;
|
||||
comboBoost.Items.AddRange(new object[] { "Disabled", "Enabled", "Aggressive", "Efficient Enabled", "Efficient Aggressive" });
|
||||
comboBoost.Location = new Point(503, 16);
|
||||
comboBoost.Location = new Point(506, 16);
|
||||
comboBoost.Name = "comboBoost";
|
||||
comboBoost.Size = new Size(287, 40);
|
||||
comboBoost.TabIndex = 42;
|
||||
@@ -282,11 +281,12 @@ namespace GHelper
|
||||
//
|
||||
// labelFans
|
||||
//
|
||||
labelFans.AutoSize = true;
|
||||
labelFans.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
labelFans.Location = new Point(64, 20);
|
||||
labelFans.Location = new Point(62, 20);
|
||||
labelFans.Margin = new Padding(4, 0, 4, 0);
|
||||
labelFans.Name = "labelFans";
|
||||
labelFans.Size = new Size(293, 32);
|
||||
labelFans.Size = new Size(138, 32);
|
||||
labelFans.TabIndex = 40;
|
||||
labelFans.Text = "Fan Curves";
|
||||
//
|
||||
@@ -317,7 +317,7 @@ namespace GHelper
|
||||
checkApplyFans.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
checkApplyFans.AutoSize = true;
|
||||
checkApplyFans.BackColor = SystemColors.ControlLight;
|
||||
checkApplyFans.Location = new Point(454, 46);
|
||||
checkApplyFans.Location = new Point(453, 45);
|
||||
checkApplyFans.Margin = new Padding(4, 2, 4, 2);
|
||||
checkApplyFans.Name = "checkApplyFans";
|
||||
checkApplyFans.Padding = new Padding(15, 5, 15, 5);
|
||||
@@ -804,9 +804,10 @@ namespace GHelper
|
||||
tableFanCharts.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)chartGPU).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartCPU).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartMid).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartXGM).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)chartMid).EndInit();
|
||||
panelTitleFans.ResumeLayout(false);
|
||||
panelTitleFans.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)picturePerf).EndInit();
|
||||
panelApplyFans.ResumeLayout(false);
|
||||
panelApplyFans.PerformLayout();
|
||||
|
||||
78
app/Fans.cs
78
app/Fans.cs
@@ -152,10 +152,10 @@ namespace GHelper
|
||||
{
|
||||
panelGPU.Visible = true;
|
||||
|
||||
int gpu_boost = Program.config.getConfigPerf("gpu_boost");
|
||||
int gpu_temp = Program.config.getConfigPerf("gpu_temp");
|
||||
int core = Program.config.getConfigPerf("gpu_core");
|
||||
int memory = Program.config.getConfigPerf("gpu_memory");
|
||||
int gpu_boost = AppConfig.getConfigPerf("gpu_boost");
|
||||
int gpu_temp = AppConfig.getConfigPerf("gpu_temp");
|
||||
int core = AppConfig.getConfigPerf("gpu_core");
|
||||
int memory = AppConfig.getConfigPerf("gpu_memory");
|
||||
|
||||
if (gpu_boost < 0) gpu_boost = AsusACPI.MaxGPUBoost;
|
||||
if (gpu_temp < 0) gpu_temp = AsusACPI.MaxGPUTemp;
|
||||
@@ -217,8 +217,8 @@ namespace GHelper
|
||||
TrackBar track = (TrackBar)sender;
|
||||
track.Value = (int)Math.Round((float)track.Value / 5) * 5;
|
||||
|
||||
Program.config.setConfigPerf("gpu_core", trackGPUCore.Value);
|
||||
Program.config.setConfigPerf("gpu_memory", trackGPUMemory.Value);
|
||||
AppConfig.setConfigPerf("gpu_core", trackGPUCore.Value);
|
||||
AppConfig.setConfigPerf("gpu_memory", trackGPUMemory.Value);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
|
||||
@@ -226,8 +226,8 @@ namespace GHelper
|
||||
|
||||
private void trackGPUPower_Scroll(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfigPerf("gpu_boost", trackGPUBoost.Value);
|
||||
Program.config.setConfigPerf("gpu_temp", trackGPUTemp.Value);
|
||||
AppConfig.setConfigPerf("gpu_boost", trackGPUBoost.Value);
|
||||
AppConfig.setConfigPerf("gpu_temp", trackGPUTemp.Value);
|
||||
|
||||
VisualiseGPUSettings();
|
||||
}
|
||||
@@ -326,10 +326,10 @@ namespace GHelper
|
||||
|
||||
private void ComboBoost_Changed(object? sender, EventArgs e)
|
||||
{
|
||||
if (Program.config.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
|
||||
if (AppConfig.getConfigPerf("auto_boost") != comboBoost.SelectedIndex)
|
||||
{
|
||||
NativeMethods.SetCPUBoost(comboBoost.SelectedIndex);
|
||||
Program.config.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
|
||||
AppConfig.setConfigPerf("auto_boost", comboBoost.SelectedIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace GHelper
|
||||
{
|
||||
if (sender is null) return;
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
Program.config.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
|
||||
AppConfig.setConfigPerf("auto_apply_power", chk.Checked ? 1 : 0);
|
||||
|
||||
if (chk.Checked)
|
||||
{
|
||||
@@ -345,7 +345,7 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "PerfMode");
|
||||
Program.settingsForm.AutoFans();
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ namespace GHelper
|
||||
if (sender is null) return;
|
||||
CheckBox chk = (CheckBox)sender;
|
||||
|
||||
Program.config.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
|
||||
AppConfig.setConfigPerf("auto_apply", chk.Checked ? 1 : 0);
|
||||
|
||||
if (chk.Checked)
|
||||
{
|
||||
@@ -364,7 +364,7 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "PerfMode");
|
||||
Program.settingsForm.AutoPower();
|
||||
}
|
||||
}
|
||||
@@ -405,7 +405,7 @@ namespace GHelper
|
||||
|
||||
int limit_total;
|
||||
int limit_cpu;
|
||||
bool apply = Program.config.getConfigPerf("auto_apply_power") == 1;
|
||||
bool apply = AppConfig.getConfigPerf("auto_apply_power") == 1;
|
||||
|
||||
if (changed)
|
||||
{
|
||||
@@ -414,8 +414,8 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
limit_total = Program.config.getConfigPerf("limit_total");
|
||||
limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||
limit_total = AppConfig.getConfigPerf("limit_total");
|
||||
limit_cpu = AppConfig.getConfigPerf("limit_cpu");
|
||||
}
|
||||
|
||||
if (limit_total < 0) limit_total = AsusACPI.DefaultTotal;
|
||||
@@ -434,8 +434,8 @@ namespace GHelper
|
||||
labelTotal.Text = trackTotal.Value.ToString() + "W";
|
||||
labelCPU.Text = trackCPU.Value.ToString() + "W";
|
||||
|
||||
Program.config.setConfigPerf("limit_total", limit_total);
|
||||
Program.config.setConfigPerf("limit_cpu", limit_cpu);
|
||||
AppConfig.setConfigPerf("limit_total", limit_total);
|
||||
AppConfig.setConfigPerf("limit_cpu", limit_cpu);
|
||||
|
||||
|
||||
}
|
||||
@@ -455,7 +455,7 @@ namespace GHelper
|
||||
// Middle / system fan check
|
||||
if (!AsusACPI.IsEmptyCurve(Program.acpi.GetFanCurve(AsusFan.Mid)))
|
||||
{
|
||||
Program.config.setConfig("mid_fan", 1);
|
||||
AppConfig.setConfig("mid_fan", 1);
|
||||
chartCount++;
|
||||
chartMid.Visible = true;
|
||||
SetChart(chartMid, AsusFan.Mid);
|
||||
@@ -464,13 +464,13 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.config.setConfig("mid_fan", 0);
|
||||
AppConfig.setConfig("mid_fan", 0);
|
||||
}
|
||||
|
||||
// XG Mobile Fan check
|
||||
if (Program.acpi.IsXGConnected())
|
||||
{
|
||||
Program.config.setConfig("xgm_fan", 1);
|
||||
AppConfig.setConfig("xgm_fan", 1);
|
||||
chartCount++;
|
||||
chartXGM.Visible = true;
|
||||
SetChart(chartXGM, AsusFan.XGM);
|
||||
@@ -479,7 +479,7 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.config.setConfig("xgm_fan", 0);
|
||||
AppConfig.setConfig("xgm_fan", 0);
|
||||
}
|
||||
|
||||
SetChart(chartCPU, AsusFan.CPU);
|
||||
@@ -488,7 +488,7 @@ namespace GHelper
|
||||
LoadProfile(seriesCPU, AsusFan.CPU);
|
||||
LoadProfile(seriesGPU, AsusFan.GPU);
|
||||
|
||||
int auto_apply = Program.config.getConfigPerf("auto_apply");
|
||||
int auto_apply = AppConfig.getConfigPerf("auto_apply");
|
||||
|
||||
checkApplyFans.Checked = (auto_apply == 1);
|
||||
|
||||
@@ -504,15 +504,15 @@ namespace GHelper
|
||||
|
||||
series.Points.Clear();
|
||||
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
byte[] curve = Program.config.getFanConfig(device);
|
||||
int mode = AppConfig.getConfig("performance_mode");
|
||||
byte[] curve = AppConfig.getFanConfig(device);
|
||||
|
||||
if (reset || AsusACPI.IsEmptyCurve(curve))
|
||||
{
|
||||
curve = Program.acpi.GetFanCurve(device, mode);
|
||||
|
||||
if (AsusACPI.IsEmptyCurve(curve))
|
||||
curve = Program.config.getDefaultCurve(device);
|
||||
curve = AppConfig.getDefaultCurve(device);
|
||||
|
||||
curve = AsusACPI.FixFanCurve(curve);
|
||||
|
||||
@@ -543,7 +543,7 @@ namespace GHelper
|
||||
i++;
|
||||
}
|
||||
|
||||
Program.config.setFanConfig(device, curve);
|
||||
AppConfig.setFanConfig(device, curve);
|
||||
//Program.wmi.SetFanCurve(device, curve);
|
||||
|
||||
}
|
||||
@@ -555,19 +555,19 @@ namespace GHelper
|
||||
LoadProfile(seriesCPU, AsusFan.CPU, true);
|
||||
LoadProfile(seriesGPU, AsusFan.GPU, true);
|
||||
|
||||
if (Program.config.isConfig("mid_fan"))
|
||||
if (AppConfig.isConfig("mid_fan"))
|
||||
LoadProfile(seriesMid, AsusFan.Mid, true);
|
||||
|
||||
if (Program.config.isConfig("xgm_fan"))
|
||||
if (AppConfig.isConfig("xgm_fan"))
|
||||
LoadProfile(seriesXGM, AsusFan.XGM, true);
|
||||
|
||||
checkApplyFans.Checked = false;
|
||||
checkApplyPower.Checked = false;
|
||||
|
||||
Program.config.setConfigPerf("auto_apply", 0);
|
||||
Program.config.setConfigPerf("auto_apply_power", 0);
|
||||
AppConfig.setConfigPerf("auto_apply", 0);
|
||||
AppConfig.setConfigPerf("auto_apply_power", 0);
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, Program.config.getConfig("performance_mode"), "PerfMode");
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, AppConfig.getConfig("performance_mode"), "PerfMode");
|
||||
if (Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
||||
|
||||
trackGPUCore.Value = 0;
|
||||
@@ -575,10 +575,10 @@ namespace GHelper
|
||||
trackGPUBoost.Value = AsusACPI.MaxGPUBoost;
|
||||
trackGPUTemp.Value = AsusACPI.MaxGPUTemp;
|
||||
|
||||
Program.config.setConfigPerf("gpu_boost", trackGPUBoost.Value);
|
||||
Program.config.setConfigPerf("gpu_temp", trackGPUTemp.Value);
|
||||
Program.config.setConfigPerf("gpu_core", trackGPUCore.Value);
|
||||
Program.config.setConfigPerf("gpu_memory", trackGPUMemory.Value);
|
||||
AppConfig.setConfigPerf("gpu_boost", trackGPUBoost.Value);
|
||||
AppConfig.setConfigPerf("gpu_temp", trackGPUTemp.Value);
|
||||
AppConfig.setConfigPerf("gpu_core", trackGPUCore.Value);
|
||||
AppConfig.setConfigPerf("gpu_memory", trackGPUMemory.Value);
|
||||
VisualiseGPUSettings();
|
||||
|
||||
Program.settingsForm.SetGPUClocks(true);
|
||||
@@ -593,10 +593,10 @@ namespace GHelper
|
||||
SaveProfile(seriesCPU, AsusFan.CPU);
|
||||
SaveProfile(seriesGPU, AsusFan.GPU);
|
||||
|
||||
if (Program.config.isConfig("mid_fan"))
|
||||
if (AppConfig.isConfig("mid_fan"))
|
||||
SaveProfile(seriesMid, AsusFan.Mid);
|
||||
|
||||
if (Program.config.isConfig("xgm_fan"))
|
||||
if (AppConfig.isConfig("xgm_fan"))
|
||||
SaveProfile(seriesXGM, AsusFan.XGM);
|
||||
|
||||
Program.settingsForm.AutoFans();
|
||||
|
||||
@@ -132,8 +132,8 @@ public class NvidiaGpuControl : IGpuControl
|
||||
|
||||
public int SetClocksFromConfig()
|
||||
{
|
||||
int core = Program.config.getConfig("gpu_core");
|
||||
int memory = Program.config.getConfig("gpu_memory");
|
||||
int core = AppConfig.getConfig("gpu_core");
|
||||
int memory = AppConfig.getConfig("gpu_memory");
|
||||
int status = SetClocks(core, memory);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -19,14 +19,14 @@ public static class HardwareControl
|
||||
public static int GetFanMax()
|
||||
{
|
||||
int max = 58;
|
||||
if (Program.config.ContainsModel("401")) max = 72;
|
||||
else if (Program.config.ContainsModel("503")) max = 68;
|
||||
return Math.Max(max, Program.config.getConfig("fan_max"));
|
||||
if (AppConfig.ContainsModel("401")) max = 72;
|
||||
else if (AppConfig.ContainsModel("503")) max = 68;
|
||||
return Math.Max(max, AppConfig.getConfig("fan_max"));
|
||||
}
|
||||
|
||||
public static void SetFanMax(int fan)
|
||||
{
|
||||
Program.config.setConfig("fan_max", fan);
|
||||
AppConfig.setConfig("fan_max", fan);
|
||||
}
|
||||
private static string FormatFan(int fan)
|
||||
{
|
||||
@@ -40,7 +40,7 @@ public static class HardwareControl
|
||||
int fanMax = GetFanMax();
|
||||
if (fan > fanMax && fan < 110) SetFanMax(fan);
|
||||
|
||||
if (Program.config.getConfig("fan_rpm") == 1)
|
||||
if (AppConfig.getConfig("fan_rpm") == 1)
|
||||
return GHelper.Properties.Strings.FanSpeed + (fan * 100).ToString() + GHelper.Properties.Strings.RPM;
|
||||
else
|
||||
return GHelper.Properties.Strings.FanSpeed + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
|
||||
|
||||
208
app/Program.cs
208
app/Program.cs
@@ -6,6 +6,7 @@ using System.Management;
|
||||
using System.Reflection;
|
||||
using System.Security.Principal;
|
||||
using Tools;
|
||||
using static NativeMethods;
|
||||
|
||||
namespace GHelper
|
||||
{
|
||||
@@ -20,7 +21,6 @@ namespace GHelper
|
||||
};
|
||||
|
||||
public static AsusACPI? acpi;
|
||||
public static AppConfig config = new AppConfig();
|
||||
|
||||
public static SettingsForm settingsForm = new SettingsForm();
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace GHelper
|
||||
private static long lastTheme;
|
||||
private static long lastAdmin;
|
||||
|
||||
private static bool isOptimizationRunning = OptimizationService.IsRunning();
|
||||
public static EventDispatcher eventDispatcher;
|
||||
|
||||
private static PowerLineStatus isPlugged = PowerLineStatus.Unknown;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace GHelper
|
||||
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;
|
||||
Debug.WriteLine(CultureInfo.CurrentUICulture);
|
||||
|
||||
//Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("fr");
|
||||
//Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("es");
|
||||
|
||||
CheckProcesses();
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace GHelper
|
||||
}
|
||||
|
||||
Logger.WriteLine("------------");
|
||||
Logger.WriteLine("App launched: " + config.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator() ? "A" : ""));
|
||||
Logger.WriteLine("App launched: " + AppConfig.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator() ? "A" : ""));
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace GHelper
|
||||
|
||||
trayIcon.MouseClick += TrayIcon_MouseClick;
|
||||
|
||||
acpi.SubscribeToEvents(WatcherEventArrived);
|
||||
eventDispatcher = new EventDispatcher(ds);
|
||||
|
||||
settingsForm.InitAura();
|
||||
settingsForm.InitMatrix();
|
||||
@@ -88,16 +88,9 @@ namespace GHelper
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
|
||||
// Subscribing for monitor power on events
|
||||
var settingGuid = new NativeMethods.PowerSettingGuid();
|
||||
PowerSettingGuid settingGuid = new NativeMethods.PowerSettingGuid();
|
||||
unRegPowerNotify = NativeMethods.RegisterPowerSettingNotification(ds, settingGuid.ConsoleDisplayState, NativeMethods.DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
|
||||
// CTRL + SHIFT + F5 to cycle profiles
|
||||
Keys keybind_profile = (config.getConfig("keybind_profile") != -1) ? (Keys)config.getConfig("keybind_profile") : Keys.F5;
|
||||
if (keybind_profile != 0)
|
||||
{
|
||||
var ghk = new KeyHandler(KeyHandler.SHIFT | KeyHandler.CTRL, keybind_profile, ds);
|
||||
ghk.Register();
|
||||
}
|
||||
|
||||
|
||||
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0)
|
||||
@@ -105,7 +98,7 @@ namespace GHelper
|
||||
SettingsToggle(action);
|
||||
}
|
||||
|
||||
if (!isOptimizationRunning) AsusUSB.RunListener(HandleEvent);
|
||||
|
||||
|
||||
Application.Run();
|
||||
|
||||
@@ -149,7 +142,7 @@ namespace GHelper
|
||||
isPlugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
Logger.WriteLine("AutoSetting for " + isPlugged.ToString());
|
||||
|
||||
settingsForm.SetBatteryChargeLimit(config.getConfig("charge_limit"));
|
||||
settingsForm.SetBatteryChargeLimit(AppConfig.getConfig("charge_limit"));
|
||||
settingsForm.AutoPerformance();
|
||||
|
||||
bool switched = settingsForm.AutoGPUMode();
|
||||
@@ -173,191 +166,8 @@ namespace GHelper
|
||||
}
|
||||
|
||||
|
||||
static void LaunchProcess(string command = "")
|
||||
{
|
||||
string executable = command.Split(' ')[0];
|
||||
string arguments = command.Substring(executable.Length).Trim();
|
||||
|
||||
try
|
||||
{
|
||||
Process proc = Process.Start(executable, arguments);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Logger.WriteLine("Failed to run " + command);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void CustomKey(string configKey = "m3")
|
||||
{
|
||||
string command = config.getConfigString(configKey + "_custom");
|
||||
int intKey;
|
||||
|
||||
try
|
||||
{
|
||||
intKey = Convert.ToInt32(command, 16);
|
||||
}
|
||||
catch
|
||||
{
|
||||
intKey = -1;
|
||||
}
|
||||
|
||||
|
||||
if (intKey > 0)
|
||||
NativeMethods.KeyPress(intKey);
|
||||
else
|
||||
LaunchProcess(command);
|
||||
|
||||
}
|
||||
|
||||
static void KeyProcess(string name = "m3")
|
||||
{
|
||||
string action = config.getConfigString(name);
|
||||
|
||||
if (action is null || action.Length <= 1)
|
||||
{
|
||||
if (name == "m4")
|
||||
action = "ghelper";
|
||||
if (name == "fnf4")
|
||||
action = "aura";
|
||||
if (name == "m3" && !isOptimizationRunning)
|
||||
action = "micmute";
|
||||
}
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case "mute":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_VOLUME_MUTE);
|
||||
break;
|
||||
case "play":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_MEDIA_PLAY_PAUSE);
|
||||
break;
|
||||
case "screenshot":
|
||||
NativeMethods.KeyPress(NativeMethods.VK_SNAPSHOT);
|
||||
break;
|
||||
case "screen":
|
||||
NativeMethods.TurnOffScreen(Program.settingsForm.Handle);
|
||||
break;
|
||||
case "miniled":
|
||||
settingsForm.BeginInvoke(settingsForm.ToogleMiniled);
|
||||
break;
|
||||
case "aura":
|
||||
settingsForm.BeginInvoke(settingsForm.CycleAuraMode);
|
||||
break;
|
||||
case "performance":
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
break;
|
||||
case "ghelper":
|
||||
settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
SettingsToggle();
|
||||
});
|
||||
break;
|
||||
case "custom":
|
||||
CustomKey(name);
|
||||
break;
|
||||
case "micmute":
|
||||
using (var enumerator = new MMDeviceEnumerator())
|
||||
{
|
||||
var commDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
|
||||
bool muteStatus = !commDevice.AudioEndpointVolume.Mute;
|
||||
commDevice.AudioEndpointVolume.Mute = muteStatus;
|
||||
settingsForm.BeginInvoke(settingsForm.RunToast, muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void TabletMode()
|
||||
{
|
||||
bool touchpadState, tabletState;
|
||||
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
|
||||
{
|
||||
touchpadState = (key?.GetValue("Enabled")?.ToString() == "1");
|
||||
}
|
||||
|
||||
tabletState = acpi.DeviceGet(AsusACPI.TabletState) > 0;
|
||||
|
||||
Logger.WriteLine("Tablet: " + tabletState + " Touchpad: " + touchpadState);
|
||||
|
||||
if ((tabletState && touchpadState) || (!tabletState && !touchpadState)) AsusUSB.TouchpadToggle();
|
||||
|
||||
}
|
||||
|
||||
static void HandleEvent(int EventID)
|
||||
{
|
||||
switch (EventID)
|
||||
{
|
||||
case 124: // M3
|
||||
KeyProcess("m3");
|
||||
return;
|
||||
case 56: // M4 / Rog button
|
||||
KeyProcess("m4");
|
||||
return;
|
||||
case 174: // FN+F5
|
||||
settingsForm.BeginInvoke(settingsForm.CyclePerformanceMode);
|
||||
return;
|
||||
case 179: // FN+F4
|
||||
KeyProcess("fnf4");
|
||||
return;
|
||||
case 189: // Tablet mode
|
||||
TabletMode();
|
||||
return;
|
||||
}
|
||||
|
||||
if (isOptimizationRunning) return;
|
||||
|
||||
// Asus Optimization service Events
|
||||
|
||||
int brightness = config.getConfig("keyboard_brightness");
|
||||
|
||||
switch (EventID)
|
||||
{
|
||||
case 197: // FN+F2
|
||||
brightness = Math.Max(0, brightness - 1);
|
||||
config.setConfig("keyboard_brightness", brightness);
|
||||
AsusUSB.ApplyBrightness(brightness);
|
||||
settingsForm.BeginInvoke(settingsForm.RunToast, "Backlight", ToastIcon.BacklightDown);
|
||||
break;
|
||||
case 196: // FN+F3
|
||||
brightness = Math.Min(3, brightness + 1);
|
||||
config.setConfig("keyboard_brightness", brightness);
|
||||
AsusUSB.ApplyBrightness(brightness);
|
||||
settingsForm.BeginInvoke(settingsForm.RunToast, "Backlight", ToastIcon.BacklightUp);
|
||||
break;
|
||||
case 16: // FN+F7
|
||||
ScreenBrightness.Adjust(-10);
|
||||
settingsForm.BeginInvoke(settingsForm.RunToast, "Brightness", ToastIcon.BrightnessDown);
|
||||
break;
|
||||
case 32: // FN+F8
|
||||
ScreenBrightness.Adjust(+10);
|
||||
settingsForm.BeginInvoke(settingsForm.RunToast, "Brightness", ToastIcon.BrightnessUp);
|
||||
break;
|
||||
case 107: // FN+F10
|
||||
AsusUSB.TouchpadToggle();
|
||||
settingsForm.BeginInvoke(settingsForm.RunToast, "Touchpad", ToastIcon.Touchpad);
|
||||
break;
|
||||
case 108: // FN+F11
|
||||
Application.SetSuspendState(PowerState.Suspend, true, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void WatcherEventArrived(object sender, EventArrivedEventArgs e)
|
||||
{
|
||||
if (e.NewEvent is null) return;
|
||||
int EventID = int.Parse(e.NewEvent["EventID"].ToString());
|
||||
Logger.WriteLine("WMI event " + EventID);
|
||||
HandleEvent(EventID);
|
||||
}
|
||||
|
||||
static void SettingsToggle(string action = "")
|
||||
public static void SettingsToggle(string action = "")
|
||||
{
|
||||
if (settingsForm.Visible)
|
||||
settingsForm.Hide();
|
||||
|
||||
@@ -356,9 +356,12 @@
|
||||
</data>
|
||||
<data name="Multizone" xml:space="preserve">
|
||||
<value>多區域</value>
|
||||
</data>
|
||||
<data name="MuteMic" xml:space="preserve">
|
||||
<value>麥克風開關</value>
|
||||
</data>
|
||||
<data name="OpenGHelper" xml:space="preserve">
|
||||
<value>打開G-Helper視窗</value>
|
||||
<value>開啟G-Helper視窗</value>
|
||||
</data>
|
||||
<data name="Optimized" xml:space="preserve">
|
||||
<value>自動模式</value>
|
||||
|
||||
179
app/Settings.cs
179
app/Settings.cs
@@ -135,13 +135,13 @@ namespace GHelper
|
||||
|
||||
SetVersionLabel(Properties.Strings.VersionLabel + ": " + Assembly.GetExecutingAssembly().GetName().Version);
|
||||
|
||||
string model = Program.config.GetModel();
|
||||
string model = AppConfig.GetModel();
|
||||
int trim = model.LastIndexOf("_");
|
||||
if (trim > 0) model = model.Substring(0, trim);
|
||||
|
||||
labelModel.Text = model + (Program.IsUserAdministrator() ? "." : "");
|
||||
|
||||
TopMost = Program.config.getConfig("topmost") == 1;
|
||||
TopMost = AppConfig.getConfig("topmost") == 1;
|
||||
|
||||
SetContextMenu();
|
||||
|
||||
@@ -274,8 +274,8 @@ namespace GHelper
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.GPUXG, 1, "GPU XGM");
|
||||
|
||||
if (Program.config.getConfigPerf("auto_apply") == 1)
|
||||
AsusUSB.SetXGMFan(Program.config.getFanConfig(AsusFan.XGM));
|
||||
if (AppConfig.getConfigPerf("auto_apply") == 1)
|
||||
AsusUSB.SetXGMFan(AppConfig.getFanConfig(AsusFan.XGM));
|
||||
}
|
||||
|
||||
InitXGM();
|
||||
@@ -308,13 +308,13 @@ namespace GHelper
|
||||
if (gitVersion.CompareTo(appVersion) > 0)
|
||||
{
|
||||
SetVersionLabel(Properties.Strings.DownloadUpdate + ": " + tag, url);
|
||||
if (Program.config.getConfigString("skip_version") != tag)
|
||||
if (AppConfig.getConfigString("skip_version") != tag)
|
||||
{
|
||||
DialogResult dialogResult = MessageBox.Show(Properties.Strings.DownloadUpdate + ": G-Helper " + tag + "?", "Update", MessageBoxButtons.YesNo);
|
||||
if (dialogResult == DialogResult.Yes)
|
||||
AutoUpdate(url);
|
||||
else
|
||||
Program.config.setConfig("skip_version", tag);
|
||||
AppConfig.setConfig("skip_version", tag);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -443,14 +443,14 @@ namespace GHelper
|
||||
|
||||
private void ButtonOptimized_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("gpu_auto", (Program.config.getConfig("gpu_auto") == 1) ? 0 : 1);
|
||||
AppConfig.setConfig("gpu_auto", (AppConfig.getConfig("gpu_auto") == 1) ? 0 : 1);
|
||||
VisualiseGPUMode();
|
||||
AutoGPUMode();
|
||||
}
|
||||
|
||||
private void ButtonScreenAuto_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 1);
|
||||
AppConfig.setConfig("screen_auto", 1);
|
||||
InitScreen();
|
||||
AutoScreen();
|
||||
}
|
||||
@@ -468,7 +468,7 @@ namespace GHelper
|
||||
{
|
||||
case 0:
|
||||
Logger.WriteLine("Monitor Power Off");
|
||||
SetBatteryChargeLimit(Program.config.getConfig("charge_limit"));
|
||||
SetBatteryChargeLimit(AppConfig.getConfig("charge_limit"));
|
||||
break;
|
||||
case 1:
|
||||
Logger.WriteLine("Monitor Power On");
|
||||
@@ -511,7 +511,7 @@ namespace GHelper
|
||||
{
|
||||
if (sender is null) return;
|
||||
CheckBox check = (CheckBox)sender;
|
||||
Program.config.setConfig("matrix_auto", check.Checked ? 1 : 0);
|
||||
AppConfig.setConfig("matrix_auto", check.Checked ? 1 : 0);
|
||||
matrix?.SetMatrix();
|
||||
}
|
||||
|
||||
@@ -538,8 +538,8 @@ namespace GHelper
|
||||
|
||||
if (fileName is not null)
|
||||
{
|
||||
Program.config.setConfig("matrix_picture", fileName);
|
||||
Program.config.setConfig("matrix_running", 2);
|
||||
AppConfig.setConfig("matrix_picture", fileName);
|
||||
AppConfig.setConfig("matrix_running", 2);
|
||||
|
||||
matrix?.SetMatrixPicture(fileName);
|
||||
BeginInvoke(delegate
|
||||
@@ -553,21 +553,21 @@ namespace GHelper
|
||||
|
||||
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||
AppConfig.setConfig("matrix_running", comboMatrixRunning.SelectedIndex);
|
||||
matrix?.SetMatrix();
|
||||
}
|
||||
|
||||
|
||||
private void ComboMatrix_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||
AppConfig.setConfig("matrix_brightness", comboMatrix.SelectedIndex);
|
||||
matrix?.SetMatrix();
|
||||
}
|
||||
|
||||
|
||||
private void LabelCPUFan_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("fan_rpm", (Program.config.getConfig("fan_rpm") == 1) ? 0 : 1);
|
||||
AppConfig.setConfig("fan_rpm", (AppConfig.getConfig("fan_rpm") == 1) ? 0 : 1);
|
||||
RefreshSensors(true);
|
||||
}
|
||||
|
||||
@@ -580,7 +580,7 @@ namespace GHelper
|
||||
|
||||
if (colorDlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Program.config.setConfig("aura_color2", colorDlg.Color.ToArgb());
|
||||
AppConfig.setConfig("aura_color2", colorDlg.Color.ToArgb());
|
||||
SetAura();
|
||||
}
|
||||
}
|
||||
@@ -635,17 +635,17 @@ namespace GHelper
|
||||
|
||||
if (colorDlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Program.config.setConfig("aura_color", colorDlg.Color.ToArgb());
|
||||
AppConfig.setConfig("aura_color", colorDlg.Color.ToArgb());
|
||||
SetAura();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitAura()
|
||||
{
|
||||
AsusUSB.Mode = Program.config.getConfig("aura_mode");
|
||||
AsusUSB.Speed = Program.config.getConfig("aura_speed");
|
||||
AsusUSB.SetColor(Program.config.getConfig("aura_color"));
|
||||
AsusUSB.SetColor2(Program.config.getConfig("aura_color2"));
|
||||
AsusUSB.Mode = AppConfig.getConfig("aura_mode");
|
||||
AsusUSB.Speed = AppConfig.getConfig("aura_speed");
|
||||
AsusUSB.SetColor(AppConfig.getConfig("aura_color"));
|
||||
AsusUSB.SetColor2(AppConfig.getConfig("aura_color2"));
|
||||
|
||||
comboKeyboard.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboKeyboard.DataSource = new BindingSource(AsusUSB.GetModes(), null);
|
||||
@@ -670,13 +670,13 @@ namespace GHelper
|
||||
return;
|
||||
}
|
||||
|
||||
int brightness = Program.config.getConfig("matrix_brightness");
|
||||
int running = Program.config.getConfig("matrix_running");
|
||||
int brightness = AppConfig.getConfig("matrix_brightness");
|
||||
int running = AppConfig.getConfig("matrix_running");
|
||||
|
||||
comboMatrix.SelectedIndex = (brightness != -1) ? Math.Min(brightness, comboMatrix.Items.Count - 1) : 0;
|
||||
comboMatrixRunning.SelectedIndex = (running != -1) ? Math.Min(running, comboMatrixRunning.Items.Count - 1) : 0;
|
||||
|
||||
checkMatrix.Checked = (Program.config.getConfig("matrix_auto") == 1);
|
||||
checkMatrix.Checked = (AppConfig.getConfig("matrix_auto") == 1);
|
||||
|
||||
|
||||
}
|
||||
@@ -684,10 +684,10 @@ namespace GHelper
|
||||
|
||||
public void SetAura()
|
||||
{
|
||||
AsusUSB.Mode = Program.config.getConfig("aura_mode");
|
||||
AsusUSB.Speed = Program.config.getConfig("aura_speed");
|
||||
AsusUSB.SetColor(Program.config.getConfig("aura_color"));
|
||||
AsusUSB.SetColor2(Program.config.getConfig("aura_color2"));
|
||||
AsusUSB.Mode = AppConfig.getConfig("aura_mode");
|
||||
AsusUSB.Speed = AppConfig.getConfig("aura_speed");
|
||||
AsusUSB.SetColor(AppConfig.getConfig("aura_color"));
|
||||
AsusUSB.SetColor2(AppConfig.getConfig("aura_color2"));
|
||||
|
||||
pictureColor.BackColor = AsusUSB.Color1;
|
||||
pictureColor2.BackColor = AsusUSB.Color2;
|
||||
@@ -707,27 +707,27 @@ namespace GHelper
|
||||
|
||||
private void ComboKeyboard_SelectedValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("aura_mode", (int)comboKeyboard.SelectedValue);
|
||||
AppConfig.setConfig("aura_mode", (int)comboKeyboard.SelectedValue);
|
||||
SetAura();
|
||||
}
|
||||
|
||||
|
||||
private void Button120Hz_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 0);
|
||||
AppConfig.setConfig("screen_auto", 0);
|
||||
SetScreen(1000, 1);
|
||||
}
|
||||
|
||||
private void Button60Hz_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Program.config.setConfig("screen_auto", 0);
|
||||
AppConfig.setConfig("screen_auto", 0);
|
||||
SetScreen(60, 0);
|
||||
}
|
||||
|
||||
public void ToogleMiniled()
|
||||
{
|
||||
int miniled = (Program.config.getConfig("miniled") == 1) ? 0 : 1;
|
||||
Program.config.setConfig("miniled", miniled);
|
||||
int miniled = (AppConfig.getConfig("miniled") == 1) ? 0 : 1;
|
||||
AppConfig.setConfig("miniled", miniled);
|
||||
SetScreen(-1, -1, miniled);
|
||||
}
|
||||
|
||||
@@ -757,7 +757,7 @@ namespace GHelper
|
||||
|
||||
if (overdrive >= 0)
|
||||
{
|
||||
if (Program.config.getConfig("no_overdrive") == 1) overdrive = 0;
|
||||
if (AppConfig.getConfig("no_overdrive") == 1) overdrive = 0;
|
||||
Program.acpi.DeviceSet(AsusACPI.ScreenOverdrive, overdrive, "ScreenOverdrive");
|
||||
|
||||
}
|
||||
@@ -777,8 +777,8 @@ namespace GHelper
|
||||
int frequency = NativeMethods.GetRefreshRate();
|
||||
int maxFrequency = NativeMethods.GetRefreshRate(true);
|
||||
|
||||
bool screenAuto = (Program.config.getConfig("screen_auto") == 1);
|
||||
bool overdriveSetting = (Program.config.getConfig("no_overdrive") != 1);
|
||||
bool screenAuto = (AppConfig.getConfig("screen_auto") == 1);
|
||||
bool overdriveSetting = (AppConfig.getConfig("no_overdrive") != 1);
|
||||
|
||||
int overdrive = Program.acpi.DeviceGet(AsusACPI.ScreenOverdrive);
|
||||
int miniled = Program.acpi.DeviceGet(AsusACPI.ScreenMiniled);
|
||||
@@ -824,15 +824,15 @@ namespace GHelper
|
||||
if (miniled >= 0)
|
||||
{
|
||||
buttonMiniled.Activated = (miniled == 1);
|
||||
Program.config.setConfig("miniled", miniled);
|
||||
AppConfig.setConfig("miniled", miniled);
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonMiniled.Visible = false;
|
||||
}
|
||||
|
||||
Program.config.setConfig("frequency", frequency);
|
||||
Program.config.setConfig("overdrive", overdrive);
|
||||
AppConfig.setConfig("frequency", frequency);
|
||||
AppConfig.setConfig("overdrive", overdrive);
|
||||
}
|
||||
|
||||
private void ButtonQuit_Click(object? sender, EventArgs e)
|
||||
@@ -937,8 +937,8 @@ namespace GHelper
|
||||
public void SetPower()
|
||||
{
|
||||
|
||||
int limit_total = Program.config.getConfigPerf("limit_total");
|
||||
int limit_cpu = Program.config.getConfigPerf("limit_cpu");
|
||||
int limit_total = AppConfig.getConfigPerf("limit_total");
|
||||
int limit_cpu = AppConfig.getConfigPerf("limit_cpu");
|
||||
|
||||
if (limit_total > AsusACPI.MaxTotal) return;
|
||||
if (limit_total < AsusACPI.MinTotal) return;
|
||||
@@ -967,8 +967,8 @@ namespace GHelper
|
||||
public void SetGPUClocks(bool launchAsAdmin = true)
|
||||
{
|
||||
|
||||
int gpu_core = Program.config.getConfigPerf("gpu_core");
|
||||
int gpu_memory = Program.config.getConfigPerf("gpu_memory");
|
||||
int gpu_core = AppConfig.getConfigPerf("gpu_core");
|
||||
int gpu_memory = AppConfig.getConfigPerf("gpu_memory");
|
||||
|
||||
if (gpu_core == -1 && gpu_memory == -1) return;
|
||||
|
||||
@@ -1000,8 +1000,8 @@ namespace GHelper
|
||||
public void SetGPUPower()
|
||||
{
|
||||
|
||||
int gpu_boost = Program.config.getConfigPerf("gpu_boost");
|
||||
int gpu_temp = Program.config.getConfigPerf("gpu_temp");
|
||||
int gpu_boost = AppConfig.getConfigPerf("gpu_boost");
|
||||
int gpu_temp = AppConfig.getConfigPerf("gpu_temp");
|
||||
|
||||
|
||||
if (gpu_boost < AsusACPI.MinGPUBoost || gpu_boost > AsusACPI.MaxGPUBoost) return;
|
||||
@@ -1030,21 +1030,21 @@ namespace GHelper
|
||||
{
|
||||
customFans = false;
|
||||
|
||||
if (Program.config.getConfigPerf("auto_apply") == 1 || force)
|
||||
if (AppConfig.getConfigPerf("auto_apply") == 1 || force)
|
||||
{
|
||||
int cpuResult = Program.acpi.SetFanCurve(AsusFan.CPU, Program.config.getFanConfig(AsusFan.CPU));
|
||||
int gpuResult = Program.acpi.SetFanCurve(AsusFan.GPU, Program.config.getFanConfig(AsusFan.GPU));
|
||||
int cpuResult = Program.acpi.SetFanCurve(AsusFan.CPU, AppConfig.getFanConfig(AsusFan.CPU));
|
||||
int gpuResult = Program.acpi.SetFanCurve(AsusFan.GPU, AppConfig.getFanConfig(AsusFan.GPU));
|
||||
|
||||
if (Program.config.isConfig("mid_fan"))
|
||||
Program.acpi.SetFanCurve(AsusFan.Mid, Program.config.getFanConfig(AsusFan.Mid));
|
||||
if (AppConfig.isConfig("mid_fan"))
|
||||
Program.acpi.SetFanCurve(AsusFan.Mid, AppConfig.getFanConfig(AsusFan.Mid));
|
||||
|
||||
if (Program.config.isConfig("xgm_fan") && Program.acpi.IsXGConnected())
|
||||
AsusUSB.SetXGMFan(Program.config.getFanConfig(AsusFan.XGM));
|
||||
if (AppConfig.isConfig("xgm_fan") && Program.acpi.IsXGConnected())
|
||||
AsusUSB.SetXGMFan(AppConfig.getFanConfig(AsusFan.XGM));
|
||||
|
||||
// something went wrong, resetting to default profile
|
||||
if (cpuResult != 1 || gpuResult != 1)
|
||||
{
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
int mode = AppConfig.getConfig("performance_mode");
|
||||
Logger.WriteLine("ASUS BIOS rejected fan curve, resetting mode to " + mode);
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, mode, "PerformanceMode");
|
||||
LabelFansResult("ASUS BIOS rejected fan curve");
|
||||
@@ -1056,7 +1056,7 @@ namespace GHelper
|
||||
}
|
||||
|
||||
// fix for misbehaving bios on intell based TUF 2022
|
||||
if ((Program.config.ContainsModel("FX507") || Program.config.ContainsModel("FX517")) && Program.config.getConfigPerf("auto_apply_power") != 1)
|
||||
if ((AppConfig.ContainsModel("FX507") || AppConfig.ContainsModel("FX517")) && AppConfig.getConfigPerf("auto_apply_power") != 1)
|
||||
{
|
||||
Task.Run(async () =>
|
||||
{
|
||||
@@ -1076,7 +1076,7 @@ namespace GHelper
|
||||
{
|
||||
|
||||
// fix for misbehaving bios PPTs on G513
|
||||
if (Program.config.ContainsModel("G513") && Program.config.getConfigPerf("auto_apply") != 1)
|
||||
if (AppConfig.ContainsModel("G513") && AppConfig.getConfigPerf("auto_apply") != 1)
|
||||
{
|
||||
AutoFans(true);
|
||||
delay = 500;
|
||||
@@ -1084,7 +1084,7 @@ namespace GHelper
|
||||
|
||||
customPower = 0;
|
||||
|
||||
bool applyPower = Program.config.getConfigPerf("auto_apply_power") == 1;
|
||||
bool applyPower = AppConfig.getConfigPerf("auto_apply_power") == 1;
|
||||
bool applyGPU = true;
|
||||
|
||||
if (delay > 0)
|
||||
@@ -1112,7 +1112,7 @@ namespace GHelper
|
||||
{
|
||||
|
||||
if (PerformanceMode < 0)
|
||||
PerformanceMode = Program.config.getConfig("performance_mode");
|
||||
PerformanceMode = AppConfig.getConfig("performance_mode");
|
||||
|
||||
buttonSilent.Activated = false;
|
||||
buttonBalanced.Activated = false;
|
||||
@@ -1139,12 +1139,12 @@ namespace GHelper
|
||||
menuBalanced.Checked = buttonBalanced.Activated;
|
||||
menuTurbo.Checked = buttonTurbo.Activated;
|
||||
|
||||
int oldMode = Program.config.getConfig("performance_mode");
|
||||
Program.config.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
||||
Program.config.setConfig("performance_mode", PerformanceMode);
|
||||
int oldMode = AppConfig.getConfig("performance_mode");
|
||||
AppConfig.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
||||
AppConfig.setConfig("performance_mode", PerformanceMode);
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.PerformanceMode, PerformanceMode, "PerformanceMode");
|
||||
if (Program.config.isConfig("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
||||
if (AppConfig.isConfig("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
||||
|
||||
if (notify && (oldMode != PerformanceMode))
|
||||
{
|
||||
@@ -1163,17 +1163,17 @@ namespace GHelper
|
||||
AutoFans();
|
||||
AutoPower(1000);
|
||||
|
||||
if (Program.config.getConfig("auto_apply_power_plan") != 0)
|
||||
if (AppConfig.getConfig("auto_apply_power_plan") != 0)
|
||||
{
|
||||
if (Program.config.getConfigPerfString("scheme") is not null)
|
||||
NativeMethods.SetPowerScheme(Program.config.getConfigPerfString("scheme"));
|
||||
if (AppConfig.getConfigPerfString("scheme") is not null)
|
||||
NativeMethods.SetPowerScheme(AppConfig.getConfigPerfString("scheme"));
|
||||
else
|
||||
NativeMethods.SetPowerScheme(PerformanceMode);
|
||||
}
|
||||
|
||||
if (Program.config.getConfigPerf("auto_boost") != -1)
|
||||
if (AppConfig.getConfigPerf("auto_boost") != -1)
|
||||
{
|
||||
NativeMethods.SetCPUBoost(Program.config.getConfigPerf("auto_boost"));
|
||||
NativeMethods.SetCPUBoost(AppConfig.getConfigPerf("auto_boost"));
|
||||
}
|
||||
|
||||
if (NativeMethods.PowerGetEffectiveOverlayScheme(out Guid activeScheme) == 0)
|
||||
@@ -1193,7 +1193,7 @@ namespace GHelper
|
||||
|
||||
public void CyclePerformanceMode()
|
||||
{
|
||||
int mode = Program.config.getConfig("performance_mode");
|
||||
int mode = AppConfig.getConfig("performance_mode");
|
||||
|
||||
if (Control.ModifierKeys == Keys.Shift)
|
||||
mode = (mode == 0) ? 2 : mode - 1;
|
||||
@@ -1206,7 +1206,7 @@ namespace GHelper
|
||||
|
||||
public void AutoKeyboard()
|
||||
{
|
||||
if (Program.config.getConfig("keyboard_auto") != 1) return;
|
||||
if (AppConfig.getConfig("keyboard_auto") != 1) return;
|
||||
|
||||
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
||||
AsusUSB.ApplyBrightness(3);
|
||||
@@ -1220,17 +1220,17 @@ namespace GHelper
|
||||
{
|
||||
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||
|
||||
int mode = Program.config.getConfig("performance_" + (int)Plugged);
|
||||
int mode = AppConfig.getConfig("performance_" + (int)Plugged);
|
||||
if (mode != -1)
|
||||
SetPerformanceMode(mode, true);
|
||||
else
|
||||
SetPerformanceMode(Program.config.getConfig("performance_mode"));
|
||||
SetPerformanceMode(AppConfig.getConfig("performance_mode"));
|
||||
}
|
||||
|
||||
|
||||
public void AutoScreen(bool force = false)
|
||||
{
|
||||
if (force || Program.config.getConfig("screen_auto") == 1)
|
||||
if (force || AppConfig.getConfig("screen_auto") == 1)
|
||||
{
|
||||
if (SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online)
|
||||
SetScreen(1000, 1);
|
||||
@@ -1239,7 +1239,7 @@ namespace GHelper
|
||||
}
|
||||
else
|
||||
{
|
||||
SetScreen(overdrive: Program.config.getConfig("overdrive"));
|
||||
SetScreen(overdrive: AppConfig.getConfig("overdrive"));
|
||||
}
|
||||
|
||||
|
||||
@@ -1248,7 +1248,7 @@ namespace GHelper
|
||||
|
||||
public static bool IsPlugged()
|
||||
{
|
||||
bool optimizedUSBC = Program.config.getConfig("optimized_usbc") != 1;
|
||||
bool optimizedUSBC = AppConfig.getConfig("optimized_usbc") != 1;
|
||||
|
||||
return SystemInformation.PowerStatus.PowerLineStatus == PowerLineStatus.Online &&
|
||||
(optimizedUSBC || Program.acpi.DeviceGet(AsusACPI.ChargerMode) != AsusACPI.ChargerUSB);
|
||||
@@ -1258,10 +1258,10 @@ namespace GHelper
|
||||
public bool AutoGPUMode()
|
||||
{
|
||||
|
||||
bool GpuAuto = Program.config.getConfig("gpu_auto") == 1;
|
||||
bool ForceGPU = Program.config.ContainsModel("503");
|
||||
bool GpuAuto = AppConfig.getConfig("gpu_auto") == 1;
|
||||
bool ForceGPU = AppConfig.ContainsModel("503");
|
||||
|
||||
int GpuMode = Program.config.getConfig("gpu_mode");
|
||||
int GpuMode = AppConfig.getConfig("gpu_mode");
|
||||
|
||||
if (!GpuAuto && !ForceGPU) return false;
|
||||
|
||||
@@ -1303,7 +1303,7 @@ namespace GHelper
|
||||
public bool ReEnableGPU()
|
||||
{
|
||||
|
||||
if (Program.config.getConfig("gpu_reenable") != 1) return false;
|
||||
if (AppConfig.getConfig("gpu_reenable") != 1) return false;
|
||||
if (Screen.AllScreens.Length <= 1) return false;
|
||||
|
||||
Logger.WriteLine("Re-enabling gpu for 503 model");
|
||||
@@ -1333,6 +1333,15 @@ namespace GHelper
|
||||
{
|
||||
buttonXGM.Enabled = buttonXGM.Visible = Program.acpi.IsXGConnected();
|
||||
buttonXGM.Activated = (Program.acpi.DeviceGet(AsusACPI.GPUXG) == 1);
|
||||
|
||||
if (buttonXGM.Activated)
|
||||
{
|
||||
ButtonEnabled(buttonOptimized, false);
|
||||
ButtonEnabled(buttonEco, false);
|
||||
ButtonEnabled(buttonStandard, false);
|
||||
ButtonEnabled(buttonUltimate, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1360,7 +1369,7 @@ namespace GHelper
|
||||
|
||||
}
|
||||
|
||||
Program.config.setConfig("gpu_mode", GpuMode);
|
||||
AppConfig.setConfig("gpu_mode", GpuMode);
|
||||
|
||||
ButtonEnabled(buttonOptimized, true);
|
||||
ButtonEnabled(buttonEco, true);
|
||||
@@ -1467,8 +1476,8 @@ namespace GHelper
|
||||
public void SetGPUMode(int GPUMode)
|
||||
{
|
||||
|
||||
int CurrentGPU = Program.config.getConfig("gpu_mode");
|
||||
Program.config.setConfig("gpu_auto", 0);
|
||||
int CurrentGPU = AppConfig.getConfig("gpu_mode");
|
||||
AppConfig.setConfig("gpu_auto", 0);
|
||||
|
||||
if (CurrentGPU == GPUMode)
|
||||
{
|
||||
@@ -1515,7 +1524,7 @@ namespace GHelper
|
||||
|
||||
if (changed)
|
||||
{
|
||||
Program.config.setConfig("gpu_mode", GPUMode);
|
||||
AppConfig.setConfig("gpu_mode", GPUMode);
|
||||
}
|
||||
|
||||
if (restart)
|
||||
@@ -1531,9 +1540,9 @@ namespace GHelper
|
||||
{
|
||||
|
||||
if (GPUMode == -1)
|
||||
GPUMode = Program.config.getConfig("gpu_mode");
|
||||
GPUMode = AppConfig.getConfig("gpu_mode");
|
||||
|
||||
bool GPUAuto = (Program.config.getConfig("gpu_auto") == 1);
|
||||
bool GPUAuto = (AppConfig.getConfig("gpu_auto") == 1);
|
||||
|
||||
buttonEco.Activated = false;
|
||||
buttonStandard.Activated = false;
|
||||
@@ -1548,6 +1557,7 @@ namespace GHelper
|
||||
buttonOptimized.Activated = GPUAuto;
|
||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeEco;
|
||||
Program.trayIcon.Icon = Properties.Resources.eco;
|
||||
ButtonEnabled(buttonXGM, false);
|
||||
break;
|
||||
case AsusACPI.GPUModeUltimate:
|
||||
buttonUltimate.Activated = true;
|
||||
@@ -1560,6 +1570,7 @@ namespace GHelper
|
||||
buttonOptimized.Activated = GPUAuto;
|
||||
labelGPU.Text = Properties.Strings.GPUMode + ": " + Properties.Strings.GPUModeStandard;
|
||||
Program.trayIcon.Icon = Properties.Resources.standard;
|
||||
ButtonEnabled(buttonXGM, true);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1624,7 +1635,7 @@ namespace GHelper
|
||||
Debug.WriteLine(ex);
|
||||
}
|
||||
|
||||
Program.config.setConfig("charge_limit", limit);
|
||||
AppConfig.setConfig("charge_limit", limit);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user