Update checker

This commit is contained in:
Serge
2023-09-07 13:44:31 +02:00
parent 46c91d1956
commit 082eceed9a
4 changed files with 41 additions and 24 deletions

View File

@@ -543,6 +543,7 @@ namespace GHelper
Invoke(delegate Invoke(delegate
{ {
comboMatrixRunning.SelectedIndex = mode; comboMatrixRunning.SelectedIndex = mode;
if (comboMatrix.SelectedIndex == 0) comboMatrix.SelectedIndex = 3;
}); });
} }

View File

@@ -54,16 +54,17 @@ namespace GHelper
// //
tableBios.AutoSize = true; tableBios.AutoSize = true;
tableBios.AutoSizeMode = AutoSizeMode.GrowAndShrink; tableBios.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableBios.ColumnCount = 3; tableBios.ColumnCount = 4;
tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 15F));
tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableBios.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableBios.Dock = DockStyle.Top; tableBios.Dock = DockStyle.Top;
tableBios.Location = new Point(20, 20); tableBios.Location = new Point(20, 20);
tableBios.Margin = new Padding(4); tableBios.Margin = new Padding(4);
tableBios.MinimumSize = new Size(1100, 0); tableBios.MinimumSize = new Size(1300, 0);
tableBios.Name = "tableBios"; tableBios.Name = "tableBios";
tableBios.Size = new Size(1216, 0); tableBios.Size = new Size(1300, 0);
tableBios.TabIndex = 0; tableBios.TabIndex = 0;
// //
// labelBIOS // labelBIOS
@@ -105,7 +106,7 @@ namespace GHelper
// //
labelUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Right; labelUpdates.Anchor = AnchorStyles.Top | AnchorStyles.Right;
labelUpdates.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point); labelUpdates.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
labelUpdates.Location = new Point(941, 23); labelUpdates.Location = new Point(810, 23);
labelUpdates.Name = "labelUpdates"; labelUpdates.Name = "labelUpdates";
labelUpdates.Size = new Size(245, 32); labelUpdates.Size = new Size(245, 32);
labelUpdates.TabIndex = 4; labelUpdates.TabIndex = 4;
@@ -156,16 +157,17 @@ namespace GHelper
// //
tableDrivers.AutoSize = true; tableDrivers.AutoSize = true;
tableDrivers.AutoSizeMode = AutoSizeMode.GrowAndShrink; tableDrivers.AutoSizeMode = AutoSizeMode.GrowAndShrink;
tableDrivers.ColumnCount = 3; tableDrivers.ColumnCount = 4;
tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 20F));
tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F)); tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 40F));
tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 15F));
tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F)); tableDrivers.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableDrivers.Dock = DockStyle.Top; tableDrivers.Dock = DockStyle.Top;
tableDrivers.Location = new Point(20, 20); tableDrivers.Location = new Point(20, 20);
tableDrivers.Margin = new Padding(4); tableDrivers.Margin = new Padding(4);
tableDrivers.MinimumSize = new Size(1100, 0); tableDrivers.MinimumSize = new Size(1300, 0);
tableDrivers.Name = "tableDrivers"; tableDrivers.Name = "tableDrivers";
tableDrivers.Size = new Size(1216, 0); tableDrivers.Size = new Size(1300, 0);
tableDrivers.TabIndex = 0; tableDrivers.TabIndex = 0;
// //
// panelDriversTitle // panelDriversTitle

View File

