diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index a429fe2..ef090cc 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -18,7 +18,17 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); + ContentRendered += MainWindow_ContentRendered; + } + + // Open url on button click. + private void Button_Click(object sender, RoutedEventArgs e) { + Button button = (Button)sender; + string url = (string)button.Tag; + Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); + } + public void MainWindow_ContentRendered(object sender, EventArgs e) { (bool, string) result = Nvidia.API.IsNewDriver(); Grid appGrid = (Grid)this.FindName("appGrid"); @@ -28,7 +38,7 @@ public MainWindow() gpuName.Text += $" ({guessedGpu})"; - if (result.Item1) { + if (!result.Item1) { // Show new driver available in application window. textBlock.Text = "New NVIDIA driver found!"; // Create a button with a link. @@ -45,16 +55,9 @@ public MainWindow() Grid.SetColumn(button, 1); Grid.SetRow(button, 2); } else { - textBlock.Text = "You're up to date!"; + textBlock.Text = "You're up to date!\n(or unknown GPU)"; } } - // Open url on button click. - private void Button_Click(object sender, RoutedEventArgs e) { - Button button = (Button)sender; - string url = (string)button.Tag; - Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); - } - } } diff --git a/Nvidia/NvidiaWeb.cs b/Nvidia/NvidiaWeb.cs index 1065af9..e6c34d0 100644 --- a/Nvidia/NvidiaWeb.cs +++ b/Nvidia/NvidiaWeb.cs @@ -32,6 +32,9 @@ public static (bool, string) IsNewDriver() { // Fetch downloadUrl. HttpResponseMessage response = client.GetAsync(downloadUrl).Result; string downloadPage = response.Content.ReadAsStringAsync().Result; + if (downloadPage.Contains("No certified downloads were found for this configuration")) { + return (false, ""); + } var web = new HtmlWeb(); var doc = web.Load(downloadPage);