private async void DownloadItemPackClick(object sender, RoutedEventArgs e)
        {
            String lang       = ((Button)sender).DataContext as String;
            string resourceId = "split.language-" + lang.Substring(0, 2).ToLower();

            AvailableLanguages languageSel = (AvailableLanguages)Enum.Parse(typeof(AvailableLanguages), lang.Replace('-', '_'));

            var packageCatalog = PackageCatalog.OpenForCurrentPackage();
            var result         = await packageCatalog.AddResourcePackageAsync("29270depappf.CaffeMacchiato_gah1vdar1nn7a", resourceId, AddResourcePackageOptions.ApplyUpdateIfAvailable | AddResourcePackageOptions.ForceTargetApplicationShutdown).AsTask <PackageCatalogAddResourcePackageResult, PackageInstallProgress>(new Progress <PackageInstallProgress>
                                                                                                                                                                                                                                                                                                                                (progress =>
            {
                DownloadButtonList[(int)languageSel].Visibility = Visibility.Collapsed;
                ProgressBarList[(int)languageSel].Visibility    = Visibility.Visible;
                CancelButtonList[(int)languageSel].Visibility   = Visibility.Visible;

                ProgressBarList[(int)languageSel].Value = progress.PercentComplete;
            }));

            if (result.ExtendedError != null)
            {
                await new MessageDialog(result.ExtendedError.ToString()).ShowAsync();

                DownloadButtonList[(int)languageSel].Visibility = Visibility.Visible;
                ProgressBarList[(int)languageSel].Visibility    = Visibility.Collapsed;
                CancelButtonList[(int)languageSel].Visibility   = Visibility.Collapsed;
            }
            else if (result.IsComplete)
            {
                ProgressBarList[(int)languageSel].Visibility  = Visibility.Collapsed;
                RemoveButtonList[(int)languageSel].Visibility = Visibility.Visible;
            }
        }
Пример #2
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            navigationHelper.OnNavigatedTo(e);

            try
            {
                packageCatalog = PackageCatalog.OpenForCurrentPackage();
                packageCatalog.PackageInstalling    += Catalog_PackageInstalling;
                packageCatalog.PackageStaging       += Catalog_PackageStaging;
                packageCatalog.PackageStatusChanged += Catalog_PackageStatusChanged;
            }
            catch (Exception ex)
            {
                await new MessageDialog("Unable to setup deployment event handlers. {" + ex.InnerException + "}").ShowAsync();
            }

            dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;

            optionalPackagesList = new ObservableCollection <Controls.OptionalPackageControl>();
            OptionalPackagesListView.ItemsSource = optionalPackagesList;

            storeOptionalPackagesList = new ObservableCollection <StoreProductControl>();
            StoreOptionalPackagesListView.ItemsSource = storeOptionalPackagesList;

            deployingOptionalPackagesList   = new Dictionary <string, PackageDeploymentControl>();
            deployingOptionalPackagesListUI = new ObservableCollection <PackageDeploymentControl>();
            DeployingOptionalPackagesListView.ItemsSource = deployingOptionalPackagesListUI;

            context = StoreContext.GetDefault();

            LoadInstalledOptionalPackages();
        }
Пример #3
0
        void HookupCatalog()
        {
            catalog = PackageCatalog.OpenForCurrentPackage();

            catalog.PackageContentGroupStaging += Catalog_PackageContentGroupStaging;
            catalog.PackageStaging             += Catalog_PackageStaging;
            catalog.PackageInstalling          += Catalog_PackageInstalling;
        }
Пример #4
0
        void HookupCatalog()
        {
            catalog = PackageCatalog.OpenForCurrentPackage();
            //catalog = PackageCatalog.OpenForCurrentUser();

            catalog.PackageContentGroupStaging   += Catalog_PackageContentGroupStaging;
            this.PackageEvents_checkBox.IsChecked = true;
            GetContentIntegrityStatus();
        }
Пример #5
0
 private void HookupCatalog()
 {
     try
     {
         packageCatalog = PackageCatalog.OpenForCurrentPackage();
         packageCatalog.PackageInstalling += Catalog_PackageInstalling;
     }
     catch (Exception ex)
     {
         PopupUI("Unable to setup deployment event handlers. {" + ex.InnerException + "}");
     }
 }
Пример #6
0
        async Task AddStreamedPictureSourcesAsync()
        {
            // Handle any streamed packages that are already installed.
            var groups = await Package.Current.GetContentGroupsAsync();

            foreach (var group in groups.Where(
                         g => !g.IsRequired && g.State == PackageContentGroupState.Staged))
            {
                await this.AddPictureSourceAsync(group.Name, group.Name);
            }

            // Now set up handlers to wait for any others to arrive
            this.catalog = PackageCatalog.OpenForCurrentPackage();
            this.catalog.PackageInstalling += OnPackageInstalling;
        }
Пример #7
0
        async Task AddStreamedPictureSourcesAsync()
        {
            // Handle any streamed packages that are already installed.
            var groups = await Package.Current.GetContentGroupsAsync();

            // TBD - unsure exactly of the state to check for here in order
            // to be sure that the content group is present.
            foreach (var group in groups.Where(
                         g => !g.IsRequired && g.State == PackageContentGroupState.Staged))
            {
                await this.AddPictureSourceAsync(group.Name, group.Name);
            }

            // Now set up handlers to wait for any others to arrive
            this.catalog = PackageCatalog.OpenForCurrentPackage();
            this.catalog.PackageContentGroupStaging += OnContentGroupStaging;
        }
        private async void RemoveItemPackClick(object sender, RoutedEventArgs e)
        {
            String lang = ((Button)sender).DataContext as String;

            var packageCatalog = PackageCatalog.OpenForCurrentPackage();

            Package package = Package.Current;
            List <Windows.ApplicationModel.Package> resourcePackagesToRemove = new List <Windows.ApplicationModel.Package>();

            foreach (Package p in package.Dependencies)
            {
                if (p.IsResourcePackage)
                {
                    //the resource package name only contains the language code for example ar-sa is 29270depappf.UWPCoffeeApplication_1.2.0.0_neutral_split.language-ar_gah1vdar1nn7a
                    if (p.Id.ResourceId.ToLower().Contains(lang.ToLower().Substring(0, 2)))
                    {
                        resourcePackagesToRemove.Add(p);
                        break;
                    }
                }
            }

            if (resourcePackagesToRemove.Count < 1)
            {
                await new MessageDialog("Did not find a resource package that matches " + lang).ShowAsync();
            }
            else
            {
                await new MessageDialog("Going to remove " + resourcePackagesToRemove[0].Id.FullName + " resource package. App will need to restart").ShowAsync();

                var removePackageResult = await packageCatalog.RemoveResourcePackagesAsync(resourcePackagesToRemove);

                if (removePackageResult != null)
                {
                    await new MessageDialog("RemoveResourcePackagesAsync failed with error " + removePackageResult.ExtendedError).ShowAsync();
                }
            }
        }