diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications.sln b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications.sln new file mode 100644 index 000000000..e17ab380e --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications.sln @@ -0,0 +1,57 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32505.173 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "CppPackagedAppNotifications (Package)", "CppPackagedAppNotifications\CppPackagedAppNotifications (Package)\CppPackagedAppNotifications (Package).wapproj", "{DD0A6C40-D9D2-419C-85E1-D491A835DBB4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CppPackagedAppNotifications", "CppPackagedAppNotifications\CppPackagedAppNotifications\CppPackagedAppNotifications.vcxproj", "{8388B1E5-C891-4AF3-9380-4F89C7EB9690}" +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 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|arm64.ActiveCfg = Debug|arm64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|arm64.Build.0 = Debug|arm64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|arm64.Deploy.0 = Debug|arm64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|x64.ActiveCfg = Debug|x64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|x64.Build.0 = Debug|x64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|x64.Deploy.0 = Debug|x64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|x86.ActiveCfg = Debug|x86 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|x86.Build.0 = Debug|x86 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Debug|x86.Deploy.0 = Debug|x86 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|arm64.ActiveCfg = Release|arm64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|arm64.Build.0 = Release|arm64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|arm64.Deploy.0 = Release|arm64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|x64.ActiveCfg = Release|x64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|x64.Build.0 = Release|x64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|x64.Deploy.0 = Release|x64 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|x86.ActiveCfg = Release|x86 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|x86.Build.0 = Release|x86 + {DD0A6C40-D9D2-419C-85E1-D491A835DBB4}.Release|x86.Deploy.0 = Release|x86 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Debug|arm64.ActiveCfg = Debug|arm64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Debug|arm64.Build.0 = Debug|arm64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Debug|x64.ActiveCfg = Debug|x64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Debug|x64.Build.0 = Debug|x64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Debug|x86.ActiveCfg = Debug|Win32 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Debug|x86.Build.0 = Debug|Win32 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Release|arm64.ActiveCfg = Release|arm64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Release|arm64.Build.0 = Release|arm64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Release|x64.ActiveCfg = Release|x64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Release|x64.Build.0 = Release|x64 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Release|x86.ActiveCfg = Release|Win32 + {8388B1E5-C891-4AF3-9380-4F89C7EB9690}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D03F5394-3C2A-41D0-8FF2-E1797073B319} + EndGlobalSection +EndGlobal diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/CppPackagedAppNotifications (Package).wapproj b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/CppPackagedAppNotifications (Package).wapproj new file mode 100644 index 000000000..0a582f0f3 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/CppPackagedAppNotifications (Package).wapproj @@ -0,0 +1,100 @@ + + + + 15.0 + + + + Debug + x86 + + + Release + x86 + + + Debug + x64 + + + Release + x64 + + + Debug + arm64 + + + Release + arm64 + + + + $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ + NativeOnly + NativeOnly + + + + dd0a6c40-d9d2-419c-85e1-d491a835dbb4 + 10.0.22000.0 + 10.0.17763.0 + en-US + True + ..\CppPackagedAppNotifications\CppPackagedAppNotifications.vcxproj + ACA086B7A353F6C7E2CB72FEFC1DD02AD0048727 + CppPackagedAppNotifications %28Package%29_TemporaryKey.pfx + + + + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + + + + + + + + + \ No newline at end of file diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/LockScreenLogo.scale-200.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/LockScreenLogo.scale-200.png new file mode 100644 index 000000000..7440f0d4b Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/LockScreenLogo.scale-200.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/SplashScreen.scale-200.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/SplashScreen.scale-200.png new file mode 100644 index 000000000..32f486a86 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/SplashScreen.scale-200.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-100.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-100.png new file mode 100644 index 000000000..4b3c7ed17 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-100.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-125.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-125.png new file mode 100644 index 000000000..199f086d5 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-125.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-150.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-150.png new file mode 100644 index 000000000..6c1b4257d Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-150.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-200.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-200.png new file mode 100644 index 000000000..f4df75500 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-200.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-400.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-400.png new file mode 100644 index 000000000..8a383b7f8 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square150x150Logo.scale-400.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-16.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-16.png new file mode 100644 index 000000000..cd269127e Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-16.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-24.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-24.png new file mode 100644 index 000000000..0973bc422 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-24.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-256.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-256.png new file mode 100644 index 000000000..0d710c411 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-256.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-32.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-32.png new file mode 100644 index 000000000..977199dc6 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-32.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-48.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-48.png new file mode 100644 index 000000000..8865c9780 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-lightunplated_targetsize-48.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-16.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-16.png new file mode 100644 index 000000000..cd269127e Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-16.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-256.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-256.png new file mode 100644 index 000000000..0d710c411 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-256.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-32.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-32.png new file mode 100644 index 000000000..977199dc6 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-32.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-48.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-48.png new file mode 100644 index 000000000..8865c9780 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.altform-unplated_targetsize-48.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-100.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-100.png new file mode 100644 index 000000000..74208ccab Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-100.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-125.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-125.png new file mode 100644 index 000000000..612c6eafe Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-125.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-150.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-150.png new file mode 100644 index 000000000..77a191964 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-150.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-200.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-200.png new file mode 100644 index 000000000..46762cd4b Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-200.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-400.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-400.png new file mode 100644 index 000000000..71c2f252a Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.scale-400.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-16.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-16.png new file mode 100644 index 000000000..cd269127e Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-16.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-24.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-24.png new file mode 100644 index 000000000..0973bc422 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-24.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 000000000..0973bc422 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-256.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-256.png new file mode 100644 index 000000000..0d710c411 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-256.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-32.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-32.png new file mode 100644 index 000000000..977199dc6 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-32.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-48.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-48.png new file mode 100644 index 000000000..8865c9780 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Square44x44Logo.targetsize-48.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/StoreLogo.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/StoreLogo.png new file mode 100644 index 000000000..a4586f26b Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/StoreLogo.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-100.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-100.png new file mode 100644 index 000000000..781e2c557 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-100.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-125.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-125.png new file mode 100644 index 000000000..88c781c9c Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-125.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-150.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-150.png new file mode 100644 index 000000000..eb8c8ed79 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-150.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-200.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-200.png new file mode 100644 index 000000000..e15a78d1b Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-200.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-400.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-400.png new file mode 100644 index 000000000..11450e664 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Images/Wide310x150Logo.scale-400.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Package.appxmanifest b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Package.appxmanifest new file mode 100644 index 000000000..e986a885b --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications (Package)/Package.appxmanifest @@ -0,0 +1,75 @@ + + + + + + + + CppPackagedAppNotifications (Package) + erlangl + Images\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml new file mode 100644 index 000000000..c20f037c2 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml.cpp new file mode 100644 index 000000000..b34249ea0 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml.cpp @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "App.xaml.h" +#include "MainWindow.xaml.h" +#include "Notifications\NotificationManager.h" +#include +#include +#include +#include + +namespace winrt +{ + using namespace Windows::Foundation; + using namespace Microsoft::UI::Xaml; + using namespace winrt::Microsoft::Windows::AppLifecycle; + using namespace winrt::Microsoft::Windows::AppNotifications; +} + +// NotificationManager is responsible for registering and unregistering the Sample for App Notifications as well as +// dispatching actioned notifications to the appropriate scenario. +// Registration will happen when Init() is called and Unregistration will happen when this +// instance variable goes out of scope, i.e.: when the App is terminated. +static NotificationManager g_notificationManager; + +namespace winrt::CppPackagedAppNotifications::implementation +{ + static App* app{ nullptr }; + + App::App() + { + InitializeComponent(); + app = this; + +#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::ToForeground() + { + assert(app != nullptr); + + HWND hwnd; + auto windowNative{ app->window.as() }; + if (windowNative && SUCCEEDED(windowNative->get_WindowHandle(&hwnd))) + { + SwitchToThisWindow(hwnd, TRUE); + } + } + + std::wstring App::GetFullPathToExe() + { + TCHAR buffer[MAX_PATH] = { 0 }; + GetModuleFileName(NULL, buffer, MAX_PATH); + std::wstring::size_type pos = std::wstring(buffer).find_last_of(L"\\/"); + return std::wstring(buffer).substr(0, pos); + } + + std::wstring App::GetFullPathToAsset(std::wstring const& assetName) + { + return GetFullPathToExe() + L"\\Images\\" + assetName; + } + + void App::OnLaunched(winrt::Microsoft::UI::Xaml::LaunchActivatedEventArgs const& /*args*/) + { + window = make(); + + g_notificationManager.Init(); + + // NOTE: AppInstance is ambiguous between + // Microsoft.Windows.AppLifecycle.AppInstance and + // Windows.ApplicationModel.AppInstance + auto currentInstance{ winrt::AppInstance::GetCurrent() }; + if (currentInstance) + { + // AppInstance.GetActivatedEventArgs will report the correct ActivationKind, + // even in WinUI's OnLaunched. + winrt::AppActivationArguments activationArgs{ currentInstance.GetActivatedEventArgs() }; + if (activationArgs) + { + winrt::ExtendedActivationKind extendedKind{ activationArgs.Kind() }; + if (extendedKind == winrt::Microsoft::Windows::AppLifecycle::ExtendedActivationKind::AppNotification) + { + winrt::AppNotificationActivatedEventArgs notificationActivatedEventArgs{ activationArgs.Data().as() }; + g_notificationManager.ProcessLaunchActivationArgs(notificationActivatedEventArgs); + } + } + } + + window.Activate(); + } +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml.h new file mode 100644 index 000000000..e63693907 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/App.xaml.h @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "App.xaml.g.h" +#include "pch.h" + +namespace winrt::CppPackagedAppNotifications::implementation +{ + struct App : AppT + { + App(); + + static std::wstring GetFullPathToExe(); + static std::wstring GetFullPathToAsset(std::wstring const& assetName); + static void ToForeground(); + + void OnLaunched(Microsoft::UI::Xaml::LaunchActivatedEventArgs const&); + + private: + Microsoft::UI::Xaml::Window window{ nullptr }; + }; +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/SplashScreen.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/SplashScreen.png new file mode 100644 index 000000000..184821318 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/SplashScreen.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Square150x150Logo.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Square150x150Logo.png new file mode 100644 index 000000000..a50c70379 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Square150x150Logo.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Square44x44Logo.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Square44x44Logo.png new file mode 100644 index 000000000..844b60c20 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Square44x44Logo.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Wide310x150Logo.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Wide310x150Logo.png new file mode 100644 index 000000000..b5d5f2c42 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/Wide310x150Logo.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/logo.png b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/logo.png new file mode 100644 index 000000000..fd2293e7b Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/logo.png differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/windows-sdk.ico b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/windows-sdk.ico new file mode 100644 index 000000000..3ad20c7c2 Binary files /dev/null and b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Assets/windows-sdk.ico differ diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications.vcxproj b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications.vcxproj new file mode 100644 index 000000000..66d093339 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications.vcxproj @@ -0,0 +1,235 @@ + + + + + + + true + true + true + {8388b1e5-c891-4af3-9380-4f89c7eb9690} + CppPackagedAppNotifications + CppPackagedAppNotifications + + $(RootNamespace) + en-US + 16.0 + false + false + Windows Store + 10.0 + 10.0 + 10.0.17763.0 + true + true + + + + + Debug + Win32 + + + Debug + x64 + + + Debug + arm64 + + + Release + Win32 + + + Release + x64 + + + Release + arm64 + + + + Application + v142 + Unicode + true + + + true + true + + + false + true + false + + + + + + + + + + + Use + pch.h + $(IntDir)pch.pch + Level4 + %(AdditionalOptions) /bigobj + + + + + _DEBUG;%(PreprocessorDefinitions) + + + onecore.lib;onecoreuap.lib;%(AdditionalDependencies) + + + onecore.lib;onecoreuap.lib;%(AdditionalDependencies) + + + onecore.lib;onecoreuap.lib;%(AdditionalDependencies) + + + + + NDEBUG;%(PreprocessorDefinitions) + + + true + true + onecore.lib;onecoreuap.lib;%(AdditionalDependencies) + onecore.lib;onecoreuap.lib;%(AdditionalDependencies) + onecore.lib;onecoreuap.lib;%(AdditionalDependencies) + + + + + + + + MainPage.xaml + Code + + + + + + + + + App.xaml + + + MainWindow.xaml + + + + Scenario1_ToastWithAvatar.xaml + Code + + + Scenario2_ToastWithTextBox.xaml + Code + + + SettingsPage.xaml + Code + + + + + + Designer + + + + Designer + + + Designer + + + Designer + + + Designer + + + + + MainPage.xaml + Code + + + + + + + + Create + + + App.xaml + + + MainWindow.xaml + + + + + Scenario1_ToastWithAvatar.xaml + Code + + + Scenario2_ToastWithTextBox.xaml + Code + + + SettingsPage.xaml + Code + + + + + Code + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications.vcxproj.filters b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications.vcxproj.filters new file mode 100644 index 000000000..b7cb4a87d --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications.vcxproj.filters @@ -0,0 +1,84 @@ + + + + + + Notifications + + + Notifications + + + Notifications + + + Notifications + + + + + + + + {e48dc53e-40b1-40cb-970a-f89935452892} + + + {88af0e69-0f57-40f4-b16f-039a285b63b3} + + + + + + + + + + + Notifications + + + Notifications + + + Notifications + + + Notifications + + + + + + + + + + + + + + + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + Assets + + + + + + \ No newline at end of file diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml new file mode 100644 index 000000000..8a69235b9 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + Received Notifications + + + + + + + + + + + + + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml.cpp new file mode 100644 index 000000000..d6d96bdb7 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml.cpp @@ -0,0 +1,185 @@ +// 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 winrt::Windows::Foundation; + 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::CppPackagedAppNotifications::implementation +{ + CppPackagedAppNotifications::MainPage MainPage::current{ nullptr }; + + MainPage::MainPage() + { + messages = winrt::single_threaded_observable_vector(); + + InitializeComponent(); + MainPage::current = *this; + this->notificationBox().ItemsSource(messages); + } + + void MainPage::NotificationReceived(Notification const& notification) + { + std::wstring text{ notification.Originator }; + + text.append(L"\t- Action: " + notification.Action); + + if (notification.HasInput) + { + if (notification.Input.empty()) + { + text.append(L"\t- No input received"); + } + else + { + text.append(L"\t- Input received: " + notification.Input); + } + } + messages.InsertAt(0, PropertyValue::CreateString(text)); + } + + 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; + } + + NavView_NavigateToPage(pageType); + } + + void MainPage::NavView_NavigateToPage(TypeName const& pageType) + { + // 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/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml.h new file mode 100644 index 000000000..d9c99931f --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainPage.xaml.h @@ -0,0 +1,38 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "MainPage.g.h" + +namespace winrt::CppPackagedAppNotifications::implementation +{ + struct MainPage : MainPageT + { + MainPage(); + static CppPackagedAppNotifications::MainPage Current() { return current; } + static Windows::Foundation::Collections::IVector Scenarios() { return scenariosInner; } + void NotificationReceived(Notification const& notification); + 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 CppPackagedAppNotifications::MainPage current; + + void NavView_NavigateToPage(winrt::Windows::UI::Xaml::Interop::TypeName const& pageType); + + Windows::Foundation::Collections::IVector messages; + }; +} + +namespace winrt::CppPackagedAppNotifications::factory_implementation +{ + struct MainPage : MainPageT + { + }; +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml new file mode 100644 index 000000000..88d5f98ce --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml @@ -0,0 +1,13 @@ + + + + + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml.cpp new file mode 100644 index 000000000..234740d9c --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml.cpp @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "MainWindow.xaml.h" +#include +#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::CppPackagedAppNotifications::implementation +{ + MainWindow::MainWindow() + { + InitializeComponent(); + + Title(winrt::CppPackagedAppNotifications::SampleConfig::FeatureName); + + HWND hwnd = GetWindowHandle(); + LoadIcon(hwnd, L"Assets/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/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/MainWindow.xaml.h new file mode 100644 index 000000000..967fcbf11 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/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::CppPackagedAppNotifications::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::CppPackagedAppNotifications::factory_implementation +{ + struct MainWindow : MainWindowT + { + }; +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/Common.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/Common.cpp new file mode 100644 index 000000000..11bda104f --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/Common.cpp @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "Common.h" + +static auto scenarioTag{ L"scenarioId" }; + +std::optional Common::ExtractParamFromArgs(std::wstring const& args, std::wstring const& paramName) +{ + auto tag{ paramName }; + tag.append(L"="); + + auto tagStart{ args.find(tag) }; + if (tagStart == std::wstring::npos) + { + return std::nullopt; + } + + auto paramStart{ tagStart + tag.length() }; + auto paramEnd{ args.find(L"&", paramStart) }; + + return args.substr(paramStart, paramEnd - paramStart); +} + +std::wstring Common::MakeScenarioIdToken(unsigned id) +{ + return std::wstring(scenarioTag) + L"=" + std::to_wstring(id); +} + +std::optional Common::ExtractScenarioIdFromArgs(std::wstring const& args) +{ + auto scenarioId{ ExtractParamFromArgs(args, scenarioTag) }; + + if (!scenarioId.has_value()) + { + return std::nullopt; + } + + return std::stoul(scenarioId.value()); +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/Common.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/Common.h new file mode 100644 index 000000000..84c9ec436 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/Common.h @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +struct Common +{ +public: + static std::optional ExtractParamFromArgs(std::wstring const& args, std::wstring const& paramName); + + static std::wstring MakeScenarioIdToken(unsigned Id); + static std::optional ExtractScenarioIdFromArgs(std::wstring const& args); +}; + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/NotificationManager.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/NotificationManager.cpp new file mode 100644 index 000000000..2ffbbddba --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/NotificationManager.cpp @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "NotificationManager.h" +#include "App.xaml.h" +#include "MainPage.xaml.h" +#include +#include "ToastWithAvatar.h" +#include "ToastWithTextBox.h" +#include "Common.h" +#include "NotifyUser.h" +#include +#include + +namespace winrt +{ + using namespace Microsoft::UI::Xaml::Controls; + using namespace Microsoft::Windows::AppNotifications; + using namespace CppPackagedAppNotifications::implementation; +} + +static const std::map> c_notificationHandlers +{ + // When adding new a scenario, be sure to add its notification handler here. + { ToastWithAvatar::ScenarioId, ToastWithAvatar::NotificationReceived }, + { ToastWithTextBox::ScenarioId, ToastWithTextBox::NotificationReceived } +}; + +NotificationManager::NotificationManager():m_isRegistered(false){} + +NotificationManager::~NotificationManager() +{ + if (m_isRegistered) + { + winrt::AppNotificationManager::Default().Unregister(); + } +} + +void NotificationManager::Init() +{ + auto notificationManager{ winrt::AppNotificationManager::Default() }; + + // To ensure all Notification handling happens in this process instance, register for + // NotificationInvoked before calling Register(). Without this a new process will + // be launched to handle the notification. + const auto token{ notificationManager.NotificationInvoked([&](const auto&, winrt::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs) + { + NotifyUser::NotificationReceived(); + + if (!DispatchNotification(notificationActivatedEventArgs)) + { + NotifyUser::UnrecognizedToastOriginator(); + } + }) }; + + winrt::AppNotificationManager::Default().Register(); + m_isRegistered = true; +} + +void NotificationManager::ProcessLaunchActivationArgs(winrt::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs) +{ + DispatchNotification(notificationActivatedEventArgs); + NotifyUser::AppLaunchedFromNotification(); +} + +bool NotificationManager::DispatchNotification(winrt::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs) +{ + auto scenarioId{ Common::ExtractScenarioIdFromArgs(notificationActivatedEventArgs.Argument().c_str())}; + if (scenarioId.has_value()) + { + try + { + c_notificationHandlers.at(scenarioId.value())(notificationActivatedEventArgs); // Will throw if out of range + return true; + } + catch (...) + { + return false; // Couldn't find a NotificationHandler for scenarioId. + } + } + else + { + return false; // No scenario specified in the notification + } +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/NotificationManager.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/NotificationManager.h new file mode 100644 index 000000000..f0ea77b74 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/NotificationManager.h @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include + +class NotificationManager +{ +public: + NotificationManager(); + ~NotificationManager(); + + void Init(); + void ProcessLaunchActivationArgs(winrt::Microsoft::Windows::AppNotifications::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs); + + private: + bool DispatchNotification(winrt::Microsoft::Windows::AppNotifications::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs); + + bool m_isRegistered; +}; diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithAvatar.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithAvatar.cpp new file mode 100644 index 000000000..304072e45 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithAvatar.cpp @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "ToastWithAvatar.h" +#include "Common.h" +#include +#include "App.xaml.h" +#include "MainPage.xaml.h" + +namespace winrt +{ + using namespace Microsoft::Windows::AppNotifications; + using namespace CppPackagedAppNotifications::implementation; +} + +const wchar_t* ToastWithAvatar::ScenarioName{ L"Local Toast with Avatar Image" }; + +bool ToastWithAvatar::SendToast() +{ + // The ScenarioIdToken uniquely identify a scenario and is used to route the response received when the user clicks on a toast to the correct scenario. + auto ScenarioIdToken{ Common::MakeScenarioIdToken(ToastWithAvatar::ScenarioId) }; + + winrt::hstring xmlPayload{ + L"\ + \ + \ + \ + " + ScenarioName + L"\ + This is an example message using XML\ + \ + \ + \ + \ + \ + " }; + + auto toast{ winrt::AppNotification(xmlPayload) }; + winrt::AppNotificationManager::Default().Show(toast); + + return toast.Id() != 0; // return true (indicating success) if the toast was sent (if it has an Id) +} + +void ToastWithAvatar::NotificationReceived(winrt::Microsoft::Windows::AppNotifications::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs) +{ + winrt::CppPackagedAppNotifications::Notification notification{}; + notification.Originator = ScenarioName; + auto action{ Common::ExtractParamFromArgs(notificationActivatedEventArgs.Argument().c_str(), L"action") }; + notification.Action = action.has_value() ? action.value() : L""; + winrt::MainPage::Current().NotificationReceived(notification); + winrt::App::ToForeground(); +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithAvatar.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithAvatar.h new file mode 100644 index 000000000..c5e8b52d8 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithAvatar.h @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include + +struct ToastWithAvatar +{ +public: + static const unsigned ScenarioId{ 1 }; + static const wchar_t* ScenarioName; + + static bool SendToast(); + static void NotificationReceived(winrt::Microsoft::Windows::AppNotifications::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs); +}; + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithTextBox.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithTextBox.cpp new file mode 100644 index 000000000..c57b4964d --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithTextBox.cpp @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" +#include "ToastWithTextBox.h" +#include "Common.h" +#include +#include "App.xaml.h" +#include "MainPage.xaml.h" + +namespace winrt +{ + using namespace Microsoft::Windows::AppNotifications; + using namespace CppPackagedAppNotifications::implementation; +} + +const wchar_t* ToastWithTextBox::ScenarioName{ L"Local Toast with Avatar and Text Box" }; +auto textboxReplyId{ L"textboxReply" }; + +bool ToastWithTextBox::SendToast() +{ + // The ScenarioIdToken uniquely identify a scenario and is used to route the response received when the user clicks on a toast to the correct scenario. + auto ScenarioIdToken{ Common::MakeScenarioIdToken(ToastWithTextBox::ScenarioId) }; + + winrt::hstring xmlPayload{ + L"\ + \ + \ + \ + " + ScenarioName + L"\ + This is an example message using XML\ + \ + \ + \ + \ + \ + \ + " }; + + auto toast{ winrt::AppNotification(xmlPayload) }; + winrt::AppNotificationManager::Default().Show(toast); + + return toast.Id() != 0; // return true (indicating success) if the toast was sent (if it has an Id) +} + +void ToastWithTextBox::NotificationReceived(winrt::Microsoft::Windows::AppNotifications::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs) +{ + // In a real-life scenario, this type of action would usually be processed in the background. Your App would process the payload in + // the background (sending the payload back to your App Server) without ever showing the App's UI. + // This is not something that can easily be demonstrated in a sample such as this one, as we need to show the UI to demonstrate how + // the payload is routed internally + + auto input{ notificationActivatedEventArgs.UserInput() }; + auto text{ input.Lookup(textboxReplyId) }; + + winrt::CppPackagedAppNotifications::Notification notification{}; + notification.Originator = ScenarioName; + auto action{ Common::ExtractParamFromArgs(notificationActivatedEventArgs.Argument().c_str(), L"action") }; + notification.Action = action.has_value() ? action.value() : L""; + notification.HasInput = true; + notification.Input = text; + winrt::MainPage::Current().NotificationReceived(notification); + winrt::App::ToForeground(); +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithTextBox.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithTextBox.h new file mode 100644 index 000000000..1012466d2 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Notifications/ToastWithTextBox.h @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include + +struct ToastWithTextBox +{ +public: + static const unsigned ScenarioId{ 2 }; + static const wchar_t* ScenarioName; + + static bool SendToast(); + static void NotificationReceived(winrt::Microsoft::Windows::AppNotifications::AppNotificationActivatedEventArgs const& notificationActivatedEventArgs); +}; + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/NotifyUser.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/NotifyUser.cpp new file mode 100644 index 000000000..3c589bc80 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/NotifyUser.cpp @@ -0,0 +1,35 @@ +#include "pch.h" +#include "NotifyUser.h" +#include "MainPage.xaml.h" +#include + +namespace winrt +{ + using namespace Microsoft::UI::Xaml::Controls; + using namespace winrt::CppPackagedAppNotifications::implementation; +} + +void NotifyUser::CouldNotSendToast() +{ + winrt::MainPage::Current().NotifyUser(L"Could not send toast", winrt::InfoBarSeverity::Error); +} + +void NotifyUser::ToastSentSuccessfully() +{ + winrt::MainPage::Current().NotifyUser(L"Toast sent successfully!", winrt::InfoBarSeverity::Success); +} + +void NotifyUser::AppLaunchedFromNotification() +{ + winrt::MainPage::Current().NotifyUser(L"App launched from notifications", winrt::InfoBarSeverity::Informational); +} + +void NotifyUser::NotificationReceived() +{ + winrt::MainPage::Current().NotifyUser(L"Notification received", winrt::InfoBarSeverity::Informational); +} + +void NotifyUser::UnrecognizedToastOriginator() +{ + winrt::MainPage::Current().NotifyUser(L"Unrecognized Toast Originator", winrt::InfoBarSeverity::Error); +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/NotifyUser.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/NotifyUser.h new file mode 100644 index 000000000..27e843672 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/NotifyUser.h @@ -0,0 +1,10 @@ +#pragma once +struct NotifyUser +{ + static void CouldNotSendToast(); + static void ToastSentSuccessfully(); + static void AppLaunchedFromNotification(); + static void NotificationReceived(); + static void UnrecognizedToastOriginator(); +}; + diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Project.idl b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Project.idl new file mode 100644 index 000000000..f49469e0d --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Project.idl @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +namespace CppPackagedAppNotifications +{ + /* The following code is scenario/feature-specific IDL. + Samples authors should modify these runtime classes as appropriate. */ + + struct Notification + { + String Originator; + String Action; + Boolean HasInput; + String Input; + }; + + [default_interface] + runtimeclass Scenario1_ToastWithAvatar : Microsoft.UI.Xaml.Controls.Page + { + Scenario1_ToastWithAvatar(); + } + + [default_interface] + runtimeclass Scenario2_ToastWithTextBox : Microsoft.UI.Xaml.Controls.Page + { + Scenario2_ToastWithTextBox(); + } + + /* 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); + void NotificationReceived(Notification notification); + } + + // 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/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/SampleConfiguration.cpp b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/SampleConfiguration.cpp new file mode 100644 index 000000000..cf626e336 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/SampleConfiguration.cpp @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "pch.h" +#include "SampleConfiguration.h" +#include "MainPage.xaml.h" +#include "Notifications\ToastWithAvatar.h" +#include "Notifications\ToastWithTextBox.h" + +namespace winrt +{ + using namespace Microsoft::UI::Xaml; + using namespace Windows::Foundation::Collections; +} + +namespace winrt::CppPackagedAppNotifications +{ + IVector implementation::MainPage::scenariosInner = single_threaded_observable_vector( + { + Scenario{ ToastWithAvatar::ScenarioName, hstring(name_of())}, + Scenario{ ToastWithTextBox::ScenarioName, hstring(name_of())} + }); + + hstring SampleConfig::FeatureName{ L"CppPackagedAppNotifications" }; + ElementTheme SampleConfig::CurrentTheme{ ElementTheme::Default }; +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/SampleConfiguration.h b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/SampleConfiguration.h new file mode 100644 index 000000000..69daad73f --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/SampleConfiguration.h @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#pragma once +#include "pch.h" + +namespace winrt::CppPackagedAppNotifications +{ + struct SampleConfig + { + public: + static hstring FeatureName; + static Microsoft::UI::Xaml::ElementTheme CurrentTheme; + }; +} diff --git a/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Scenario1_ToastWithAvatar.xaml b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Scenario1_ToastWithAvatar.xaml new file mode 100644 index 000000000..a2e198ca3 --- /dev/null +++ b/Samples/Notifications/App/CppPackagedAppNotifications/CppPackagedAppNotifications/CppPackagedAppNotifications/Scenario1_ToastWithAvatar.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + This example demonstrates using a raw XML payload to produce a local toast notification with an avatar image and activation. + + +