commit 9f7d540722740625b2b85c2ec65888fca538ee36 parent 80fcb9bd9d44b193492d2278578df7ba3477125c Author: Chacón <lechacon@users.noreply.github.com> Date: Mon, 27 Sep 2021 13:09:30 -0700 Changes for sample COM caller project (#1514) Some miscellaneous improvements for the sample COM caller project: * Added some help labels and status messages to the UI * Changed toggle button for using WinGetDev to a toggle switch * Rearranged UI elements in screen to separate elements visually and prevent them from jumping around when resizing * Set window size to get rid of all the unneeded whitespace * Set some global UI styles to reduce styling on individual controls * Deleted some unused code and renamed some things to be more consistent * Added needed capability to app manifest * Added copyright headers to files Diffstat:
14 files changed, 174 insertions(+), 131 deletions(-)
diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt @@ -475,6 +475,7 @@ stringstream strstr strtoll subcontext +subheader SUBLANG subresource subselect diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/App.cpp b/tools/SampleWinGetUWPCaller/AppInstallerCaller/App.cpp @@ -1,4 +1,6 @@ -#include "pch.h" +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" #include "App.h" #include "MainPage.h" diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/App.h b/tools/SampleWinGetUWPCaller/AppInstallerCaller/App.h @@ -1,4 +1,6 @@ -#pragma once +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once #include "App.xaml.g.h" namespace winrt::AppInstallerCaller::implementation diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/App.xaml b/tools/SampleWinGetUWPCaller/AppInstallerCaller/App.xaml @@ -1,4 +1,6 @@ -<Application +<!-- Copyright (c) Microsoft Corporation. + Licensed under the MIT License. --> +<Application x:Class="AppInstallerCaller.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/AppInstallerCaller.vcxproj.filters b/tools/SampleWinGetUWPCaller/AppInstallerCaller/AppInstallerCaller.vcxproj.filters @@ -25,19 +25,19 @@ <Image Include="Assets\Wide310x150Logo.scale-200.png"> <Filter>Assets</Filter> </Image> - <Image Include="Assets\StoreLogo.png"> + <Image Include="Assets\SplashScreen.scale-200.png"> <Filter>Assets</Filter> </Image> - <Image Include="Assets\Square150x150Logo.scale-200.png"> + <Image Include="Assets\Square44x44Logo.scale-200.png"> <Filter>Assets</Filter> </Image> <Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png"> <Filter>Assets</Filter> </Image> - <Image Include="Assets\Square44x44Logo.scale-200.png"> + <Image Include="Assets\Square150x150Logo.scale-200.png"> <Filter>Assets</Filter> </Image> - <Image Include="Assets\SplashScreen.scale-200.png"> + <Image Include="Assets\StoreLogo.png"> <Filter>Assets</Filter> </Image> <Image Include="Assets\LockScreenLogo.scale-200.png"> @@ -51,4 +51,9 @@ <None Include="PropertySheet.props" /> <None Include="packages.config" /> </ItemGroup> + <ItemGroup> + <Filter Include="Assets"> + <UniqueIdentifier>{adeebf4e-70b7-41ae-936b-ded00e6e6777}</UniqueIdentifier> + </Filter> + </ItemGroup> </Project> \ No newline at end of file diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/InstallingPackageView.cpp b/tools/SampleWinGetUWPCaller/AppInstallerCaller/InstallingPackageView.cpp @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. #include "pch.h" #include "InstallingPackageView.h" #include "InstallingPackageView.g.cpp" diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/InstallingPackageView.h b/tools/SampleWinGetUWPCaller/AppInstallerCaller/InstallingPackageView.h @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. #pragma once #include "InstallingPackageView.g.h" diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.cpp b/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.cpp @@ -131,8 +131,8 @@ namespace winrt::AppInstallerCaller::implementation } IAsyncAction UpdateUIProgress( - InstallProgress progress, - winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, + InstallProgress progress, + winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, winrt::Windows::UI::Xaml::Controls::TextBlock statusText) { co_await winrt::resume_foreground(progressBar.Dispatcher()); @@ -166,10 +166,10 @@ namespace winrt::AppInstallerCaller::implementation // This method is called from a background thread. IAsyncAction UpdateUIForInstall( - IAsyncOperationWithProgress<InstallResult, InstallProgress> installPackageOperation, + IAsyncOperationWithProgress<InstallResult, InstallProgress> installPackageOperation, winrt::Windows::UI::Xaml::Controls::Button installButton, winrt::Windows::UI::Xaml::Controls::Button cancelButton, - winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, + winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, winrt::Windows::UI::Xaml::Controls::TextBlock statusText) { installPackageOperation.Progress([=]( @@ -177,8 +177,7 @@ namespace winrt::AppInstallerCaller::implementation InstallProgress const& progress) { UpdateUIProgress(progress, progressBar, statusText).get(); - }); - + }); winrt::hresult installOperationHr = S_OK; std::wstring errorMessage{ L"Unknown Error" }; @@ -242,19 +241,21 @@ namespace winrt::AppInstallerCaller::implementation PackageManager packageManager = CreatePackageManager(); auto catalogs{ packageManager.GetPackageCatalogs() }; - auto catalog{ packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog::MicrosoftStore) }; + auto storeCatalog{ packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog::MicrosoftStore) }; + co_await winrt::resume_foreground(button.Dispatcher()); + m_packageCatalogs.Clear(); - for (uint32_t i = 0; i < catalogs.Size(); i++) + for (auto const catalog : catalogs) { - m_packageCatalogs.Append(catalogs.GetAt(i)); + m_packageCatalogs.Append(catalog); } - m_packageCatalogs.Append(catalog); + m_packageCatalogs.Append(storeCatalog); co_return; - } - - IAsyncAction MainPage::GetInstalledPackages(winrt::Windows::UI::Xaml::Controls::Button button) + } + + IAsyncAction MainPage::GetInstalledPackages(winrt::Windows::UI::Xaml::Controls::TextBlock statusText) { int32_t selectedIndex = catalogsListBox().SelectedIndex(); co_await winrt::resume_background(); @@ -282,6 +283,8 @@ namespace winrt::AppInstallerCaller::implementation if (!installedCatalog) { // Connect Error. + co_await winrt::resume_foreground(statusText.Dispatcher()); + statusText.Text(L"Failed to connect to catalog."); co_return; } @@ -290,21 +293,22 @@ namespace winrt::AppInstallerCaller::implementation FindPackagesResult findResult{ TryFindPackageInCatalogAsync(installedCatalog, m_installAppId).get() }; auto matches = findResult.Matches(); - co_await winrt::resume_foreground(button.Dispatcher()); + co_await winrt::resume_foreground(statusText.Dispatcher()); m_installedPackages.Clear(); - for (uint32_t i = 0; i < matches.Size(); ++i) + for (auto const match : matches) { // Filter to only packages that match the selectedCatalogRef - auto version = matches.GetAt(i).CatalogPackage().DefaultInstallVersion(); + auto version = match.CatalogPackage().DefaultInstallVersion(); if (selectedIndex < 0 || (version && version.PackageCatalog().Info().Id() == m_packageCatalogs.GetAt(selectedIndex).Info().Id())) { - m_installedPackages.Append(matches.GetAt(i).CatalogPackage()); + m_installedPackages.Append(match.CatalogPackage()); } } + statusText.Text(L""); co_return; } - IAsyncAction MainPage::GetInstallingPackages(winrt::Windows::UI::Xaml::Controls::Button button) + IAsyncAction MainPage::GetInstallingPackages(winrt::Windows::UI::Xaml::Controls::TextBlock statusText) { int32_t selectedIndex = catalogsListBox().SelectedIndex(); co_await winrt::resume_background(); @@ -316,6 +320,8 @@ namespace winrt::AppInstallerCaller::implementation if (selectedIndex < 0) { // Installing package querying is only really useful if you know what Catalog you're interested in. + co_await winrt::resume_foreground(statusText.Dispatcher()); + statusText.Text(L"No catalog selected."); co_return; } @@ -326,6 +332,8 @@ namespace winrt::AppInstallerCaller::implementation PackageCatalog selectedRemoteCatalog = remoteConnectResult.PackageCatalog(); if (!selectedRemoteCatalog) { + co_await winrt::resume_foreground(statusText.Dispatcher()); + statusText.Text(L"Failed to connect to catalog."); co_return; } @@ -333,6 +341,8 @@ namespace winrt::AppInstallerCaller::implementation PackageCatalog installingCatalog = connectResult.PackageCatalog(); if (!installingCatalog) { + co_await winrt::resume_foreground(statusText.Dispatcher()); + statusText.Text(L"Failed to connect to catalog."); co_return; } @@ -341,22 +351,23 @@ namespace winrt::AppInstallerCaller::implementation FindPackagesResult findResult{ TryFindPackageInCatalogAsync(selectedRemoteCatalog, m_installAppId).get() }; auto matches = findResult.Matches(); - co_await winrt::resume_foreground(button.Dispatcher()); - + co_await winrt::resume_foreground(statusText.Dispatcher()); + m_installingPackageViews.Clear(); - for (uint32_t i = 0; i < matches.Size(); ++i) + for (auto const match : matches) { winrt::AppInstallerCaller::InstallingPackageView installingView; - installingView.Package(matches.GetAt(i).CatalogPackage()); + installingView.Package(match.CatalogPackage()); auto installOperation = packageManager.GetInstallProgress(installingView.Package(), selectedRemoteCatalog.Info()); if (installOperation) { - installingView.Dispatcher(button.Dispatcher()); + installingView.Dispatcher(statusText.Dispatcher()); installingView.AsyncOperation(installOperation); m_installingPackageViews.Append(installingView); } } + statusText.Text(L""); co_return; } @@ -400,15 +411,15 @@ namespace winrt::AppInstallerCaller::implementation } IAsyncAction MainPage::FindPackage( - winrt::Windows::UI::Xaml::Controls::Button button, + winrt::Windows::UI::Xaml::Controls::Button installButton, winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, winrt::Windows::UI::Xaml::Controls::TextBlock statusText) { int32_t selectedIndex = catalogsListBox().SelectedIndex(); if (selectedIndex < 0) { - co_await winrt::resume_foreground(button.Dispatcher()); - button.IsEnabled(false); + co_await winrt::resume_foreground(installButton.Dispatcher()); + installButton.IsEnabled(false); statusText.Text(L"No catalog selected to search."); co_return; } @@ -426,55 +437,41 @@ namespace winrt::AppInstallerCaller::implementation PackageCatalog compositeCatalog = connectResult.PackageCatalog(); if (!compositeCatalog) { - co_await winrt::resume_foreground(button.Dispatcher()); - button.IsEnabled(false); - statusText.Text(L"Failed to Connect to Catalog."); + co_await winrt::resume_foreground(installButton.Dispatcher()); + installButton.IsEnabled(false); + statusText.Text(L"Failed to connect to catalog."); co_return; } + // Do the search. FindPackagesResult findPackagesResult{ TryFindPackageInCatalogAsync(compositeCatalog, m_installAppId).get() }; winrt::IVectorView<MatchResult> matches = findPackagesResult.Matches(); if (matches.Size() > 0) { - auto version = matches.GetAt(0).CatalogPackage().InstalledVersion(); - if (version != nullptr) + auto installedVersion = matches.GetAt(0).CatalogPackage().InstalledVersion(); + if (installedVersion != nullptr) { - co_await winrt::resume_foreground(button.Dispatcher()); - button.IsEnabled(false); - statusText.Text(version.ProductCodes().GetAt(0)); + co_await winrt::resume_foreground(installButton.Dispatcher()); + installButton.IsEnabled(false); + statusText.Text(L"Already installed. Product code: " + installedVersion.ProductCodes().GetAt(0)); } else { - co_await winrt::resume_foreground(button.Dispatcher()); - button.IsEnabled(true); + co_await winrt::resume_foreground(installButton.Dispatcher()); + installButton.IsEnabled(true); statusText.Text(L"Found the package to install."); } } else { - co_await winrt::resume_foreground(button.Dispatcher()); - button.IsEnabled(false); - statusText.Text(L"Did not find package"); + co_await winrt::resume_foreground(installButton.Dispatcher()); + installButton.IsEnabled(false); + statusText.Text(L"Did not find package."); } co_return; } - IAsyncOperation<CatalogPackage> MainPage::FindPackageAsync() - { - co_await winrt::resume_background(); - - PackageManager packageManager = CreatePackageManager(); - PackageCatalogReference catalogRef{ packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog::OpenWindowsCatalog) }; - PackageCatalog catalog = catalogRef.ConnectAsync().get().PackageCatalog(); - if (!catalog) - { - //Connect error. - co_return nullptr; - } - co_return FindPackageInCatalogAsync(catalog, m_installAppId).get(); - } - void MainPage::SearchButtonClickHandler(IInspectable const&, RoutedEventArgs const&) { m_installAppId = catalogIdTextBox().Text(); @@ -498,37 +495,26 @@ namespace winrt::AppInstallerCaller::implementation m_installPackageOperation.Cancel(); } } - void MainPage::RefreshButtonClickHandler(IInspectable const&, RoutedEventArgs const&) + void MainPage::RefreshInstalledButtonClickHandler(IInspectable const&, RoutedEventArgs const&) { - GetInstalledPackages(installButton()); + GetInstalledPackages(installedStatusText()); } void MainPage::ClearInstalledButtonClickHandler(IInspectable const&, RoutedEventArgs const&) { m_installedPackages.Clear(); } - void MainPage::InstallingRefreshButtonClickHandler(IInspectable const&, RoutedEventArgs const&) + void MainPage::RefreshInstallingButtonClickHandler(IInspectable const&, RoutedEventArgs const&) { - GetInstallingPackages(installButton()); + GetInstallingPackages(installingStatusText()); } void MainPage::ClearInstallingButtonClickHandler(IInspectable const&, RoutedEventArgs const&) { m_installingPackageViews.Clear(); } - IAsyncAction MainPage::StartServer() - { - co_await winrt::resume_background(); - PackageManager packageManager = CreatePackageManager(); - } - void MainPage::StartServerButtonClickHandler(IInspectable const&, RoutedEventArgs const&) - { - StartServer(); - } - void MainPage::ToggleDevButtonClicked(IInspectable const&, RoutedEventArgs const&) + + void MainPage::ToggleDevSwitchToggled(IInspectable const&, winrt::Windows::UI::Xaml::RoutedEventArgs const&) { - if (toggleDevButton().IsChecked()) - { - m_useDev = toggleDevButton().IsChecked().Value(); - } + m_useDev = toggleDevSwitch().IsOn(); } void MainPage::FindSourcesButtonClickHandler(IInspectable const&, RoutedEventArgs const&) { diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.h b/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.h @@ -1,4 +1,6 @@ -#pragma once +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once #include "InstallingPackageView.h" #include <winrt\Microsoft.Management.Deployment.h> @@ -15,38 +17,29 @@ namespace winrt::AppInstallerCaller::implementation Windows::Foundation::Collections::IObservableVector<Deployment::CatalogPackage> InstalledApps(); Windows::Foundation::Collections::IObservableVector<winrt::AppInstallerCaller::InstallingPackageView> InstallingPackages(); - void InitializeUI(); - void ToggleDevButtonClicked(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); + void ToggleDevSwitchToggled(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); void FindSourcesButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); - void StartServerButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); void InstallButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); void CancelButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); void SearchButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); - void RefreshButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); + void RefreshInstalledButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); void ClearInstalledButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); - void InstallingRefreshButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); + void RefreshInstallingButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); void ClearInstallingButtonClickHandler(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& args); Windows::Foundation::IAsyncAction GetSources(winrt::Windows::UI::Xaml::Controls::Button button); - Windows::Foundation::IAsyncAction GetInstalledPackages(winrt::Windows::UI::Xaml::Controls::Button button); - Windows::Foundation::IAsyncAction GetInstallingPackages(winrt::Windows::UI::Xaml::Controls::Button button); + Windows::Foundation::IAsyncAction GetInstalledPackages(winrt::Windows::UI::Xaml::Controls::TextBlock statusText); + Windows::Foundation::IAsyncAction GetInstallingPackages(winrt::Windows::UI::Xaml::Controls::TextBlock statusText); - Windows::Foundation::IAsyncAction InitializeInstallUI( - std::wstring installAppId, - winrt::Windows::UI::Xaml::Controls::Button installButton, - winrt::Windows::UI::Xaml::Controls::Button cancelButton, - winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, - winrt::Windows::UI::Xaml::Controls::TextBlock statusText); Windows::Foundation::IAsyncAction StartInstall( winrt::Windows::UI::Xaml::Controls::Button installButton, winrt::Windows::UI::Xaml::Controls::Button cancelButton, winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, winrt::Windows::UI::Xaml::Controls::TextBlock statusText); Windows::Foundation::IAsyncAction FindPackage( - winrt::Windows::UI::Xaml::Controls::Button button, + winrt::Windows::UI::Xaml::Controls::Button installButton, winrt::Windows::UI::Xaml::Controls::ProgressBar progressBar, winrt::Windows::UI::Xaml::Controls::TextBlock statusText); - Windows::Foundation::IAsyncOperation<Deployment::CatalogPackage> FindPackageAsync(); private: Deployment::PackageManager CreatePackageManager(); @@ -59,7 +52,6 @@ namespace winrt::AppInstallerCaller::implementation Windows::Foundation::IAsyncOperation<Deployment::CatalogPackage> FindPackageInCatalogAsync(Deployment::PackageCatalog catalog, std::wstring packageId); Windows::Foundation::IAsyncOperationWithProgress<Deployment::InstallResult, Deployment::InstallProgress> InstallPackage(Deployment::CatalogPackage package); Windows::Foundation::IAsyncOperation<Deployment::PackageCatalog> FindSourceAsync(std::wstring packageSource); - Windows::Foundation::IAsyncAction StartServer(); Windows::Foundation::Collections::IObservableVector<Deployment::PackageCatalogReference> m_packageCatalogs; Windows::Foundation::Collections::IObservableVector<Deployment::CatalogPackage> m_installedPackages; @@ -68,7 +60,6 @@ namespace winrt::AppInstallerCaller::implementation std::wstring m_installAppId; Deployment::PackageManager m_packageManager{ nullptr }; bool m_useDev = false; - }; } diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.idl b/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.idl @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. namespace AppInstallerCaller { [default_interface] diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.xaml b/tools/SampleWinGetUWPCaller/AppInstallerCaller/MainPage.xaml @@ -1,4 +1,6 @@ -<Page +<!-- Copyright (c) Microsoft Corporation. + Licensed under the MIT License. --> +<Page x:Class="AppInstallerCaller.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" @@ -8,62 +10,99 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="12"> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top"> - <TextBlock Margin="0 12 0 0">Select catalogs to search</TextBlock> - <ToggleButton x:Name="toggleDevButton" Click="ToggleDevButtonClicked" HorizontalAlignment="Center" Margin="12">Use WinGetDev</ToggleButton> - <Button x:Name="findSourcesButton" Click="FindSourcesButtonClickHandler" HorizontalAlignment="Center" Margin="12">Find Catalogs.</Button> - <ListBox x:Name="catalogsListBox" ItemsSource="{x:Bind PackageCatalogs}" SelectionMode="Multiple" MaxWidth="300" MinHeight="50"> + <Page.Resources> + <ResourceDictionary> + <Style TargetType="StackPanel"> + <Setter Property="Margin" Value="5" /> + <Setter Property="HorizontalAlignment" Value="Center" /> + </Style> + <Style TargetType="Button"> + <Setter Property="Margin" Value="5" /> + <Setter Property="HorizontalAlignment" Value="Center" /> + </Style> + </ResourceDictionary> + </Page.Resources> + + <Grid MinWidth="800" MinHeight="600"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + <RowDefinition Height="Auto"/> + </Grid.RowDefinitions> + <Grid.ColumnDefinitions> + <ColumnDefinition Width="*"/> + <ColumnDefinition Width="*"/> + </Grid.ColumnDefinitions> + + <ToggleSwitch x:Name="toggleDevSwitch" Toggled="ToggleDevSwitchToggled">Use WinGetDev</ToggleSwitch> + + <StackPanel Grid.Row="1"> + <TextBlock Style="{StaticResource SubheaderTextBlockStyle}">Select catalog</TextBlock> + + <Button x:Name="findSourcesButton" Click="FindSourcesButtonClickHandler">Find Catalogs</Button> + <TextBlock>Select catalog to search</TextBlock> + <ListBox x:Name="catalogsListBox" ItemsSource="{x:Bind PackageCatalogs}" SelectionMode="Single" Height="200"> <ItemsControl.ItemTemplate> <DataTemplate x:DataType="deployment:PackageCatalogReference"> - <TextBlock Text="{x:Bind Info.Name, Mode=OneWay}"/> + <TextBlock Text="{x:Bind Info.Name, Mode=OneTime}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ListBox> </StackPanel> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="12"> - <TextBox x:Name="catalogIdTextBox" Header="Find an app to install:" PlaceholderText="App Id"></TextBox> - <Button x:Name="searchButton" Click="SearchButtonClickHandler" VerticalAlignment="Bottom">🔍</Button> - </StackPanel> - <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> + + <StackPanel Grid.Row="1" Grid.Column="1"> + <TextBlock Style="{StaticResource SubheaderTextBlockStyle}">Install app</TextBlock> + + <StackPanel Orientation="Horizontal"> + <TextBox x:Name="catalogIdTextBox" Header="Find an app to install:" PlaceholderText="App Id (e.g. Microsoft.Teams)"></TextBox> + <Button x:Name="searchButton" Click="SearchButtonClickHandler" VerticalAlignment="Bottom" Margin="0">🔍</Button> + </StackPanel> + + <StackPanel Orientation="Horizontal"> <Button x:Name="installButton" Click="InstallButtonClickHandler" IsEnabled="False">Install</Button> - <Button x:Name="cancelButton" Click="CancelButtonClickHandler" Margin="12 0 0 0" IsEnabled="False">Cancel</Button> + <Button x:Name="cancelButton" Click="CancelButtonClickHandler" IsEnabled="False">Cancel</Button> </StackPanel> - <ProgressBar x:Name="installProgressBar" Value="0" Maximum="100" Width="200px" Margin="12" ></ProgressBar> - <TextBlock x:Name="installStatusText" Text="" HorizontalAlignment="Center"></TextBlock> + + <ProgressBar x:Name="installProgressBar" Value="0" Maximum="100" Width="200px"/> + <TextBlock x:Name="installStatusText" Text="" HorizontalAlignment="Center"/> </StackPanel> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top"> + + <StackPanel Grid.Row="2" Margin="3"> + <TextBlock Style="{StaticResource SubheaderTextBlockStyle}">Installed apps</TextBlock> + <TextBlock>List installed apps from selected catalog</TextBlock> <StackPanel Orientation="Horizontal" > - <TextBlock Margin="0 12 0 0">Installed apps</TextBlock> - <Button x:Name="refreshButton" Click="RefreshButtonClickHandler" Margin="12 0 0 0" IsEnabled="True">Refresh</Button> - <Button x:Name="clearInstalledButton" Click="ClearInstalledButtonClickHandler" Margin="12 0 0 0" IsEnabled="True">Clear</Button> + <Button x:Name="refreshButton" Click="RefreshInstalledButtonClickHandler" IsEnabled="True">Refresh</Button> + <Button x:Name="clearInstalledButton" Click="ClearInstalledButtonClickHandler" IsEnabled="True">Clear</Button> </StackPanel> - <ListBox x:Name="installedListBox" ItemsSource="{x:Bind InstalledApps}" SelectionMode="Multiple" MaxWidth="300" MaxHeight="600" MinHeight="200" ScrollViewer.VerticalScrollBarVisibility="Visible"> + <TextBlock x:Name="installedStatusText" Text=""/> + <ListBox x:Name="installedListBox" ItemsSource="{x:Bind InstalledApps}" Height="300" ScrollViewer.VerticalScrollBarVisibility="Visible"> <ItemsControl.ItemTemplate> <DataTemplate x:DataType="deployment:CatalogPackage"> <TextBlock Text="{x:Bind Name, Mode=OneWay}"/> </DataTemplate> </ItemsControl.ItemTemplate> </ListBox> - </StackPanel> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Top"> + </StackPanel> + + <StackPanel Grid.Row="2" Grid.Column="1" Margin="3"> + <TextBlock Style="{StaticResource SubheaderTextBlockStyle}">Installing apps</TextBlock> + <TextBlock>List apps being installed from selected catalog</TextBlock> <StackPanel Orientation="Horizontal" > - <TextBlock Margin="0 12 0 0">Installing apps</TextBlock> - <Button x:Name="installingRefreshButton" Click="InstallingRefreshButtonClickHandler" Margin="12 0 0 0" IsEnabled="True">Refresh</Button> - <Button x:Name="installingClearInstalledButton" Click="ClearInstallingButtonClickHandler" Margin="12 0 0 0" IsEnabled="True">Clear</Button> + <Button x:Name="installingRefreshButton" Click="RefreshInstallingButtonClickHandler" IsEnabled="True">Refresh</Button> + <Button x:Name="installingClearInstalledButton" Click="ClearInstallingButtonClickHandler" IsEnabled="True">Clear</Button> </StackPanel> - <ListBox x:Name="installingListBox" ItemsSource="{x:Bind InstallingPackages}" SelectionMode="Multiple" MaxWidth="300" MaxHeight="600" MinHeight="200" ScrollViewer.VerticalScrollBarVisibility="Visible"> + <TextBlock x:Name="installingStatusText" Text=""/> + <ListBox x:Name="installingListBox" ItemsSource="{x:Bind InstallingPackages}" Height="300" ScrollViewer.VerticalScrollBarVisibility="Visible"> <ItemsControl.ItemTemplate> <DataTemplate x:DataType="local:InstallingPackageView"> - <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> + <StackPanel HorizontalAlignment="Center"> <TextBlock Text="{x:Bind Package.Id, Mode=OneWay}"/> - <ProgressBar Value="{x:Bind Progress, Mode=OneWay}" Maximum="100" Width="200px" Margin="12" ></ProgressBar> + <ProgressBar Value="{x:Bind Progress, Mode=OneWay}" Maximum="100" Width="200px"></ProgressBar> <TextBlock Text="{x:Bind StatusText, Mode=OneWay}" HorizontalAlignment="Center"></TextBlock> </StackPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ListBox> </StackPanel> - </StackPanel> + </Grid> </Page> diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/Package.appxmanifest b/tools/SampleWinGetUWPCaller/AppInstallerCaller/Package.appxmanifest @@ -1,5 +1,9 @@ <?xml version="1.0" encoding="utf-8"?> -<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp"> +<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" + xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" + xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" + xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" + IgnorableNamespaces="uap mp rescap"> <Identity Name="SampleWinGetCaller" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="1.0.0.0" /> <mp:PhoneIdentity PhoneProductId="8b5526fe-0870-42b7-bde0-da8c4c7ea1aa" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> <Properties> @@ -22,5 +26,6 @@ </Applications> <Capabilities> <Capability Name="internetClient" /> + <rescap:Capability Name="packageManagement" /> </Capabilities> </Package> \ No newline at end of file diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/pch.cpp b/tools/SampleWinGetUWPCaller/AppInstallerCaller/pch.cpp @@ -1 +1,3 @@ -#include "pch.h" +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" diff --git a/tools/SampleWinGetUWPCaller/AppInstallerCaller/pch.h b/tools/SampleWinGetUWPCaller/AppInstallerCaller/pch.h @@ -1,4 +1,6 @@ -#pragma once +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once #include <windows.h> #include <unknwn.h> #include <hstring.h>