DriverUpdate.cs (1790B)
1 using System.ComponentModel; 2 using System.Runtime.CompilerServices; 3 4 namespace DriverUpdater; 5 6 // One row in the list. Usually a device with a newer driver available. Vendor checks also add a row 7 // when the device is already up to date or the check failed, so you can see the check ran. 8 sealed class DriverUpdate : INotifyPropertyChanged 9 { 10 public required string Device { get; init; } 11 public required string Source { get; init; } 12 public string InstalledVersion { get; init; } = ""; 13 public string AvailableVersion { get; init; } = ""; 14 public DateTime? ReleaseDate { get; init; } 15 public long? SizeBytes { get; init; } 16 public Uri? NotesUrl { get; init; } 17 18 // How to install it. A Windows Update row carries the update's COM object. A vendor row carries 19 // the package that holds the driver and the device to install it on. 20 public object? WindowsUpdateItem { get; init; } 21 public VendorPackage? Package { get; init; } 22 public InstalledDevice? TargetDevice { get; init; } 23 24 public bool CanInstall => WindowsUpdateItem is not null || Package is not null; 25 26 public string SizeText => SizeBytes is long bytes ? $"{bytes / 1_048_576.0:0.#} MB" : ""; 27 28 public bool IsSelected 29 { 30 get; 31 set 32 { 33 if (field == value) 34 return; 35 field = value; 36 Changed(); 37 } 38 } 39 40 public string Status 41 { 42 get; 43 set 44 { 45 if (field == value) 46 return; 47 field = value; 48 Changed(); 49 } 50 } = ""; 51 52 public event PropertyChangedEventHandler? PropertyChanged; 53 54 void Changed([CallerMemberName] string? property = null) => 55 PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); 56 }