winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

MainPage.h (5894B)


      1 // Copyright (c) Microsoft Corporation.
      2 // Licensed under the MIT License.
      3 #pragma once
      4 
      5 #include "InstallingPackageView.h"
      6 #include <winrt\Microsoft.Management.Deployment.h>
      7 
      8 #include "MainPage.g.h"
      9 namespace Deployment = winrt::Microsoft::Management::Deployment;
     10 
     11 namespace winrt::AppInstallerCaller::implementation
     12 {
     13     struct MainPage : MainPageT<MainPage>
     14     {
     15         MainPage();
     16         Windows::Foundation::Collections::IObservableVector<Deployment::PackageCatalogReference> PackageCatalogs();
     17         Windows::Foundation::Collections::IObservableVector<Deployment::CatalogPackage> InstalledApps();
     18         Windows::Foundation::Collections::IObservableVector<winrt::AppInstallerCaller::InstallingPackageView> InstallingPackages();
     19 
     20         void ToggleDevSwitchToggled(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     21         void FindSourcesButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     22         void InstallButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     23         void CancelButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     24         void DownloadButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     25         void DownloadCancelButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     26         void SearchButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     27         void RefreshInstalledButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     28         void ClearInstalledButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     29         void RefreshInstallingButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     30         void ClearInstallingButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args);
     31 
     32         Windows::Foundation::IAsyncAction GetSources(winrt::Windows::UI::Xaml::Controls::Button button);
     33         Windows::Foundation::IAsyncAction GetInstalledPackages(winrt::Windows::UI::Xaml::Controls::TextBlock statusText);
     34         Windows::Foundation::IAsyncAction GetInstallingPackages(winrt::Windows::UI::Xaml::Controls::TextBlock statusText);
     35 
     36         Windows::Foundation::IAsyncAction StartInstall(
     37             winrt::Windows::UI::Xaml::Controls::Button installButton,
     38             winrt::Windows::UI::Xaml::Controls::Button cancelButton,
     39             winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar,
     40             winrt::Windows::UI::Xaml::Controls::TextBlock statusText);
     41         Windows::Foundation::IAsyncAction StartDownload(
     42             winrt::Windows::UI::Xaml::Controls::Button installButton,
     43             winrt::Windows::UI::Xaml::Controls::Button cancelButton,
     44             winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar,
     45             winrt::Windows::UI::Xaml::Controls::TextBlock statusText);
     46         Windows::Foundation::IAsyncAction FindPackage(
     47             winrt::Windows::UI::Xaml::Controls::Button installButton,
     48             winrt::Windows::UI::Xaml::Controls::Button downloadButton,
     49             winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar,
     50             winrt::Windows::UI::Xaml::Controls::TextBlock statusText);
     51 
     52     private:
     53         Deployment::PackageManager CreatePackageManager();
     54         Deployment::InstallOptions CreateInstallOptions();
     55         Deployment::FindPackagesOptions CreateFindPackagesOptions();
     56         Deployment::CreateCompositePackageCatalogOptions CreateCreateCompositePackageCatalogOptions();
     57         Deployment::PackageMatchFilter CreatePackageMatchFilter();
     58         Deployment::DownloadOptions CreateDownloadOptions();
     59 
     60         Windows::Foundation::IAsyncOperation<Deployment::FindPackagesResult> TryFindPackageInCatalogAsync(Deployment::PackageCatalog catalog, std::wstring packageId);
     61         Windows::Foundation::IAsyncOperation<Deployment::CatalogPackage> FindPackageInCatalogAsync(Deployment::PackageCatalog catalog, std::wstring packageId);
     62         Windows::Foundation::IAsyncOperationWithProgress<Deployment::InstallResult, Deployment::InstallProgress> InstallPackage(Deployment::CatalogPackage package);
     63         Windows::Foundation::IAsyncOperationWithProgress<Deployment::DownloadResult, Deployment::PackageDownloadProgress> DownloadPackage(Deployment::CatalogPackage package, std::wstring downloadDirectory);
     64         Windows::Foundation::IAsyncOperation<Deployment::PackageCatalog> FindSourceAsync(std::wstring packageSource);
     65 
     66         Windows::Foundation::Collections::IObservableVector<Deployment::PackageCatalogReference> m_packageCatalogs;
     67         Windows::Foundation::Collections::IObservableVector<Deployment::CatalogPackage> m_installedPackages;
     68         Windows::Foundation::Collections::IObservableVector<winrt::AppInstallerCaller::InstallingPackageView> m_installingPackageViews;
     69         Windows::Foundation::IAsyncOperationWithProgress<Deployment::InstallResult, Deployment::InstallProgress> m_installPackageOperation;
     70         Windows::Foundation::IAsyncOperationWithProgress<Deployment::DownloadResult, Deployment::PackageDownloadProgress> m_downloadPackageOperation;
     71         std::wstring m_installAppId;
     72         std::wstring m_downloadDirectory;
     73         Deployment::PackageManager m_packageManager{ nullptr };
     74         bool m_useDev = false;
     75     };
     76 }
     77 
     78 namespace winrt::AppInstallerCaller::factory_implementation
     79 {
     80     struct MainPage : MainPageT<MainPage, implementation::MainPage>
     81     {
     82     };
     83 }