diff --git a/Samples/CameraCaptureUI/README.md b/Samples/CameraCaptureUI/README.md new file mode 100644 index 000000000..614845220 --- /dev/null +++ b/Samples/CameraCaptureUI/README.md @@ -0,0 +1,57 @@ +--- +page_type: sample +languages: +- csharp +- cppwinrt +- cpp +products: +- windows +- windows-app-sdk +name: "CameraCaptureUI Sample" +urlFragment: CameraCaptureUISample +description: "Demonstrates how to capture photos and videos using the CameraCaptureUI API in WinAppSDK, showcasing how to integrate camera functionality into desktop apps." +extendedZipContent: +- path: LICENSE + target: LICENSE +--- + + +# Camera Capture UI Sample Application + +This sample demonstrates how to capture photos and videos using the **CameraCaptureUI** API in a **WinUI3** app. It shows how to use the CameraCaptureUI API to launch the camera for photo and video captures within a desktop application. The sample highlights setting custom camera capture options such as format and resolution, handling successful captures, and displaying the captured media. + +> **Note**: This sample is targeted and tested for the **Windows App SDK 1.7 Experimental 1** and **Visual Studio 2022**. + + +## Features + +This sample demonstrates: + +- **Photo Capture**: Capturing images with optional settings, including format and resolution. +- **Video Capture**: Capturing videos, with options settings for format and maximum resolution. +- **BitmapImage Display**: Displaying captured photos using `BitmapImage` in XAML. +- **Media Playback**: Playing back captured videos using `MediaPlayerElement`. + + + +## Prerequisites + + +* See [System requirements for Windows app development](https://docs.microsoft.com/windows/apps/windows-app-sdk/system-requirements). +* Make sure that your development environment is set up correctly—see [Install tools for developing apps for Windows 10 and Windows 11](https://docs.microsoft.com/windows/apps/windows-app-sdk/set-up-your-development-environment). +* The C# sample requires Visual Studio 2022 and .NET 6. + +## Building and Running the Sample + +* Open the solution file (`.sln`) in Visual Studio. +* Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. + + +## Related Documentation and Code Samples +* [Windows App SDK](https://docs.microsoft.com/windows/apps/windows-app-sdk/) +* [CameraCaptureUI API Spec Documentation](https://github.com/microsoft/WindowsAppSDK/blob/main/specs/CameraCaptureUI/CameraCaptureUI.md) +* [Windows Media Playback API](https://learn.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.mediaplayerelement?view=winrt-26100) +* [BitmapImage Class Documentation](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.imaging.bitmapimage?view=windowsdesktop-8.0) + + + diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui.sln b/Samples/CameraCaptureUI/cpp-winui/cpp-winui.sln new file mode 100644 index 000000000..3e3d47cf6 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35514.174 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpp-winui", "cpp-winui\cpp-winui.vcxproj", "{2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|arm64 = Debug|arm64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|arm64 = Release|arm64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|arm64.ActiveCfg = Debug|arm64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|arm64.Build.0 = Debug|arm64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|arm64.Deploy.0 = Debug|arm64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x64.ActiveCfg = Debug|x64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x64.Build.0 = Debug|x64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x64.Deploy.0 = Debug|x64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x86.ActiveCfg = Debug|Win32 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x86.Build.0 = Debug|Win32 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Debug|x86.Deploy.0 = Debug|Win32 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|arm64.ActiveCfg = Release|arm64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|arm64.Build.0 = Release|arm64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|arm64.Deploy.0 = Release|arm64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x64.ActiveCfg = Release|x64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x64.Build.0 = Release|x64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x64.Deploy.0 = Release|x64 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x86.ActiveCfg = Release|Win32 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x86.Build.0 = Release|Win32 + {2D525B7C-DAFB-477D-86AC-9D9CD85BD8BC}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml new file mode 100644 index 000000000..15590f109 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.cpp new file mode 100644 index 000000000..711946a44 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.cpp @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" + +#include "App.xaml.h" +#include "MainWindow.xaml.h" + +namespace winrt +{ + using namespace Windows::Foundation; + using namespace Microsoft::UI::Xaml; +} + +namespace winrt::cpp_winui::implementation +{ + App::App() + { + InitializeComponent(); + +#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION + UnhandledException([](winrt::IInspectable const&, winrt::UnhandledExceptionEventArgs const& e) + { + if (IsDebuggerPresent()) + { + auto errorMessage = e.Message(); + __debugbreak(); + } + }); +#endif + } + + void App::OnLaunched(winrt::LaunchActivatedEventArgs const&) + { + window = winrt::make(); + window.Activate(); + } +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.h new file mode 100644 index 000000000..4db951599 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/App.xaml.h @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "App.xaml.g.h" +#include "pch.h" + +namespace winrt::cpp_winui::implementation +{ + struct App : AppT + { + App(); + + void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&); + + private: + Microsoft::UI::Xaml::Window window{ nullptr }; + }; +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/SplashScreen.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/SplashScreen.png new file mode 100644 index 000000000..184821318 Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/SplashScreen.png differ diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square150x150Logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square150x150Logo.png new file mode 100644 index 000000000..a50c70379 Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square150x150Logo.png differ diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square44x44Logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square44x44Logo.png new file mode 100644 index 000000000..844b60c20 Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Square44x44Logo.png differ diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Wide310x150Logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Wide310x150Logo.png new file mode 100644 index 000000000..b5d5f2c42 Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/Wide310x150Logo.png differ diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/logo.png b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/logo.png new file mode 100644 index 000000000..fd2293e7b Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/logo.png differ diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/windows-sdk.ico b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/windows-sdk.ico new file mode 100644 index 000000000..3ad20c7c2 Binary files /dev/null and b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Assets/windows-sdk.ico differ diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml new file mode 100644 index 000000000..9c5c0dfd7 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.cpp new file mode 100644 index 000000000..833d3ab23 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.cpp @@ -0,0 +1,156 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "MainPage.xaml.h" +#if __has_include("MainPage.g.cpp") +#include "MainPage.g.cpp" +#endif + +namespace winrt +{ + using namespace Microsoft::UI::Xaml; + using namespace Microsoft::UI::Xaml::Controls; + using namespace Microsoft::UI::Xaml::Media; + using namespace Microsoft::UI::Xaml::Media::Animation; + using namespace Microsoft::UI::Xaml::Navigation; + using namespace Windows::UI::Xaml::Interop; +} + +namespace winrt::cpp_winui::implementation +{ + cpp_winui::MainPage MainPage::current{ nullptr }; + + MainPage::MainPage() + { + InitializeComponent(); + MainPage::current = *this; + } + + void MainPage::NotifyUser(hstring const& strMessage, InfoBarSeverity const& severity) + { + // If called from the UI thread, then update immediately. + // Otherwise, schedule a task on the UI thread to perform the update. + if (this->DispatcherQueue().HasThreadAccess()) + { + UpdateStatus(strMessage, severity); + } + else + { + DispatcherQueue().TryEnqueue([strongThis = get_strong(), this, strMessage, severity] + { UpdateStatus(strMessage, severity); }); + } + } + + void MainPage::UpdateStatus(hstring const& strMessage, InfoBarSeverity severity) + { + infoBar().Message(strMessage); + infoBar().IsOpen(!strMessage.empty()); + infoBar().Severity(severity); + } + + void MainPage::NavView_Loaded(IInspectable const&, RoutedEventArgs const&) + { + for (auto&& s : Scenarios()) + { + FontIcon fontIcon{}; + fontIcon.FontFamily(winrt::FontFamily(L"Segoe MDL2 Assets")); + fontIcon.Glyph(L"\uE82D"); + + NavigationViewItem navViewItem{}; + navViewItem.Content(box_value(s.Title)); + navViewItem.Tag(box_value(s.ClassName)); + navViewItem.Icon(fontIcon); + NavView().MenuItems().Append(navViewItem); + } + + // NavView doesn't load any page by default, so load home page. + NavView().SelectedItem(NavView().MenuItems().GetAt(0)); + + // If navigation occurs on SelectionChanged, this isn't needed. + // Because we use ItemInvoked to navigate, we need to call Navigate + // here to load the home page. + if (Scenarios().Size() > 0) + { + NavView_Navigate(Scenarios().GetAt(0).ClassName, nullptr); + } + } + + + void MainPage::NavView_ItemInvoked(NavigationView const&, NavigationViewItemInvokedEventArgs const& args) + { + if (args.IsSettingsInvoked() == true) + { + hstring xamltypename = winrt::xaml_typename().Name; + NavView_Navigate(xamltypename, args.RecommendedNavigationTransitionInfo()); + } + else if (args.InvokedItemContainer() != nullptr) + { + auto navItemTag = winrt::unbox_value(args.InvokedItemContainer().Tag()); + if (navItemTag != L"") + { + NavView_Navigate(navItemTag, args.RecommendedNavigationTransitionInfo()); + } + } + } + + void MainPage::NavView_Navigate(hstring navItemTag, NavigationTransitionInfo const&) + { + TypeName pageType; + + if (navItemTag == winrt::xaml_typename().Name) + { + pageType = winrt::xaml_typename(); + } + else + { + pageType.Name = navItemTag; + pageType.Kind = TypeKind::Metadata; + } + + // Get the page type before navigation so you can prevent duplicate + // entries in the backstack. + TypeName prePageType = ContentFrame().CurrentSourcePageType(); + + // Only navigate if the selected page isn't currently loaded. + if (prePageType.Name != pageType.Name) + { + DrillInNavigationTransitionInfo drillIn; + ContentFrame().Navigate(pageType, nullptr, drillIn); + } + } + + void MainPage::NavView_BackRequested(NavigationView const&, NavigationViewBackRequestedEventArgs const&) + { + if (ContentFrame().CanGoBack()) + { + ContentFrame().GoBack(); + } + } + + void MainPage::ContentFrame_Navigated(IInspectable const&, NavigationEventArgs const& e) + { + NavView().IsBackEnabled(ContentFrame().CanGoBack()); + + if (ContentFrame().SourcePageType().Name == winrt::xaml_typename().Name) + { + // SettingsItem is not part of NavView.MenuItems, and doesn't have a Tag. + NavView().SelectedItem((NavView().SettingsItem().as())); + NavView().Header(winrt::box_value(L"Settings")); + } + else + { + for (auto&& item : NavView().MenuItems()) + { + auto navViewItem = item.try_as(); + if (navViewItem != nullptr && + winrt::unbox_value(navViewItem.Tag()) == e.SourcePageType().Name) + { + NavView().SelectedItem(navViewItem); + NavView().Header(navViewItem.Content()); + break; + } + } + } + } +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.h new file mode 100644 index 000000000..23ce2b17d --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainPage.xaml.h @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "MainPage.g.h" + +namespace winrt::cpp_winui::implementation +{ + struct MainPage : MainPageT + { + MainPage(); + static cpp_winui::MainPage Current() { return current; } + static Windows::Foundation::Collections::IVector Scenarios() { return scenariosInner; } + void NotifyUser(hstring const& strMessage, Microsoft::UI::Xaml::Controls::InfoBarSeverity const& severity); + void UpdateStatus(hstring const& strMessage, Microsoft::UI::Xaml::Controls::InfoBarSeverity severity); + void NavView_Loaded(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::RoutedEventArgs const& e); + void NavView_ItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView const& sender, Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs const& args); + void NavView_Navigate(hstring navItemTag, Microsoft::UI::Xaml::Media::Animation::NavigationTransitionInfo const& transitionInfo); + void NavView_BackRequested(Microsoft::UI::Xaml::Controls::NavigationView const& sender, Microsoft::UI::Xaml::Controls::NavigationViewBackRequestedEventArgs const& args); + void ContentFrame_Navigated(Windows::Foundation::IInspectable const& sender, Microsoft::UI::Xaml::Navigation::NavigationEventArgs const& e); + + private: + static Windows::Foundation::Collections::IVector scenariosInner; + static cpp_winui::MainPage current; + }; +} + +namespace winrt::cpp_winui::factory_implementation +{ + struct MainPage : MainPageT + { + }; +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml new file mode 100644 index 000000000..50419d214 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.cpp new file mode 100644 index 000000000..9d9936532 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.cpp @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "MainWindow.xaml.h" +#if __has_include("MainWindow.g.cpp") +#include "MainWindow.g.cpp" + +#include "microsoft.ui.xaml.window.h" +#include "SampleConfiguration.h" +#endif + +namespace winrt +{ + using namespace Microsoft::UI::Xaml; +} + +namespace winrt::cpp_winui::implementation +{ + MainWindow::MainWindow() + { + InitializeComponent(); + + Title(winrt::cpp_winui::SampleConfig::FeatureName); + + HWND hwnd = GetWindowHandle(); + LoadIcon(hwnd, L"windows-sdk.ico"); + SetWindowSize(hwnd, 1050, 800); + PlacementCenterWindowInMonitorWin32(hwnd); + } + + HWND MainWindow::GetWindowHandle() + { + if (_hwnd == nullptr) + { + Window window = *this; + window.as()->get_WindowHandle(&_hwnd); + } + return _hwnd; + } + + void MainWindow::LoadIcon(HWND hwnd, wchar_t const* iconPath) + { + HANDLE hSmallIcon = LoadImageW(nullptr, iconPath, IMAGE_ICON, + GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), + LR_LOADFROMFILE | LR_SHARED); + SendMessageW(hwnd, WM_SETICON, ICON_SMALL, reinterpret_cast(hSmallIcon)); + + HANDLE hBigIcon = LoadImageW(nullptr, iconPath, IMAGE_ICON, + GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), + LR_LOADFROMFILE | LR_SHARED); + SendMessageW(hwnd, WM_SETICON, ICON_BIG, reinterpret_cast(hBigIcon)); + } + + void MainWindow::SetWindowSize(HWND hwnd, int width, int height) + { + // Win32 uses pixels and WinUI 3 uses effective pixels, so you should apply the DPI scale factor + const UINT dpi = GetDpiForWindow(hwnd); + const float scalingFactor = static_cast(dpi) / 96; + const int widthScaled = static_cast(width * scalingFactor); + const int heightScaled = static_cast(height * scalingFactor); + + SetWindowPos(hwnd, nullptr, 0, 0, widthScaled, heightScaled, SWP_NOMOVE | SWP_NOZORDER); + } + + void MainWindow::PlacementCenterWindowInMonitorWin32(HWND hwnd) + { + RECT windowMontiorRectToAdjust; + GetWindowRect(hwnd, &windowMontiorRectToAdjust); + ClipOrCenterRectToMonitorWin32(windowMontiorRectToAdjust); + SetWindowPos(hwnd, nullptr, windowMontiorRectToAdjust.left, + windowMontiorRectToAdjust.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); + } + + void MainWindow::ClipOrCenterRectToMonitorWin32(RECT& adjustedWindowRect) + { + MONITORINFO mi{ sizeof(mi) }; + GetMonitorInfoW(MonitorFromRect(&adjustedWindowRect, MONITOR_DEFAULTTONEAREST), &mi); + + const auto& rcWork = mi.rcWork; + const int w = adjustedWindowRect.right - adjustedWindowRect.left; + const int h = adjustedWindowRect.bottom - adjustedWindowRect.top; + + adjustedWindowRect.left = rcWork.left + (rcWork.right - rcWork.left - w) / 2; + adjustedWindowRect.top = rcWork.top + (rcWork.bottom - rcWork.top - h) / 2; + adjustedWindowRect.right = adjustedWindowRect.left + w; + adjustedWindowRect.bottom = adjustedWindowRect.top + h; + } +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.h new file mode 100644 index 000000000..7ad2a192a --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/MainWindow.xaml.h @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "MainWindow.g.h" +#include "pch.h" + +namespace winrt::cpp_winui::implementation +{ + struct MainWindow : MainWindowT + { + MainWindow(); + + private: + HWND _hwnd{ nullptr }; + void SetWindowSize(HWND hwnd, const int width, const int height); + HWND GetWindowHandle(); + void LoadIcon(HWND hwnd, wchar_t const* iconName); + void ClipOrCenterRectToMonitorWin32(RECT& rc); + void PlacementCenterWindowInMonitorWin32(HWND hwnd); + }; +} + +namespace winrt::cpp_winui::factory_implementation +{ + struct MainWindow : MainWindowT + { + }; +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Package.appxmanifest b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Package.appxmanifest new file mode 100644 index 000000000..6efd2a9c5 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Package.appxmanifest @@ -0,0 +1,47 @@ + + + + + + + + cpp-winui + Microsoft Corporation + Assets\logo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Project.idl b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Project.idl new file mode 100644 index 000000000..7bb139a47 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Project.idl @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace cpp_winui +{ + /* The following code is scenario/feature-specific IDL. + Samples authors should modify these runtime classes as appropriate. */ + + [default_interface] + runtimeclass Scenario1_CapturePhoto : Microsoft.UI.Xaml.Controls.Page + { + Scenario1_CapturePhoto(); + } + + [default_interface] + runtimeclass Scenario2_CaptureVideo : Microsoft.UI.Xaml.Controls.Page + { + Scenario2_CaptureVideo(); + } + + /* The following code is template-specific IDL. + These runtime classes are the same across all C++/WinRT WinUI samples. */ + + runtimeclass MainPage : Microsoft.UI.Xaml.Controls.Page + { + MainPage(); + static MainPage Current(); + void NotifyUser(String strMessage, Microsoft.UI.Xaml.Controls.InfoBarSeverity severity); + } + + // To use Scenario in a winrt::Windows::Foundation::Collections::IVector, Scenario should be a WinRT type + struct Scenario + { + String Title; + String ClassName; + }; + + [default_interface] + runtimeclass MainWindow : Microsoft.UI.Xaml.Window + { + MainWindow(); + } + + [default_interface] + runtimeclass SettingsPage : Microsoft.UI.Xaml.Controls.Page + { + SettingsPage(); + } +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.cpp b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.cpp new file mode 100644 index 000000000..648011c90 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.cpp @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "pch.h" +#include "SampleConfiguration.h" +#include "MainPage.xaml.h" + +namespace winrt +{ + using namespace Microsoft::UI::Xaml; + using namespace Windows::Foundation::Collections; +} + +namespace winrt::cpp_winui +{ + IVector implementation::MainPage::scenariosInner = single_threaded_observable_vector( + { + Scenario{ L"Capture Photo", hstring(name_of())}, + Scenario{ L"Capture Video", hstring(name_of())} + }); + + hstring SampleConfig::FeatureName{ L"CameraCaptureUI_CPP_SAMPLE" }; + ElementTheme SampleConfig::CurrentTheme{ ElementTheme::Default }; +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.h b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.h new file mode 100644 index 000000000..c38a92976 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/SampleConfiguration.h @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "pch.h" + +namespace winrt::cpp_winui +{ + struct SampleConfig + { + public: + static hstring FeatureName; + static Microsoft::UI::Xaml::ElementTheme CurrentTheme; + }; +} diff --git a/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml new file mode 100644 index 000000000..dcf028e35 --- /dev/null +++ b/Samples/CameraCaptureUI/cpp-winui/cpp-winui/Scenario1_CapturePhoto.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + +