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 00000000..0c74eb0c Binary files /dev/null and b/app/Resources/icons8-bios-48.png differ diff --git a/app/Resources/icons8-software-48.png b/app/Resources/icons8-software-48.png new file mode 100644 index 00000000..c5bb0c8f Binary files /dev/null and b/app/Resources/icons8-software-48.png differ diff --git a/app/Settings.Designer.cs b/app/Settings.Designer.cs index 6af76aae..6a97c3e4 100644 --- a/app/Settings.Designer.cs +++ b/app/Settings.Designer.cs @@ -47,6 +47,7 @@ namespace GHelper pictureBattery = new PictureBox(); labelBatteryTitle = new Label(); panelFooter = new Panel(); + buttonUpdates = new RButton(); buttonQuit = new RButton(); checkStartup = new CheckBox(); panelPerformance = new Panel(); @@ -121,7 +122,7 @@ namespace GHelper panelMatrix.Controls.Add(pictureMatrix); panelMatrix.Controls.Add(labelMatrix); panelMatrix.Dock = DockStyle.Top; - panelMatrix.Location = new Point(10, 795); + panelMatrix.Location = new Point(10, 777); panelMatrix.Margin = new Padding(8); panelMatrix.Name = "panelMatrix"; panelMatrix.Padding = new Padding(0, 0, 0, 12); @@ -244,7 +245,7 @@ namespace GHelper panelBattery.Controls.Add(pictureBattery); panelBattery.Controls.Add(labelBatteryTitle); panelBattery.Dock = DockStyle.Top; - panelBattery.Location = new Point(10, 963); + panelBattery.Location = new Point(10, 945); panelBattery.Margin = new Padding(8); panelBattery.Name = "panelBattery"; panelBattery.Padding = new Padding(0, 0, 0, 12); @@ -322,16 +323,34 @@ namespace GHelper // panelFooter.AutoSize = true; panelFooter.AutoSizeMode = AutoSizeMode.GrowAndShrink; + panelFooter.Controls.Add(buttonUpdates); panelFooter.Controls.Add(buttonQuit); panelFooter.Controls.Add(checkStartup); panelFooter.Dock = DockStyle.Top; - panelFooter.Location = new Point(10, 1126); + panelFooter.Location = new Point(10, 1108); panelFooter.Margin = new Padding(8); panelFooter.Name = "panelFooter"; panelFooter.Padding = new Padding(0, 0, 0, 10); panelFooter.Size = new Size(810, 74); panelFooter.TabIndex = 35; // + // buttonUpdates + // + buttonUpdates.Activated = false; + buttonUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonUpdates.BackColor = SystemColors.ControlLight; + buttonUpdates.BorderColor = Color.Transparent; + buttonUpdates.BorderRadius = 2; + buttonUpdates.FlatStyle = FlatStyle.Flat; + buttonUpdates.Location = new Point(401, 16); + buttonUpdates.Margin = new Padding(8, 4, 8, 4); + buttonUpdates.Name = "buttonUpdates"; + buttonUpdates.Secondary = true; + buttonUpdates.Size = new Size(180, 44); + buttonUpdates.TabIndex = 19; + buttonUpdates.Text = "Updates"; + buttonUpdates.UseVisualStyleBackColor = false; + // // buttonQuit // buttonQuit.Activated = false; @@ -340,11 +359,11 @@ namespace GHelper buttonQuit.BorderColor = Color.Transparent; buttonQuit.BorderRadius = 2; buttonQuit.FlatStyle = FlatStyle.Flat; - buttonQuit.Location = new Point(599, 16); + buttonQuit.Location = new Point(597, 16); buttonQuit.Margin = new Padding(8, 4, 8, 4); buttonQuit.Name = "buttonQuit"; buttonQuit.Secondary = true; - buttonQuit.Size = new Size(185, 44); + buttonQuit.Size = new Size(180, 44); buttonQuit.TabIndex = 18; buttonQuit.Text = Properties.Strings.Quit; buttonQuit.UseVisualStyleBackColor = false; @@ -536,20 +555,18 @@ namespace GHelper panelGPU.Margin = new Padding(8); panelGPU.Name = "panelGPU"; panelGPU.Padding = new Padding(0, 0, 0, 45); - panelGPU.Size = new Size(810, 237); + panelGPU.Size = new Size(810, 257); panelGPU.TabIndex = 37; // // labelTipGPU // + labelTipGPU.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; labelTipGPU.ForeColor = SystemColors.GrayText; - labelTipGPU.Location = new Point(44, 191); + labelTipGPU.Location = new Point(44, 211); labelTipGPU.Margin = new Padding(4, 0, 4, 0); labelTipGPU.Name = "labelTipGPU"; labelTipGPU.Size = new Size(760, 36); labelTipGPU.TabIndex = 20; - labelTipGPU.Text = ""; - labelTipGPU.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; - // // pictureGPU // @@ -604,7 +621,8 @@ namespace GHelper tableGPU.Name = "tableGPU"; tableGPU.RowCount = 1; tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 128F)); - tableGPU.Size = new Size(772, 128); + tableGPU.RowStyles.Add(new RowStyle(SizeType.Absolute, 20F)); + tableGPU.Size = new Size(772, 148); tableGPU.TabIndex = 16; // // buttonEco @@ -668,7 +686,7 @@ namespace GHelper buttonXGM.Margin = new Padding(4); buttonXGM.Name = "buttonXGM"; buttonXGM.Secondary = false; - buttonXGM.Size = new Size(185, 120); + buttonXGM.Size = new Size(185, 12); buttonXGM.TabIndex = 2; buttonXGM.Text = "XG Mobile"; buttonXGM.TextImageRelation = TextImageRelation.ImageAboveText; @@ -729,7 +747,7 @@ namespace GHelper panelScreen.Controls.Add(pictureScreen); panelScreen.Controls.Add(labelSreen); panelScreen.Dock = DockStyle.Top; - panelScreen.Location = new Point(10, 485); + panelScreen.Location = new Point(10, 467); panelScreen.Margin = new Padding(8); panelScreen.Name = "panelScreen"; panelScreen.Padding = new Padding(0, 0, 0, 10); @@ -886,7 +904,7 @@ namespace GHelper panelKeyboard.Controls.Add(pictureKeyboard); panelKeyboard.Controls.Add(labelKeyboard); panelKeyboard.Dock = DockStyle.Top; - panelKeyboard.Location = new Point(10, 666); + panelKeyboard.Location = new Point(10, 648); panelKeyboard.Margin = new Padding(8); panelKeyboard.Name = "panelKeyboard"; panelKeyboard.Padding = new Padding(0, 0, 0, 12); @@ -1027,7 +1045,7 @@ namespace GHelper AutoScaleMode = AutoScaleMode.Dpi; AutoSize = true; AutoSizeMode = AutoSizeMode.GrowAndShrink; - ClientSize = new Size(830, 1173); + ClientSize = new Size(830, 1195); Controls.Add(panelFooter); Controls.Add(panelBattery); Controls.Add(panelMatrix); @@ -1137,5 +1155,6 @@ namespace GHelper private Label labelMidFan; private Label labelModel; private WinFormsSliderBar.Slider sliderBattery; + private RButton buttonUpdates; } } \ No newline at end of file diff --git a/app/Settings.cs b/app/Settings.cs index 7eb3366f..9c71942a 100644 --- a/app/Settings.cs +++ b/app/Settings.cs @@ -28,6 +28,7 @@ namespace GHelper public AniMatrix matrix; public Fans fans; public Extra keyb; + public Updates updates; static long lastRefresh; @@ -71,6 +72,7 @@ namespace GHelper buttonMatrix.Text = Properties.Strings.PictureGif; buttonQuit.Text = Properties.Strings.Quit; + buttonUpdates.Text = Properties.Strings.Updates; FormClosing += SettingsForm_FormClosing; @@ -157,6 +159,8 @@ namespace GHelper button120Hz.MouseMove += Button120Hz_MouseHover; button120Hz.MouseLeave += ButtonScreen_MouseLeave; + buttonUpdates.Click += ButtonUpdates_Click; + sliderBattery.ValueChanged += SliderBattery_ValueChanged; Program.trayIcon.MouseMove += TrayIcon_MouseMove; @@ -184,6 +188,18 @@ namespace GHelper } + private void ButtonUpdates_Click(object? sender, EventArgs e) + { + if (updates == null || updates.Text == "") + { + updates = new Updates(); + updates.Show(); + } + else + { + updates.Close(); + } + } protected override void WndProc(ref Message m) { diff --git a/app/Updates.Designer.cs b/app/Updates.Designer.cs new file mode 100644 index 00000000..545e174f --- /dev/null +++ b/app/Updates.Designer.cs @@ -0,0 +1,204 @@ +namespace GHelper +{ + partial class Updates + { + /// + /// 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