├── .gitattributes ├── .gitignore ├── CPP-WINRT ├── DesktopToastsCppWinRtApp.sln └── DesktopToastsCppWinRtApp │ ├── DesktopNotificationManagerCompat.cpp │ ├── DesktopNotificationManagerCompat.h │ ├── DesktopToastsCppWinRtApp.vcxproj │ ├── DesktopToastsCppWinRtApp.vcxproj.filters │ ├── main.cpp │ ├── packages.config │ └── pch.h ├── CPP-WRL ├── DesktopToastsCppWrlApp.sln ├── DesktopToastsCppWrlApp │ ├── DesktopNotificationManagerCompat.cpp │ ├── DesktopNotificationManagerCompat.h │ ├── DesktopToastsCppWrlApp.vcxproj │ └── DesktopToastsSample.cpp ├── DesktopToastsCppWrlPackageProject │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ ├── DesktopToastsCppWrlPackageProject.wapproj │ ├── DesktopToastsCppWrlPackageProject_TemporaryKey.pfx │ └── Package.appxmanifest └── DesktopToastsCppWrlSetupProject │ ├── DesktopToastsCppWrlSetupProject.wixproj │ └── Product.wxs ├── CS ├── DesktopToastsApp.sln ├── DesktopToastsApp │ ├── App.config │ ├── App.xaml │ ├── App.xaml.cs │ ├── DesktopToastsApp.csproj │ ├── MainWindow.xaml │ ├── MainWindow.xaml.cs │ └── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings └── DesktopToastsPackageProject │ ├── Assets │ ├── LockScreenLogo.scale-200.png │ ├── Square150x150Logo.scale-200.png │ ├── Square44x44Logo.scale-200.png │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ ├── StoreLogo.png │ └── Wide310x150Logo.scale-200.png │ ├── DesktopToastsPackageProject.wapproj │ ├── DesktopToastsPackageProject_TemporaryKey.pfx │ └── Package.appxmanifest ├── LICENSE ├── README.md └── ThirdPartyNotices.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | 49 | ## Ignore Visual Studio temporary files, build results, and 50 | ## files generated by popular Visual Studio add-ons. 51 | 52 | # User-specific files 53 | *.suo 54 | *.user 55 | *.userosscache 56 | *.sln.docstates 57 | 58 | # User-specific files (MonoDevelop/Xamarin Studio) 59 | *.userprefs 60 | 61 | # Build results 62 | [Dd]ebug/ 63 | [Dd]ebugPublic/ 64 | [Rr]elease/ 65 | [Rr]eleases/ 66 | x64/ 67 | x86/ 68 | bld/ 69 | [Bb]in/ 70 | [Oo]bj/ 71 | [Ll]og/ 72 | 73 | # Visual Studio 2015 cache/options directory 74 | .vs/ 75 | # Uncomment if you have tasks that create the project's static files in wwwroot 76 | #wwwroot/ 77 | 78 | # MSTest test Results 79 | [Tt]est[Rr]esult*/ 80 | [Bb]uild[Ll]og.* 81 | 82 | # NUNIT 83 | *.VisualState.xml 84 | TestResult.xml 85 | 86 | # Build Results of an ATL Project 87 | [Dd]ebugPS/ 88 | [Rr]eleasePS/ 89 | dlldata.c 90 | 91 | # DNX 92 | project.lock.json 93 | artifacts/ 94 | 95 | *_i.c 96 | *_p.c 97 | *_i.h 98 | *.ilk 99 | *.meta 100 | *.obj 101 | *.pch 102 | *.pdb 103 | *.pgc 104 | *.pgd 105 | *.rsp 106 | *.sbr 107 | *.tlb 108 | *.tli 109 | *.tlh 110 | *.tmp 111 | *.tmp_proj 112 | *.log 113 | *.vspscc 114 | *.vssscc 115 | .builds 116 | *.pidb 117 | *.svclog 118 | *.scc 119 | 120 | # Chutzpah Test files 121 | _Chutzpah* 122 | 123 | # Visual C++ cache files 124 | ipch/ 125 | *.aps 126 | *.ncb 127 | *.opendb 128 | *.opensdf 129 | *.sdf 130 | *.cachefile 131 | *.VC.db 132 | *.VC.VC.opendb 133 | 134 | # Visual Studio profiler 135 | *.psess 136 | *.vsp 137 | *.vspx 138 | *.sap 139 | 140 | # TFS 2012 Local Workspace 141 | $tf/ 142 | 143 | # Guidance Automation Toolkit 144 | *.gpState 145 | 146 | # ReSharper is a .NET coding add-in 147 | _ReSharper*/ 148 | *.[Rr]e[Ss]harper 149 | *.DotSettings.user 150 | 151 | # JustCode is a .NET coding add-in 152 | .JustCode 153 | 154 | # TeamCity is a build add-in 155 | _TeamCity* 156 | 157 | # DotCover is a Code Coverage Tool 158 | *.dotCover 159 | 160 | # NCrunch 161 | _NCrunch_* 162 | .*crunch*.local.xml 163 | nCrunchTemp_* 164 | 165 | # MightyMoose 166 | *.mm.* 167 | AutoTest.Net/ 168 | 169 | # Web workbench (sass) 170 | .sass-cache/ 171 | 172 | # Installshield output folder 173 | [Ee]xpress/ 174 | 175 | # DocProject is a documentation generator add-in 176 | DocProject/buildhelp/ 177 | DocProject/Help/*.HxT 178 | DocProject/Help/*.HxC 179 | DocProject/Help/*.hhc 180 | DocProject/Help/*.hhk 181 | DocProject/Help/*.hhp 182 | DocProject/Help/Html2 183 | DocProject/Help/html 184 | 185 | # Click-Once directory 186 | publish/ 187 | 188 | # Publish Web Output 189 | *.[Pp]ublish.xml 190 | *.azurePubxml 191 | # TODO: Comment the next line if you want to checkin your web deploy settings 192 | # but database connection strings (with potential passwords) will be unencrypted 193 | *.pubxml 194 | *.publishproj 195 | 196 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 197 | # checkin your Azure Web App publish settings, but sensitive information contained 198 | # in these scripts will be unencrypted 199 | PublishScripts/ 200 | 201 | # NuGet Packages 202 | *.nupkg 203 | # The packages folder can be ignored because of Package Restore 204 | **/packages/* 205 | # except build/, which is used as an MSBuild target. 206 | !**/packages/build/ 207 | # Uncomment if necessary however generally it will be regenerated when needed 208 | #!**/packages/repositories.config 209 | # NuGet v3's project.json files produces more ignoreable files 210 | *.nuget.props 211 | *.nuget.targets 212 | 213 | # Microsoft Azure Build Output 214 | csx/ 215 | *.build.csdef 216 | 217 | # Microsoft Azure Emulator 218 | ecf/ 219 | rcf/ 220 | 221 | # Windows Store app package directories and files 222 | AppPackages/ 223 | BundleArtifacts/ 224 | Package.StoreAssociation.xml 225 | _pkginfo.txt 226 | 227 | # Visual Studio cache files 228 | # files ending in .cache can be ignored 229 | *.[Cc]ache 230 | # but keep track of directories ending in .cache 231 | !*.[Cc]ache/ 232 | 233 | # Others 234 | ClientBin/ 235 | ~$* 236 | *~ 237 | *.dbmdl 238 | *.dbproj.schemaview 239 | *.publishsettings 240 | node_modules/ 241 | orleans.codegen.cs 242 | 243 | # Since there are multiple workflows, uncomment next line to ignore bower_components 244 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 245 | #bower_components/ 246 | 247 | # RIA/Silverlight projects 248 | Generated_Code/ 249 | 250 | # Backup & report files from converting an old project file 251 | # to a newer Visual Studio version. Backup files are not needed, 252 | # because we have git ;-) 253 | _UpgradeReport_Files/ 254 | Backup*/ 255 | UpgradeLog*.XML 256 | UpgradeLog*.htm 257 | 258 | # SQL Server files 259 | *.mdf 260 | *.ldf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | 267 | # Microsoft Fakes 268 | FakesAssemblies/ 269 | 270 | # GhostDoc plugin setting file 271 | *.GhostDoc.xml 272 | 273 | # Node.js Tools for Visual Studio 274 | .ntvs_analysis.dat 275 | 276 | # Visual Studio 6 build log 277 | *.plg 278 | 279 | # Visual Studio 6 workspace options file 280 | *.opt 281 | 282 | # Visual Studio LightSwitch build output 283 | **/*.HTMLClient/GeneratedArtifacts 284 | **/*.DesktopClient/GeneratedArtifacts 285 | **/*.DesktopClient/ModelManifest.xml 286 | **/*.Server/GeneratedArtifacts 287 | **/*.Server/ModelManifest.xml 288 | _Pvt_Extensions 289 | 290 | # Paket dependency manager 291 | .paket/paket.exe 292 | paket-files/ 293 | 294 | # FAKE - F# Make 295 | .fake/ 296 | 297 | # JetBrains Rider 298 | .idea/ 299 | *.sln.iml 300 | -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30517.126 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DesktopToastsCppWinRtApp", "DesktopToastsCppWinRtApp\DesktopToastsCppWinRtApp.vcxproj", "{0A552836-978A-425A-9296-9C8B44D67DA1}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Debug|x64.ActiveCfg = Debug|x64 17 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Debug|x64.Build.0 = Debug|x64 18 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Debug|x86.ActiveCfg = Debug|Win32 19 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Debug|x86.Build.0 = Debug|Win32 20 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Release|x64.ActiveCfg = Release|x64 21 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Release|x64.Build.0 = Release|x64 22 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Release|x86.ActiveCfg = Release|Win32 23 | {0A552836-978A-425A-9296-9C8B44D67DA1}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {FC3E968C-56B2-44FA-9AE5-C081D9D6C426} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/DesktopNotificationManagerCompat.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WINRT/DesktopToastsCppWinRtApp/DesktopNotificationManagerCompat.cpp -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/DesktopNotificationManagerCompat.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WINRT/DesktopToastsCppWinRtApp/DesktopNotificationManagerCompat.h -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/DesktopToastsCppWinRtApp.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Debug 7 | Win32 8 | 9 | 10 | Release 11 | Win32 12 | 13 | 14 | Debug 15 | x64 16 | 17 | 18 | Release 19 | x64 20 | 21 | 22 | 23 | 16.0 24 | Win32Proj 25 | {0a552836-978a-425a-9296-9c8b44d67da1} 26 | DesktopToastsCppWinRtApp 27 | 10.0 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v142 53 | true 54 | Unicode 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | true 82 | 83 | 84 | false 85 | 86 | 87 | 88 | Level3 89 | true 90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 91 | true 92 | Create 93 | pch.h 94 | 95 | 96 | Console 97 | true 98 | 99 | 100 | 101 | 102 | Level3 103 | true 104 | true 105 | true 106 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 107 | true 108 | Create 109 | pch.h 110 | 111 | 112 | Console 113 | true 114 | true 115 | true 116 | 117 | 118 | 119 | 120 | Level3 121 | true 122 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 123 | true 124 | Create 125 | pch.h 126 | 127 | 128 | Console 129 | true 130 | 131 | 132 | 133 | 134 | Level3 135 | true 136 | true 137 | true 138 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 139 | true 140 | Create 141 | pch.h 142 | 143 | 144 | Console 145 | true 146 | true 147 | true 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 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}. 168 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/DesktopToastsCppWinRtApp.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "pch.h" 3 | #include 4 | #include "DesktopNotificationManagerCompat.h"; 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace winrt; 11 | using namespace Windows::Data::Xml::Dom; 12 | using namespace Windows::UI::Notifications; 13 | 14 | bool _hasStarted; 15 | 16 | void start(); 17 | void sendToast(); 18 | void showWindow(); 19 | void sendBasicToast(std::wstring message); 20 | 21 | int main(int argc, char* argv[]) 22 | { 23 | DesktopNotificationManagerCompat::Register(L"Microsoft.SampleCppWinRtApp", L"Sample C++ WinRT App", L"C:\\MyIcon.png"); 24 | 25 | DesktopNotificationManagerCompat::OnActivated([](DesktopNotificationActivatedEventArgsCompat e) 26 | { 27 | if (e.Argument()._Starts_with(L"action=like")) 28 | { 29 | sendBasicToast(L"Sent like!"); 30 | 31 | if (!_hasStarted) 32 | { 33 | exit(0); 34 | } 35 | } 36 | 37 | else if (e.Argument()._Starts_with(L"action=reply")) 38 | { 39 | std::wstring msg = e.UserInput().Lookup(L"tbReply").c_str(); 40 | 41 | sendBasicToast(L"Sent reply! Reply: " + msg); 42 | 43 | if (!_hasStarted) 44 | { 45 | exit(0); 46 | } 47 | } 48 | 49 | else 50 | { 51 | if (!_hasStarted) 52 | { 53 | if (e.Argument()._Starts_with(L"action=viewConversation")) 54 | { 55 | std::cout << "Launched from toast, opening the conversation!\n\n"; 56 | } 57 | 58 | start(); 59 | } 60 | else 61 | { 62 | showWindow(); 63 | 64 | if (e.Argument()._Starts_with(L"action=viewConversation")) 65 | { 66 | std::cout << "\n\nOpening the conversation!\n\nEnter a number to continue: "; 67 | } 68 | else 69 | { 70 | std::wcout << L"\n\nToast activated!\n - Argument: " + e.Argument() + L"\n\nEnter a number to continue: "; 71 | } 72 | } 73 | } 74 | }); 75 | 76 | if (argc >= 2 && strcmp(argv[1], TOAST_ACTIVATED_LAUNCH_ARG) == 0) 77 | { 78 | // Was launched from a toast, OnActivated will be called and we'll decide whether to start the app or exit 79 | std::cin.ignore(); 80 | } 81 | 82 | else 83 | { 84 | start(); 85 | } 86 | } 87 | 88 | void start() 89 | { 90 | _hasStarted = true; 91 | 92 | std::cout << "Welcome!"; 93 | 94 | while (true) 95 | { 96 | std::cout << "\n\nHere are your options...\n\n - 1. Send a toast\n - 2. Clear all toasts\n - 3. Uninstall and quit\n - 4. Exit\n\nEnter a number to continue: "; 97 | 98 | bool exit = false; 99 | 100 | switch (_getch()) 101 | { 102 | case '1': 103 | sendToast(); 104 | break; 105 | case '2': 106 | DesktopNotificationManagerCompat::History().Clear(); 107 | break; 108 | case '3': 109 | DesktopNotificationManagerCompat::Uninstall(); 110 | exit = true; 111 | break; 112 | case '4': 113 | exit = true; 114 | break; 115 | default: 116 | std::cout << "\nInvalid entry. Please try again: "; 117 | break; 118 | } 119 | 120 | if (exit) 121 | { 122 | break; 123 | } 124 | } 125 | } 126 | 127 | void sendToast() 128 | { 129 | std::cout << "\n\nSending a toast... "; 130 | 131 | // Construct the toast template 132 | XmlDocument doc; 133 | doc.LoadXml(L"\ 134 | \ 135 | \ 136 | \ 137 | \ 138 | \ 139 | \ 140 | \ 141 | \ 142 | \ 143 | \ 147 | \ 150 | \ 153 | \ 156 | \ 157 | "); 158 | 159 | // Populate with text and values 160 | doc.DocumentElement().SetAttribute(L"launch", L"action=viewConversation&conversationId=9813"); 161 | doc.SelectSingleNode(L"//text[1]").InnerText(L"Andrew sent you a picture"); 162 | doc.SelectSingleNode(L"//text[2]").InnerText(L"Check this out, Happy Canyon in Utah!"); 163 | doc.SelectSingleNode(L"//image[1]").as().SetAttribute(L"src", L"https://unsplash.it/64?image=1005"); 164 | doc.SelectSingleNode(L"//image[2]").as().SetAttribute(L"src", L"https://picsum.photos/364/202?image=883"); 165 | doc.SelectSingleNode(L"//action[1]").as().SetAttribute(L"arguments", L"action=reply&conversationId=9813"); 166 | doc.SelectSingleNode(L"//action[2]").as().SetAttribute(L"arguments", L"action=like&conversationId=9813"); 167 | doc.SelectSingleNode(L"//action[3]").as().SetAttribute(L"arguments", L"action=viewImage&imageUrl=https://picsum.photos/364/202?image=883"); 168 | 169 | // Construct the notification 170 | ToastNotification notif{ doc }; 171 | 172 | // And send it! 173 | DesktopNotificationManagerCompat::CreateToastNotifier().Show(notif); 174 | 175 | std::cout << "Sent!\n"; 176 | } 177 | 178 | void showWindow() 179 | { 180 | HWND hwnd = GetConsoleWindow(); 181 | WINDOWPLACEMENT place = { sizeof(WINDOWPLACEMENT) }; 182 | GetWindowPlacement(hwnd, &place); 183 | switch (place.showCmd) 184 | { 185 | case SW_SHOWMAXIMIZED: 186 | ShowWindow(hwnd, SW_SHOWMAXIMIZED); 187 | break; 188 | case SW_SHOWMINIMIZED: 189 | ShowWindow(hwnd, SW_RESTORE); 190 | break; 191 | default: 192 | ShowWindow(hwnd, SW_NORMAL); 193 | break; 194 | } 195 | SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE); 196 | SetForegroundWindow(hwnd); 197 | } 198 | 199 | void sendBasicToast(std::wstring message) 200 | { 201 | // Construct the toast template 202 | XmlDocument doc; 203 | doc.LoadXml(L"\ 204 | \ 205 | \ 206 | \ 207 | \ 208 | \ 209 | "); 210 | 211 | // Populate with text and values 212 | doc.SelectSingleNode(L"//text[1]").InnerText(message); 213 | 214 | // Construct the notification 215 | ToastNotification notif{ doc }; 216 | 217 | // And send it! 218 | DesktopNotificationManagerCompat::CreateToastNotifier().Show(notif); 219 | } 220 | 221 | // Run program: Ctrl + F5 or Debug > Start Without Debugging menu 222 | // Debug program: F5 or Debug > Start Debugging menu 223 | 224 | // Tips for Getting Started: 225 | // 1. Use the Solution Explorer window to add/manage files 226 | // 2. Use the Team Explorer window to connect to source control 227 | // 3. Use the Output window to see build output and other messages 228 | // 4. Use the Error List window to view errors 229 | // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project 230 | // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file 231 | -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /CPP-WINRT/DesktopToastsCppWinRtApp/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include // Needed for notifications -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27004.2005 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DesktopToastsCppWrlApp", "DesktopToastsCppWrlApp\DesktopToastsCppWrlApp.vcxproj", "{77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}" 7 | EndProject 8 | Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "DesktopToastsCppWrlSetupProject", "DesktopToastsCppWrlSetupProject\DesktopToastsCppWrlSetupProject.wixproj", "{02C29081-2F02-4F63-BDA6-FFCF2CCD3337}" 9 | EndProject 10 | Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "DesktopToastsCppWrlPackageProject", "DesktopToastsCppWrlPackageProject\DesktopToastsCppWrlPackageProject.wapproj", "{FBC51592-72BB-4177-ABB3-69BF7242CE27}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Debug|x64 = Debug|x64 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Debug|Win32.Build.0 = Debug|Win32 22 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Debug|x64.ActiveCfg = Debug|x64 23 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Debug|x64.Build.0 = Debug|x64 24 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Release|Win32.ActiveCfg = Release|Win32 25 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Release|Win32.Build.0 = Release|Win32 26 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Release|x64.ActiveCfg = Release|x64 27 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3}.Release|x64.Build.0 = Release|x64 28 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Debug|Win32.ActiveCfg = Debug|x86 29 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Debug|Win32.Build.0 = Debug|x86 30 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Debug|x64.ActiveCfg = Debug|x86 31 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Debug|x64.Build.0 = Debug|x86 32 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Release|Win32.ActiveCfg = Release|x86 33 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Release|Win32.Build.0 = Release|x86 34 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Release|x64.ActiveCfg = Release|x86 35 | {02C29081-2F02-4F63-BDA6-FFCF2CCD3337}.Release|x64.Build.0 = Release|x86 36 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Debug|Win32.ActiveCfg = Debug|x86 37 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Debug|Win32.Build.0 = Debug|x86 38 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Debug|Win32.Deploy.0 = Debug|x86 39 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Debug|x64.ActiveCfg = Debug|x64 40 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Debug|x64.Build.0 = Debug|x64 41 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Debug|x64.Deploy.0 = Debug|x64 42 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Release|Win32.ActiveCfg = Release|x86 43 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Release|Win32.Build.0 = Release|x86 44 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Release|Win32.Deploy.0 = Release|x86 45 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Release|x64.ActiveCfg = Release|x64 46 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Release|x64.Build.0 = Release|x64 47 | {FBC51592-72BB-4177-ABB3-69BF7242CE27}.Release|x64.Deploy.0 = Release|x64 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {9FC95EA2-F364-43D4-8562-5C84CD6886FC} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlApp/DesktopNotificationManagerCompat.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlApp/DesktopNotificationManagerCompat.cpp -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlApp/DesktopNotificationManagerCompat.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlApp/DesktopNotificationManagerCompat.h -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlApp/DesktopToastsCppWrlApp.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {77CC36BE-AD64-4AD3-95C6-0F352F6A3FE3} 23 | Win32Proj 24 | DesktopToastsSample 25 | 10.0 26 | 27 | 28 | 29 | Application 30 | true 31 | v142 32 | Unicode 33 | 34 | 35 | Application 36 | true 37 | v142 38 | Unicode 39 | 40 | 41 | Application 42 | false 43 | v142 44 | true 45 | Unicode 46 | 47 | 48 | Application 49 | false 50 | v142 51 | true 52 | Unicode 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | true 72 | $(IncludePath) 73 | 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | false 82 | 83 | 84 | 85 | NotUsing 86 | Level3 87 | Disabled 88 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 89 | MultiThreadedDebug 90 | 91 | 92 | Windows 93 | true 94 | Pathcch.lib;runtimeobject.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 95 | 96 | 97 | 98 | 99 | Use 100 | Level3 101 | Disabled 102 | WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 103 | 104 | 105 | Windows 106 | true 107 | Pathcch.lib;runtimeobject.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 108 | 109 | 110 | 111 | 112 | Level3 113 | Use 114 | MaxSpeed 115 | true 116 | true 117 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 118 | 119 | 120 | Windows 121 | true 122 | true 123 | true 124 | Pathcch.lib;runtimeobject.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 125 | 126 | 127 | 128 | 129 | Level3 130 | Use 131 | MaxSpeed 132 | true 133 | true 134 | WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 135 | 136 | 137 | Windows 138 | true 139 | true 140 | true 141 | Pathcch.lib;runtimeobject.lib;shlwapi.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlApp/DesktopToastsSample.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlApp/DesktopToastsSample.cpp -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/StoreLogo.png -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/DesktopToastsCppWrlPackageProject.wapproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15.0 5 | 6 | 7 | 8 | Debug 9 | x86 10 | 11 | 12 | Release 13 | x86 14 | 15 | 16 | Debug 17 | x64 18 | 19 | 20 | Release 21 | x64 22 | 23 | 24 | 25 | $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ 26 | 27 | 28 | 29 | fbc51592-72bb-4177-abb3-69bf7242ce27 30 | 10.0.16299.0 31 | 10.0.14393.0 32 | en-US 33 | DesktopToastsCppWrlPackageProject_TemporaryKey.pfx 34 | ..\DesktopToastsCppWrlApp\DesktopToastsCppWrlApp.vcxproj 35 | 36 | 37 | 38 | Designer 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/DesktopToastsCppWrlPackageProject_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WindowsNotifications/desktop-toasts/53783524b3f594d0ddf8ae85bf7d5442c9bb4075/CPP-WRL/DesktopToastsCppWrlPackageProject/DesktopToastsCppWrlPackageProject_TemporaryKey.pfx -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlPackageProject/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 11 | 12 | 16 | 17 | 18 | DesktopToastsCppWrlPackageProject 19 | anbare 20 | Assets\StoreLogo.png 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 36 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlSetupProject/DesktopToastsCppWrlSetupProject.wixproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 3.9 7 | 02c29081-2f02-4f63-bda6-ffcf2ccd3337 8 | 2.0 9 | DesktopToastsCppWrlApp 10 | Package 11 | $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets 12 | $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets 13 | DesktopToastsCppWrlSetupProject 14 | 15 | 16 | bin\$(Configuration)\ 17 | obj\$(Configuration)\ 18 | Debug 19 | 20 | 21 | bin\$(Configuration)\ 22 | obj\$(Configuration)\ 23 | 24 | 25 | 26 | 27 | 28 | 29 | DesktopToastsCppWrlApp 30 | {77cc36be-ad64-4ad3-95c6-0f352f6a3fe3} 31 | True 32 | True 33 | Binaries;Content;Satellites 34 | INSTALLFOLDER 35 | 36 | 37 | 38 | 46 | -------------------------------------------------------------------------------- /CPP-WRL/DesktopToastsCppWrlSetupProject/Product.wxs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /CS/DesktopToastsApp.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29709.97 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesktopToastsApp", "DesktopToastsApp\DesktopToastsApp.csproj", "{85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}" 7 | EndProject 8 | Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "DesktopToastsPackageProject", "DesktopToastsPackageProject\DesktopToastsPackageProject.wapproj", "{FC77102B-6837-412D-9099-3F9DF5E73D75}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Debug|x64 = Debug|x64 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Debug|x64.ActiveCfg = Debug|Any CPU 23 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Debug|x64.Build.0 = Debug|Any CPU 24 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Debug|x86.Build.0 = Debug|Any CPU 26 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Release|x64.ActiveCfg = Release|Any CPU 29 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Release|x64.Build.0 = Release|Any CPU 30 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Release|x86.ActiveCfg = Release|Any CPU 31 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC}.Release|x86.Build.0 = Release|Any CPU 32 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|Any CPU.Deploy.0 = Debug|Any CPU 35 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|x64.ActiveCfg = Debug|x64 36 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|x64.Build.0 = Debug|x64 37 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|x64.Deploy.0 = Debug|x64 38 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|x86.ActiveCfg = Debug|x86 39 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|x86.Build.0 = Debug|x86 40 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Debug|x86.Deploy.0 = Debug|x86 41 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|Any CPU.Deploy.0 = Release|Any CPU 44 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|x64.ActiveCfg = Release|x64 45 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|x64.Build.0 = Release|x64 46 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|x64.Deploy.0 = Release|x64 47 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|x86.ActiveCfg = Release|x86 48 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|x86.Build.0 = Release|x86 49 | {FC77102B-6837-412D-9099-3F9DF5E73D75}.Release|x86.Deploy.0 = Release|x86 50 | EndGlobalSection 51 | GlobalSection(SolutionProperties) = preSolution 52 | HideSolutionNode = FALSE 53 | EndGlobalSection 54 | GlobalSection(ExtensibilityGlobals) = postSolution 55 | SolutionGuid = {477D8659-A905-437A-8BFC-4863568FD595} 56 | EndGlobalSection 57 | EndGlobal 58 | -------------------------------------------------------------------------------- /CS/DesktopToastsApp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /CS/DesktopToastsApp/App.xaml: -------------------------------------------------------------------------------- 1 |  5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /CS/DesktopToastsApp/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // ****************************************************************** 2 | // Copyright (c) Microsoft. All rights reserved. 3 | // This code is licensed under the MIT License (MIT). 4 | // THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 5 | // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 7 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 8 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 9 | // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH 10 | // THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE. 11 | // ****************************************************************** 12 | 13 | using Microsoft.Toolkit.Uwp.Notifications; 14 | using System; 15 | using System.Collections.Generic; 16 | using System.Configuration; 17 | using System.Data; 18 | using System.Linq; 19 | using System.Threading.Tasks; 20 | using System.Windows; 21 | 22 | namespace DesktopToastsApp 23 | { 24 | /// 25 | /// Interaction logic for App.xaml 26 | /// 27 | public partial class App : Application 28 | { 29 | protected override void OnStartup(StartupEventArgs e) 30 | { 31 | // Register toast activator 32 | ToastNotificationManagerCompat.OnActivated += ToastNotificationManagerCompat_OnActivated; 33 | 34 | // If launched from a toast 35 | // This launch arg was specified in our WiX installer where we register the LocalServer32 exe path. 36 | if (ToastNotificationManagerCompat.WasCurrentProcessToastActivated()) 37 | { 38 | // Our NotificationActivator code will run after this completes, 39 | // and will show a window if necessary. 40 | } 41 | 42 | else 43 | { 44 | // Show the window 45 | // In App.xaml, be sure to remove the StartupUri so that a window doesn't 46 | // get created by default, since we're creating windows ourselves (and sometimes we 47 | // don't want to create a window if handling a background activation). 48 | new MainWindow().Show(); 49 | } 50 | 51 | base.OnStartup(e); 52 | } 53 | 54 | private void ToastNotificationManagerCompat_OnActivated(ToastNotificationActivatedEventArgsCompat e) 55 | { 56 | // Parse the arguments 57 | var args = ToastArguments.Parse(e.Argument); 58 | 59 | Application.Current.Dispatcher.Invoke(delegate 60 | { 61 | if (args.Count == 0) 62 | { 63 | OpenWindowIfNeeded(); 64 | return; 65 | } 66 | 67 | // See what action is being requested 68 | switch (args["action"]) 69 | { 70 | // Open the image 71 | case "viewImage": 72 | 73 | // The URL retrieved from the toast args 74 | string imageUrl = args["imageUrl"]; 75 | 76 | // Make sure we have a window open and in foreground 77 | OpenWindowIfNeeded(); 78 | 79 | // And then show the image 80 | (App.Current.Windows[0] as MainWindow).ShowImage(imageUrl); 81 | 82 | break; 83 | 84 | // Open the conversation 85 | case "viewConversation": 86 | 87 | // The conversation ID retrieved from the toast args 88 | int conversationId = int.Parse(args["conversationId"]); 89 | 90 | // Make sure we have a window open and in foreground 91 | OpenWindowIfNeeded(); 92 | 93 | // And then show the conversation 94 | (App.Current.Windows[0] as MainWindow).ShowConversation(); 95 | 96 | break; 97 | 98 | // Background: Quick reply to the conversation 99 | case "reply": 100 | 101 | // Get the response the user typed 102 | string msg = e.UserInput["tbReply"] as string; 103 | 104 | // And send this message 105 | ShowToast("Sending message: " + msg); 106 | 107 | // If there's no windows open, exit the app 108 | if (App.Current.Windows.Count == 0) 109 | { 110 | Application.Current.Shutdown(); 111 | } 112 | 113 | break; 114 | 115 | // Background: Send a like 116 | case "like": 117 | 118 | ShowToast("Sending like"); 119 | 120 | // If there's no windows open, exit the app 121 | if (App.Current.Windows.Count == 0) 122 | { 123 | Application.Current.Shutdown(); 124 | } 125 | 126 | break; 127 | 128 | default: 129 | 130 | OpenWindowIfNeeded(); 131 | 132 | break; 133 | } 134 | }); 135 | } 136 | 137 | 138 | 139 | private void OpenWindowIfNeeded() 140 | { 141 | // Make sure we have a window open (in case user clicked toast while app closed) 142 | if (App.Current.Windows.Count == 0) 143 | { 144 | new MainWindow().Show(); 145 | } 146 | 147 | // Activate the window, bringing it to focus 148 | App.Current.Windows[0].Activate(); 149 | 150 | // And make sure to maximize the window too, in case it was currently minimized 151 | App.Current.Windows[0].WindowState = WindowState.Normal; 152 | } 153 | 154 | private void ShowToast(string msg) 155 | { 156 | // Send the toast 157 | new ToastContentBuilder() 158 | .AddArgument("action", "ok") 159 | .AddText(msg) 160 | .Show(); 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /CS/DesktopToastsApp/DesktopToastsApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {85B9B3A4-F6C9-4D16-A6A6-D096FE784BFC} 8 | WinExe 9 | DesktopToastsApp 10 | DesktopToastsApp 11 | v4.6.1 12 | 512 13 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 14 | 4 15 | true 16 | 17 | 18 | AnyCPU 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | AnyCPU 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 4.0 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | MSBuild:Compile 58 | Designer 59 | 60 | 61 | MSBuild:Compile 62 | Designer 63 | 64 | 65 | App.xaml 66 | Code 67 | 68 | 69 | MainWindow.xaml 70 | Code 71 | 72 | 73 | 74 | 75 | Code 76 | 77 | 78 | True 79 | True 80 | Resources.resx 81 | 82 | 83 | True 84 | Settings.settings 85 | True 86 | 87 | 88 | ResXFileCodeGenerator 89 | Resources.Designer.cs 90 | 91 | 92 | SettingsSingleFileGenerator 93 | Settings.Designer.cs 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 7.0.0 102 | 103 | 104 | 10.0.19041.1 105 | 106 | 107 | 1.0.0 108 | 109 | 110 | 4.3.1 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /CS/DesktopToastsApp/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |