private async void Download_Click(object sender, RoutedEventArgs e) { InstallButton.IsEnabled = false; var culture = CultureInfo.CurrentUICulture; string productId = ViewModel.Product.ProductId; var dialog = new ProgressDialog() { Title = ViewModel.Product.Title, Body = "Fetching packages..." }; dialog.ShowAsync(); DisplayCatalogHandler dcathandler = new DisplayCatalogHandler(DCatEndpoint.Production, new Locale(culture, true)); await dcathandler.QueryDCATAsync(productId); var packs = await dcathandler.GetPackagesForProductAsync(); string packageFamilyName = dcathandler.ProductListing.Product.Properties.PackageFamilyName; dialog.Hide(); if (packs != null)// && packs.Count > 0) { var package = PackageHelper.GetLatestDesktopPackage(packs.ToList(), packageFamilyName, ViewModel.Product); if (package == null) { var noPackagesDialog = new ContentDialog() { Title = ViewModel.Product.Title, Content = "No available packages for this product.", PrimaryButtonText = "Ok" }; await noPackagesDialog.ShowAsync(); return; } else { var file = (await PackageHelper.DownloadPackage(package, ViewModel.Product)).Item1; var toast = PackageHelper.GenerateDownloadSuccessToast(package, ViewModel.Product, file); Windows.UI.Notifications.ToastNotificationManager.GetDefault().CreateToastNotifier().Show(toast); } } InstallButton.IsEnabled = true; }
private async void InstallButton_Click(SplitButton sender, SplitButtonClickEventArgs e) { InstallButton.IsEnabled = false; var culture = CultureInfo.CurrentUICulture; string productId = ViewModel.Product.ProductId; var dialog = new ProgressDialog() { Title = ViewModel.Product.Title, Body = "Fetching packages..." }; dialog.ShowAsync(); DisplayCatalogHandler dcathandler = new DisplayCatalogHandler(DCatEndpoint.Production, new Locale(Market.US, Lang.en, true)); await dcathandler.QueryDCATAsync(productId); var packs = await dcathandler.GetMainPackagesForProductAsync(); string packageFamilyName = dcathandler.ProductListing.Product.Properties.PackageFamilyName; dialog.Hide(); if (packs != null)// && packs.Count > 0) { var package = PackageHelper.GetLatestDesktopPackage(packs.ToList(), packageFamilyName, ViewModel.Product); if (package == null) { var noPackagesDialog = new ContentDialog() { Title = ViewModel.Product.Title, Content = "No available packages for this product.", PrimaryButtonText = "Ok" }; await noPackagesDialog.ShowAsync(); return; } else { await PackageHelper.InstallPackage(package, ViewModel.Product); } } InstallButton.IsEnabled = true; }
private async void Download_Click(object sender, RoutedEventArgs e) { InstallButton.IsEnabled = false; var gettingPackagesDialog = new ProgressDialog() { Title = ViewModel.Product.Title, Body = "Fetching packages..." }; await PackageHelper.DownloadPackage(ViewModel.Product, gettingPackagesCallback : product => { gettingPackagesDialog.ShowAsync(); }, noPackagesCallback : async product => { var noPackagesDialog = new ContentDialog() { Title = product.Title, Content = "No available packages for this product.", PrimaryButtonText = "Ok" }; await noPackagesDialog.ShowAsync(); }, packagesLoadedCallback : product => { gettingPackagesDialog.Hide(); }, packageDownloadedCallback : async(product, details, file, toast) => { var savePicker = new Windows.Storage.Pickers.FileSavePicker(); savePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.Downloads; if (file.FileType.EndsWith("bundle")) { savePicker.FileTypeChoices.Add("Windows App Bundle", new string[] { file.FileType }); } else { savePicker.FileTypeChoices.Add("Windows App Package", new string[] { file.FileType }); } savePicker.SuggestedFileName = file.DisplayName; savePicker.SuggestedSaveFile = file; var userFile = await savePicker.PickSaveFileAsync(); if (userFile != null) { await file.MoveAndReplaceAsync(userFile); } }); InstallButton.IsEnabled = true; return; var culture = CultureInfo.CurrentUICulture; string productId = ViewModel.Product.ProductId; DisplayCatalogHandler dcathandler = new DisplayCatalogHandler(DCatEndpoint.Production, new Locale(culture, true)); await dcathandler.QueryDCATAsync(productId); var packs = await dcathandler.GetMainPackagesForProductAsync(); string packageFamilyName = dcathandler.ProductListing.Product.Properties.PackageFamilyName; gettingPackagesDialog.Hide(); if (packs != null)// && packs.Count > 0) { var package = PackageHelper.GetLatestDesktopPackage(packs.ToList(), packageFamilyName, ViewModel.Product); if (package == null) { return; } else { var file = (await PackageHelper.DownloadPackage(package, ViewModel.Product)).Item1; var toast = PackageHelper.GenerateDownloadSuccessToast(package, ViewModel.Product, file); Windows.UI.Notifications.ToastNotificationManager.GetDefault().CreateToastNotifier().Show(toast); } } InstallButton.IsEnabled = true; }