mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Driver Updater improvements
This commit is contained in:
@@ -135,7 +135,7 @@ namespace GHelper
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void SetAutoModes()
|
public static void SetAutoModes(bool powerChanged = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 3000) return;
|
if (Math.Abs(DateTimeOffset.Now.ToUnixTimeMilliseconds() - lastAuto) < 3000) return;
|
||||||
@@ -147,7 +147,7 @@ namespace GHelper
|
|||||||
inputDispatcher.Init();
|
inputDispatcher.Init();
|
||||||
|
|
||||||
settingsForm.SetBatteryChargeLimit(AppConfig.getConfig("charge_limit"));
|
settingsForm.SetBatteryChargeLimit(AppConfig.getConfig("charge_limit"));
|
||||||
settingsForm.AutoPerformance();
|
settingsForm.AutoPerformance(powerChanged);
|
||||||
|
|
||||||
bool switched = settingsForm.AutoGPUMode();
|
bool switched = settingsForm.AutoGPUMode();
|
||||||
|
|
||||||
@@ -163,11 +163,9 @@ namespace GHelper
|
|||||||
|
|
||||||
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
|
if (SystemInformation.PowerStatus.PowerLineStatus == isPlugged) return;
|
||||||
|
|
||||||
Logger.WriteLine("Power Mode Changed");
|
Logger.WriteLine("Power Mode Changed");
|
||||||
SetAutoModes();
|
SetAutoModes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
20
app/Properties/Resources.Designer.cs
generated
20
app/Properties/Resources.Designer.cs
generated
@@ -130,6 +130,16 @@ namespace GHelper.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap icons8_charged_battery_96 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("icons8_charged_battery_96", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -140,6 +150,16 @@ namespace GHelper.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap icons8_electrical_96 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("icons8_electrical_96", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -238,4 +238,10 @@
|
|||||||
<data name="icons8-software-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icons8-software-48" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icons8-software-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icons8-software-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="icons8_charged_battery_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\icons8-charged-battery-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="icons8_electrical_96" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\icons8-electrical-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
BIN
app/Resources/icons8-charged-battery-96.png
Normal file
BIN
app/Resources/icons8-charged-battery-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 406 B |
BIN
app/Resources/icons8-electrical-96.png
Normal file
BIN
app/Resources/icons8-electrical-96.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1000 B |
@@ -176,7 +176,7 @@ namespace GHelper
|
|||||||
|
|
||||||
labelModel.Text = model + (ProcessHelper.IsUserAdministrator() ? "." : "");
|
labelModel.Text = model + (ProcessHelper.IsUserAdministrator() ? "." : "");
|
||||||
|
|
||||||
TopMost = AppConfig.getConfig("topmost") == 1;
|
TopMost = AppConfig.isConfig("topmost");
|
||||||
|
|
||||||
SetContextMenu();
|
SetContextMenu();
|
||||||
|
|
||||||
@@ -1260,24 +1260,25 @@ namespace GHelper
|
|||||||
{
|
{
|
||||||
case AsusACPI.PerformanceSilent:
|
case AsusACPI.PerformanceSilent:
|
||||||
buttonSilent.Activated = true;
|
buttonSilent.Activated = true;
|
||||||
|
menuSilent.Checked = true;
|
||||||
perfName = Properties.Strings.Silent;
|
perfName = Properties.Strings.Silent;
|
||||||
break;
|
break;
|
||||||
case AsusACPI.PerformanceTurbo:
|
case AsusACPI.PerformanceTurbo:
|
||||||
buttonTurbo.Activated = true;
|
buttonTurbo.Activated = true;
|
||||||
|
menuTurbo.Checked = true;
|
||||||
perfName = Properties.Strings.Turbo;
|
perfName = Properties.Strings.Turbo;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
buttonBalanced.Activated = true;
|
buttonBalanced.Activated = true;
|
||||||
|
menuBalanced.Checked = true;
|
||||||
PerformanceMode = AsusACPI.PerformanceBalanced;
|
PerformanceMode = AsusACPI.PerformanceBalanced;
|
||||||
perfName = Properties.Strings.Balanced;
|
perfName = Properties.Strings.Balanced;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
menuSilent.Checked = buttonSilent.Activated;
|
var powerStatus = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
menuBalanced.Checked = buttonBalanced.Activated;
|
|
||||||
menuTurbo.Checked = buttonTurbo.Activated;
|
|
||||||
|
|
||||||
AppConfig.setConfig("performance_" + (int)SystemInformation.PowerStatus.PowerLineStatus, PerformanceMode);
|
AppConfig.setConfig("performance_" + (int)powerStatus, PerformanceMode);
|
||||||
AppConfig.setConfig("performance_mode", PerformanceMode);
|
AppConfig.setConfig("performance_mode", PerformanceMode);
|
||||||
|
|
||||||
if (isManualModeRequired())
|
if (isManualModeRequired())
|
||||||
@@ -1287,11 +1288,11 @@ namespace GHelper
|
|||||||
|
|
||||||
if (AppConfig.isConfig("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
if (AppConfig.isConfig("xgm_fan") && Program.acpi.IsXGConnected()) AsusUSB.ResetXGM();
|
||||||
|
|
||||||
if (notify && (oldMode != PerformanceMode))
|
if (notify)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
toast.RunToast(perfName);
|
toast.RunToast(perfName, powerStatus == PowerLineStatus.Online ? ToastIcon.Charger : ToastIcon.Battery);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@@ -1352,13 +1353,13 @@ namespace GHelper
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutoPerformance()
|
public void AutoPerformance(bool powerChanged = false)
|
||||||
{
|
{
|
||||||
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
|
var Plugged = SystemInformation.PowerStatus.PowerLineStatus;
|
||||||
|
|
||||||
int mode = AppConfig.getConfig("performance_" + (int)Plugged);
|
int mode = AppConfig.getConfig("performance_" + (int)Plugged);
|
||||||
if (mode != -1)
|
if (mode != -1)
|
||||||
SetPerformanceMode(mode, true);
|
SetPerformanceMode(mode, powerChanged);
|
||||||
else
|
else
|
||||||
SetPerformanceMode(AppConfig.getConfig("performance_mode"));
|
SetPerformanceMode(AppConfig.getConfig("performance_mode"));
|
||||||
}
|
}
|
||||||
@@ -1724,10 +1725,13 @@ namespace GHelper
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isGpuSection)
|
||||||
|
{
|
||||||
menuEco.Checked = buttonEco.Activated;
|
menuEco.Checked = buttonEco.Activated;
|
||||||
menuStandard.Checked = buttonStandard.Activated;
|
menuStandard.Checked = buttonStandard.Activated;
|
||||||
menuUltimate.Checked = buttonUltimate.Activated;
|
menuUltimate.Checked = buttonUltimate.Activated;
|
||||||
menuOptimized.Checked = buttonOptimized.Activated;
|
menuOptimized.Checked = buttonOptimized.Activated;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ namespace GHelper
|
|||||||
Touchpad,
|
Touchpad,
|
||||||
Microphone,
|
Microphone,
|
||||||
MicrophoneMute,
|
MicrophoneMute,
|
||||||
FnLock
|
FnLock,
|
||||||
|
Battery,
|
||||||
|
Charger
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ToastForm : OSDNativeForm
|
public class ToastForm : OSDNativeForm
|
||||||
@@ -107,6 +109,12 @@ namespace GHelper
|
|||||||
case ToastIcon.FnLock:
|
case ToastIcon.FnLock:
|
||||||
icon = Properties.Resources.icons8_function;
|
icon = Properties.Resources.icons8_function;
|
||||||
break;
|
break;
|
||||||
|
case ToastIcon.Battery:
|
||||||
|
icon = Properties.Resources.icons8_charged_battery_96;
|
||||||
|
break;
|
||||||
|
case ToastIcon.Charger:
|
||||||
|
icon = Properties.Resources.icons8_electrical_96;
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
121
app/Updates.cs
121
app/Updates.cs
@@ -1,10 +1,22 @@
|
|||||||
using CustomControls;
|
using CustomControls;
|
||||||
|
using HidSharp;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace GHelper
|
namespace GHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct DriverDownload
|
||||||
|
{
|
||||||
|
public string categoryName;
|
||||||
|
public string title;
|
||||||
|
public string version;
|
||||||
|
public string downloadUrl;
|
||||||
|
public JsonElement hardwares;
|
||||||
|
}
|
||||||
|
|
||||||
public partial class Updates : RForm
|
public partial class Updates : RForm
|
||||||
{
|
{
|
||||||
//static int rowCount = 0;
|
//static int rowCount = 0;
|
||||||
@@ -30,7 +42,7 @@ namespace GHelper
|
|||||||
|
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
DriversAsync($"https://rog.asus.com/support/webapi/product/GetPDDrivers?website=global&model={model}&osid=52", 0, tableDrivers);
|
DriversAsync($"https://rog.asus.com/support/webapi/product/GetPDDrivers?website=global&model={model}&cpu={model}&osid=52", 0, tableDrivers);
|
||||||
});
|
});
|
||||||
|
|
||||||
Shown += Updates_Shown;
|
Shown += Updates_Shown;
|
||||||
@@ -86,23 +98,20 @@ namespace GHelper
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Dictionary<string, string> devices = new();
|
using (var httpClient = new HttpClient(new HttpClientHandler
|
||||||
string biosVersion = "";
|
|
||||||
|
|
||||||
if (type == 0) devices = GetDeviceVersions();
|
|
||||||
else biosVersion = GetBiosVersion();
|
|
||||||
|
|
||||||
//Debug.WriteLine(biosVersion);
|
|
||||||
|
|
||||||
using (var httpClient = new HttpClient())
|
|
||||||
{
|
{
|
||||||
|
AutomaticDecompression = DecompressionMethods.All
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
httpClient.DefaultRequestHeaders.AcceptEncoding.ParseAdd("gzip, deflate, br");
|
||||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App");
|
httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App");
|
||||||
var json = await httpClient.GetStringAsync(url);
|
var json = await httpClient.GetStringAsync(url);
|
||||||
var data = JsonSerializer.Deserialize<JsonElement>(json);
|
var data = JsonSerializer.Deserialize<JsonElement>(json);
|
||||||
var groups = data.GetProperty("Result").GetProperty("Obj");
|
var groups = data.GetProperty("Result").GetProperty("Obj");
|
||||||
|
|
||||||
|
|
||||||
List<string> skipList = new() { "Armoury Crate & Aura Creator Installer", "MyASUS", "ASUS Smart Display Control", "Aura Wallpaper" };
|
List<string> skipList = new() { "Armoury Crate & Aura Creator Installer", "MyASUS", "ASUS Smart Display Control", "Aura Wallpaper", "Virtual Pet","ROG Font V1.5" };
|
||||||
|
List<DriverDownload> drivers = new();
|
||||||
|
|
||||||
for (int i = 0; i < groups.GetArrayLength(); i++)
|
for (int i = 0; i < groups.GetArrayLength(); i++)
|
||||||
{
|
{
|
||||||
@@ -116,62 +125,43 @@ namespace GHelper
|
|||||||
|
|
||||||
var file = files[j];
|
var file = files[j];
|
||||||
var title = file.GetProperty("Title").ToString();
|
var title = file.GetProperty("Title").ToString();
|
||||||
var version = file.GetProperty("Version").ToString().Replace("V", "");
|
|
||||||
var downloadUrl = file.GetProperty("DownloadUrl").GetProperty("Global").ToString();
|
|
||||||
|
|
||||||
//Debug.WriteLine(" - " + title + " " + version + " " + downloadUrl);
|
|
||||||
|
|
||||||
if (oldTitle != title && !skipList.Contains(title))
|
if (oldTitle != title && !skipList.Contains(title))
|
||||||
{
|
{
|
||||||
JsonElement hardwares = file.GetProperty("HardwareInfoList");
|
|
||||||
bool newer = false;
|
|
||||||
|
|
||||||
if (type == 0 && hardwares.ToString().Length > 0)
|
var driver = new DriverDownload();
|
||||||
for (int k = 0; k < hardwares.GetArrayLength(); k++)
|
driver.categoryName = categoryName;
|
||||||
{
|
driver.title = title;
|
||||||
var deviceID = hardwares[k].GetProperty("hardwareid").ToString();
|
driver.version = file.GetProperty("Version").ToString().Replace("V", "");
|
||||||
var localVersion = devices.Where(p => p.Key.Contains(deviceID)).Select(p => p.Value).FirstOrDefault();
|
driver.downloadUrl = file.GetProperty("DownloadUrl").GetProperty("Global").ToString();
|
||||||
if (localVersion is not null)
|
driver.hardwares = file.GetProperty("HardwareInfoList");
|
||||||
{
|
drivers.Add(driver);
|
||||||
newer = (new Version(version).CompareTo(new Version(localVersion)) > 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == 1)
|
|
||||||
{
|
|
||||||
newer = Int32.Parse(version) > Int32.Parse(biosVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
BeginInvoke(delegate
|
BeginInvoke(delegate
|
||||||
{
|
{
|
||||||
string versionText = version.Replace("latest version at the ", "");
|
string versionText = driver.version.Replace("latest version at the ", "");
|
||||||
Label versionLabel = new Label { Text = versionText, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Height = 50 };
|
Label versionLabel = new Label { Text = versionText, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Height = 50 };
|
||||||
versionLabel.Cursor = Cursors.Hand;
|
versionLabel.Cursor = Cursors.Hand;
|
||||||
versionLabel.Font = new Font(versionLabel.Font, newer ? FontStyle.Underline | FontStyle.Bold : FontStyle.Underline);
|
versionLabel.Font = new Font(versionLabel.Font, FontStyle.Underline);
|
||||||
versionLabel.ForeColor = newer ? colorTurbo : colorEco;
|
versionLabel.ForeColor = colorEco;
|
||||||
versionLabel.Padding = new Padding(5, 5, 5, 5);
|
versionLabel.Padding = new Padding(5, 5, 5, 5);
|
||||||
versionLabel.Click += delegate
|
versionLabel.Click += delegate
|
||||||
{
|
{
|
||||||
Process.Start(new ProcessStartInfo(downloadUrl) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(driver.downloadUrl) { UseShellExecute = true });
|
||||||
};
|
};
|
||||||
|
|
||||||
table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
|
||||||
table.Controls.Add(new Label { Text = categoryName, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 0, table.RowCount);
|
table.Controls.Add(new Label { Text = driver.categoryName, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 0, table.RowCount);
|
||||||
table.Controls.Add(new Label { Text = title, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 1, table.RowCount);
|
table.Controls.Add(new Label { Text = driver.title, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 1, table.RowCount);
|
||||||
table.Controls.Add(versionLabel, 2, table.RowCount);
|
table.Controls.Add(versionLabel, 2, table.RowCount);
|
||||||
table.RowCount++;
|
table.RowCount++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
oldTitle = title;
|
oldTitle = title;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BeginInvoke(delegate
|
BeginInvoke(delegate
|
||||||
{
|
{
|
||||||
table.Visible = true;
|
table.Visible = true;
|
||||||
@@ -179,11 +169,54 @@ namespace GHelper
|
|||||||
PerformLayout();
|
PerformLayout();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Dictionary<string, string> devices = new();
|
||||||
|
string biosVersion = "0";
|
||||||
|
|
||||||
|
if (type == 0) devices = GetDeviceVersions();
|
||||||
|
else biosVersion = GetBiosVersion();
|
||||||
|
|
||||||
|
//Debug.WriteLine(biosVersion);
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
foreach (var driver in drivers)
|
||||||
|
{
|
||||||
|
int newer = -2;
|
||||||
|
if (type == 0 && driver.hardwares.ToString().Length > 0)
|
||||||
|
for (int k = 0; k < driver.hardwares.GetArrayLength(); k++)
|
||||||
|
{
|
||||||
|
var deviceID = driver.hardwares[k].GetProperty("hardwareid").ToString();
|
||||||
|
var localVersion = devices.Where(p => p.Key.Contains(deviceID)).Select(p => p.Value).FirstOrDefault();
|
||||||
|
if (localVersion is not null)
|
||||||
|
{
|
||||||
|
newer = new Version(driver.version).CompareTo(new Version(localVersion));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == 1)
|
||||||
|
newer = Int32.Parse(driver.version) > Int32.Parse(biosVersion) ? 1 : -1;
|
||||||
|
|
||||||
|
if (newer > 0)
|
||||||
|
{
|
||||||
|
var label = table.GetControlFromPosition(2, count) as Label;
|
||||||
|
if (label != null)
|
||||||
|
{
|
||||||
|
BeginInvoke(delegate
|
||||||
|
{
|
||||||
|
label.Font = new Font(label.Font, FontStyle.Underline | FontStyle.Bold);
|
||||||
|
label.ForeColor = colorTurbo;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Debug.WriteLine(ex.ToString());
|
Logger.WriteLine(ex.ToString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user