@@ -9,6 +9,9 @@ namespace GHelper
public partial class Updates : RForm public partial class Updates : RForm
{ {
const int DRIVER_NOT_FOUND = 2;
const int DRIVER_NEWER = 1;
//static int rowCount = 0; //static int rowCount = 0;
static string model; static string model;
static string bios; static string bios;
@@ -21,6 +24,7 @@ namespace GHelper
public string title; public string title;
public string version; public string version;
public string downloadUrl; public string downloadUrl;
public string date;
public JsonElement hardwares; public JsonElement hardwares;
} }
private void LoadUpdates(bool force = false) private void LoadUpdates(bool force = false)
@@ -156,7 +160,8 @@ namespace GHelper
table.RowStyles.Add(new RowStyle(SizeType.AutoSize)); table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
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 = driver.categoryName, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 0, 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(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(new Label { Text = driver.date, Anchor = AnchorStyles.Left, Dock = DockStyle.Fill, Padding = new Padding(5, 5, 5, 5) }, 2, table.RowCount);
table.Controls.Add(versionLabel, 3, table.RowCount);
table.RowCount++; table.RowCount++;
}); });
} }
@@ -171,15 +176,21 @@ namespace GHelper
}); });
} }
public void VisualiseNewDriver(int position, TableLayoutPanel table) public void VisualiseNewDriver(int position, int newer, TableLayoutPanel table)
{ {
var label = table.GetControlFromPosition(2, position) as Label; var label = table.GetControlFromPosition(3, position) as Label;
if (label != null) if (label != null)
{ {
Invoke(delegate Invoke(delegate
{ {
label.Font = new Font(label.Font, FontStyle.Underline | FontStyle.Bold); if (newer == DRIVER_NEWER)
label.ForeColor = colorTurbo; {
label.Font = new Font(label.Font, FontStyle.Underline | FontStyle.Bold);
label.ForeColor = colorTurbo;
}
if (newer == DRIVER_NOT_FOUND) label.ForeColor = Color.Gray;
}); });
} }
} }
@@ -237,6 +248,7 @@ namespace GHelper
driver.version = file.GetProperty("Version").ToString().Replace("V", ""); driver.version = file.GetProperty("Version").ToString().Replace("V", "");
driver.downloadUrl = file.GetProperty("DownloadUrl").GetProperty("Global").ToString(); driver.downloadUrl = file.GetProperty("DownloadUrl").GetProperty("Global").ToString();
driver.hardwares = file.GetProperty("HardwareInfoList"); driver.hardwares = file.GetProperty("HardwareInfoList");
driver.date = file.GetProperty("ReleaseDate").ToString();
drivers.Add(driver); drivers.Add(driver);
VisualiseDriver(driver, table); VisualiseDriver(driver, table);
@@ -257,26 +269,28 @@ namespace GHelper
int count = 0; int count = 0;
foreach (var driver in drivers) foreach (var driver in drivers)
{ {
int newer = -2; int newer = DRIVER_NOT_FOUND;
if (type == 0 && driver.hardwares.ToString().Length > 0) if (type == 0 && driver.hardwares.ToString().Length > 0)
for (int k = 0; k < driver.hardwares.GetArrayLength(); k++) for (int k = 0; k < driver.hardwares.GetArrayLength(); k++)
{ {
var deviceID = driver.hardwares[k].GetProperty("hardwareid").ToString(); var deviceID = driver.hardwares[k].GetProperty("hardwareid").ToString();
var localVersion = devices.Where(p => p.Key.Contains(deviceID)).Select(p => p.Value).FirstOrDefault(); var localVersions = devices.Where(p => p.Key.Contains(deviceID)).Select(p => p.Value);
if (localVersion is not null) foreach (var localVersion in localVersions)
{ {
newer = new Version(driver.version).CompareTo(new Version(localVersion)); newer = Math.Min(newer, new Version(driver.version).CompareTo(new Version(localVersion)));
break; Logger.WriteLine(driver.title + " " + driver.version + " vs " + localVersion + " = " + newer);
} }
} }
if (type == 1) if (type == 1)
newer = Int32.Parse(driver.version) > Int32.Parse(bios) ? 1 : -1; newer = Int32.Parse(driver.version) > Int32.Parse(bios) ? 1 : -1;
if (newer > 0) VisualiseNewDriver(count, newer, table);
if (newer == DRIVER_NEWER)
{ {
updatesCount++; updatesCount++;
VisualiseNewDriver(count, table);
VisualiseNewCount(updatesCount, table); VisualiseNewCount(updatesCount, table);
} }

View File

@@ -18,7 +18,7 @@
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>