From 4bbfbd03825ec7c982d9b9f81828a105174cca09 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Mon, 5 Jun 2023 17:31:59 +0200 Subject: [PATCH] Driver Updates --- app/AppConfig.cs | 19 ++- app/GHelper.csproj | 2 +- app/Program.cs | 3 + app/Properties/Resources.Designer.cs | 10 ++ app/Properties/Resources.resx | 79 ++++++----- app/Properties/Strings.Designer.cs | 27 ++++ app/Properties/Strings.resx | 9 ++ app/Resources/icons8-bios-48.png | Bin 0 -> 362 bytes app/Resources/icons8-software-48.png | Bin 0 -> 645 bytes app/Settings.Designer.cs | 49 +++++-- app/Settings.cs | 16 +++ app/Updates.Designer.cs | 204 +++++++++++++++++++++++++++ app/Updates.cs | 187 ++++++++++++++++++++++++ app/Updates.resx | 149 +++++++++++++++++++ 14 files changed, 699 insertions(+), 55 deletions(-) create mode 100644 app/Resources/icons8-bios-48.png create mode 100644 app/Resources/icons8-software-48.png create mode 100644 app/Updates.Designer.cs create mode 100644 app/Updates.cs create mode 100644 app/Updates.resx diff --git a/app/AppConfig.cs b/app/AppConfig.cs index e1ec8234..15bdcf54 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -61,8 +61,25 @@ public static class AppConfig GetModel(); 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() { config = new Dictionary(); diff --git a/app/GHelper.csproj b/app/GHelper.csproj index 1ed2cc7f..9170ec4b 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ AnyCPU False True - 0.78 + 0.79 diff --git a/app/Program.cs b/app/Program.cs index 6adf399c..4d8c4280 100644 --- a/app/Program.cs +++ b/app/Program.cs @@ -126,6 +126,9 @@ namespace GHelper if (settingsForm.keyb is not null && settingsForm.keyb.Text != "") settingsForm.keyb.InitTheme(); + if (settingsForm.updates is not null && settingsForm.updates.Text != "") + settingsForm.updates.InitTheme(); + break; } } diff --git a/app/Properties/Resources.Designer.cs b/app/Properties/Resources.Designer.cs index 66570f4a..c7c33cd6 100644 --- a/app/Properties/Resources.Designer.cs +++ b/app/Properties/Resources.Designer.cs @@ -350,6 +350,16 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icons8_software_48 { + get { + object obj = ResourceManager.GetObject("icons8-software-48", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/app/Properties/Resources.resx b/app/Properties/Resources.resx index 2eca7afa..1e205fa7 100644 --- a/app/Properties/Resources.resx +++ b/app/Properties/Resources.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\brightness-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-leaf-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -133,11 +136,17 @@ ..\Resources\icons8-fiat-500-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-microphone-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-rocket-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-bicycle-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-game-controller-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-touchpad-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-fan-head-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -145,8 +154,8 @@ ..\Resources\icons8-processor-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-spa-flower-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-game-controller-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-spa-flower-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -157,9 +166,15 @@ ..\Resources\icons8-keyboard-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\brightness-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-fan-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-help-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-speed-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -169,12 +184,24 @@ ..\Resources\icons8-laptop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-video-card-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\backlight-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icons8-spa-flower-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-organic-food-961.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-function-mac-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-balance-symbol-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -184,55 +211,31 @@ ..\Resources\icons8-matrix-desktop-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-mute-unmute-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-xbox-controller-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-project-management-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\icons8-leaf-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\ultimate.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-rocket-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\backlight-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\icons8-speed-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\icons8-help-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8-video-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8-project-management-48 (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8-microphone-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8-touchpad-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\backlight-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\backlight-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\brightness-down.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\brightness-up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8-mute-unmute-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\icons8-function-mac-96.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\icons8-software-48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/app/Properties/Strings.Designer.cs b/app/Properties/Strings.Designer.cs index deb9a462..891d02c6 100644 --- a/app/Properties/Strings.Designer.cs +++ b/app/Properties/Strings.Designer.cs @@ -312,6 +312,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to BIOS and Driver Updates. + /// + internal static string BiosAndDriverUpdates { + get { + return ResourceManager.GetString("BiosAndDriverUpdates", resourceCulture); + } + } + /// /// Looks up a localized string similar to Boot. /// @@ -393,6 +402,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Drivers and Software. + /// + internal static string DriverAndSoftware { + get { + return ResourceManager.GetString("DriverAndSoftware", resourceCulture); + } + } + /// /// Looks up a localized string similar to Disables dGPU for battery savings. /// @@ -1095,6 +1113,15 @@ namespace GHelper.Properties { } } + /// + /// Looks up a localized string similar to Updates. + /// + internal static string Updates { + get { + return ResourceManager.GetString("Updates", resourceCulture); + } + } + /// /// Looks up a localized string similar to Version. /// diff --git a/app/Properties/Strings.resx b/app/Properties/Strings.resx index 3b54d187..f622dde0 100644 --- a/app/Properties/Strings.resx +++ b/app/Properties/Strings.resx @@ -201,6 +201,9 @@ Battery Charge Limit + + BIOS and Driver Updates + Boot @@ -228,6 +231,9 @@ Download Update + + Drivers and Software + Disables dGPU for battery savings @@ -462,6 +468,9 @@ Ultimate + + Updates + Version diff --git a/app/Resources/icons8-bios-48.png b/app/Resources/icons8-bios-48.png new file mode 100644 index 0000000000000000000000000000000000000000..0c74eb0c961a89fbad6b4b3aa0b88faff368e658 GIT binary patch literal 362 zcmV-w0hRuVP)O*hAoa6JQRj+8 zxgf*|?OcBhJOESRz45`+@dylk#Seh3vT$)?4`eRgAuWu+2v|Bg z4nD=DQ|Q&Y$YhR=FQ3Bb$JjrR5G}tIRX5}{<_($Jz@>h7=1vXdwTX3Hjp+<%AZ9=r zu?{FB)&XV2I-rbL2b7UscA&iXf#&EGE|g4+f#=YXa@Bz$UK&v?8vabyv9-!Bb%707*qo IM6N<$f}cH*djJ3c literal 0 HcmV?d00001 diff --git a/app/Resources/icons8-software-48.png b/app/Resources/icons8-software-48.png new file mode 100644 index 0000000000000000000000000000000000000000..c5bb0c8fddec6c738662ccea56a5d245b0badb05 GIT binary patch literal 645 zcmV;00($+4P)P_o z^D|OdXd@f4BJmHTi3kZQ>7vE9frPM%yG{Ju8%9RB9OmAgxgXw(nFmg@yXT$voINvl zcERKEcqqjRc2Pf_My0!I#}qv8iJ zf0xGlfz=F*%Xkm;01{ekgfQP^Y@It@0A2V)Wfx$e@9~u_D2G)Q{ z2d#17V?-fpq@Lt4Hm1)11g2ByP5}*r?zgPRDQe~~^+}S3$H3=^J&_5ox@^8Iig*xF z#C#U#{E=a7E_3=O8ixIl>N&As*s#;uY#v2CH*D-TX#{tLm^y84kwshqZ%I#Gthtls zZWHcC$8c2M7NN|)CL6{L>y9K5S`wX54=EGXj5;6YK&-t;0%}5J*&(+AYyoW@+xls2 z%R905Mgspg*Wa+njDz`O!;yHR-?L#(W(1++`h + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Updates)); + tableBios = new TableLayoutPanel(); + labelBIOS = new Label(); + pictureBios = new PictureBox(); + panelBiosTitle = new Panel(); + panelBios = new Panel(); + panelDrivers = new Panel(); + tableDrivers = new TableLayoutPanel(); + panelDriversTitle = new Panel(); + labelDrivers = new Label(); + pictureDrivers = new PictureBox(); + ((System.ComponentModel.ISupportInitialize)pictureBios).BeginInit(); + panelBiosTitle.SuspendLayout(); + panelBios.SuspendLayout(); + panelDrivers.SuspendLayout(); + panelDriversTitle.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)pictureDrivers).BeginInit(); + SuspendLayout(); + // + // tableBios + // + tableBios.AutoSize = true; + tableBios.ColumnCount = 3; + tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableBios.Dock = DockStyle.Fill; + tableBios.Location = new Point(20, 20); + tableBios.MinimumSize = new Size(1100, 0); + tableBios.Name = "tableBios"; + tableBios.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + tableBios.Size = new Size(1138, 0); + tableBios.TabIndex = 0; + // + // labelBIOS + // + labelBIOS.AutoSize = true; + labelBIOS.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelBIOS.Location = new Point(67, 27); + labelBIOS.Name = "labelBIOS"; + labelBIOS.Size = new Size(68, 32); + labelBIOS.TabIndex = 1; + labelBIOS.Text = "BIOS"; + // + // pictureBios + // + pictureBios.BackgroundImage = (Image)resources.GetObject("pictureBios.BackgroundImage"); + pictureBios.BackgroundImageLayout = ImageLayout.Zoom; + pictureBios.Location = new Point(29, 27); + pictureBios.Name = "pictureBios"; + pictureBios.Size = new Size(32, 32); + pictureBios.TabIndex = 2; + pictureBios.TabStop = false; + // + // panelBiosTitle + // + panelBiosTitle.Controls.Add(labelBIOS); + panelBiosTitle.Controls.Add(pictureBios); + panelBiosTitle.Dock = DockStyle.Top; + panelBiosTitle.Location = new Point(0, 0); + panelBiosTitle.Name = "panelBiosTitle"; + panelBiosTitle.Size = new Size(1178, 62); + panelBiosTitle.TabIndex = 3; + // + // panelBios + // + panelBios.AutoSize = true; + panelBios.Controls.Add(tableBios); + panelBios.Dock = DockStyle.Top; + panelBios.Location = new Point(0, 62); + panelBios.Name = "panelBios"; + panelBios.Padding = new Padding(20); + panelBios.Size = new Size(1178, 40); + panelBios.TabIndex = 4; + // + // panelDrivers + // + panelDrivers.AutoSize = true; + panelDrivers.Controls.Add(tableDrivers); + panelDrivers.Dock = DockStyle.Top; + panelDrivers.Location = new Point(0, 146); + panelDrivers.Name = "panelDrivers"; + panelDrivers.Padding = new Padding(20); + panelDrivers.Size = new Size(1178, 40); + panelDrivers.TabIndex = 6; + // + // tableDrivers + // + tableDrivers.AutoSize = true; + tableDrivers.ColumnCount = 3; + tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); + tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); + tableDrivers.Dock = DockStyle.Fill; + tableDrivers.Location = new Point(20, 20); + tableDrivers.MinimumSize = new Size(1100, 0); + tableDrivers.Name = "tableDrivers"; + tableDrivers.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + tableDrivers.Size = new Size(1138, 0); + tableDrivers.TabIndex = 0; + // + // panelDriversTitle + // + panelDriversTitle.Controls.Add(labelDrivers); + panelDriversTitle.Controls.Add(pictureDrivers); + panelDriversTitle.Dock = DockStyle.Top; + panelDriversTitle.Location = new Point(0, 102); + panelDriversTitle.Name = "panelDriversTitle"; + panelDriversTitle.Size = new Size(1178, 44); + panelDriversTitle.TabIndex = 5; + // + // labelDrivers + // + labelDrivers.AutoSize = true; + labelDrivers.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); + labelDrivers.Location = new Point(67, 7); + labelDrivers.Name = "labelDrivers"; + labelDrivers.Size = new Size(254, 32); + labelDrivers.TabIndex = 1; + labelDrivers.Text = "Drivers and Software"; + // + // pictureDrivers + // + pictureDrivers.BackgroundImage = (Image)resources.GetObject("pictureDrivers.BackgroundImage"); + pictureDrivers.BackgroundImageLayout = ImageLayout.Zoom; + pictureDrivers.Location = new Point(29, 8); + pictureDrivers.Name = "pictureDrivers"; + pictureDrivers.Size = new Size(32, 32); + pictureDrivers.TabIndex = 2; + pictureDrivers.TabStop = false; + // + // Updates + // + AutoScaleDimensions = new SizeF(192F, 192F); + AutoScaleMode = AutoScaleMode.Dpi; + AutoScroll = true; + ClientSize = new Size(1178, 690); + Controls.Add(panelDrivers); + Controls.Add(panelDriversTitle); + Controls.Add(panelBios); + Controls.Add(panelBiosTitle); + MinimizeBox = false; + Name = "Updates"; + ShowIcon = false; + ShowInTaskbar = false; + Text = "BIOS and Driver Updates"; + ((System.ComponentModel.ISupportInitialize)pictureBios).EndInit(); + panelBiosTitle.ResumeLayout(false); + panelBiosTitle.PerformLayout(); + panelBios.ResumeLayout(false); + panelBios.PerformLayout(); + panelDrivers.ResumeLayout(false); + panelDrivers.PerformLayout(); + panelDriversTitle.ResumeLayout(false); + panelDriversTitle.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)pictureDrivers).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private TableLayoutPanel tableBios; + private Label labelBIOS; + private PictureBox pictureBios; + private Panel panelBiosTitle; + private Panel panelBios; + private Panel panelDrivers; + private TableLayoutPanel tableDrivers; + private Panel panelDriversTitle; + private Label labelDrivers; + private PictureBox pictureDrivers; + } +} \ No newline at end of file diff --git a/app/Updates.cs b/app/Updates.cs new file mode 100644 index 00000000..972fae89 --- /dev/null +++ b/app/Updates.cs @@ -0,0 +1,187 @@ +using CustomControls; +using NAudio.CoreAudioApi; +using System.Diagnostics; +using System.Management; +using System.Text.Json; +using System.Xml.Linq; + +namespace GHelper +{ + public partial class Updates : RForm + { + //static int rowCount = 0; + static string model = AppConfig.GetModelShort(); + + public Updates() + { + InitializeComponent(); + InitTheme(); + + Text = Properties.Strings.BiosAndDriverUpdates + ": " + model + " " + GetBiosVersion(); + labelBIOS.Text = "BIOS"; + labelDrivers.Text = Properties.Strings.DriverAndSoftware; + + SuspendLayout(); + tableBios.Visible = false; + tableDrivers.Visible = false; + + Task.Run(async () => + { + DriversAsync($"https://rog.asus.com/support/webapi/product/GetPDBIOS?website=global&model={model}&cpu=", 1, tableBios); + }); + + Task.Run(async () => + { + DriversAsync($"https://rog.asus.com/support/webapi/product/GetPDDrivers?website=global&model={model}&osid=52", 0, tableDrivers); + }); + + Shown += Updates_Shown; + } + + private void Updates_Shown(object? sender, EventArgs e) + { + Height = Program.settingsForm.Height; + Top = Program.settingsForm.Top; + Left = Program.settingsForm.Left - Width - 5; + } + private Dictionary GetDeviceVersions() + { + ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("Select * from Win32_PnPSignedDriver"); + ManagementObjectCollection objCollection = objSearcher.Get(); + Dictionary list = new(); + + foreach (ManagementObject obj in objCollection) + { + if (obj["DeviceID"] is not null && obj["DriverVersion"] is not null) + list[obj["DeviceID"].ToString()] = obj["DriverVersion"].ToString(); + } + + return list; + } + + private string GetBiosVersion() + { + ManagementObjectSearcher objSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_BIOS"); + ManagementObjectCollection objCollection = objSearcher.Get(); + + 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; + } + + return ""; + } + + public async void DriversAsync(string url, int type, TableLayoutPanel table) + { + + try + { + Dictionary devices = new(); + string biosVersion = ""; + + if (type == 0) devices = GetDeviceVersions(); + else biosVersion = GetBiosVersion(); + + //Debug.WriteLine(biosVersion); + + using (var httpClient = new HttpClient()) + { + httpClient.DefaultRequestHeaders.Add("User-Agent", "C# App"); + var json = await httpClient.GetStringAsync(url); + var data = JsonSerializer.Deserialize(json); + var groups = data.GetProperty("Result").GetProperty("Obj"); + + + List skipList = new() { "Armoury Crate & Aura Creator Installer", "MyASUS", "ASUS Smart Display Control", "Aura Wallpaper" }; + + for (int i = 0; i < groups.GetArrayLength(); i++) + { + var categoryName = groups[i].GetProperty("Name").ToString(); + var files = groups[i].GetProperty("Files"); + + var oldTitle = ""; + + for (int j = 0; j < files.GetArrayLength(); j++) + { + + var file = files[j]; + 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)) + { + JsonElement hardwares = file.GetProperty("HardwareInfoList"); + bool newer = false; + + if (type == 0 && hardwares.ToString().Length > 0) + for (int k = 0; k < hardwares.GetArrayLength(); k++) + { + var deviceID = 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(version).CompareTo(new Version(localVersion)) > 0); + break; + } + } + + if (type == 1) + { + newer = Int32.Parse(version) > Int32.Parse(biosVersion); + } + + BeginInvoke(delegate + { + string versionText = version.Replace("latest version at the ", ""); + Label versionLabel = new Label { Text = versionText, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Height = 50 }; + versionLabel.Cursor = Cursors.Hand; + versionLabel.Font = new Font(versionLabel.Font, newer ? FontStyle.Underline | FontStyle.Bold : FontStyle.Underline); + versionLabel.ForeColor = newer ? colorTurbo : colorEco; + versionLabel.Padding = new Padding(5, 5, 5, 5); + versionLabel.Click += delegate + { + Process.Start(new ProcessStartInfo(downloadUrl) { UseShellExecute = true }); + }; + + table.RowStyles.Add(new RowStyle(SizeType.Percent, 50F)); + 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 = 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.RowCount++; + }); + } + + oldTitle = title; + + } + + + } + + + BeginInvoke(delegate + { + table.Visible = true; + ResumeLayout(false); + PerformLayout(); + }); + + } + } + catch (Exception ex) + { + Debug.WriteLine(ex.ToString()); + + } + + } + } +} diff --git a/app/Updates.resx b/app/Updates.resx new file mode 100644 index 00000000..4cc6e934 --- /dev/null +++ b/app/Updates.resx @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL + DwAACw8BkvkDpQAAAWlJREFUaEPtmN1Kw0AQhVOkoo8q7ZUiguid9ULwZaS+g3jtnT6FCv4g2DOhA23I + LrvHzKTCfPBRkuFsT9JCyDZBEASBB7fwE960R9tcwze4aI+2sZhRfMHf9WeXDygz+exiMaOQxdQu3jOK + 3ILes2ImcAYf4eaC3s7hFFaxB+9g34JjeA/3YTHHsG+hMT2BxbxADZ7C6p9wAA7gOdQeT7CYH6jBqp9u + YOS7tce3nChFQ+LYUF1SIXlCvsPBnpAFpLpkSYXk8S7nXtsjH1JdsqRCcuflIq7aIx9SXbJQISOoLlTI + CKoLFTKC6kKFjKC6UCEjqC5UyAiqCxUygupChYygulAhI6guVMgIqgsVMoLqQoWMoLr8+xeaZ6jBMzjG + RRzCC6g9ql4pL6EGd0XZaChG7vgubassYfW/QDa2juAD7FvUS9lc+/OuyOaCXbxnFLkFvWcU7Fa4xYxC + X+b7tlO8Z0EQBMFQNM0KZ46+F5QUhV4AAAAASUVORK5CYII= + + + + + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL + DAAACwwBP0AiyAAAAnJJREFUaEPtmL1qlEEUhhdF8Acbo51/KGKRWhvBP7S0Ve9AvAQxuYwUFkkjioro + DdgogqJipxa2giIqamOiieZ5IQuH4ezOmf2+3R3ke+CBsLvnzJnZmfnOptfR0dHx33AYr+JtfI1f8PeG + +luv3UJ95hBWwWa8jE/xL/4Lqs8q5hJuwqlwDt+hV2CJb/AsToxteAO9Ypq4gFtxrOzBF+gVoG3xGOfw + JO7H7bgDj+Ip1HsvcdB2e4YzOBZU/FtMB13DRZzFKEfwDnoT0Zbaja2ibeOt/Ac8gaNyDN9jmvc5trqd + Bu35P6ibpAm78BGmuXUmWuE8psmtbUxiC3qTaHw76Z5Pr0ptGxVtX2vrm0i3k85Do+eEHlI2oQ6s9ryK + HcckjmN6sC/iyOhpaZPptumTTmIVr2FT7qId8wmOhHobuxr6O70q+5NQ8Rf0Qgvoik3HPYjFqOnqJ5F6 + SHloEm2svOUV2rGvYDHqHG2S6xhlH97Hnxs+RD2No8yjHfsmFqP21yZRexBBxX9FGyu/od6LcAZtrL6R + YtTD2yQHMIJW3sZZ72EEfVs27jMWs4I2iRqzCNoyNs76AyPsRBu3jMX8QptE/VCEYRP4jhG0WDZOtRTz + CW2SvRhBB9bGWXXHR9BZsXEfsRj17TbJaYyg/asDa2OlzlR0EdJDrE64mCW0SUrueq2gDqz2vNTKR4sX + GsuOrVrC2MAazeIF1WQWL6gms3hBNZnFC6rJLF5QTWbxgmoyixdUk1m8oJrM4gXVZJZh3eS0DXWzD9AL + rkH9WMqibtL7SThtVZP+YxFCnWO/m/SSTVLVoJUPF9/R0dExKXq9dc3qWY2Pp0GbAAAAAElFTkSuQmCC + + + \ No newline at end of file