From e16f612311ff780a96599034b8fc6a6bf2afbed2 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 8 Jun 2023 13:20:26 +0200 Subject: [PATCH] Driver updater fix --- app/AppConfig.cs | 16 ---------------- app/Extra.cs | 3 +-- app/Updates.cs | 29 +++++++++++++++++------------ 3 files changed, 18 insertions(+), 30 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index 9f4c042d..ff2df7a8 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -63,22 +63,6 @@ public static class AppConfig return (_model is not null && _model.ToLower().Contains(contains.ToLower())); } - public static string GetModelShort() - { - GetModel(); - if (_model is not null) - { - int trim = _model.LastIndexOf("_"); - if (trim > 0) return _model.Substring(trim+1); - - trim = _model.LastIndexOf(" "); - if (trim > 0) return _model.Substring(trim + 1); - - return _model; - } - - return ""; - } private static void initConfig() { diff --git a/app/Extra.cs b/app/Extra.cs index e588bf66..7e48f43b 100644 --- a/app/Extra.cs +++ b/app/Extra.cs @@ -245,8 +245,6 @@ namespace GHelper labelServices.Text = Properties.Strings.AsusServicesRunning + ": " + OptimizationService.GetRunningCount(); buttonServices.Enabled = true; - Program.inputDispatcher.Init(); - } public void ServiesToggle() @@ -263,6 +261,7 @@ namespace GHelper { InitServices(); }); + Program.inputDispatcher.Init(); }); } else diff --git a/app/Updates.cs b/app/Updates.cs index e950cc4f..9a1d06fb 100644 --- a/app/Updates.cs +++ b/app/Updates.cs @@ -20,14 +20,17 @@ namespace GHelper public partial class Updates : RForm { //static int rowCount = 0; - static string model = AppConfig.GetModelShort(); + static string model; + static string bios; public Updates() { InitializeComponent(); InitTheme(); - Text = Properties.Strings.BiosAndDriverUpdates + ": " + model + " " + GetBiosVersion(); + InitBiosAndModel(); + + Text = Properties.Strings.BiosAndDriverUpdates + ": " + model + " " + bios; labelBIOS.Text = "BIOS"; labelDrivers.Text = Properties.Strings.DriverAndSoftware; @@ -73,7 +76,7 @@ namespace GHelper } } - private string GetBiosVersion() + private string InitBiosAndModel() { using (ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS")) { @@ -82,10 +85,15 @@ namespace GHelper foreach (ManagementObject obj in objCollection) if (obj["SMBIOSBIOSVersion"] is not null) { - var bios = obj["SMBIOSBIOSVersion"].ToString(); - int trim = bios.LastIndexOf("."); - if (trim > 0) return bios.Substring(trim + 1); - else return bios; + string[] results = obj["SMBIOSBIOSVersion"].ToString().Split("."); + if (results.Length > 1) + { + model = results[0]; + bios = results[1]; + } else + { + model = obj["SMBIOSBIOSVersion"].ToString(); + } } return ""; @@ -140,7 +148,7 @@ namespace GHelper BeginInvoke(delegate { 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, AutoSize = true }; versionLabel.Cursor = Cursors.Hand; versionLabel.Font = new Font(versionLabel.Font, FontStyle.Underline); versionLabel.ForeColor = colorEco; @@ -170,10 +178,7 @@ namespace GHelper }); Dictionary devices = new(); - string biosVersion = "0"; - if (type == 0) devices = GetDeviceVersions(); - else biosVersion = GetBiosVersion(); //Debug.WriteLine(biosVersion); @@ -194,7 +199,7 @@ namespace GHelper } if (type == 1) - newer = Int32.Parse(driver.version) > Int32.Parse(biosVersion) ? 1 : -1; + newer = Int32.Parse(driver.version) > Int32.Parse(bios) ? 1 : -1; if (newer > 0) {