private async void InstallTestButton_Click(object sender, RoutedEventArgs e) { SetInstallEnabled(false); InstallTestProgress.Visibility = Visibility.Visible; InstallTestMessage.Text = ""; InstallTestMessage.Foreground = new SolidColorBrush(App.GetDefaultTextColor()); try { Software software = GetSoftwareFromInputs(); await software.DetermineInstalledVersion(); if (software.HasInstalledError()) { throw new Exception(software.InstalledError); } InstallTestMessage.Text = "Installed Version: '" + software.InstalledVersion + "'"; } catch (Exception ex) { InstallTestMessage.Foreground = new SolidColorBrush(Colors.Red); InstallTestMessage.Text = ex.Message; } finally { InstallTestProgress.Visibility = Visibility.Collapsed; SetInstallEnabled(true); } }
public async Task Refresh() { RefreshButton.IsEnabled = false; LoadingSpinner.IsActive = true; Software software = App.SoftwareList[Row - 1]; Task installedTask = CoreWindow.GetForCurrentThread().Dispatcher.RunTaskAsync(async() => { TextBlock installedBlock = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 1, typeof(TextBlock)) as TextBlock; ProgressBar installedProgress = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 1, typeof(ProgressBar)) as ProgressBar; installedProgress.Visibility = Visibility.Visible; installedBlock.Visibility = Visibility.Collapsed; installedBlock.Text = ""; await software.DetermineInstalledVersion(); bool error = software.HasInstalledError(); installedBlock.Foreground = new SolidColorBrush(error ? Colors.Red : App.GetDefaultTextColor()); installedBlock.Text = error ? software.InstalledError : software.InstalledVersion; installedProgress.Visibility = Visibility.Collapsed; installedBlock.Visibility = Visibility.Visible; }); Task latestTask = CoreWindow.GetForCurrentThread().Dispatcher.RunTaskAsync(async() => { TextBlock latestBlock = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 2, typeof(TextBlock)) as TextBlock; ProgressBar latestProgress = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 2, typeof(ProgressBar)) as ProgressBar; latestBlock.Visibility = Visibility.Collapsed; latestProgress.Visibility = Visibility.Visible; latestBlock.Text = ""; await software.DetermineLatestVersion(); bool error = software.HasLatestError(); latestBlock.Foreground = new SolidColorBrush(error ? Colors.Red : App.GetDefaultTextColor()); latestBlock.Text = error ? software.LatestError : software.LatestVersion; latestProgress.Visibility = Visibility.Collapsed; latestBlock.Visibility = Visibility.Visible; }); await Task.WhenAll(new Task[] { installedTask, latestTask }); TextBlock nameBlock = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 0, typeof(TextBlock)) as TextBlock; if (software.UpdateAvailable()) { TextBlock installedBlock = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 1, typeof(TextBlock)) as TextBlock; TextBlock latestBlock = MainPage.GetGridCellOfType(GetSoftwareGrid(RefreshButton), Row, 2, typeof(TextBlock)) as TextBlock; nameBlock.Foreground = new SolidColorBrush(Colors.Green); installedBlock.Foreground = new SolidColorBrush(Colors.Green); latestBlock.Foreground = new SolidColorBrush(Colors.Green); } else { nameBlock.Foreground = new SolidColorBrush(Colors.White); } RefreshButton.IsEnabled = true; LoadingSpinner.IsActive = false; }
private async void Save_Click(object sender, RoutedEventArgs e) { SetSaveEnabled(false); SaveProgress.IsActive = true; SaveError.Text = ""; SetLatestEnabled(false); SetInstallEnabled(false); SoftwareName.IsEnabled = false; bool success = false; try { if (SoftwareName.Text == "") { throw new Exception("Must specify name above"); } Software software = GetSoftwareFromInputs(); await software.DetermineInstalledVersion(); if (software.HasInstalledError()) { throw new Exception("Could not determine installed version, test above to troubleshoot"); } await software.DetermineLatestVersion(); if (software.HasLatestError()) { throw new Exception("Could not determine latest software, test above to troubleshoot"); } if (existingSoftware == null) { await App.Current.AddSoftware(software); } else { await App.Current.EditSoftware(existingSoftware, software); } success = true; } catch (Exception ex) { SaveError.Text = ex.Message; } finally { if (success) { this.Frame.Navigate(typeof(MainPage)); } else { SoftwareName.IsEnabled = true; SetInstallEnabled(true); SetLatestEnabled(true); SaveProgress.IsActive = false; SetSaveEnabled(true); } } }