From 0db108e9d0af7386767194b3293c4082c1c8daa7 Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Wed, 15 May 2024 17:00:15 -0700 Subject: [PATCH] Windows 11 Version 22H2 - May 2024 Samples Update --- README.md | 5 +- Samples/Geolocation/README.md | 64 +- .../cppwinrt/Scenario1_TrackPosition.cpp | 3 + Samples/Geolocation/cs/Geolocation.csproj | 38 +- Samples/Geolocation/cs/Geolocation.sln | 12 + Samples/Geolocation/cs/Package.appxmanifest | 4 +- .../cs/Scenario1_TrackPosition.xaml.cs | 2 + Samples/Geolocation/cs/Tasks/Tasks.csproj | 30 +- .../shared/Scenario1_TrackPosition.xaml | 7 +- Samples/NetworkConnectivity/README.md | 22 +- .../cs/NetworkConnectivity.csproj | 6 +- .../PersonalDataEncryption}/README.md | 52 +- .../cppwinrt/Package.appxmanifest | 39 + .../cppwinrt/PersonalDataEncryption.sln | 40 + .../cppwinrt/PersonalDataEncryption.vcxproj | 188 ++++ .../PersonalDataEncryption.vcxproj.filters | 50 +- .../cppwinrt/Project.idl | 22 +- .../cppwinrt/SampleConfiguration.cpp | 30 + .../cppwinrt/SampleConfiguration.h | 9 +- .../cppwinrt/Scenario1_Files.cpp | 116 +++ .../cppwinrt/Scenario1_Files.h | 47 + .../cppwinrt/Scenario2_Memory.cpp | 108 ++ .../cppwinrt/Scenario2_Memory.h | 43 + .../cppwinrt/packages.config | 4 + .../PersonalDataEncryption/cppwinrt/pch.cpp | 6 + Samples/PersonalDataEncryption/cppwinrt/pch.h | 22 + .../cs}/Package.appxmanifest | 28 +- .../cs/PersonalDataEncryption.csproj | 38 +- .../cs/PersonalDataEncryption.sln | 40 + .../cs/SampleConfiguration.cs | 34 + .../cs/Scenario1_Files.xaml.cs | 116 +++ .../cs/Scenario2_Memory.xaml.cs | 112 +++ .../shared/Scenario1_Files.xaml | 52 + .../shared/Scenario2_Memory.xaml | 46 + Samples/RadioManager/README.md | 31 +- .../RadioManager/cppwinrt/RadioManager.sln | 20 +- .../cppwinrt/RadioManager.vcxproj | 18 +- Samples/RadioManager/cppwinrt/packages.config | 2 +- Samples/RadioManager/cs/RadioManager.csproj | 21 +- Samples/RadioManager/cs/RadioManager.sln | 20 +- .../cpp/Scenario1_Basic.xaml.cpp | 20 + .../ResizeAppView/cs/Scenario1_Basic.xaml.cs | 34 +- archived/CallerID/cs/CallerID.sln | 54 - archived/CallerID/cs/Package.appxmanifest | 51 - archived/CallerID/cs/SampleConfiguration.cs | 50 - archived/CallerID/cs/Scenario1_Register.xaml | 36 - .../CallerID/cs/Scenario1_Register.xaml.cs | 94 -- .../CallerID/cs/Scenario2_SetDefault.xaml | 44 - .../CallerID/cs/Scenario2_SetDefault.xaml.cs | 58 -- .../cs/Tasks/CallerIDBackgroundTask.cs | 63 -- archived/CallerID/cs/Tasks/Tasks.csproj | 126 --- archived/Geolocation/README.md | 91 -- .../cpp/BackgroundTask/BackgroundTask.vcxproj | 232 ----- .../BackgroundTask/LocationBackgroundTask.cpp | 371 ------- .../BackgroundTask/LocationBackgroundTask.h | 54 - .../BackgroundTask/VisitBackgroundTask.cpp | 192 ---- .../cpp/BackgroundTask/VisitBackgroundTask.h | 36 - .../cpp/BackgroundTask/badge-logo.png | Bin 1133 -> 0 bytes .../Geolocation/cpp/BackgroundTask/pch.cpp | 12 - archived/Geolocation/cpp/BackgroundTask/pch.h | 15 - archived/Geolocation/cpp/Geolocation.sln | 57 -- .../cpp/GeolocationCPP/GeofenceItem.cpp | 77 -- .../cpp/GeolocationCPP/GeofenceItem.h | 100 -- .../cpp/GeolocationCPP/Geolocation.vcxproj | 284 ------ .../Geolocation.vcxproj.filters | 85 -- .../cpp/GeolocationCPP/Package.appxmanifest | 67 -- .../GeolocationCPP/SampleConfiguration.cpp | 20 - .../cpp/GeolocationCPP/SampleConfiguration.h | 39 - .../Scenario1_TrackPosition.xaml | 50 - .../Scenario1_TrackPosition.xaml.cpp | 205 ---- .../Scenario1_TrackPosition.xaml.h | 52 - .../GeolocationCPP/Scenario2_GetPosition.xaml | 75 -- .../Scenario2_GetPosition.xaml.cpp | 188 ---- .../Scenario2_GetPosition.xaml.h | 51 - .../Scenario3_BackgroundTask.xaml | 40 - .../Scenario3_BackgroundTask.xaml.cpp | 275 ------ .../Scenario3_BackgroundTask.xaml.h | 54 - .../Scenario4_ForegroundGeofence.xaml | 204 ---- .../Scenario4_ForegroundGeofence.xaml.cpp | 442 --------- .../Scenario4_ForegroundGeofence.xaml.h | 100 -- .../Scenario4_ForegroundGeofenceHelpers.cpp | 637 ------------ .../Scenario5_GeofenceBackgroundTask.xaml | 40 - .../Scenario5_GeofenceBackgroundTask.xaml.cpp | 285 ------ .../Scenario5_GeofenceBackgroundTask.xaml.h | 58 -- .../Scenario6_GetLastVisit.xaml | 67 -- .../Scenario6_GetLastVisit.xaml.cpp | 117 --- .../Scenario6_GetLastVisit.xaml.h | 41 - .../Scenario7_ForegroundVisits.xaml | 55 -- .../Scenario7_ForegroundVisits.xaml.cpp | 161 --- .../Scenario7_ForegroundVisits.xaml.h | 48 - .../Scenario8_VisitsBackgroundTask.xaml | 40 - .../Scenario8_VisitsBackgroundTask.xaml.cpp | 266 ----- .../Scenario8_VisitsBackgroundTask.xaml.h | 50 - .../Geolocation/cpp/GeolocationCPP/pch.cpp | 17 - archived/Geolocation/cpp/GeolocationCPP/pch.h | 46 - archived/Geolocation/js/Geolocation.sln | 48 - .../js/geolocationjs/Geolocation.jsproj | 169 ---- .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-us/placeholder.txt | 0 .../js/geolocationjs/Package.appxmanifest | 73 -- .../css/scenario1_TrackPosition.css | 1 - .../css/scenario2_GetPosition.css | 1 - .../css/scenario3_BackgroundTask.css | 1 - .../css/scenario4_ForegroundGeofence.css | 39 - .../css/scenario5_GeofenceBackgroundTask.css | 19 - .../css/scenario8_VisitsBackgroundTask.css | 17 - .../html/scenario1_TrackPosition.html | 26 - .../html/scenario2_GetPosition.html | 42 - .../html/scenario3_BackgroundTask.html | 25 - .../html/scenario4_ForegroundGeofence.html | 129 --- .../scenario5_GeofenceBackgroundTask.html | 29 - .../html/scenario6_GetLastVisit.html | 31 - .../html/scenario7_ForegroundVisits.html | 31 - .../html/scenario8_VisitsBackgroundTask.html | 32 - .../js/geolocationjs/images/badge-logo.png | Bin 1133 -> 0 bytes .../js/geolocationjs/js/backgroundtask.js | 58 -- .../js/geofencebackgroundtask.js | 192 ---- .../js/geolocationjs/js/geofenceitem.js | 59 -- .../geolocationjs/js/sample-configuration.js | 43 - .../js/scenario1_TrackPosition.js | 141 --- .../geolocationjs/js/scenario2_GetPosition.js | 179 ---- .../js/scenario3_BackgroundTask.js | 187 ---- .../js/scenario4_ForegroundGeofence.js | 578 ----------- .../js/scenario5_GeofenceBackgroundTask.js | 255 ----- .../js/scenario6_GetLastVisit.js | 101 -- .../js/scenario7_ForegroundVisits.js | 114 --- .../js/scenario8_VisitsBackgroundTask.js | 229 ----- .../geolocationjs/js/visitbackgroundtask.js | 165 ---- .../sample-utils/placeholder.txt | 0 archived/PhoneCall/README.md | 89 -- archived/PhoneCall/cs/App.xaml | 33 - archived/PhoneCall/cs/App.xaml.cs | 114 --- .../PhoneCall/cs/Assets/defaultContact.png | Bin 377 -> 0 bytes .../PhoneCall/cs/Controls/ContactsPanel.xaml | 201 ---- .../cs/Controls/ContactsPanel.xaml.cs | 60 -- .../PhoneCall/cs/Controls/DialerPanel.xaml | 96 -- .../PhoneCall/cs/Controls/DialerPanel.xaml.cs | 65 -- archived/PhoneCall/cs/Controls/Dialpad.xaml | 146 --- .../PhoneCall/cs/Controls/Dialpad.xaml.cs | 47 - .../PhoneCall/cs/Controls/LinePicker.xaml | 54 - .../PhoneCall/cs/Controls/LinePicker.xaml.cs | 61 -- .../PhoneCall/cs/Controls/StatusPanel.xaml | 101 -- .../PhoneCall/cs/Controls/StatusPanel.xaml.cs | 32 - .../PhoneCall/cs/Controls/VoicemailPanel.xaml | 60 -- .../cs/Controls/VoicemailPanel.xaml.cs | 32 - .../PhoneCall/cs/Helpers/AlphaKeyGroup.cs | 109 -- .../PhoneCall/cs/Helpers/BindableFlyout.cs | 80 -- archived/PhoneCall/cs/Helpers/CallingInfo.cs | 463 --------- archived/PhoneCall/cs/Helpers/ContactItem.cs | 92 -- .../cs/Helpers/PhoneLinePickerItem.cs | 71 -- archived/PhoneCall/cs/Helpers/RelayCommand.cs | 93 -- archived/PhoneCall/cs/MainPage.xaml | 78 -- archived/PhoneCall/cs/MainPage.xaml.cs | 137 --- archived/PhoneCall/cs/Package.appxmanifest | 29 - archived/PhoneCall/cs/PhoneCall.csproj | 232 ----- archived/PhoneCall/cs/PhoneCall.sln | 40 - archived/PhoneCall/cs/Styles/Styles.xaml | 927 ------------------ .../cs/ViewModels/ContactsViewModel.cs | 534 ---------- .../cs/ViewModels/DialerPhoneNumber.cs | 186 ---- .../cs/ViewModels/DialerViewModel.cs | 161 --- .../cs/ViewModels/LinePickerViewModel.cs | 195 ---- .../cs/ViewModels/StatusViewModel.cs | 363 ------- .../PhoneCall/cs/ViewModels/ViewModelBase.cs | 34 - .../cs/ViewModels/ViewModelDispatcher.cs | 106 -- .../cs/ViewModels/VoicemailViewModel.cs | 165 ---- archived/RadioManager/README.md | 64 -- archived/RadioManager/cpp/RadioManager.sln | 40 - .../RadioManager/cpp/RadioManager.vcxproj | 214 ---- archived/RadioManager/cpp/RadioModel.cpp | 75 -- archived/RadioManager/cpp/RadioModel.h | 64 -- .../RadioManager/cpp/SampleConfiguration.h | 47 - .../cpp/Scenario1_ToggleRadios.xaml | 59 -- .../cpp/Scenario1_ToggleRadios.xaml.cpp | 68 -- .../cpp/Scenario1_ToggleRadios.xaml.h | 31 - archived/RadioManager/cpp/pch.h | 22 - archived/VoIP/README.md | 26 +- archived/VoIP/cs/Voip.sln | 49 +- archived/VoIP/cs/Voip/Voip.csproj | 27 +- .../VoIP/cs/VoipBackEnd/VoipBackEnd.vcxproj | 34 +- archived/VoIP/cs/VoipHost/VoipHost.vcxproj | 30 +- archived/VoIP/cs/VoipTasks/VoipTasks.csproj | 32 +- 182 files changed, 1457 insertions(+), 15298 deletions(-) rename {archived/CallerID => Samples/PersonalDataEncryption}/README.md (56%) create mode 100644 Samples/PersonalDataEncryption/cppwinrt/Package.appxmanifest create mode 100644 Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.sln create mode 100644 Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj rename archived/RadioManager/cpp/RadioManager.vcxproj.filters => Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj.filters (55%) rename archived/RadioManager/cpp/SampleConfiguration.cpp => Samples/PersonalDataEncryption/cppwinrt/Project.idl (61%) create mode 100644 Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.cpp rename archived/RadioManager/cpp/pch.cpp => Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.h (86%) create mode 100644 Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.cpp create mode 100644 Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.h create mode 100644 Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.cpp create mode 100644 Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.h create mode 100644 Samples/PersonalDataEncryption/cppwinrt/packages.config create mode 100644 Samples/PersonalDataEncryption/cppwinrt/pch.cpp create mode 100644 Samples/PersonalDataEncryption/cppwinrt/pch.h rename {archived/RadioManager/cpp => Samples/PersonalDataEncryption/cs}/Package.appxmanifest (63%) rename archived/CallerID/cs/CallerID.csproj => Samples/PersonalDataEncryption/cs/PersonalDataEncryption.csproj (85%) create mode 100644 Samples/PersonalDataEncryption/cs/PersonalDataEncryption.sln create mode 100644 Samples/PersonalDataEncryption/cs/SampleConfiguration.cs create mode 100644 Samples/PersonalDataEncryption/cs/Scenario1_Files.xaml.cs create mode 100644 Samples/PersonalDataEncryption/cs/Scenario2_Memory.xaml.cs create mode 100644 Samples/PersonalDataEncryption/shared/Scenario1_Files.xaml create mode 100644 Samples/PersonalDataEncryption/shared/Scenario2_Memory.xaml delete mode 100644 archived/CallerID/cs/CallerID.sln delete mode 100644 archived/CallerID/cs/Package.appxmanifest delete mode 100644 archived/CallerID/cs/SampleConfiguration.cs delete mode 100644 archived/CallerID/cs/Scenario1_Register.xaml delete mode 100644 archived/CallerID/cs/Scenario1_Register.xaml.cs delete mode 100644 archived/CallerID/cs/Scenario2_SetDefault.xaml delete mode 100644 archived/CallerID/cs/Scenario2_SetDefault.xaml.cs delete mode 100644 archived/CallerID/cs/Tasks/CallerIDBackgroundTask.cs delete mode 100644 archived/CallerID/cs/Tasks/Tasks.csproj delete mode 100644 archived/Geolocation/README.md delete mode 100644 archived/Geolocation/cpp/BackgroundTask/BackgroundTask.vcxproj delete mode 100644 archived/Geolocation/cpp/BackgroundTask/LocationBackgroundTask.cpp delete mode 100644 archived/Geolocation/cpp/BackgroundTask/LocationBackgroundTask.h delete mode 100644 archived/Geolocation/cpp/BackgroundTask/VisitBackgroundTask.cpp delete mode 100644 archived/Geolocation/cpp/BackgroundTask/VisitBackgroundTask.h delete mode 100644 archived/Geolocation/cpp/BackgroundTask/badge-logo.png delete mode 100644 archived/Geolocation/cpp/BackgroundTask/pch.cpp delete mode 100644 archived/Geolocation/cpp/BackgroundTask/pch.h delete mode 100644 archived/Geolocation/cpp/Geolocation.sln delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/GeofenceItem.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/GeofenceItem.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Geolocation.vcxproj delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Geolocation.vcxproj.filters delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Package.appxmanifest delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/SampleConfiguration.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/SampleConfiguration.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario1_TrackPosition.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario1_TrackPosition.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario1_TrackPosition.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario2_GetPosition.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario2_GetPosition.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario2_GetPosition.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario3_BackgroundTask.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario3_BackgroundTask.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario3_BackgroundTask.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario4_ForegroundGeofence.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario4_ForegroundGeofence.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario4_ForegroundGeofence.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario4_ForegroundGeofenceHelpers.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario5_GeofenceBackgroundTask.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario5_GeofenceBackgroundTask.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario5_GeofenceBackgroundTask.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario6_GetLastVisit.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario6_GetLastVisit.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario6_GetLastVisit.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario7_ForegroundVisits.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario7_ForegroundVisits.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario7_ForegroundVisits.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario8_VisitsBackgroundTask.xaml delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario8_VisitsBackgroundTask.xaml.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/Scenario8_VisitsBackgroundTask.xaml.h delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/pch.cpp delete mode 100644 archived/Geolocation/cpp/GeolocationCPP/pch.h delete mode 100644 archived/Geolocation/js/Geolocation.sln delete mode 100644 archived/Geolocation/js/geolocationjs/Geolocation.jsproj delete mode 100644 archived/Geolocation/js/geolocationjs/Microsoft.WinJS.4.0/css/placeholder.txt delete mode 100644 archived/Geolocation/js/geolocationjs/Microsoft.WinJS.4.0/fonts/placeholder delete mode 100644 archived/Geolocation/js/geolocationjs/Microsoft.WinJS.4.0/js/en-us/placeholder.txt delete mode 100644 archived/Geolocation/js/geolocationjs/Package.appxmanifest delete mode 100644 archived/Geolocation/js/geolocationjs/css/scenario1_TrackPosition.css delete mode 100644 archived/Geolocation/js/geolocationjs/css/scenario2_GetPosition.css delete mode 100644 archived/Geolocation/js/geolocationjs/css/scenario3_BackgroundTask.css delete mode 100644 archived/Geolocation/js/geolocationjs/css/scenario4_ForegroundGeofence.css delete mode 100644 archived/Geolocation/js/geolocationjs/css/scenario5_GeofenceBackgroundTask.css delete mode 100644 archived/Geolocation/js/geolocationjs/css/scenario8_VisitsBackgroundTask.css delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario1_TrackPosition.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario2_GetPosition.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario3_BackgroundTask.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario4_ForegroundGeofence.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario5_GeofenceBackgroundTask.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario6_GetLastVisit.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario7_ForegroundVisits.html delete mode 100644 archived/Geolocation/js/geolocationjs/html/scenario8_VisitsBackgroundTask.html delete mode 100644 archived/Geolocation/js/geolocationjs/images/badge-logo.png delete mode 100644 archived/Geolocation/js/geolocationjs/js/backgroundtask.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/geofencebackgroundtask.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/geofenceitem.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/sample-configuration.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario1_TrackPosition.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario2_GetPosition.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario3_BackgroundTask.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario4_ForegroundGeofence.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario5_GeofenceBackgroundTask.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario6_GetLastVisit.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario7_ForegroundVisits.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/scenario8_VisitsBackgroundTask.js delete mode 100644 archived/Geolocation/js/geolocationjs/js/visitbackgroundtask.js delete mode 100644 archived/Geolocation/js/geolocationjs/sample-utils/placeholder.txt delete mode 100644 archived/PhoneCall/README.md delete mode 100644 archived/PhoneCall/cs/App.xaml delete mode 100644 archived/PhoneCall/cs/App.xaml.cs delete mode 100644 archived/PhoneCall/cs/Assets/defaultContact.png delete mode 100644 archived/PhoneCall/cs/Controls/ContactsPanel.xaml delete mode 100644 archived/PhoneCall/cs/Controls/ContactsPanel.xaml.cs delete mode 100644 archived/PhoneCall/cs/Controls/DialerPanel.xaml delete mode 100644 archived/PhoneCall/cs/Controls/DialerPanel.xaml.cs delete mode 100644 archived/PhoneCall/cs/Controls/Dialpad.xaml delete mode 100644 archived/PhoneCall/cs/Controls/Dialpad.xaml.cs delete mode 100644 archived/PhoneCall/cs/Controls/LinePicker.xaml delete mode 100644 archived/PhoneCall/cs/Controls/LinePicker.xaml.cs delete mode 100644 archived/PhoneCall/cs/Controls/StatusPanel.xaml delete mode 100644 archived/PhoneCall/cs/Controls/StatusPanel.xaml.cs delete mode 100644 archived/PhoneCall/cs/Controls/VoicemailPanel.xaml delete mode 100644 archived/PhoneCall/cs/Controls/VoicemailPanel.xaml.cs delete mode 100644 archived/PhoneCall/cs/Helpers/AlphaKeyGroup.cs delete mode 100644 archived/PhoneCall/cs/Helpers/BindableFlyout.cs delete mode 100644 archived/PhoneCall/cs/Helpers/CallingInfo.cs delete mode 100644 archived/PhoneCall/cs/Helpers/ContactItem.cs delete mode 100644 archived/PhoneCall/cs/Helpers/PhoneLinePickerItem.cs delete mode 100644 archived/PhoneCall/cs/Helpers/RelayCommand.cs delete mode 100644 archived/PhoneCall/cs/MainPage.xaml delete mode 100644 archived/PhoneCall/cs/MainPage.xaml.cs delete mode 100644 archived/PhoneCall/cs/Package.appxmanifest delete mode 100644 archived/PhoneCall/cs/PhoneCall.csproj delete mode 100644 archived/PhoneCall/cs/PhoneCall.sln delete mode 100644 archived/PhoneCall/cs/Styles/Styles.xaml delete mode 100644 archived/PhoneCall/cs/ViewModels/ContactsViewModel.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/DialerPhoneNumber.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/DialerViewModel.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/LinePickerViewModel.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/StatusViewModel.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/ViewModelBase.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/ViewModelDispatcher.cs delete mode 100644 archived/PhoneCall/cs/ViewModels/VoicemailViewModel.cs delete mode 100644 archived/RadioManager/README.md delete mode 100644 archived/RadioManager/cpp/RadioManager.sln delete mode 100644 archived/RadioManager/cpp/RadioManager.vcxproj delete mode 100644 archived/RadioManager/cpp/RadioModel.cpp delete mode 100644 archived/RadioManager/cpp/RadioModel.h delete mode 100644 archived/RadioManager/cpp/SampleConfiguration.h delete mode 100644 archived/RadioManager/cpp/Scenario1_ToggleRadios.xaml delete mode 100644 archived/RadioManager/cpp/Scenario1_ToggleRadios.xaml.cpp delete mode 100644 archived/RadioManager/cpp/Scenario1_ToggleRadios.xaml.h delete mode 100644 archived/RadioManager/cpp/pch.h diff --git a/README.md b/README.md index f833841027..8e44997189 100644 --- a/README.md +++ b/README.md @@ -450,16 +450,17 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. Lock screen personalization Microsoft Passport and Windows Hello - Smart cards + Personal Data Encryption + Smart cards User information UserCertificateStore - UserConsentVerifier Web account management WebAuthenticationBroker + UserConsentVerifier diff --git a/Samples/Geolocation/README.md b/Samples/Geolocation/README.md index 47e116844b..10a58dcb8e 100644 --- a/Samples/Geolocation/README.md +++ b/Samples/Geolocation/README.md @@ -27,68 +27,66 @@ and track when the location changes in various ways. After obtaining access to the user's location, an app can -* Retrieve the current location. -* Receiving events when the location changes. -* Receiving events when the device has entered or exited locations of interest. -* Receiving events when the device has spent significant time in a location (a "visit"). +- Retrieve the current location. +- Receiving events when the location changes. +- Receiving events when the device has entered or exited locations of interest. +- Receiving events when the device has spent significant time in a location (a "visit"). -> **Note:** This sample is part of a large collection of UWP feature samples. +> **Note:** This sample is part of a large collection of UWP feature samples. > You can download this sample as a standalone ZIP file > [from docs.microsoft.com](https://docs.microsoft.com/samples/microsoft/windows-universal-samples/geolocation/), > or you can download the entire collection as a single -> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be -> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, -> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). -> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. +> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be +> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, +> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). +> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. This sample also shows how to: -- **Use a [geofence](http://msdn.microsoft.com/library/windows/apps/dn263744):** Receive notifications when the user's device has entered or left an area of interest. -- **Handle changes in location permissions**: Register for the Geolocator's StatusChanged event and use the [StatusChangedEventArgs](http://msdn.microsoft.com/library/windows/apps/br225600) to determine the current position status. -- **Get location from a background task** -- **Handle geofencing events from a background task** -- **Handle geovisit events from a background task** -- **Obtain satellite data:** When available, use the [GeocoordinateSatelliteData](http://msdn.microsoft.com/library/windows/apps/jj635260) class to obtain additional information on the quality of the satellite based location data. -- **Display a toast:** Notify the user when a geofencing event has occurred in the background. -- **Refresh geofence binding:** Refresh the binding on resume and after removal of a geofence. Note that removal requires subscribing to removal events if a geofence is set as single use or a duration is set. +- **Use a [geofence](http://msdn.microsoft.com/library/windows/apps/dn263744):** Receive notifications when the user's device has entered or left an area of interest. +- **Handle changes in location permissions**: Register for the Geolocator's StatusChanged event and use the [StatusChangedEventArgs](http://msdn.microsoft.com/library/windows/apps/br225600) to determine the current position status. +- **Get location from a background task** +- **Handle geofencing events from a background task** +- **Handle geovisit events from a background task** +- **Obtain satellite data:** When available, use the [GeocoordinateSatelliteData](http://msdn.microsoft.com/library/windows/apps/jj635260) class to obtain additional information on the quality of the satellite based location data. +- **Display a toast:** Notify the user when a geofencing event has occurred in the background. +- **Refresh geofence binding:** Refresh the binding on resume and after removal of a geofence. Note that removal requires subscribing to removal events if a geofence is set as single use or a duration is set. - **Request access to the user's location:** Request access to the user's location using the RequestAccessAsync method. Important: call the RequestAccessAsync before accessing the user's location. At that time, your app must be in the foreground and RequestAccessAsync must be called from the UI thread. Until the user grants your app permission to their location, your app can't access location data. -- **Track when the user visits a location:** Poll for or receive notifications when the user spends significant time in a location. +- **Track when the user visits a location:** Poll for or receive notifications when the user spends significant time in a location. - **Help the user change location settings:** Link to location privacy settings from your app if the user revokes access to location while your app is in the foreground. Call the LaunchUriAsync method with the URI "ms-settings://privacy/location". -Geofences need to be created in the Foreground Geofencing scenario (Scenario 4) and then you can go to Background Geofencing scenario (Scenario 5) to register for background geofencing events. +Geofences need to be created in the foreground geofencing scenario (Scenario 4) and then you can go to background geofencing scenario (Scenario 5) to register for background geofencing events. -The Geolocation sample formats and parses time and dates in the en-US locale using the Gregorian calendar and 24-hour clock. To help other locales in entering data the edit fields have a format example shown below the control. For example, Start Time would be entered mm/dd/yyyy hh:mm:ss format. February 2, 2014 at 10:34 pm would be written 2/2/2014 22:34:00. For the Dwell Time and Duration the format is dd:hh:mm:ss so a time span of 7 days, 23 hours, 45 minutes and 55 seconds would be written as 7:23:45:55. +The Geolocation sample formats and parses time and dates in the en-US locale using the Gregorian calendar and 24-hour clock. To help other locales in entering data the edit fields have a format example shown below the control. For example, Start Time would be entered mm/dd/yyyy hh:mm:ss format. February 2, 2014 at 10:34 pm would be written 2/2/2014 22:34:00. For the Dwell Time and Duration the format is dd:hh:mm:ss so a time span of 7 days, 23 hours, 45 minutes and 55 seconds would be written as 7:23:45:55. -### Declaring the Location capability +## Declaring the Location capability This sample requires that location capability be set in the *Package.appxmanifest* file to allow the app to access location at runtime. The capability can be set in the app manifest using Microsoft Visual Studio. - ## Related topics ### Conceptual -* [Get current location](https://msdn.microsoft.com/library/windows/apps/mt219698) -* [Guidelines for location-aware apps](https://msdn.microsoft.com/library/windows/apps/hh465148) +- [Get current location](https://msdn.microsoft.com/library/windows/apps/mt219698) +- [Guidelines for location-aware apps](https://msdn.microsoft.com/library/windows/apps/hh465148) ### Reference -* [Windows.Devices.Geolocation](http://msdn.microsoft.com/library/windows/apps/br225603) -* [Windows.Devices.Geolocation.Geofencing](https://msdn.microsoft.com/library/windows/apps/dn263744) +- [Windows.Devices.Geolocation](http://msdn.microsoft.com/library/windows/apps/br225603) +- [Windows.Devices.Geolocation.Geofencing](https://msdn.microsoft.com/library/windows/apps/dn263744) ### Related samples -* [Traffic App sample](https://github.com/microsoft/windows-appsample-trafficapp/) -* [Lunch Scheduler app sample](https://github.com/Microsoft/Windows-appsample-lunch-scheduler) -* [Geolocation sample](/archived/Geolocation/) for C++/CX and JavaScript (archived) +- [Traffic App sample](https://github.com/microsoft/windows-appsample-trafficapp/) +- [Lunch Scheduler app sample](https://github.com/Microsoft/Windows-appsample-lunch-scheduler) ## System requirements -* Windows 10 +- Requires Windows SDK 10.0.22621.0 to build and Windows 10 to run. ## Build the sample -1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. +1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. 2. Start Microsoft Visual Studio and select **File** \> **Open** \> **Project/Solution**. 3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file. 4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. @@ -99,8 +97,8 @@ The next steps depend on whether you just want to deploy the sample or you want ### Deploying the sample -- Select Build > Deploy Solution. +- Select Build > Deploy Solution. ### Deploying and running the sample -- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging. +- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging. diff --git a/Samples/Geolocation/cppwinrt/Scenario1_TrackPosition.cpp b/Samples/Geolocation/cppwinrt/Scenario1_TrackPosition.cpp index 1952d3f4e0..e746be2474 100644 --- a/Samples/Geolocation/cppwinrt/Scenario1_TrackPosition.cpp +++ b/Samples/Geolocation/cppwinrt/Scenario1_TrackPosition.cpp @@ -12,6 +12,7 @@ #include "pch.h" #include "Scenario1_TrackPosition.h" #include "Scenario1_TrackPosition.g.cpp" +#include "SampleConfiguration.h" using namespace winrt; using namespace winrt::Windows::Devices::Geolocation; @@ -173,6 +174,7 @@ namespace winrt::SDKTemplate::implementation ScenarioOutput_Latitude().Text(L"No data"); ScenarioOutput_Longitude().Text(L"No data"); ScenarioOutput_Accuracy().Text(L"No data"); + ScenarioOutput_Source().Text(L"No data"); ScenarioOutput_IsRemoteSource().Text(L"No data"); } else @@ -180,6 +182,7 @@ namespace winrt::SDKTemplate::implementation ScenarioOutput_Latitude().Text(to_hstring(position.Coordinate().Point().Position().Latitude)); ScenarioOutput_Longitude().Text(to_hstring(position.Coordinate().Point().Position().Longitude)); ScenarioOutput_Accuracy().Text(to_hstring(position.Coordinate().Accuracy())); + ScenarioOutput_Source().Text(to_hstring(position.Coordinate().PositionSource())); ScenarioOutput_IsRemoteSource().Text(to_hstring(position.Coordinate().IsRemoteSource())); } } diff --git a/Samples/Geolocation/cs/Geolocation.csproj b/Samples/Geolocation/cs/Geolocation.csproj index f147accdf6..f6527d208a 100644 --- a/Samples/Geolocation/cs/Geolocation.csproj +++ b/Samples/Geolocation/cs/Geolocation.csproj @@ -21,6 +21,30 @@ 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP + ;2008 + true + full + ARM64 + false + 7.3 + prompt + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UAP + true + ;2008 + true + pdbonly + ARM64 + false + 7.3 + prompt + true bin\ARM\Debug\ @@ -53,7 +77,6 @@ x64 false prompt - true bin\x64\Release\ @@ -64,7 +87,6 @@ x64 false prompt - true true @@ -194,6 +216,9 @@ Assets\smallTile-sdk.png + + Assets\badge-logo.png + Assets\splash-sdk.png @@ -218,12 +243,7 @@ - 5.0.0 - - - - - 5.0.0 + 6.2.14 @@ -237,4 +257,4 @@ --> - \ No newline at end of file + diff --git a/Samples/Geolocation/cs/Geolocation.sln b/Samples/Geolocation/cs/Geolocation.sln index 13246d85ab..89dae9f383 100644 --- a/Samples/Geolocation/cs/Geolocation.sln +++ b/Samples/Geolocation/cs/Geolocation.sln @@ -10,9 +10,11 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection @@ -20,6 +22,9 @@ Global {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|ARM.ActiveCfg = Debug|ARM {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|ARM.Build.0 = Debug|ARM {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|ARM.Deploy.0 = Debug|ARM + {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|ARM64.Build.0 = Debug|ARM64 + {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|ARM64.Deploy.0 = Debug|ARM64 {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|x64.ActiveCfg = Debug|x64 {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|x64.Build.0 = Debug|x64 {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Debug|x64.Deploy.0 = Debug|x64 @@ -29,6 +34,9 @@ Global {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|ARM.ActiveCfg = Release|ARM {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|ARM.Build.0 = Release|ARM {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|ARM.Deploy.0 = Release|ARM + {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|ARM64.ActiveCfg = Release|ARM64 + {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|ARM64.Build.0 = Release|ARM64 + {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|ARM64.Deploy.0 = Release|ARM64 {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|x64.ActiveCfg = Release|x64 {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|x64.Build.0 = Release|x64 {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|x64.Deploy.0 = Release|x64 @@ -37,12 +45,16 @@ Global {C214806D-57CA-5528-89FA-B9A7DEB22DFF}.Release|x86.Deploy.0 = Release|x86 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|ARM.ActiveCfg = Debug|ARM {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|ARM.Build.0 = Debug|ARM + {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|ARM64.Build.0 = Debug|ARM64 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|x64.ActiveCfg = Debug|x64 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|x64.Build.0 = Debug|x64 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|x86.ActiveCfg = Debug|x86 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Debug|x86.Build.0 = Debug|x86 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|ARM.ActiveCfg = Release|ARM {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|ARM.Build.0 = Release|ARM + {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|ARM64.ActiveCfg = Release|ARM64 + {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|ARM64.Build.0 = Release|ARM64 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|x64.ActiveCfg = Release|x64 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|x64.Build.0 = Release|x64 {5A7BDE18-030E-5DC9-B9A2-70EA568A6E9D}.Release|x86.ActiveCfg = Release|x86 diff --git a/Samples/Geolocation/cs/Package.appxmanifest b/Samples/Geolocation/cs/Package.appxmanifest index 6254040535..736559af06 100644 --- a/Samples/Geolocation/cs/Package.appxmanifest +++ b/Samples/Geolocation/cs/Package.appxmanifest @@ -17,7 +17,7 @@ - + @@ -41,4 +41,4 @@ - \ No newline at end of file + diff --git a/Samples/Geolocation/cs/Scenario1_TrackPosition.xaml.cs b/Samples/Geolocation/cs/Scenario1_TrackPosition.xaml.cs index 490f59ef63..66258049ad 100644 --- a/Samples/Geolocation/cs/Scenario1_TrackPosition.xaml.cs +++ b/Samples/Geolocation/cs/Scenario1_TrackPosition.xaml.cs @@ -197,6 +197,7 @@ private void UpdateLocationData(Geoposition position) ScenarioOutput_Latitude.Text = "No data"; ScenarioOutput_Longitude.Text = "No data"; ScenarioOutput_Accuracy.Text = "No data"; + ScenarioOutput_Source.Text = "No data"; ScenarioOutput_IsRemoteSource.Text = "No data"; } else @@ -204,6 +205,7 @@ private void UpdateLocationData(Geoposition position) ScenarioOutput_Latitude.Text = position.Coordinate.Point.Position.Latitude.ToString(); ScenarioOutput_Longitude.Text = position.Coordinate.Point.Position.Longitude.ToString(); ScenarioOutput_Accuracy.Text = position.Coordinate.Accuracy.ToString(); + ScenarioOutput_Source.Text = position.Coordinate.PositionSource.ToString(); ScenarioOutput_IsRemoteSource.Text = position.Coordinate.IsRemoteSource.ToString(); } } diff --git a/Samples/Geolocation/cs/Tasks/Tasks.csproj b/Samples/Geolocation/cs/Tasks/Tasks.csproj index 121251f654..3504250f19 100644 --- a/Samples/Geolocation/cs/Tasks/Tasks.csproj +++ b/Samples/Geolocation/cs/Tasks/Tasks.csproj @@ -21,6 +21,30 @@ 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + true + bin\ARM64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UAP + ;2008 + true + full + ARM64 + false + 7.3 + prompt + + + bin\ARM64\Release\ + TRACE;NETFX_CORE;WINDOWS_UAP + true + ;2008 + true + pdbonly + ARM64 + false + 7.3 + prompt + ARM true @@ -56,7 +80,6 @@ x64 false prompt - true x64 @@ -68,7 +91,6 @@ x64 false prompt - true true @@ -108,7 +130,7 @@ - 5.0.0 + 6.2.14 @@ -122,4 +144,4 @@ --> - \ No newline at end of file + diff --git a/Samples/Geolocation/shared/Scenario1_TrackPosition.xaml b/Samples/Geolocation/shared/Scenario1_TrackPosition.xaml index 25ed9d66b0..08cbcea613 100644 --- a/Samples/Geolocation/shared/Scenario1_TrackPosition.xaml +++ b/Samples/Geolocation/shared/Scenario1_TrackPosition.xaml @@ -36,17 +36,20 @@ + - + + - + + Application is not able to get location data. Go to diff --git a/Samples/NetworkConnectivity/README.md b/Samples/NetworkConnectivity/README.md index 1de9d8508c..9e0e4f44fe 100644 --- a/Samples/NetworkConnectivity/README.md +++ b/Samples/NetworkConnectivity/README.md @@ -2,7 +2,6 @@ page_type: sample languages: - csharp -- cpp - cppwinrt products: - windows @@ -33,28 +32,27 @@ This sample also demonstrates how to register for network connectivity change ev Apps can subscribe to the events instead of building their own logic to track network connectivity changes. -> **Note:** This sample is part of a large collection of UWP feature samples. +> **Note:** This sample is part of a large collection of UWP feature samples. > You can download this sample as a standalone ZIP file > [from docs.microsoft.com](https://docs.microsoft.com/samples/microsoft/windows-universal-samples/networkingconnectivity/), > or you can download the entire collection as a single -> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/main.zip), but be -> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, -> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). -> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. +> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/main.zip), but be +> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, +> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). +> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. - -### Declaring the internetClient capability +## Declaring the internetClient capability This sample requires that internetClient capability be set in the *Package.appxmanifest* file to allow the app to access the Internet connection at runtime. The capability can be set in the app manifest using Microsoft Visual Studio. ## System requirements -* Windows 10 +- Requires Windows SDK 10.0.22621.0 to build and Windows 10 to run. ## Build the sample -1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. +1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. 2. Start Microsoft Visual Studio and select **File** \> **Open** \> **Project/Solution**. 3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file. 4. Press Ctrl+Shift+B or select **Build** \> **Build Solution**. @@ -65,8 +63,8 @@ The next steps depend on whether you just want to deploy the sample or you want ### Deploying the sample -- Select Build > Deploy Solution. +- Select Build > Deploy Solution. ### Debugging and running the sample -- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging. +- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging. diff --git a/Samples/NetworkConnectivity/cs/NetworkConnectivity.csproj b/Samples/NetworkConnectivity/cs/NetworkConnectivity.csproj index c4b914af94..0a5c17847c 100644 --- a/Samples/NetworkConnectivity/cs/NetworkConnectivity.csproj +++ b/Samples/NetworkConnectivity/cs/NetworkConnectivity.csproj @@ -37,7 +37,7 @@ bin\ARM64\Release\ - TRACE;NETFX_CORE;WINDOWS_UAP;CODE_ANALYSIS + TRACE;NETFX_CORE;WINDOWS_UAP true ;2008 true @@ -185,7 +185,7 @@ - 5.0.0 + 6.2.14 @@ -199,4 +199,4 @@ --> - \ No newline at end of file + diff --git a/archived/CallerID/README.md b/Samples/PersonalDataEncryption/README.md similarity index 56% rename from archived/CallerID/README.md rename to Samples/PersonalDataEncryption/README.md index ff4eb78659..7a50030df5 100644 --- a/archived/CallerID/README.md +++ b/Samples/PersonalDataEncryption/README.md @@ -1,65 +1,62 @@ --- -topic: sample +page_type: sample languages: - csharp +- cplusplus +- cppwinrt products: - windows - windows-uwp -urlFragment: CallerID +urlFragment: PersonalDataEncryption extendedZipContent: - path: SharedContent target: SharedContent - path: LICENSE target: LICENSE -description: "Shows how to set Call Origin information for an unrecognized incoming call." +description: "Demonstrates the usage of Personal Data Encryption (Windows Data Protection)." --- - +# Personal Data Encryption sample -# Caller ID sample - -Shows how to set Call Origin information for an unrecognized incoming call. +Shows how to use [Personal Data Encryption](https://learn.microsoft.com/windows/security/operating-system-security/data-protection/personal-data-encryption/) +for protecting user files and memory buffers. > **Note:** This sample is part of a large collection of UWP feature samples. > You can download this sample as a standalone ZIP file -> [from docs.microsoft.com](https://docs.microsoft.com/samples/microsoft/windows-universal-samples/callerid/), +> [from docs.microsoft.com](https://docs.microsoft.com/samples/microsoft/windows-universal-samples/resizeappview/), > or you can download the entire collection as a single > [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be > sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, > the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). > For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. -Specifically, this sample shows how to: -- Register a Caller ID background task to be triggered when an unrecognized incoming call arrives. - The task sets the call location, category, category description, and display name of the call. -- Display the system UI to let the user choose the active Caller ID app. -- Determine whether the app is the the active Caller ID app. +Personal Data Encryption can protect data either while a user is signed ("Level 1" or "L1") out or while a system is locked ("Level 2" or "L2"). -See the Package.appxmanifest file for the extensions and capabilities a Caller ID app must declare. +The sample shows the following: -**Note** The Windows universal samples require Visual Studio to build and Windows 10 to execute. +- Marking a folder so that all new files are protected at a particular level, or removing protection. +- Protecting a file at a particular level, or removing protection. +- Protecting a memory buffer at a particular level, or removing protection. -To obtain information about Windows 10 development, go to the [Windows Dev Center](http://go.microsoft.com/fwlink/?LinkID=532421) +**Note** The Windows universal samples require Visual Studio to build and Windows 11 to execute. + +To obtain information about Windows development, go to the [Windows Dev Center](http://go.microsoft.com/fwlink/?LinkID=532421) To obtain information about Microsoft Visual Studio and the tools for developing Windows apps, go to [Visual Studio](http://go.microsoft.com/fwlink/?LinkID=532422) +## Related topics + ### Reference -[Windows.ApplicationModel.Calls.Provider namespace](https://msdn.microsoft.com/library/windows/apps/windows.applicationmodel.calls.provider.aspx) +[UserDataProtectionManager class](https://learn.microsoft.com/en-us/uwp/api/windows.security.dataprotection.userdataprotectionmanager) -[PhoneCallOriginManager class](https://msdn.microsoft.com/library/windows/apps/windows.applicationmodel.calls.provider.phonecalloriginmanager.aspx) +### Related samples -[PhoneCallOrigin class](https://msdn.microsoft.com/library/windows/apps/windows.applicationmodel.calls.provider.phonecallorigin.aspx) +* [EnterpriseDataProtection](/Samples/EnterpriseDataProtection) ## System requirements -**Client:** Not Supported - -**Server:** Not Supported - -**Phone:** Windows 10 +* Windows 11 version 22H2 or higher ## Build the sample @@ -78,4 +75,5 @@ The next steps depend on whether you just want to deploy the sample or you want ### Deploying and running the sample -- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging. +- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging. +- In order for the sample to exercise Personal Data Encryption, [it must be configured](https://learn.microsoft.com/windows/security/operating-system-security/data-protection/personal-data-encryption/configure). diff --git a/Samples/PersonalDataEncryption/cppwinrt/Package.appxmanifest b/Samples/PersonalDataEncryption/cppwinrt/Package.appxmanifest new file mode 100644 index 0000000000..4ecd12324e --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/Package.appxmanifest @@ -0,0 +1,39 @@ + + + + + + Personal Data Encryption C++/WinRT Sample + Microsoft Corporation + Assets\storelogo-sdk.png + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.sln b/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.sln new file mode 100644 index 0000000000..b47cbde1f4 --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2006 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PersonalDataEncryption", "PersonalDataEncryption.vcxproj", "{3180E6C1-8D0E-4120-B794-AEFF6D6055B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Debug|ARM = Debug|ARM + Release|ARM = Release|ARM + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|ARM.ActiveCfg = Debug|ARM + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|ARM.Build.0 = Debug|ARM + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|ARM.Deploy.0 = Debug|ARM + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|x64.ActiveCfg = Debug|x64 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|x64.Build.0 = Debug|x64 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|x64.Deploy.0 = Debug|x64 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|x86.ActiveCfg = Debug|Win32 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|x86.Build.0 = Debug|Win32 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Debug|x86.Deploy.0 = Debug|Win32 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|ARM.ActiveCfg = Release|ARM + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|ARM.Build.0 = Release|ARM + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|ARM.Deploy.0 = Release|ARM + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|x64.ActiveCfg = Release|x64 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|x64.Build.0 = Release|x64 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|x64.Deploy.0 = Release|x64 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|x86.ActiveCfg = Release|Win32 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|x86.Build.0 = Release|Win32 + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9}.Release|x86.Deploy.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj b/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj new file mode 100644 index 0000000000..8e1a218fef --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj @@ -0,0 +1,188 @@ + + + + + $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), LICENSE))\SharedContent + + + true + true + {3180E6C1-8D0E-4120-B794-AEFF6D6055B9} + PersonalDataEncryption + SDKTemplate + en-US + 15.0 + true + Windows Store + 10.0 + 10.0.22000.0 + $(WindowsTargetPlatformVersion) + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + Application + Unicode + + + true + true + + + false + true + false + + + + + + + + $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);$(SharedContentDir)\cppwinrt + true + + + + Use + pch.h + $(IntDir)pch.pch + Level4 + %(AdditionalOptions) /bigobj + 4453;28204 + + + + + _DEBUG;%(PreprocessorDefinitions) + + + + + NDEBUG;%(PreprocessorDefinitions) + + + + + $(SharedContentDir)\xaml\App.xaml + + + $(SharedContentDir)\xaml\MainPage.xaml + + + + ..\shared\Scenario1_Files.xaml + + + ..\shared\Scenario2_Memory.xaml + + + + + + Designer + + + Designer + + + + + Styles\Styles.xaml + + + + + $(SharedContentDir)\xaml\App.xaml + + + $(SharedContentDir)\xaml\MainPage.xaml + + + + ..\shared\Scenario1_Files.xaml + + + ..\shared\Scenario2_Memory.xaml + + + Create + + + Project.idl + + + + + $(SharedContentDir)\xaml\MainPage.xaml + + + + + + Designer + + + + + Assets\microsoft-sdk.png + + + Assets\smallTile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squareTile-sdk.png + + + Assets\storeLogo-sdk.png + + + Assets\tile-sdk.png + + + Assets\windows-sdk.png + + + + + + + + + + + + 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/archived/RadioManager/cpp/RadioManager.vcxproj.filters b/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj.filters similarity index 55% rename from archived/RadioManager/cpp/RadioManager.vcxproj.filters rename to Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj.filters index 0e55041794..98996670ea 100644 --- a/archived/RadioManager/cpp/RadioManager.vcxproj.filters +++ b/Samples/PersonalDataEncryption/cppwinrt/PersonalDataEncryption.vcxproj.filters @@ -1,47 +1,41 @@  - + - 80bfd669-aa83-4537-9611-027cffe0d8af + 4416d50a-7676-4d0a-9b2c-91ff70c6047f bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png - - {c6978fb6-bc64-498d-97c8-f5b53997e54e} - - + + + + + + + + - - + + + - - - - + + - - + + - - - - + + - - - - Styles - - - Assets @@ -65,4 +59,10 @@ Assets + + + + + + \ No newline at end of file diff --git a/archived/RadioManager/cpp/SampleConfiguration.cpp b/Samples/PersonalDataEncryption/cppwinrt/Project.idl similarity index 61% rename from archived/RadioManager/cpp/SampleConfiguration.cpp rename to Samples/PersonalDataEncryption/cppwinrt/Project.idl index a32329ab52..f8ac2d3410 100644 --- a/archived/RadioManager/cpp/SampleConfiguration.cpp +++ b/Samples/PersonalDataEncryption/cppwinrt/Project.idl @@ -9,13 +9,17 @@ // //********************************************************* -#include "pch.h" -#include "MainPage.xaml.h" -#include "SampleConfiguration.h" - -using namespace SDKTemplate; - -Platform::Array^ MainPage::scenariosInner = ref new Platform::Array +namespace SDKTemplate { - { "Toggle Radios", "SDKTemplate.Scenario1_ToggleRadios" } -}; + [default_interface] + runtimeclass Scenario1_Files : Windows.UI.Xaml.Controls.Page + { + Scenario1_Files(); + } + + [default_interface] + runtimeclass Scenario2_Memory : Windows.UI.Xaml.Controls.Page + { + Scenario2_Memory(); + } +} diff --git a/Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.cpp b/Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.cpp new file mode 100644 index 0000000000..7c2c8bd42a --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.cpp @@ -0,0 +1,30 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "pch.h" +#include +#include "MainPage.h" +#include "SampleConfiguration.h" + +using namespace winrt; +using namespace Windows::Foundation::Collections; +using namespace SDKTemplate; + +hstring implementation::MainPage::FEATURE_NAME() +{ + return L"Personal Data Encryption"; +} + +IVector implementation::MainPage::scenariosInner = winrt::single_threaded_observable_vector( +{ + Scenario{ L"Files and folders", xaml_typename() }, + Scenario{ L"Memory", xaml_typename() }, +}); diff --git a/archived/RadioManager/cpp/pch.cpp b/Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.h similarity index 86% rename from archived/RadioManager/cpp/pch.cpp rename to Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.h index e5b0b06e30..ba0eb7c8c2 100644 --- a/archived/RadioManager/cpp/pch.cpp +++ b/Samples/PersonalDataEncryption/cppwinrt/SampleConfiguration.h @@ -9,8 +9,9 @@ // //********************************************************* -// -// Include the standard header and generate the precompiled header. -// - +#pragma once #include "pch.h" + +namespace winrt::SDKTemplate +{ +} diff --git a/Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.cpp b/Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.cpp new file mode 100644 index 0000000000..e27133a86f --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.cpp @@ -0,0 +1,116 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "pch.h" +#include "Scenario1_Files.h" +#include "Scenario1_Files.g.cpp" + +using namespace winrt::Windows::Foundation; +using namespace winrt::Windows::Security::DataProtection; +using namespace winrt::Windows::Storage; +using namespace winrt::Windows::Storage::Pickers; +using namespace winrt::Windows::UI::Xaml; +using namespace winrt::Windows::UI::Xaml::Navigation; + +namespace winrt::SDKTemplate::implementation +{ + Scenario1_Files::Scenario1_Files() + { + InitializeComponent(); + } + + void Scenario1_Files::OnNavigatedTo(NavigationEventArgs const&) + { + userDataProtectionManager = UserDataProtectionManager::TryGetDefault(); + if (userDataProtectionManager) + { + AvailablePanel().Visibility(Visibility::Visible); + UnavailablePanel().Visibility(Visibility::Collapsed); + } + else + { + AvailablePanel().Visibility(Visibility::Collapsed); + UnavailablePanel().Visibility(Visibility::Visible); + } + } + + fire_and_forget Scenario1_Files::ChooseFile_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + FileOpenPicker picker; + picker.FileTypeFilter().Append(L"*"); + UpdateItem(co_await picker.PickSingleFileAsync()); + } + + fire_and_forget Scenario1_Files::ChooseFolder_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + FolderPicker picker; + UpdateItem(co_await picker.PickSingleFolderAsync()); + } + + void Scenario1_Files::UpdateItem(IStorageItem const& item) + { + selectedItem = item; + if (selectedItem != nullptr) + { + ItemOperationsPanel().Visibility(Visibility::Visible); + ItemNameBlock().Text(item.Path()); + } + else + { + ItemOperationsPanel().Visibility(Visibility::Collapsed); + } + } + + fire_and_forget Scenario1_Files::ProtectL1_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + UserDataStorageItemProtectionStatus status = co_await userDataProtectionManager.ProtectStorageItemAsync(selectedItem, UserDataAvailability::AfterFirstUnlock); + ReportStatus(L"Protect L1", status); + } + + fire_and_forget Scenario1_Files::ProtectL2_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + UserDataStorageItemProtectionStatus status = co_await userDataProtectionManager.ProtectStorageItemAsync(selectedItem, UserDataAvailability::WhileUnlocked); + ReportStatus(L"Protect L2", status); + } + + fire_and_forget Scenario1_Files::Unprotect_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + UserDataStorageItemProtectionStatus status = co_await userDataProtectionManager.ProtectStorageItemAsync(selectedItem, UserDataAvailability::Always); + ReportStatus(L"Protect L2", status); + } + + void Scenario1_Files::ReportStatus(hstring const& operation, UserDataStorageItemProtectionStatus status) + { + switch (status) + { + case UserDataStorageItemProtectionStatus::Succeeded: + rootPage.NotifyUser(operation + L" succeeded", NotifyType::StatusMessage); + break; + + case UserDataStorageItemProtectionStatus::NotProtectable: + rootPage.NotifyUser(operation + L" failed: Not protectable", NotifyType::ErrorMessage); + break; + + case UserDataStorageItemProtectionStatus::DataUnavailable: + rootPage.NotifyUser(operation + L" failed: Data unavailable", NotifyType::ErrorMessage); + break; + + default: + rootPage.NotifyUser(operation + L" failed: Unknown failure", NotifyType::ErrorMessage); + break; + } + } +} diff --git a/Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.h b/Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.h new file mode 100644 index 0000000000..952fa745f2 --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/Scenario1_Files.h @@ -0,0 +1,47 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#pragma once + +#include "Scenario1_Files.g.h" +#include "MainPage.h" + +namespace winrt::SDKTemplate::implementation +{ + struct Scenario1_Files : Scenario1_FilesT + { + Scenario1_Files(); + + void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs const& e); + + fire_and_forget ChooseFile_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + fire_and_forget ChooseFolder_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + fire_and_forget ProtectL1_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + fire_and_forget ProtectL2_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + fire_and_forget Unprotect_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + + private: + SDKTemplate::MainPage rootPage{ MainPage::Current() }; + winrt::Windows::Security::DataProtection::UserDataProtectionManager userDataProtectionManager{ nullptr }; + winrt::Windows::Storage::IStorageItem selectedItem{ nullptr }; + + void UpdateItem(winrt::Windows::Storage::IStorageItem const& item); + void ReportStatus(winrt::hstring const& operation, winrt::Windows::Security::DataProtection::UserDataStorageItemProtectionStatus status); + + }; +} + +namespace winrt::SDKTemplate::factory_implementation +{ + struct Scenario1_Files : Scenario1_FilesT + { + }; +} diff --git a/Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.cpp b/Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.cpp new file mode 100644 index 0000000000..3fc5124e98 --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.cpp @@ -0,0 +1,108 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#include "pch.h" +#include "Scenario2_Memory.h" +#include "Scenario2_Memory.g.cpp" + +using namespace winrt::Windows::Foundation; +using namespace winrt::Windows::Security::Cryptography; +using namespace winrt::Windows::Security::DataProtection; +using namespace winrt::Windows::Storage::Streams; +using namespace winrt::Windows::UI::Xaml; +using namespace winrt::Windows::UI::Xaml::Navigation; + +namespace winrt::SDKTemplate::implementation +{ + Scenario2_Memory::Scenario2_Memory() + { + InitializeComponent(); + } + + void Scenario2_Memory::OnNavigatedTo(NavigationEventArgs const&) + { + userDataProtectionManager = UserDataProtectionManager::TryGetDefault(); + if (userDataProtectionManager) + { + AvailablePanel().Visibility(Visibility::Visible); + UnavailablePanel().Visibility(Visibility::Collapsed); + } + else + { + AvailablePanel().Visibility(Visibility::Collapsed); + UnavailablePanel().Visibility(Visibility::Visible); + } + } + + fire_and_forget Scenario2_Memory::ProtectL1_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + hstring text = DataTextBox().Text(); + if (text.empty()) + { + // Cannot protect a zero-length buffer. + rootPage.NotifyUser(L"Please enter data to protect", NotifyType::ErrorMessage); + co_return; + } + + IBuffer buffer = CryptographicBuffer::ConvertStringToBinary(text, BinaryStringEncoding::Utf8); + + IBuffer result = co_await userDataProtectionManager.ProtectBufferAsync(buffer, UserDataAvailability::AfterFirstUnlock); + ReportProtectedBuffer(result); + } + + fire_and_forget Scenario2_Memory::ProtectL2_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + hstring text = DataTextBox().Text(); + if (text.empty()) + { + // Cannot protect a zero-length buffer. + rootPage.NotifyUser(L"Please enter data to protect", NotifyType::ErrorMessage); + co_return; + } + + IBuffer buffer = CryptographicBuffer::ConvertStringToBinary(text, BinaryStringEncoding::Utf8); + + IBuffer result = co_await userDataProtectionManager.ProtectBufferAsync(buffer, UserDataAvailability::WhileUnlocked); + ReportProtectedBuffer(result); + } + + void Scenario2_Memory::ReportProtectedBuffer(IBuffer const& buffer) + { + protectedBuffer = buffer; + ProtectedDataTextBlock().Text(CryptographicBuffer::EncodeToHexString(buffer)); + UnprotectPanel().Visibility(Visibility::Visible); + rootPage.NotifyUser(L"", NotifyType::StatusMessage); + } + + fire_and_forget Scenario2_Memory::Unprotect_Click(IInspectable const&, RoutedEventArgs const&) + { + auto lifetime = get_strong(); + UnprotectedDataTextBlock().Text(L""); + UserDataBufferUnprotectResult result = co_await userDataProtectionManager.UnprotectBufferAsync(protectedBuffer); + switch (result.Status()) + { + case UserDataBufferUnprotectStatus::Succeeded: + rootPage.NotifyUser(L"Unprotected successfully", NotifyType::StatusMessage); + UnprotectedDataTextBlock().Text(CryptographicBuffer::ConvertBinaryToString(BinaryStringEncoding::Utf8, result.UnprotectedBuffer())); + break; + + case UserDataBufferUnprotectStatus::Unavailable: + rootPage.NotifyUser(L"Unable to unprotect: Unavailable", NotifyType::ErrorMessage); + break; + + default: + rootPage.NotifyUser(L"Unable to unprotect: Unknown error", NotifyType::ErrorMessage); + break; + } + } +} \ No newline at end of file diff --git a/Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.h b/Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.h new file mode 100644 index 0000000000..066676c623 --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/Scenario2_Memory.h @@ -0,0 +1,43 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +#pragma once + +#include "Scenario2_Memory.g.h" +#include "MainPage.h" + +namespace winrt::SDKTemplate::implementation +{ + struct Scenario2_Memory : Scenario2_MemoryT + { + Scenario2_Memory(); + + void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs const& e); + + fire_and_forget ProtectL1_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + fire_and_forget ProtectL2_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + fire_and_forget Unprotect_Click(Windows::Foundation::IInspectable const& sender, Windows::UI::Xaml::RoutedEventArgs const& e); + + private: + SDKTemplate::MainPage rootPage{ MainPage::Current() }; + winrt::Windows::Security::DataProtection::UserDataProtectionManager userDataProtectionManager{ nullptr }; + winrt::Windows::Storage::Streams::IBuffer protectedBuffer{ nullptr }; + + void ReportProtectedBuffer(Windows::Storage::Streams::IBuffer const& buffer); + }; +} + +namespace winrt::SDKTemplate::factory_implementation +{ + struct Scenario2_Memory : Scenario2_MemoryT + { + }; +} diff --git a/Samples/PersonalDataEncryption/cppwinrt/packages.config b/Samples/PersonalDataEncryption/cppwinrt/packages.config new file mode 100644 index 0000000000..7a9561b2b5 --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Samples/PersonalDataEncryption/cppwinrt/pch.cpp b/Samples/PersonalDataEncryption/cppwinrt/pch.cpp new file mode 100644 index 0000000000..01484ff5aa --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/pch.cpp @@ -0,0 +1,6 @@ +// +// pch.cpp +// Include the standard header and generate the precompiled header. +// + +#include "pch.h" diff --git a/Samples/PersonalDataEncryption/cppwinrt/pch.h b/Samples/PersonalDataEncryption/cppwinrt/pch.h new file mode 100644 index 0000000000..351fe75257 --- /dev/null +++ b/Samples/PersonalDataEncryption/cppwinrt/pch.h @@ -0,0 +1,22 @@ +#pragma once + +#include +#include "winrt/Windows.Foundation.h" +#include "winrt/Windows.Foundation.Collections.h" +#include "winrt/Windows.ApplicationModel.Activation.h" +#include "winrt/Windows.Security.Cryptography.h" +#include "winrt/Windows.Security.DataProtection.h" +#include "winrt/Windows.Storage.h" +#include "winrt/Windows.Storage.Pickers.h" +#include "winrt/Windows.Storage.Streams.h" +#include "winrt/Windows.System.h" +#include "winrt/Windows.UI.Core.h" +#include "winrt/Windows.UI.Xaml.h" +#include "winrt/Windows.UI.Xaml.Automation.Peers.h" +#include "winrt/Windows.UI.Xaml.Controls.h" +#include "winrt/Windows.UI.Xaml.Controls.Primitives.h" +#include "winrt/Windows.UI.Xaml.Documents.h" +#include "winrt/Windows.UI.Xaml.Interop.h" +#include "winrt/Windows.UI.Xaml.Markup.h" +#include "winrt/Windows.UI.Xaml.Media.h" +#include "winrt/Windows.UI.Xaml.Navigation.h" diff --git a/archived/RadioManager/cpp/Package.appxmanifest b/Samples/PersonalDataEncryption/cs/Package.appxmanifest similarity index 63% rename from archived/RadioManager/cpp/Package.appxmanifest rename to Samples/PersonalDataEncryption/cs/Package.appxmanifest index 725ef789e1..8459c8793a 100644 --- a/archived/RadioManager/cpp/Package.appxmanifest +++ b/Samples/PersonalDataEncryption/cs/Package.appxmanifest @@ -7,20 +7,21 @@ IgnorableNamespaces="uap mp"> - + + - RadioManager C++ Sample + Personal Data Encryption C# Sample Microsoft Corporation Assets\StoreLogo-sdk.png - + @@ -28,17 +29,16 @@ - + EntryPoint="PersonalDataEncryption.App"> - + Square44x44Logo="Assets\SmallTile-sdk.png" + Description="PersonalDataEncryption C# sample" + BackgroundColor="#00b2f0"> + @@ -47,8 +47,4 @@ - - - - \ No newline at end of file diff --git a/archived/CallerID/cs/CallerID.csproj b/Samples/PersonalDataEncryption/cs/PersonalDataEncryption.csproj similarity index 85% rename from archived/CallerID/cs/CallerID.csproj rename to Samples/PersonalDataEncryption/cs/PersonalDataEncryption.csproj index f61e83bf48..a7b37c93c2 100644 --- a/archived/CallerID/cs/CallerID.csproj +++ b/Samples/PersonalDataEncryption/cs/PersonalDataEncryption.csproj @@ -6,18 +6,16 @@ Debug - x86 - {B2B78D7B-9604-5013-B7F1-ED35BE8D4C48} + {69AB702D-59CB-4062-B010-5BFA49237536} AppContainerExe Properties SDKTemplate - CallerID + PersonalDataEncryption en-US UAP - 10.0.18362.0 - 10.0.18362.0 + 10.0.22000.0 + 10.0.22000.0 14 - true true 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -104,12 +102,10 @@ Properties\AssemblyInfo.cs - - Scenario2_SetDefault.xaml - - - Scenario1_Register.xaml + + Scenario1_Files.xaml + @@ -127,11 +123,13 @@ MSBuild:Compile Designer - + + Scenario1_Files.xaml MSBuild:Compile Designer - + + Scenario2_Memory.xaml MSBuild:Compile Designer @@ -167,20 +165,6 @@ Assets\windows-sdk.png - - - {b866a3f0-0d25-4146-9855-2c13c424f319} - Tasks - - - - - Microsoft Visual C++ 2013 Runtime Package for Windows Universal - - - Windows Mobile Extensions for the UWP - - 5.0.0 diff --git a/Samples/PersonalDataEncryption/cs/PersonalDataEncryption.sln b/Samples/PersonalDataEncryption/cs/PersonalDataEncryption.sln new file mode 100644 index 0000000000..71b1dcdbdd --- /dev/null +++ b/Samples/PersonalDataEncryption/cs/PersonalDataEncryption.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PersonalDataEncryption", "PersonalDataEncryption.csproj", "{69AB702D-59CB-4062-B010-5BFA49237536}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|ARM.ActiveCfg = Debug|ARM + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|ARM.Build.0 = Debug|ARM + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|ARM.Deploy.0 = Debug|ARM + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|x64.ActiveCfg = Debug|x64 + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|x64.Build.0 = Debug|x64 + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|x64.Deploy.0 = Debug|x64 + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|x86.ActiveCfg = Debug|x86 + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|x86.Build.0 = Debug|x86 + {69AB702D-59CB-4062-B010-5BFA49237536}.Debug|x86.Deploy.0 = Debug|x86 + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|ARM.ActiveCfg = Release|ARM + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|ARM.Build.0 = Release|ARM + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|ARM.Deploy.0 = Release|ARM + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|x64.ActiveCfg = Release|x64 + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|x64.Build.0 = Release|x64 + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|x64.Deploy.0 = Release|x64 + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|x86.ActiveCfg = Release|x86 + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|x86.Build.0 = Release|x86 + {69AB702D-59CB-4062-B010-5BFA49237536}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/PersonalDataEncryption/cs/SampleConfiguration.cs b/Samples/PersonalDataEncryption/cs/SampleConfiguration.cs new file mode 100644 index 0000000000..345ab714d8 --- /dev/null +++ b/Samples/PersonalDataEncryption/cs/SampleConfiguration.cs @@ -0,0 +1,34 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +using System; +using System.Collections.Generic; +using Windows.UI.Xaml.Controls; + +namespace SDKTemplate +{ + public partial class MainPage : Page + { + public const string FEATURE_NAME = "Personal Data Encryption"; + + List scenarios = new List + { + new Scenario() { Title="Files and folders", ClassType=typeof(Scenario1_Files)}, + new Scenario() { Title="Memory", ClassType=typeof(Scenario2_Memory)}, + }; + } + + public class Scenario + { + public string Title { get; set; } + public Type ClassType { get; set; } + } +} diff --git a/Samples/PersonalDataEncryption/cs/Scenario1_Files.xaml.cs b/Samples/PersonalDataEncryption/cs/Scenario1_Files.xaml.cs new file mode 100644 index 0000000000..357b5906a5 --- /dev/null +++ b/Samples/PersonalDataEncryption/cs/Scenario1_Files.xaml.cs @@ -0,0 +1,116 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +using System; +using Windows.Security.DataProtection; +using Windows.Storage; +using Windows.Storage.Pickers; +using Windows.System.Update; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; + +namespace SDKTemplate +{ + public sealed partial class Scenario1_Files : Page + { + private MainPage rootPage = MainPage.Current; + UserDataProtectionManager userDataProtectionManager = null; + IStorageItem selectedItem = null; + + public Scenario1_Files() + { + this.InitializeComponent(); + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + userDataProtectionManager = UserDataProtectionManager.TryGetDefault(); + if (userDataProtectionManager != null) + { + AvailablePanel.Visibility = Visibility.Visible; + UnavailablePanel.Visibility = Visibility.Collapsed; + } + else + { + AvailablePanel.Visibility = Visibility.Collapsed; + UnavailablePanel.Visibility = Visibility.Visible; + } + } + + private async void ChooseFile_Click(object sender, RoutedEventArgs e) + { + var picker = new FileOpenPicker(); + picker.FileTypeFilter.Add("*"); + UpdateItem(await picker.PickSingleFileAsync()); + } + + private async void ChooseFolder_Click(object sender, RoutedEventArgs e) + { + var picker = new FolderPicker(); + UpdateItem(await picker.PickSingleFolderAsync()); + } + + private void UpdateItem(IStorageItem item) + { + selectedItem = item; + if (selectedItem != null) + { + ItemOperationsPanel.Visibility = Visibility.Visible; + ItemNameBlock.Text = item.Path; + } + else + { + ItemOperationsPanel.Visibility = Visibility.Collapsed; + } + } + + private async void ProtectL1_Click(object sender, RoutedEventArgs e) + { + UserDataStorageItemProtectionStatus status = await userDataProtectionManager.ProtectStorageItemAsync(selectedItem, UserDataAvailability.AfterFirstUnlock); + ReportStatus("Protect L1", status); + } + + private async void ProtectL2_Click(object sender, RoutedEventArgs e) + { + UserDataStorageItemProtectionStatus status = await userDataProtectionManager.ProtectStorageItemAsync(selectedItem, UserDataAvailability.WhileUnlocked); + ReportStatus("Protect L2", status); + } + + private async void Unprotect_Click(object sender, RoutedEventArgs e) + { + UserDataStorageItemProtectionStatus status = await userDataProtectionManager.ProtectStorageItemAsync(selectedItem, UserDataAvailability.Always); + ReportStatus("Unprotect", status); + } + + private void ReportStatus(string operation, UserDataStorageItemProtectionStatus status) + { + switch (status) + { + case UserDataStorageItemProtectionStatus.Succeeded: + rootPage.NotifyUser(operation + " succeeded", NotifyType.StatusMessage); + break; + + case UserDataStorageItemProtectionStatus.NotProtectable: + rootPage.NotifyUser(operation + " failed: Not protectable", NotifyType.ErrorMessage); + break; + + case UserDataStorageItemProtectionStatus.DataUnavailable: + rootPage.NotifyUser(operation + " failed: Data unavailable", NotifyType.ErrorMessage); + break; + + default: + rootPage.NotifyUser(operation + " failed: Unknown failure", NotifyType.ErrorMessage); + break; + } + } + } +} diff --git a/Samples/PersonalDataEncryption/cs/Scenario2_Memory.xaml.cs b/Samples/PersonalDataEncryption/cs/Scenario2_Memory.xaml.cs new file mode 100644 index 0000000000..df77098393 --- /dev/null +++ b/Samples/PersonalDataEncryption/cs/Scenario2_Memory.xaml.cs @@ -0,0 +1,112 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +using System; +using Windows.Foundation; +using Windows.Security.Cryptography; +using Windows.Security.DataProtection; +using Windows.Storage.Streams; +using Windows.UI.ViewManagement; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Navigation; + +namespace SDKTemplate +{ + public sealed partial class Scenario2_Memory : Page + { + private MainPage rootPage = MainPage.Current; + UserDataProtectionManager userDataProtectionManager = null; + IBuffer protectedBuffer = null; + + public Scenario2_Memory() + { + this.InitializeComponent(); + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + userDataProtectionManager = UserDataProtectionManager.TryGetDefault(); + if (userDataProtectionManager != null) + { + AvailablePanel.Visibility = Visibility.Visible; + UnavailablePanel.Visibility = Visibility.Collapsed; + } + else + { + AvailablePanel.Visibility = Visibility.Collapsed; + UnavailablePanel.Visibility = Visibility.Visible; + } + } + + private async void ProtectL1_Click(object sender, RoutedEventArgs e) + { + string text = DataTextBox.Text; + if (text.Length == 0) + { + // Cannot protect a zero-length buffer. + rootPage.NotifyUser("Please enter data to protect", NotifyType.ErrorMessage); + return; + } + + IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8); + + IBuffer result = await userDataProtectionManager.ProtectBufferAsync(buffer, UserDataAvailability.AfterFirstUnlock); + ReportProtectedBuffer(result); + } + + private async void ProtectL2_Click(object sender, RoutedEventArgs e) + { + string text = DataTextBox.Text; + if (text.Length == 0) + { + // Cannot protect a zero-length buffer. + rootPage.NotifyUser("Please enter data to protect", NotifyType.ErrorMessage); + return; + } + + IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8); + + IBuffer result = await userDataProtectionManager.ProtectBufferAsync(buffer, UserDataAvailability.WhileUnlocked); + ReportProtectedBuffer(result); + } + + void ReportProtectedBuffer(IBuffer buffer) + { + protectedBuffer = buffer; + ProtectedDataTextBlock.Text = CryptographicBuffer.EncodeToHexString(buffer); + UnprotectPanel.Visibility = Visibility.Visible; + rootPage.NotifyUser(string.Empty, NotifyType.StatusMessage); + } + + private async void Unprotect_Click(object sender, RoutedEventArgs e) + { + UnprotectedDataTextBlock.Text = string.Empty; + UserDataBufferUnprotectResult result = await userDataProtectionManager.UnprotectBufferAsync(protectedBuffer); + switch (result.Status) + { + case UserDataBufferUnprotectStatus.Succeeded: + rootPage.NotifyUser("Unprotected successfully", NotifyType.StatusMessage); + UnprotectedDataTextBlock.Text = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, result.UnprotectedBuffer); + break; + + case UserDataBufferUnprotectStatus.Unavailable: + rootPage.NotifyUser("Unable to unprotect: Unavailable", NotifyType.ErrorMessage); + break; + + default: + rootPage.NotifyUser("Unable to unprotect: Unknown error", NotifyType.ErrorMessage); + break; + } + } + } +} diff --git a/Samples/PersonalDataEncryption/shared/Scenario1_Files.xaml b/Samples/PersonalDataEncryption/shared/Scenario1_Files.xaml new file mode 100644 index 0000000000..26b92b961f --- /dev/null +++ b/Samples/PersonalDataEncryption/shared/Scenario1_Files.xaml @@ -0,0 +1,52 @@ + + + + + + + + Protecting and unprotecting files and folders + + + Protecting and unprotecting a folder controls the protection of new files + created in the folder. It does not affect the protection of files which are already + present in the folder. + + + + - - -
- Status: Unknown -
-
Latitude: No data -
Longitude: No data -
Accuracy: No data -
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario2_GetPosition.html b/archived/Geolocation/js/geolocationjs/html/scenario2_GetPosition.html deleted file mode 100644 index 157e917214..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario2_GetPosition.html +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - -
-

Geolocation API allows application to take a one-shot reading of the current position.

-
- DesiredAccuracy (meters): - -
- - -
-
-
-
-
-
Latitude:
-
No data
-
Longitude:
-
No data
-
Accuracy:
-
No data
-
Source:
-
No data
-
PositionDilutionOfPrecision:
-
No data
-
HorizontalDilutionOfPrecision:
-
No data
-
VerticalDilutionOfPrecision:
-
No data
-
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario3_BackgroundTask.html b/archived/Geolocation/js/geolocationjs/html/scenario3_BackgroundTask.html deleted file mode 100644 index 2aa7ee4b0a..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario3_BackgroundTask.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - -
-

Control registration of a background task to read geolocation on a periodic timer. Upon initial registration (and if the application is enabled on the lock screen) the current position will be retrieved once in the foreground. If returning to - this scenario after already being registered, the application will wait for the background task to update the location.

- - -
-
- Latitude: No data -
Longitude: No data -
Accuracy: No data -
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario4_ForegroundGeofence.html b/archived/Geolocation/js/geolocationjs/html/scenario4_ForegroundGeofence.html deleted file mode 100644 index ce98e9ab3a..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario4_ForegroundGeofence.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - -
-
-

Description:

-
-

Geofence API allows applications to add, list, and remove geofences that will be monitored by the system.

-
-
-
-

Indicates Required Fields

- -
- -
- -
- -
- -
-
- -
-
- -
-
    -
  • - Format: d:hh:mm:ss -
      -
    • Example 1: 7:22:45:55 for 7 days, 22 hours, 45 minutes, 55 seconds
    • -
    • Example 2: 1:35 for 1 minute, 35 seconds
    • -
    • Example 3: 30 for 30 seconds
    • -
    -
  • -
-
-
-
- -
- -
-
-
- -
-
-
    -
  • - Format: mm/dd/yyyy hh:mm:ss -
      -
    • Example: 2/10/2014 22:45:07 for February 10, 2014 at 10:45:07 PM
    • -
    -
  • -
-
-
-
-
-

Registered Geofences

-
-
- (, , ) -
-
-
- -
-
- -

Events

-
-
-
-
-
- -
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario5_GeofenceBackgroundTask.html b/archived/Geolocation/js/geolocationjs/html/scenario5_GeofenceBackgroundTask.html deleted file mode 100644 index 4b5c667bb9..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario5_GeofenceBackgroundTask.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - -
-

Control registration of a background task to receive geofencing events. Geofences need to be created using the Foreground Geofencing scenario before background geofence events can occur.

- - -
-
-
-
Geofence Events
-
-
-
-
-
-
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario6_GetLastVisit.html b/archived/Geolocation/js/geolocationjs/html/scenario6_GetLastVisit.html deleted file mode 100644 index 3334dfb77e..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario6_GetLastVisit.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - -
-

Geolocation API allows application to get the last visit report.

- -
-
-
-
-
State change:
-
No data
-
Timestamp:
-
No data
-
Latitude:
-
No data
-
Longitude:
-
No data
-
Accuracy:
-
No data
-
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario7_ForegroundVisits.html b/archived/Geolocation/js/geolocationjs/html/scenario7_ForegroundVisits.html deleted file mode 100644 index 2d8ed423fa..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario7_ForegroundVisits.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - -
-

Geolocation API allows application to monitor user's visits in the foreground.

- - -
-
-
-
State change:
-
No data
-
Timestamp:
-
No data
-
Latitude:
-
No data
-
Longitude:
-
No data
-
Accuracy:
-
No data
-
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/html/scenario8_VisitsBackgroundTask.html b/archived/Geolocation/js/geolocationjs/html/scenario8_VisitsBackgroundTask.html deleted file mode 100644 index 426bb61b0f..0000000000 --- a/archived/Geolocation/js/geolocationjs/html/scenario8_VisitsBackgroundTask.html +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - -
-

Control registration of a background task to receive Visit state change events.

- - -
-
-
-
Visit Events
-
-
-
- -
-
-
-
-
- - - \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/images/badge-logo.png b/archived/Geolocation/js/geolocationjs/images/badge-logo.png deleted file mode 100644 index 21dc3cf866b5f230d7e7186710619374aed95113..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1133 zcmaJ>OK1~O6rFU`YBfc$_^E=A$)<{#PtrEY(AcJ#M1!W5G-`FBPG(-4p`Cf-%&VDH z7qNm`LGil~gcd;r6@Lp6TqwG7Aqct8$KxSVuPro1)s<9aB~YAO<^2fh`1CWc71GBoc8o0s%ik`0b*BWyf#WzKVhbZN<_|tRVxqigFGO;V46#{!T$R z=VT3gwoIg8oFki@!18WN6<|93f2gj{p>3RjfBgPa*v=MB$Yr37hAf2~T%XSkWr}eN z${1N$ga#{B?9L;M>^w3-yr%{1)C?6B>=|@AEv5_`%Z36|Qj{TlR?}25DFwr!WGoRD zVx5AJ;3HBv-WlN&&EZ%l-x8E6TnQ;dIy7*FtN!68t8(2&&`lCqf|hmws!0p!U?yQv ztL`OURd1H7R`()R<#NOf=N{`{$6VPWz2i>jnwBi)+8!FD*Dcc2tLde2av|QQq*&H@ zotv7TZm0d8W%NmpuQfJ)YhEc!Eqz1Z@iZv(igCy1^Sxg%a?j)4K}~+2eoB8ieBbja zeB)?n>S{f;tD$6+r>0-lF5;go{`sOl%-4+m=s4JrKYzTnv|$`3%N^eiQFkXi-e1OA?kzX!$a_0a5 diff --git a/archived/Geolocation/js/geolocationjs/js/backgroundtask.js b/archived/Geolocation/js/geolocationjs/js/backgroundtask.js deleted file mode 100644 index e3747dccd7..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/backgroundtask.js +++ /dev/null @@ -1,58 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -// A JavaScript background task runs a specified JavaScript file. -(function () { - "use strict"; - - // Get the background task instance's activation parameters - var backgroundTaskInstance = Windows.UI.WebUI.WebUIBackgroundTaskInstance.current; - var promise; - - // Associate a cancellation handler with the background task. - function onCanceled(cancelSender, cancelReason) { - if (promise) { - promise.operation.cancel(); - } - } - backgroundTaskInstance.addEventListener("canceled", onCanceled); - - var geolocator = new Windows.Devices.Geolocation.Geolocator(); - - promise = geolocator.getGeopositionAsync(); - promise.done( - function (pos) { - var coord = pos.coordinate; - - var settings = Windows.Storage.ApplicationData.current.localSettings; - settings.values["Status"] = coord.timestamp; - - settings.values["latitude"] = coord.point.position.latitude; - settings.values["longitude"] = coord.point.position.longitude; - settings.values["accuracy"] = coord.accuracy; - - backgroundTaskInstance.succeeded = true; - - // A JavaScript background task must call close when it is done - close(); - }, - function (err) { - var settings = Windows.Storage.ApplicationData.current.localSettings; - settings.values["Status"] = err.message; - - settings.values["latitude"] = "No data"; - settings.values["longitude"] = "No data"; - settings.values["accuracy"] = "No data"; - - backgroundTaskInstance.succeeded = false; - - // A JavaScript background task must call close when it is done - close(); - } - ); -})(); diff --git a/archived/Geolocation/js/geolocationjs/js/geofencebackgroundtask.js b/archived/Geolocation/js/geolocationjs/js/geofencebackgroundtask.js deleted file mode 100644 index 1fa7b4e0d3..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/geofencebackgroundtask.js +++ /dev/null @@ -1,192 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -// A JavaScript background task runs a specified JavaScript file. -(function () { - "use strict"; - var cancel = false; - - // Get the background task instance's activation parameters - var backgroundTaskInstance = Windows.UI.WebUI.WebUIBackgroundTaskInstance.current; - var promise; - - // Associate a cancellation handler with the background task. - function onCanceled(cancelSender, cancelReason) { - if (promise) { - promise.operation.cancel(); - } - } - backgroundTaskInstance.addEventListener("canceled", onCanceled); - - var geolocator = new Windows.Devices.Geolocation.Geolocator(); - var geofenceBackgroundEvents = new Array(); - var maxEventDescriptors = 42; // Value determined by how many max length event descriptors (91 chars) - // stored as a JSON string can fit in 8K (max allowed for local settings) - - backgroundTaskInstance.succeeded = false; - - getGeofenceStateChangedReports(Windows.Devices.Geolocation.Geofencing.GeofenceMonitor.current.lastKnownGeoposition); - - backgroundTaskInstance.succeeded = true; - - // A JavaScript background task must call close when it is done - close(); - - function getGeofenceStateChangedReports(pos) { - var monitor = Windows.Devices.Geolocation.Geofencing.GeofenceMonitor.current; - var posLastKnown = monitor.lastKnownGeoposition; - var coordLastKnown = posLastKnown.coordinate; - var eventDate = coordLastKnown.timestamp; - var calendarBackground = new Windows.Globalization.Calendar(); - var formatterLongTimeBackground = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", ["en-US"], "US", Windows.Globalization.CalendarIdentifiers.gregorian, Windows.Globalization.ClockIdentifiers.twentyFourHour); - var eventArray = new Array(); - var loop = 0; - var eventOfInterest = true; - var dateResolutionToSeconds = 1000; // conversion from 1 milli-second resolution to seconds - - fillEventCollectionWithExistingEvents(); - - // NOTE TO DEVELOPER: - // These events can be filtered out if the - // geofence event time is stale. - calendarBackground.setToNow(); - var nowDate = calendarBackground.getDateTime(); - var diffTimeSpan = nowDate.getTime() - eventDate.getTime(); - var deltaInSeconds = diffTimeSpan / dateResolutionToSeconds; - - // NOTE TO DEVELOPER: - // If the time difference between the geofence event and now is too large - // the eventOfInterest should be set to false. - - if (eventOfInterest) { - // NOTE TO DEVELOPER: - // This event can be filtered out if the - // geofence event location is too far away. - if ((posLastKnown.coordinate.point.position.latitude !== pos.coordinate.point.position.latitude) || - (posLastKnown.coordinate.point.position.longitude !== pos.coordinate.point.position.longitude)) { - // NOTE TO DEVELOPER: - // Use an algorithm like the Haversine formula or Vincenty's formulae to determine - // the distance between the current location (pos.coordinate) - // and the location of the geofence event (latitudeEvent/longitudeEvent). - // If too far apart set eventOfInterest to false to - // filter the event out. - } - - if (eventOfInterest) { - var eventItem = null; - var numEventsOfInterest = 0; - - Windows.Devices.Geolocation.Geofencing.GeofenceMonitor.current.readReports().forEach(function (report) { - var state = report.newState; - var geofence = report.geofence; - var id = geofence.id; - - eventItem = new String(report.geofence.id); - eventItem += " " + formatterLongTimeBackground.format(eventDate); - - if (state === Windows.Devices.Geolocation.Geofencing.GeofenceState.removed) { - var reason = report.removalReason; - - if (reason === Windows.Devices.Geolocation.Geofencing.GeofenceRemovalReason.expired) { - eventItem += " (Removed/Expired)"; - } else if (reason === Windows.Devices.Geolocation.Geofencing.GeofenceRemovalReason.used) { - eventItem += " (Removed/Used)"; - } - } else if (state === Windows.Devices.Geolocation.Geofencing.GeofenceState.entered) { - eventItem += " (Entered)"; - } else if (state === Windows.Devices.Geolocation.Geofencing.GeofenceState.exited) { - eventItem += " (Exited)"; - } - - addEventDescription(eventItem); - - numEventsOfInterest++; - }); - - if (eventOfInterest && 0 !== numEventsOfInterest) { - saveExistingEvents(); - - // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates. - doToast(numEventsOfInterest, eventItem); - } - } - } - } - - function doToast(numEventsOfInterestArg, eventName) { - // pop a toast for each geofence event - var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.createToastNotifier(); - - // Create a two line toast and add audio reminder - - // Here the xml that will be passed to the - // ToastNotification for the toast is retrieved - // toastXml is an XmlDocument object - var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(Windows.UI.Notifications.ToastTemplateType.toastText02); - - // Set both lines of text - // nodeList is an XmlNodeList object - var nodeList = toastXml.getElementsByTagName("text"); - nodeList.item(0).appendChild(toastXml.createTextNode("Geolocation Sample")); - - if (1 === numEventsOfInterestArg) { - nodeList.item(1).appendChild(toastXml.createTextNode(eventName)); - } else { - var secondLine = "There are " + numEventsOfInterestArg + " new geofence events"; - nodeList.item(1).appendChild(toastXml.createTextNode(secondLine)); - } - - // now create a xml node for the audio source - // toastNode is an IXmlNode object - var toastNode = toastXml.selectSingleNode("/toast"); - // audio is an XmlElement - var audio = toastXml.createElement("audio"); - audio.setAttribute("src", "ms-winsoundevent:Notification.SMS"); - - // toast is a ToastNotification object - var toast = new Windows.UI.Notifications.ToastNotification(toastXml); - toastNotifier.show(toast); - } - - function fillEventCollectionWithExistingEvents() { - // empty the background event array and repopulate - while (geofenceBackgroundEvents.length > 0) { - geofenceBackgroundEvents.pop(); - } - - var settings = Windows.Storage.ApplicationData.current.localSettings; - if (settings.values.hasKey("BackgroundGeofenceEventCollection")) { - var geofenceEvent = settings.values["BackgroundGeofenceEventCollection"].toString(); - - if (0 !== geofenceEvent.length) { - var events = JSON.parse(geofenceEvent); - - // NOTE: the events are accessed in reverse order - // because the events were added to JSON from - // newer to older. addEventDescription() adds - // each new entry to the beginning of the collection. - for (var pos = events.length - 1; pos >= 0; pos--) { - var element = events[pos].toString(); - addEventDescription(element); - } - } - } - } - - function saveExistingEvents() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - settings.values["BackgroundGeofenceEventCollection"] = JSON.stringify(geofenceBackgroundEvents); - } - - function addEventDescription(eventDescription) { - if (geofenceBackgroundEvents.length === maxEventDescriptors) { - geofenceBackgroundEvents.pop(); - } - geofenceBackgroundEvents.unshift(eventDescription); - } -})(); diff --git a/archived/Geolocation/js/geolocationjs/js/geofenceitem.js b/archived/Geolocation/js/geolocationjs/js/geofenceitem.js deleted file mode 100644 index c93c54bc1a..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/geofenceitem.js +++ /dev/null @@ -1,59 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -var GeofenceItem = WinJS.Class.define( - function (geofence) { - this.geofence = geofence; - }, { - id: { - get: function () { - return this.geofence.id; - } - }, - latitude: { - get: function () { - return this.geofence.geoshape.center.latitude; - } - }, - longitude: { - get: function () { - return this.geofence.geoshape.center.longitude; - } - }, - radius: { - get: function () { - return this.geofence.geoshape.radius; - } - }, - dwellTime: { - get: function () { - return this.geofence.dwellTime; - } - }, - singleUse: { - get: function () { - return this.geofence.singleUse; - } - }, - mask: { - get: function () { - return this.geofence.monitoredStates; - } - }, - duration: { - get: function () { - return this.geofence.duration; - } - }, - startTime: { - get: function () { - return this.geofence.startTime; - } - } - } -); diff --git a/archived/Geolocation/js/geolocationjs/js/sample-configuration.js b/archived/Geolocation/js/geolocationjs/js/sample-configuration.js deleted file mode 100644 index 3a353a77f1..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/sample-configuration.js +++ /dev/null @@ -1,43 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - "use strict"; - - var sampleTitle = "GeolocationJS"; - - var scenarios = [ - { url: "/html/scenario1_TrackPosition.html", title: "Track position" }, - { url: "/html/scenario2_GetPosition.html", title: "Get position" }, - { url: "/html/scenario3_BackgroundTask.html", title: "Get position in background task" }, - { url: "/html/scenario4_ForegroundGeofence.html", title: "Foreground Geofencing" }, - { url: "/html/scenario5_GeofenceBackgroundTask.html", title: "Background Geofencing" }, - { url: "/html/scenario6_GetLastVisit.html", title: "Get last visit" }, - { url: "/html/scenario7_ForegroundVisits.html", title: "Foreground visit monitoring" }, - { url: "/html/scenario8_VisitsBackgroundTask.html", title: "Background visit monitoring" }, - ]; - - // Namespace abbreviations. - var Geolocation = Windows.Devices.Geolocation; - - function toStateChangeString(stateChange) { - switch (stateChange) { - case Geolocation.VisitStateChange.arrived: - return "Arrived"; - case Geolocation.VisitStateChange.departed: - return "Departed"; - case Geolocation.VisitStateChange.otherMovement: - return "Other Movement"; - case Geolocation.VisitStateChange.trackingLost: - return "Tracking Lost"; - default: - return "unknown"; - } - } - - WinJS.Namespace.define("SdkSample", { - sampleTitle: sampleTitle, - scenarios: new WinJS.Binding.List(scenarios), - toStateChangeString: toStateChangeString - }); -})(); \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario1_TrackPosition.js b/archived/Geolocation/js/geolocationjs/js/scenario1_TrackPosition.js deleted file mode 100644 index dd3be07625..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario1_TrackPosition.js +++ /dev/null @@ -1,141 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - //"use strict"; - - var geolocator = null; - var disposed; - var page = WinJS.UI.Pages.define("/html/scenario1_TrackPosition.html", { - ready: function (element, options) { - disposed = false; - document.getElementById("startTrackingButton").addEventListener("click", starttracking, false); - document.getElementById("stopTrackingButton").addEventListener("click", stoptracking, false); - document.getElementById("startTrackingButton").disabled = false; - document.getElementById("stopTrackingButton").disabled = true; - }, - dispose: function () { - if (!disposed) { - disposed = true; - if (document.getElementById("startTrackingButton").disabled) { - geolocator.removeEventListener("positionchanged", onPositionChanged); - geolocator.removeEventListener("statuschanged", onStatusChanged); - } - } - } - }); - - function starttracking() { - Windows.Devices.Geolocation.Geolocator.requestAccessAsync().done( - function(accessStatus){ - switch(accessStatus) - { - case Windows.Devices.Geolocation.GeolocationAccessStatus.allowed: - // You should set MovementThreshold for distance-based tracking - // or ReportInterval for periodic-based tracking before adding event - // handlers. If none is set, a ReportInterval of 1 second is used - // as a default and a position will be returned every 1 second. - // - // Value of 2000 milliseconds (2 seconds) - // isn't a requirement, it is just an example. - geolocator = new Windows.Devices.Geolocation.Geolocator(); - geolocator.ReportInterval = 2000; - - // Subscribe to PositionChanged event to get updated tracking positions - geolocator.addEventListener("positionchanged", onPositionChanged); - - // Subscribe to StatusChanged event to get updates of location status changes - geolocator.addEventListener("statuschanged", onStatusChanged); - - WinJS.log && WinJS.log("Waiting for update...", "sample", "status"); - document.getElementById("startTrackingButton").disabled = true; - document.getElementById("stopTrackingButton").disabled = false; - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }, - function(err){ - WinJS.log && WinJS.log(err, "sample", "error"); - } - ); - } - - function stoptracking() { - geolocator.removeEventListener("positionchanged", onPositionChanged); - geolocator.removeEventListener("statuschanged", onStatusChanged); - geolocator = null; - - document.getElementById("startTrackingButton").disabled = false; - document.getElementById("stopTrackingButton").disabled = true; - - // Clear status - WinJS.log && WinJS.log("", "sample", "status"); - } - - function onPositionChanged(e) { - var coord = e.position.coordinate; - - WinJS.log && WinJS.log("Location updated", "sample", "status"); - - document.getElementById("latitude").innerText = coord.point.position.latitude; - document.getElementById("longitude").innerText = coord.point.position.longitude; - document.getElementById("accuracy").innerText = coord.accuracy; - } - - function onStatusChanged(e) { - switch (e.status) { - case Windows.Devices.Geolocation.PositionStatus.ready: - // Location platform is providing valid data. - document.getElementById("status").innerText = "Ready"; - WinJS.log && WinJS.log("Location platform is ready.", "sample", "status"); - break; - case Windows.Devices.Geolocation.PositionStatus.initializing: - // Location platform is attempting to acquire a fix. - document.getElementById("status").innerText = "Initializing"; - WinJS.log && WinJS.log("Location platform is attempting to obtain a position.", "sample", "status"); - break; - case Windows.Devices.Geolocation.PositionStatus.noData: - // Location platform could not obtain location data. - document.getElementById("status").innerText = "No data"; - WinJS.log && WinJS.log("Not able to determine the location.", "sample", "error"); - break; - case Windows.Devices.Geolocation.PositionStatus.disabled: - // The permission to access location data is denied by the user or other policies. - document.getElementById("status").innerText = "Disabled"; - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - - // Clear cached location data if any - document.getElementById("latitude").innerText = "No data"; - document.getElementById("longitude").innerText = "No data"; - document.getElementById("accuracy").innerText = "No data"; - break; - case Windows.Devices.Geolocation.PositionStatus.notInitialized: - // The location platform is not initialized. This indicates that the application has - // not made a request for location data. - document.getElementById("status").innerText = "Not initialized"; - WinJS.log && WinJS.log("No request for location is made yet.", "sample", "status"); - break; - case Windows.Devices.Geolocation.PositionStatus.notAvailable: - // The location platform is not available on this version of the OS. - document.getElementById("status").innerText = "Not available"; - WinJS.log && WinJS.log("Location is not available on this version of the OS.", "sample", "error"); - break; - default: - document.getElementById("status").innerText = "Unknown"; - WinJS.log && WinJS.log("", "sample", "status"); - break; - } - } -})(); \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario2_GetPosition.js b/archived/Geolocation/js/geolocationjs/js/scenario2_GetPosition.js deleted file mode 100644 index 0b055ca7c6..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario2_GetPosition.js +++ /dev/null @@ -1,179 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - "use strict"; - - var getGeopositionPromise; - var desiredAccuracyInMeters = 0; - - var disposed; - var page = WinJS.UI.Pages.define("/html/scenario2_GetPosition.html", { - ready: function (element, options) { - disposed = false; - document.getElementById("getGeopositionButton").addEventListener("click", getGeoposition, false); - document.getElementById("cancelGetGeopositionButton").addEventListener("click", cancelGetGeoposition, false); - document.getElementById("getGeopositionButton").disabled = false; - document.getElementById("cancelGetGeopositionButton").disabled = true; - document.getElementById("desiredAccuracyInMeters").addEventListener("keyup", getDesiredAccuracy); - }, - dispose: function () { - if (!disposed) { - disposed = true; - if (document.getElementById("getGeopositionButton").disabled) { - if (getGeopositionPromise) { - getGeopositionPromise.operation.cancel(); - } - } - } - } - }); - - function getGeoposition() { - document.getElementById("getGeopositionButton").disabled = true; - document.getElementById("cancelGetGeopositionButton").disabled = false; - - Windows.Devices.Geolocation.Geolocator.requestAccessAsync().done( - function (accessStatus) { - switch (accessStatus) { - case Windows.Devices.Geolocation.GeolocationAccessStatus.allowed: - - // If DesiredAccuracy or DesiredAccuracyInMeters are not set (or value is 0), DesiredAccuracy default is used. - var geolocator = new Windows.Devices.Geolocation.Geolocator(); - geolocator.desiredAccuracyInMeters = desiredAccuracyInMeters; - - getGeopositionPromise = geolocator.getGeopositionAsync(); - getGeopositionPromise.done( - function (pos) { - if (!disposed) { - WinJS.log && WinJS.log("Location updated", "sample", "status"); - - updateLocationData(pos); - document.getElementById("getGeopositionButton").disabled = false; - document.getElementById("cancelGetGeopositionButton").disabled = true; - } - }, - function (err) { - if (!disposed) { - WinJS.log && WinJS.log(err.message, "sample", "error"); - - updateLocationData(null); - document.getElementById("getGeopositionButton").disabled = false; - document.getElementById("cancelGetGeopositionButton").disabled = true; - } - } - ); - - WinJS.log && WinJS.log("Waiting for update...", "sample", "status"); - document.getElementById("getGeopositionButton").disabled = true; - document.getElementById("cancelGetGeopositionButton").disabled = false; - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }, - function (err) { - WinJS.log && WinJS.log(err, "sample", "error"); - }); - } - - function cancelGetGeoposition() { - if (getGeopositionPromise) { - getGeopositionPromise.operation.cancel(); - } - document.getElementById("getGeopositionButton").disabled = false; - document.getElementById("cancelGetGeopositionButton").disabled = true; - } - - function getDesiredAccuracy(evt) { - var e = document.getElementById("desiredAccuracyInMeters"); - var stringValue = e.value; - var value = parseInt(stringValue); - var nullAllowed = true; - var elementName = "Desired accuracy"; - - if (!value) { - var msg; - // value is either empty or alphabetic - if (0 !== stringValue.length) { - WinJS.log && WinJS.log("Desired accuracy must be a number.", "sample", "error"); - } - } else { - // update value - desiredAccuracyInMeters = value; - - // clear out status message - WinJS.log && WinJS.log("", "sample", "status"); - } - } - - function updateLocationData(pos) { - if (pos == null) { - document.getElementById("latitude").innerHTML = "No data"; - document.getElementById("longitude").innerHTML = "No data"; - document.getElementById("accuracy").innerHTML = "No data"; - document.getElementById("source").innerHTML = "No data"; - - // hide labels and satellite data - document.getElementById("positionLabel").style.opacity = 0; - document.getElementById("position").style.opacity = 0; - document.getElementById("horizontalLabel").style.opacity = 0; - document.getElementById("horizontal").style.opacity = 0; - document.getElementById("verticalLabel").style.opacity = 0; - document.getElementById("vertical").style.opacity = 0; - } else { - var coord = pos.coordinate; - document.getElementById("latitude").innerHTML = coord.point.position.latitude; - document.getElementById("longitude").innerHTML = coord.point.position.longitude; - document.getElementById("accuracy").innerHTML = coord.accuracy; - document.getElementById("source").innerHTML = toPositionSource(coord.positionSource); - - if (coord.positionSource === Windows.Devices.Geolocation.PositionSource.satellite) { - // show labels and satellite data - document.getElementById("positionLabel").style.opacity = 1; - document.getElementById("position").style.opacity = 1; - document.getElementById("horizontalLabel").style.opacity = 1; - document.getElementById("horizontal").style.opacity = 1; - document.getElementById("verticalLabel").style.opacity = 1; - document.getElementById("vertical").style.opacity = 1; - document.getElementById("position").innerHTML = coord.satelliteData.positionDilutionOfPrecision; - document.getElementById("horizontal").innerHTML = coord.satelliteData.horizontalDilutionOfPrecision; - document.getElementById("vertical").innerHTML = coord.satelliteData.verticalDilutionOfPrecision; - } else { - // hide labels and satellite data - document.getElementById("positionLabel").style.opacity = 0; - document.getElementById("position").style.opacity = 0; - document.getElementById("horizontalLabel").style.opacity = 0; - document.getElementById("horizontal").style.opacity = 0; - document.getElementById("verticalLabel").style.opacity = 0; - document.getElementById("vertical").style.opacity = 0; - } - } - } - - function toPositionSource(val) { - switch (val) { - case Windows.Devices.Geolocation.PositionSource.satellite: - return "Satellite"; - case Windows.Devices.Geolocation.PositionSource.wiFi: - return "Wifi"; - case Windows.Devices.Geolocation.PositionSource.cellular: - return "cellular"; - case Windows.Devices.Geolocation.PositionSource.ipAddress: - return "IPAddress"; - case Windows.Devices.Geolocation.PositionSource.unknown: - return "Unknown"; - } - } -})(); \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario3_BackgroundTask.js b/archived/Geolocation/js/geolocationjs/js/scenario3_BackgroundTask.js deleted file mode 100644 index 6d25819221..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario3_BackgroundTask.js +++ /dev/null @@ -1,187 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - "use strict"; - - var Background = Windows.ApplicationModel.Background; - var geolocTask; - var sampleBackgroundTaskName = "SampleLocationBackgroundTask"; - var sampleBackgroundTaskEntryPoint = "js\\backgroundtask.js"; - var disposed; - - var page = WinJS.UI.Pages.define("/html/scenario3_BackgroundTask.html", { - ready: function (element, options) { - disposed = false; - document.getElementById("registerBackgroundTaskButton").addEventListener("click", registerBackgroundTask, false); - document.getElementById("unregisterBackgroundTaskButton").addEventListener("click", unregisterBackgroundTask, false); - - // Loop through all background tasks to see if our task is already registered - var iter = Windows.ApplicationModel.Background.BackgroundTaskRegistration.allTasks.first(); - var hascur = iter.hasCurrent; - while (hascur) { - var cur = iter.current.value; - if (cur.name === sampleBackgroundTaskName) { - geolocTask = cur; - break; - } - hascur = iter.moveNext(); - } - - if (geolocTask) { - - // Associate an event handler to the existing background task - geolocTask.addEventListener("completed", onCompleted); - try { - var backgroundAccessStatus = Background.BackgroundExecutionManager.getAccessStatus(); - switch (backgroundAccessStatus) { - case Background.BackgroundAccessStatus.alwaysAllowed: - case Background.BackgroundAccessStatus.allowedSubjectToSystemPolicy: - WinJS.log && WinJS.log("Background task is already registered. Waiting for next update...", "sample", "status"); - break; - - default: - WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "status"); - break; - } - } catch (ex) { - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - - TimerTriggerBackgroundTask.updateButtonStates(/*registered:*/ true); - } else { - TimerTriggerBackgroundTask.updateButtonStates(/*registered:*/ false); - } - }, - dispose: function () { - if (!disposed) { - disposed = true; - - if (geolocTask) { - geolocTask.removeEventListener("completed", onCompleted); - } - } - } - }); - - // Handle background task completion - function onCompleted() { - try { - var settings = Windows.Storage.ApplicationData.current.localSettings; - - WinJS.log && WinJS.log(settings.values["Status"], "sample", "status"); - - document.getElementById("latitude").innerText = settings.values["Latitude"]; - document.getElementById("longitude").innerText = settings.values["Longitude"]; - document.getElementById("accuracy").innerText = settings.values["Accuracy"]; - } catch (ex) { - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - } - - function registerBackgroundTask() { - try { - // Get permission for a background task from the user. If the user has already answered once, - // this does nothing and the user must manually update their preference via PC Settings. - Background.BackgroundExecutionManager.requestAccessAsync().done( - function (backgroundAccessStatus) { - var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder(); - - // Regardless of the answer, register the background task. If the user later adds this application - // to the lock screen, the background task will be ready to run. - - // Create a new background task builder - builder.name = sampleBackgroundTaskName; - builder.taskEntryPoint = sampleBackgroundTaskEntryPoint; - - // Create a new timer triggering at a 15 minute interval - // Associate the timer trigger with the background task builder - builder.setTrigger(new Windows.ApplicationModel.Background.TimeTrigger(15, false)); - - // Register the background task - geolocTask = builder.register(); - - // Associate an event handler with the new background task - geolocTask.addEventListener("completed", onCompleted); - - TimerTriggerBackgroundTask.updateButtonStates(/*registered:*/ true); - - switch (backgroundAccessStatus) { - case Background.BackgroundAccessStatus.alwaysAllowed: - case Background.BackgroundAccessStatus.allowedSubjectToSystemPolicy: - WinJS.log && WinJS.log("Background task registered.", "sample", "status"); - - // Need to request access to location - // This must be done with the background task registration - // because the background task cannot display UI. - requestLocationAccess(); - break; - - default: - WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "error"); - break; - } - }, - function (e) { - // Did you forget to do the background task declaration in the package manifest? - WinJS.log && WinJS.log(e.toString(), "sample", "error"); - } - ); - } catch (ex) { - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - } - - function unregisterBackgroundTask() { - // Unregister the background task - if (geolocTask) { - geolocTask.unregister(true); - geolocTask = null; - } - - WinJS.log && WinJS.log("Background task unregistered", "sample", "status"); - - document.getElementById("latitude").innerHTML = "No data"; - document.getElementById("longitude").innerHTML = "No data"; - document.getElementById("accuracy").innerHTML = "No data"; - - TimerTriggerBackgroundTask.updateButtonStates(/*registered:*/ false); - } - - function requestLocationAccess() { - Windows.Devices.Geolocation.Geolocator.requestAccessAsync().done( - function (accessStatus) { - switch (accessStatus) { - case Windows.Devices.Geolocation.GeolocationAccessStatus.allowed: - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }, - function (err) { - WinJS.log && WinJS.log(err, "sample", "error"); - }); - } -})(); - -// Update the disabled state of the register/unregister buttons. -var TimerTriggerBackgroundTask = { - "updateButtonStates": function (registered) { - var registerButton = document.getElementById("registerBackgroundTaskButton"); - var unregisterButton = document.getElementById("unregisterBackgroundTaskButton"); - - registerButton && (registerButton.disabled = registered); - unregisterButton && (unregisterButton.disabled = !registered); - } -}; \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario4_ForegroundGeofence.js b/archived/Geolocation/js/geolocationjs/js/scenario4_ForegroundGeofence.js deleted file mode 100644 index f07c44d706..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario4_ForegroundGeofence.js +++ /dev/null @@ -1,578 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - // "use strict"; - var Globalization = Windows.Globalization; - var Geolocation = Windows.Devices.Geolocation; - var App = WinJS.Application; - - var formatterShortDateLongTime = new Globalization.DateTimeFormatting.DateTimeFormatter("{month.integer}/{day.integer}/{year.full} {hour.integer}:{minute.integer(2)}:{second.integer(2)}", ["en-US"], "US", Globalization.CalendarIdentifiers.gregorian, Globalization.ClockIdentifiers.twentyFourHour); - var defaultDwellTimeSeconds = 10; - var permissionsChecked = false; - var registeredGeofenceData = new WinJS.Binding.List(); - - // Value determined by how many max length event descriptors (91 chars) - // stored as a JSON string can fit in 8K (max allowed for local settings) - var maxEventDescriptors = 42; - var foregroundGeofenceEventCollectionKey = "ForegroundGeofenceEventCollection"; - var eventsData = new WinJS.Binding.List(); - - var geofenceMonitor = Geolocation.Geofencing.GeofenceMonitor.current; - var disposed; - - var page = WinJS.UI.Pages.define("/html/scenario4_ForegroundGeofence.html", { - ready: function (element, options) { - disposed = false; - permissionsChecked = false; - - // Request location permission and register for events if allowed - requestLocationAccess(); - - // register for visibility change event to know when the app is minimized - document.addEventListener("visibilitychange", onVisibilityChanged); - - // Display currently registered geofences in a ListView - var registeredGeofenceListView = document.querySelector('#RegisteredGeofenceListView').winControl; - registeredGeofenceListView.itemTemplate = RegisteredGeofencesItemTemplate; - registeredGeofenceListView.itemDataSource = registeredGeofenceData.dataSource; - registeredGeofenceListView.addEventListener("iteminvoked", function onRegisteredGeofenceListViewItemInvoked(eventInfo) { - eventInfo.detail.itemPromise.done(function completed(item) { - if (!disposed) { - registeredGeofenceListView.selection.set([item.index]); - - // update form values with the values from this geofence item - setInputValuesForGeofenceItem(item.data); - } - }); - }, false); - repopulateRegisteredGeofenceData(); - - // Display geofence event data in a ListView - var geofenceEventsListView = document.querySelector('#GeofenceEventsListView').winControl; - geofenceEventsListView.itemTemplate = GeofenceEventsItemTemplate; - geofenceEventsListView.itemDataSource = eventsData.dataSource; - repopulateEventData(); - - // Bind handlers to the input elements and buttons - validateInputValues(); - var createGeofence = document.getElementById("createGeofenceButton"); - createGeofence.addEventListener("click", function addGeofenceItem() { - - // Generate a geofence using the input data - var geofenceValues = getValidatedInputValuesForGeofence(); - var geofence = addGeofence(geofenceValues); - - if (geofence) { - // add geofence to listview - createGeofenceItemAndAddToListView(geofence); - WinJS.log && WinJS.log("", "sample", "status"); - } - }); - - var nameElement = document.getElementById("name"); - var charCount = document.getElementById("charCount"); - nameElement.addEventListener("input", function onNameChanged() { - // get number of characters - var value = nameElement.value; - if (value && value.length > 0) { - var count = value.length; - charCount.innerText = count.toString() + " characters"; - } else { - charCount.innerText = "0 characters"; - } - - validateInputValues(); - }); - - var latitude = document.getElementById("latitude"); - latitude.addEventListener("input", function onLatitudeChanged() { - validateInputValues(); - }); - - var longitude = document.getElementById("longitude"); - longitude.addEventListener("input", function onLongitudeChanged() { - validateInputValues(); - }); - - var radius = document.getElementById("radius"); - radius.addEventListener("input", function onRadiusChanged() { - validateInputValues(); - }); - - var setPositionToHereBtn = document.getElementById("setPositionToHereButton"); - setPositionToHereBtn.addEventListener("click", function setPositionToHere(eventObject) { - function showWaitingUI(waiting) { - // set cursor to wait style - document.body.style.cursor = waiting ? 'wait' : ""; - setPositionToHereBtn.style.cursor = waiting ? 'wait' : ""; - latitude.style.cursor = waiting ? 'wait' : ""; - longitude.style.cursor = waiting ? 'wait' : ""; - radius.style.cursor = waiting ? 'wait' : ""; - - // disable the boxes that are about to be filled - setPositionToHereBtn.disabled = !!waiting; - latitude.disabled = !!waiting; - longitude.disabled = !!waiting; - radius.disabled = !!waiting; - } - - showWaitingUI(true); - - getGeoposition().done( - function (pos) { - - // Verify that the scenario has not been thrown away - if (!disposed) { - var coord = pos.coordinate; - - // restore cursor and re-enable controls - showWaitingUI(false); - - // Update the values in the page - latitude.value = coord.point.position.latitude; - longitude.value = coord.point.position.longitude; - validateInputValues(); - - // Clear status - WinJS.log && WinJS.log("", "sample", "status"); - } - }, - function (err) { - if (!disposed) { - showWaitingUI(false); - WinJS.log && WinJS.log(err.message, "sample", "error"); - } - } - ); - }); - - var dwellTimeField = document.getElementById("dwellTime"); - dwellTimeField.addEventListener("focusout", function onDwellTimeChanged() { - var validatedValue = parseTimeSpan(dwellTimeField, defaultDwellTimeSeconds); - dwellTimeField.value = getDurationString(validatedValue); - }); - - var durationField = document.getElementById("duration"); - durationField.addEventListener("focusout", function onDurationChanged() { - var validatedValue = parseTimeSpan(durationField, 0); - durationField.value = getDurationString(validatedValue); - }); - - var setStartTimeToNow = document.getElementById("setStartTimeToNowButton"); - setStartTimeToNow.addEventListener("click", function onSetStartTimeToNow() { - var startTimeField = document.getElementById("startTime"); - var startTime = new Date(); // with no params the startTime is Now - startTimeField.value = formatterShortDateLongTime.format(startTime); - }); - - var removeGeofenceItem = document.getElementById("removeGeofenceItem"); - removeGeofenceItem.addEventListener("click", function removeSelectedGeofenceItems() { - registeredGeofenceListView.selection.getItems(). - done(function completed(result) { - for (var i = 0; i < result.length; i++) { - - // get selected item and remove it - var geofenceItem = result[i].data; - removeGeofence(geofenceItem.geofence); - - // Remove from ListView - var index = registeredGeofenceData.indexOf(geofenceItem); - registeredGeofenceData.splice(index, 1); - } - }); - }); - }, - dispose: function () { - - // unregister from geofence events - geofenceMonitor.removeEventListener("geofencestatechanged", onGeofenceStateChanged); - geofenceMonitor.removeEventListener("statuschanged", onGeofenceStatusChanged); - document.removeEventListener("visibilitychange", onVisibilityChanged); - - disposed = true; - - // save off the contents of the event collection - saveExistingEvents(); - } - }); - - function requestLocationAccess() { - Windows.Devices.Geolocation.Geolocator.requestAccessAsync().done( - function (accessStatus) { - switch (accessStatus) { - case Windows.Devices.Geolocation.GeolocationAccessStatus.allowed: - - // register for geofence state change events - geofenceMonitor.addEventListener("geofencestatechanged", onGeofenceStateChanged); - geofenceMonitor.addEventListener("statuschanged", onGeofenceStatusChanged); - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }, - function (err) { - WinJS.log && WinJS.log(err, "sample", "error"); - }); - } - - function addGeofence(geofenceValues) { - var geofence; - if (!disposed) { - - try { - var fenceKey = geofenceValues.fenceKey; - var singleUse = geofenceValues.singleUse; - var dwellTimeSpan = geofenceValues.dwellTimeSpan; - var startDateTime = geofenceValues.startDateTime; - var durationTimeSpan = geofenceValues.durationTimeSpan; - - // the geofence is a circular region - var geocircle = new Windows.Devices.Geolocation.Geocircle(geofenceValues.position, geofenceValues.radius); - - // mask to listen for enter geofence, exit geofence and remove geofence events - var mask = Windows.Devices.Geolocation.Geofencing.MonitoredGeofenceStates.entered - | Windows.Devices.Geolocation.Geofencing.MonitoredGeofenceStates.exited - | Windows.Devices.Geolocation.Geofencing.MonitoredGeofenceStates.removed; - - // Add the geofence to the GeofenceMonitor's collection of fences - geofence = new Windows.Devices.Geolocation.Geofencing.Geofence(fenceKey, geocircle, mask, singleUse, dwellTimeSpan, startDateTime, durationTimeSpan); - - geofenceMonitor.geofences.push(geofence); - return geofence; - } - catch (ex) { - WinJS.log && WinJS.log(ex.message, "sample", "error"); - return null; - } - } - } - - function removeGeofence(geofenceToRemoveArg) { - - // IVector.IndexOf returns two values - a Boolean return value and an index. - // Multiple return values for JS projections are modeled as an object. - var item = geofenceMonitor.geofences.indexOf(geofenceToRemoveArg); - if (item.returnValue) { - geofenceMonitor.geofences.removeAt(item.index); - WinJS.log && WinJS.log("", "sample", "status"); - } else { - var msg = "Could not find Geofence " + geofenceToRemoveArg.id + " in the geofences collection"; - WinJS.log && WinJS.log(msg, "sample", "status"); - } - } - - function onGeofenceStateChanged(args) { - args.target.readReports().forEach(function processReport(report) { - var state = report.newState; - var geofence = report.geofence; - var eventDescription = getTimeStampedMessage(geofence.id); - - if (state === Geolocation.Geofencing.GeofenceState.removed) { - var reason = report.removalReason; - - if (reason === Geolocation.Geofencing.GeofenceRemovalReason.expired) { - eventDescription += " (Removed/Expired)"; - } else if (reason === Geolocation.Geofencing.GeofenceRemovalReason.used) { - eventDescription += " (Removed/Used)"; - } - - // remove the geofence from the client side geofences collection - removeGeofence(geofence); - - // empty the registered geofence listbox and repopulate - repopulateRegisteredGeofenceData(); - } else if (state === Geolocation.Geofencing.GeofenceState.entered) { - - // NOTE: You might want to write your app to take particular - // action based on whether the app has internet connectivity. - eventDescription += " (Entered)"; - } else if (state === Geolocation.Geofencing.GeofenceState.exited) { - eventDescription += " (Exited)"; - } else { - eventDescription += " (Unknown)"; - } - - addEventDescription(eventDescription); - }); - } - - function onGeofenceStatusChanged(args) { - var eventDescription = getTimeStampedMessage("Geofence Status"); - var geofenceStatus = args.target.status; - - if (Geolocation.Geofencing.GeofenceMonitorStatus.ready === geofenceStatus) { - eventDescription += " (Ready)"; - } else if (Geolocation.Geofencing.GeofenceMonitorStatus.initializing === geofenceStatus) { - eventDescription += " (Initializing)"; - } else if (Geolocation.Geofencing.GeofenceMonitorStatus.noData === geofenceStatus) { - eventDescription += " (NoData)"; - } else if (Geolocation.Geofencing.GeofenceMonitorStatus.disabled === geofenceStatus) { - eventDescription += " (Disabled)"; - } else if (Geolocation.Geofencing.GeofenceMonitorStatus.notInitialized === geofenceStatus) { - eventDescription += " (NotInitialized)"; - } else if (Geolocation.Geofencing.GeofenceMonitorStatus.notAvailable === geofenceStatus) { - eventDescription += " (NotAvailable)"; - } else { - eventDescription += " (Unknown)"; - } - - addEventDescription(eventDescription); - } - - function onVisibilityChanged(eventObject) { - - // NOTE: After the app is no longer visible on the screen and before the app is suspended - // you might want your app to use toast notification for any geofence activity (not shown here). - // By registering for VisibiltyChanged the app is notified when the app is no longer visible in the foreground. - if (document.visibilityState === "visible") { - - // register for foreground events - geofenceMonitor.addEventListener("geofencestatechanged", onGeofenceStateChanged); - geofenceMonitor.addEventListener("statuschanged", onGeofenceStatusChanged); - } else { - - // unregister foreground events (let background capture events) - geofenceMonitor.removeEventListener("geofencestatechanged", onGeofenceStateChanged); - geofenceMonitor.removeEventListener("statuschanged", onGeofenceStatusChanged); - } - } - - function getGeoposition() { - var geolocator = new Windows.Devices.Geolocation.Geolocator(); - var promise = geolocator.getGeopositionAsync(); - promise.done(function (pos) { - if (!disposed) { - - // clear status - WinJS.log && WinJS.log("", "sample", "status"); - } - }, function (err) { - WinJS.log && WinJS.log(err.message, "sample", "error"); - } - ); - return promise; - } - - function getValidatedInputValuesForGeofence() { - var nameElement = document.getElementById("name"); - var longitude = document.getElementById("longitude"); - var latitude = document.getElementById("latitude"); - var radius = document.getElementById("radius"); - var startTimeField = document.getElementById("startTime"); - var dwellTimeField = document.getElementById("dwellTime"); - var durationField = document.getElementById("duration"); - var geofenceSingleUse = document.getElementById("geofenceSingleUse"); - - var inputValues = { - position: { - longitude: parseFloat(longitude.value), - latitude: parseFloat(latitude.value), - altitude: 0, - }, - radius: parseFloat(radius.value), - fenceKey: nameElement.value, - singleUse: !!geofenceSingleUse.checked, - dwellTimeSpan: parseTimeSpan(dwellTimeField, defaultDwellTimeSeconds), - startDateTime: new Date(startTimeField.value || Date.now()), - durationTimeSpan: parseTimeSpan(durationField, 0) - }; - return inputValues; - } - - function setInputValuesForGeofenceItem(item) { - if (item) { - var nameElement = document.getElementById("name"); - var latitude = document.getElementById("latitude"); - var longitude = document.getElementById("longitude"); - var radius = document.getElementById("radius"); - var startTimeField = document.getElementById("startTime"); - var dwellTimeField = document.getElementById("dwellTime"); - var durationField = document.getElementById("duration"); - var geofenceSingleUse = document.getElementById("geofenceSingleUse"); - nameElement.value = item.id; - latitude.value = item.latitude; - longitude.value = item.longitude; - radius.value = item.radius; - startTimeField.value = formatterShortDateLongTime.format(item.startTime); - dwellTimeField.value = getDurationString(item.dwellTime); - durationField.value = getDurationString(item.duration); - geofenceSingleUse.checked = item.singleUse; - - // Update flags used to enable Create Geofence button - validateInputValues(); - } - } - - function repopulateRegisteredGeofenceData() { - registeredGeofenceData.length = 0; - geofenceMonitor.geofences.forEach(createGeofenceItemAndAddToListView); - } - - function createGeofenceItemAndAddToListView(fence) { - var geofenceItem = new GeofenceItem(fence); - registeredGeofenceData.unshift(geofenceItem); - } - - function getTimeStampedMessage(eventCalled) { - return eventCalled + " " + (new Date().toLocaleTimeString()); - } - - function repopulateEventData() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - if (settings.values.hasKey(foregroundGeofenceEventCollectionKey)) { - try { - var geofenceEvent = settings.values[foregroundGeofenceEventCollectionKey]; - var events = JSON.parse(geofenceEvent); - - // NOTE: the events are accessed in reverse order - // because the events were added to JSON from - // newer to older. addEventDescription() adds - // each new entry to the beginning of the collection. - eventsData.length = 0; - for (var pos = events.length - 1; pos >= 0; pos--) { - var element = events[pos].toString(); - addEventDescription(element); - } - } finally { - settings.values[foregroundGeofenceEventCollectionKey] = null; - } - } - } - - function saveExistingEvents() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - var stringifiedEventData; - try { - stringifiedEventData = JSON.stringify(eventsData.map(function (item) { - return item; - })); - } finally { - settings.values[foregroundGeofenceEventCollectionKey] = stringifiedEventData; - } - } - - function addEventDescription(eventDescription) { - if (eventsData.length === maxEventDescriptors) { - eventsData.pop(); - } - eventsData.unshift(eventDescription); - } - - // Checks the input values to verify that enough information - // has been supplied to create a geofence - function validateInputValues() { - var nameElement = document.getElementById("name"); - var longitude = document.getElementById("longitude"); - var latitude = document.getElementById("latitude"); - var radius = document.getElementById("radius"); - - // validate name - var nameSet = (nameElement.value.length > 0); - - // validate GPS coordinates - var latitudeSet = validateFloatInput(latitude); - var longitudeSet = validateFloatInput(longitude); - var radiusSet = validateFloatInput(radius); - - // Update Create Geofence button - var isValid = nameSet && latitudeSet && longitudeSet && radiusSet; - document.getElementById("createGeofenceButton").disabled = !isValid; - - return isValid; - } - - // Utilities: - var secondsPerMinute = 60; - var secondsPerHour = 60 * secondsPerMinute; - var secondsPerDay = 24 * secondsPerHour; - var millisecondsPerSecond = 1000; - var TimeSpanFields = Object.freeze({ - day: 0, - hour: 1, - minute: 2, - second: 3 - }); - - function getDurationString(duration) { - function getTimeComponentAsString(timeComponent, appendLeadingZero) { - if (timeComponent < 10 && appendLeadingZero) { - return "0" + timeComponent; - } else { - return timeComponent; - } - } - - // note that double negation turns a float to an int - var totalSeconds = ~~(duration / millisecondsPerSecond); - var days = ~~(totalSeconds / secondsPerDay); - totalSeconds -= days * secondsPerDay; - var hours = ~~(totalSeconds / secondsPerHour); - totalSeconds -= hours * secondsPerHour; - var minutes = ~~(totalSeconds / secondsPerMinute); - totalSeconds -= minutes * secondsPerMinute; - var seconds = totalSeconds; - - var str = (days > 0) ? getTimeComponentAsString(days, false) + ":" : ""; - str += (hours > 0 || str.length > 0) ? getTimeComponentAsString(hours, (str.length > 0)) + ":" : ""; - str += (minutes > 0 || str.length > 0) ? getTimeComponentAsString(minutes, (str.length > 0)) + ":" : ""; - str += getTimeComponentAsString(seconds, (str.length > 0)); - - return str; - } - - function parseTimeSpan(field, defaultValue) { - var timeSpanValue = 0; - var parts = field.value.split(':'); - var numOfParts = parts.length; - if (numOfParts <= 4) { - for (var i = 0; i < numOfParts; i++) { - var currentPart = parts[i]; - if (currentPart.length > 0) { - switch (4 - numOfParts + i) { - case TimeSpanFields.day: - timeSpanValue += parseInt(currentPart) * secondsPerDay; - break; - case TimeSpanFields.hour: - timeSpanValue += parseInt(currentPart) * secondsPerHour; - break; - case TimeSpanFields.minute: - timeSpanValue += parseInt(currentPart) * secondsPerMinute; - break; - case TimeSpanFields.second: - timeSpanValue += parseInt(currentPart); - break; - } - } - } - } - - if (0 === timeSpanValue || isNaN(timeSpanValue)) { - timeSpanValue = defaultValue; - } - - timeSpanValue *= millisecondsPerSecond; - - return timeSpanValue; - } - - function validateFloatInput(inputElement) { - var stringValue = inputElement.value; - var parsedValue = parseFloat(stringValue); - if (!isNaN(parsedValue) && parsedValue.toString() !== stringValue) { - inputElement.value = parsedValue.toString(); - } - return !isNaN(parsedValue); - } -})(); \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario5_GeofenceBackgroundTask.js b/archived/Geolocation/js/geolocationjs/js/scenario5_GeofenceBackgroundTask.js deleted file mode 100644 index eb2b3123ad..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario5_GeofenceBackgroundTask.js +++ /dev/null @@ -1,255 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -// Custom templating function -var GeofenceBackgroundEventsItemTemplate = WinJS.Utilities.markSupportedForProcessing(function GeofenceBackgroundEventsItemTemplate(itemPromise) { - return itemPromise.then(function (currentItem) { - - // Build ListView Item Container div - var result = document.createElement("div"); - result.className = "GeofenceBackgroundEventsListViewItemStyle"; - - // Build content body - var body = document.createElement("div"); - - // Display title - if (currentItem.data) { - var title = document.createElement("h4"); - title.innerText = currentItem.data; - body.appendChild(title); - } - - // put the body into the ListView Item - result.appendChild(body); - - return result; - }); -}); - -(function () { - "use strict"; - var Background = Windows.ApplicationModel.Background; - - var sampleBackgroundTaskName = "SampleGeofencingBackgroundTask"; - var sampleBackgroundTaskEntryPoint = "js\\geofencebackgroundtask.js"; - var geofenceTask; - - var geofenceEventsData; - var geofenceEventsListView; - var disposed; - - var page = WinJS.UI.Pages.define("/html/scenario5_GeofenceBackgroundTask.html", { - ready: function (element, options) { - disposed = false; - document.getElementById("registerBackgroundTaskButton").addEventListener("click", registerBackgroundTask, false); - document.getElementById("unregisterBackgroundTaskButton").addEventListener("click", unregisterBackgroundTask, false); - - // Loop through all background tasks to see if our task is already registered - var iter = Windows.ApplicationModel.Background.BackgroundTaskRegistration.allTasks.first(); - var hascur = iter.hasCurrent; - while (hascur) { - var cur = iter.current.value; - if (cur.name === sampleBackgroundTaskName) { - geofenceTask = cur; - break; - } - hascur = iter.moveNext(); - } - - if (geofenceTask) { - // Associate an event handler to the existing background task - geofenceTask.addEventListener("completed", onCompleted); - - try { - var backgroundAccessStatus = Background.BackgroundExecutionManager.getAccessStatus(); - switch (backgroundAccessStatus) { - case Background.BackgroundAccessStatus.alwaysAllowed: - case Background.BackgroundAccessStatus.allowedSubjectToSystemPolicy: - WinJS.log && WinJS.log("Background task is already registered. Waiting for next update...", "sample", "status"); - break; - - default: - WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "status"); - break; - } - } catch (ex) { - - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - - LocationTriggerBackgroundTask.updateButtonStates(/*registered:*/ true); - } else { - LocationTriggerBackgroundTask.updateButtonStates(/*registered:*/ false); - } - - geofenceEventsData = new WinJS.Binding.List(); - geofenceEventsListView = element.querySelector('#GeofenceBackgroundEventsListView').winControl; - geofenceEventsListView.itemDataSource = geofenceEventsData.dataSource; - geofenceEventsListView.itemTemplate = GeofenceBackgroundEventsItemTemplate; - fillEventListBoxWithExistingEvents(); - }, - unload: function () { - if (!disposed) { - disposed = true; - } - } - }); - - WinJS.Navigation.addEventListener("navigated", function (eventObject) { - if (eventObject.detail.location === "/html/scenario5_GeofenceBackgroundTask.html") { - // add geofence event to listbox - fillEventListBoxWithExistingEvents(); - } - }); - - // Handle background task completion - function onCompleted() { - try { - // Update the UI with the completion status of the background task - // The Run method of the background task sets the LocalSettings. - var settings = Windows.Storage.ApplicationData.current.localSettings; - - // get status - if (settings.values.hasKey("Status")) { - WinJS.log && WinJS.log(settings.values["Status"].toString(), "sample", "status"); - } - - // add geofence event to listbox - fillEventListBoxWithExistingEvents(); - } catch (ex) { - // The background task had an error - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - } - - function registerBackgroundTask() { - try { - // Get permission for a background task from the user. If the user has already answered once, - // this does nothing and the user must manually update their preference via PC Settings. - Background.BackgroundExecutionManager.requestAccessAsync().done( - function (backgroundAccessStatus) { - var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder(); - - // Regardless of the answer, register the background task. If the user later adds this application - // to the lock screen, the background task will be ready to run. - // Create a new background task builder - builder.name = sampleBackgroundTaskName; - builder.taskEntryPoint = sampleBackgroundTaskEntryPoint; - - // Create a new location trigger - // Associate the locationi trigger with the background task builder - builder.setTrigger(new Windows.ApplicationModel.Background.LocationTrigger(Windows.ApplicationModel.Background.LocationTriggerType.geofence)); - - // If it is important that there is user presence and/or - // internet connection when OnCompleted is called - // the following could be called before calling Register() - // var condition = new SystemCondition(SystemConditionType.userPresent | SystemConditionType.internetAvailable); - // builder.addCondition(condition); - - // Register the background task - geofenceTask = builder.register(); - - // Associate an event handler with the new background task - geofenceTask.addEventListener("completed", onCompleted); - - LocationTriggerBackgroundTask.updateButtonStates(/*registered:*/ true); - - switch (backgroundAccessStatus) { - case Background.BackgroundAccessStatus.alwaysAllowed: - case Background.BackgroundAccessStatus.allowedSubjectToSystemPolicy: - WinJS.log && WinJS.log("Background task registered.", "sample", "status"); - - // Need to request access to location - // This must be done with the background task registration - // because the background task cannot display UI. - requestLocationAccess(); - break; - - default: - WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "error"); - break; - } - }, - function (e) { - // Did you forget to do the background task declaration in the package manifest? - WinJS.log && WinJS.log(e.toString(), "sample", "error"); - } - ); - } catch (ex) { - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - } - - function unregisterBackgroundTask() { - // Unregister the background task - if (geofenceTask) { - geofenceTask.unregister(true); - geofenceTask = null; - } - - WinJS.log && WinJS.log("Background task unregistered", "sample", "status"); - LocationTriggerBackgroundTask.updateButtonStates(/*registered:*/ false); - } - - function requestLocationAccess() { - Windows.Devices.Geolocation.Geolocator.requestAccessAsync().done( - function (accessStatus) { - switch (accessStatus) { - case Windows.Devices.Geolocation.GeolocationAccessStatus.allowed: - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }, - function (err) { - WinJS.log && WinJS.log(err, "sample", "error"); - }); - } - - function fillEventListBoxWithExistingEvents() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - if (settings.values.hasKey("BackgroundGeofenceEventCollection")) { - var geofenceEvent = settings.values["BackgroundGeofenceEventCollection"].toString(); - - if (0 !== geofenceEvent.length) { - // remove all entries and repopulate - while (geofenceEventsData.length > 0) { - geofenceEventsData.pop(); - } - - var events = JSON.parse(geofenceEvent); - - // NOTE: the events are accessed in reverse order - // because the events were added to JSON from - // newer to older. geofenceEventsData.unshift() adds - // each new entry to the beginning of the collection. - for (var pos = events.length - 1; pos >= 0; pos--) { - var element = events[pos].toString(); - geofenceEventsData.unshift(element); - } - } - } - } -})(); - -// Update the enable state of the register/unregister buttons. -var LocationTriggerBackgroundTask = { - "updateButtonStates": function (registered) { - var registerButton = document.getElementById("registerBackgroundTaskButton"); - var unregisterButton = document.getElementById("unregisterBackgroundTaskButton"); - - registerButton && (registerButton.disabled = registered); - unregisterButton && (unregisterButton.disabled = !registered); - } -}; \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario6_GetLastVisit.js b/archived/Geolocation/js/geolocationjs/js/scenario6_GetLastVisit.js deleted file mode 100644 index ddb946af0e..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario6_GetLastVisit.js +++ /dev/null @@ -1,101 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - "use strict"; - - // Namespace abbreviations. - var Geolocation = Windows.Devices.Geolocation; - - var getLastVisitButton; - var latitudeElement; - var longitudeElement; - var accuracyElement; - var timestampElement; - var statechangeElement; - - var page = WinJS.UI.Pages.define("/html/scenario6_GetLastVisit.html", { - ready: function (element, options) { - getLastVisitButton = document.getElementById("getLastVisitButton"); - latitudeElement = document.getElementById("latitude"); - longitudeElement = document.getElementById("longitude"); - accuracyElement = document.getElementById("accuracy"); - timestampElement = document.getElementById("timestamp"); - statechangeElement = document.getElementById("statechange"); - - getLastVisitButton.addEventListener("click", getLastVisit, false); - getLastVisitButton.disabled = false; - } - }); - - function getLastVisit() { - getLastVisitButton.disabled = true; - - Geolocation.Geolocator.requestAccessAsync().then(function (accessStatus) { - switch (accessStatus) { - case Geolocation.GeolocationAccessStatus.allowed: - - WinJS.log && WinJS.log("Waiting for update...", "sample", "status"); - getLastVisitButton.disabled = true; - - // Get the last visit report, if any. This should be a quick operation - return Geolocation.GeovisitMonitor.getLastReportAsync().then(function (visit) { - WinJS.log && WinJS.log("Visit info updated", "sample", "status"); - return visit; - }); - - case Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - case Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }).done(function (visit) { - updateLastVisit(visit); - getLastVisitButton.disabled = false; - }); - } - - function updateLastVisit(visit) { - if (!visit) { - latitudeElement.innerHTML = "No data"; - longitudeElement.innerHTML = "No data"; - accuracyElement.innerHTML = "No data"; - timestampElement.innerHTML = "No data"; - statechangeElement.innerHTML = "No data"; - } else { - statechangeElement.innerHTML = SdkSample.toStateChangeString(visit.stateChange); - - var dateTimeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate longtime"); - timestampElement.innerHTML = dateTimeFormatter.format(visit.timestamp); - - // Check if there is a valid position in the report. - if (visit.position === null) { - latitudeElement.innerHTML = "No data"; - longitudeElement.innerHTML = "No data"; - accuracyElement.innerHTML = "No data"; - } else { - var coord = visit.position.coordinate; - latitudeElement.innerHTML = coord.point.position.latitude; - longitudeElement.innerHTML = coord.point.position.longitude; - accuracyElement.innerHTML = coord.accuracy; - } - } - } - -})(); \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario7_ForegroundVisits.js b/archived/Geolocation/js/geolocationjs/js/scenario7_ForegroundVisits.js deleted file mode 100644 index d02d4dd0cc..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario7_ForegroundVisits.js +++ /dev/null @@ -1,114 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -(function () { - "use strict"; - - // Namespace abbreviations. - var Geolocation = Windows.Devices.Geolocation; - - var visitmonitor; - - var startMonitoringButton; - var stopMonitoringButton; - var latitudeElement; - var longitudeElement; - var accuracyElement; - var timestampElement; - var statechangeElement; - - var page = WinJS.UI.Pages.define("/html/scenario7_ForegroundVisits.html", { - ready: function (element, options) { - startMonitoringButton = document.getElementById("startMonitoringButton"); - stopMonitoringButton = document.getElementById("stopMonitoringButton"); - latitudeElement = document.getElementById("latitude"); - longitudeElement = document.getElementById("longitude"); - accuracyElement = document.getElementById("accuracy"); - timestampElement = document.getElementById("timestamp"); - statechangeElement = document.getElementById("statechange"); - - startMonitoringButton.addEventListener("click", startMonitoring, false); - stopMonitoringButton.addEventListener("click", stopMonitoring, false); - startMonitoringButton.disabled = false; - stopMonitoringButton.disabled = true; - }, - unload: function () { - if (visitmonitor) { - visitmonitor.stop(); - } - } - }); - - function startMonitoring() { - Geolocation.Geolocator.requestAccessAsync().done(function (accessStatus) { - switch (accessStatus) { - case Geolocation.GeolocationAccessStatus.allowed: - - visitmonitor = new Geolocation.GeovisitMonitor(); - - // Subscribe to state changed event to get visit state changes. - visitmonitor.addEventListener("visitstatechanged", onVisitStateChanged); - - // Start monitoring with the desired scope. - // For higher granularity such as building/venue level changes, choose venue. - // For lower granularity more or less in the range of zipcode level changes, choose city. - // Choosing Venue here as an example. - visitmonitor.start(Geolocation.VisitMonitoringScope.venue); - - WinJS.log && WinJS.log("Waiting for update...", "sample", "status"); - startMonitoringButton.disabled = true; - stopMonitoringButton.disabled = false; - break; - - case Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - default: - case Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }); - } - - function stopMonitoring() { - visitmonitor.stop(); - visitmonitor = null; - - startMonitoringButton.disabled = false; - stopMonitoringButton.disabled = true; - - // Clear status - WinJS.log && WinJS.log("", "sample", "status"); - } - - function onVisitStateChanged(args) { - WinJS.log && WinJS.log("Visit state changed", "sample", "status"); - - updateVisitData(args.visit); - } - - function updateVisitData(visit) { - statechangeElement.innerHTML = SdkSample.toStateChangeString(visit.stateChange); - var dateTimeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate longtime"); - timestampElement.innerHTML = dateTimeFormatter.format(visit.timestamp); - - // Check if the visit has a valid position. - if (!visit.position) { - latitudeElement.innerHTML = "No data"; - longitudeElement.innerHTML = "No data"; - accuracyElement.innerHTML = "No data"; - } else { - var coord = visit.position.coordinate; - latitudeElement.innerHTML = coord.point.position.latitude; - longitudeElement.innerHTML = coord.point.position.longitude; - accuracyElement.innerHTML = coord.accuracy; - } - } -})(); \ No newline at end of file diff --git a/archived/Geolocation/js/geolocationjs/js/scenario8_VisitsBackgroundTask.js b/archived/Geolocation/js/geolocationjs/js/scenario8_VisitsBackgroundTask.js deleted file mode 100644 index 02e4192aef..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/scenario8_VisitsBackgroundTask.js +++ /dev/null @@ -1,229 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -// Custom templating function -var VisitBackgroundEventsItemTemplate = WinJS.Utilities.markSupportedForProcessing(function VisitBackgroundEventsItemTemplate(itemPromise) { - return itemPromise.then(function (currentItem) { - - // Build ListView Item Container div - var result = document.createElement("div"); - result.className = "VisitBackgroundEventsListViewItemStyle"; - - // Build content body - var body = document.createElement("div"); - - // Display title - if (currentItem.data) { - var title = document.createElement("h4"); - title.innerText = currentItem.data; - body.appendChild(title); - } - - // put the body into the ListView Item - result.appendChild(body); - - return result; - }); -}); - -(function () { - "use strict"; - var Background = Windows.ApplicationModel.Background; - - var sampleBackgroundTaskName = "SampleVisitBackgroundTask"; - var sampleBackgroundTaskEntryPoint = "js\\visitbackgroundtask.js"; - var visitTask; - - var visitBackgroundEvents; - - var registerBackgroundTaskButton; - var unregisterBackgroundTaskButton; - - var page = WinJS.UI.Pages.define("/html/scenario8_VisitsBackgroundTask.html", { - ready: function (element, options) { - registerBackgroundTaskButton = document.getElementById("registerBackgroundTaskButton"); - unregisterBackgroundTaskButton = document.getElementById("unregisterBackgroundTaskButton"); - - registerBackgroundTaskButton.addEventListener("click", registerBackgroundTask, false); - unregisterBackgroundTaskButton.addEventListener("click", unregisterBackgroundTask, false); - - // Loop through all background tasks to see if our task is already registered - var iter = Background.BackgroundTaskRegistration.allTasks.first(); - var hascur = iter.hasCurrent; - while (hascur) { - var cur = iter.current.value; - if (cur.name === sampleBackgroundTaskName) { - visitTask = cur; - break; - } - hascur = iter.moveNext(); - } - - if (visitTask) { - // Associate an event handler to the existing background task - visitTask.addEventListener("completed", onCompleted); - - var backgroundAccessStatus = Background.BackgroundExecutionManager.getAccessStatus(); - switch (backgroundAccessStatus) { - case Background.BackgroundAccessStatus.alwaysAllowed: - case Background.BackgroundAccessStatus.allowedSubjectToSystemPolicy: - WinJS.log && WinJS.log("Background task is already registered. Waiting for next update...", "sample", "status"); - break; - - default: - WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "status"); - break; - } - updateButtonStates(/*registered:*/ true); - } else { - updateButtonStates(/*registered:*/ false); - } - - visitBackgroundEvents = new WinJS.Binding.List(); - var visitEventsListView = element.querySelector('#VisitBackgroundEventsListView').winControl; - visitEventsListView.itemDataSource = visitBackgroundEvents.dataSource; - visitEventsListView.itemTemplate = VisitBackgroundEventsItemTemplate; - fillEventListBoxWithExistingEvents(); - } - }); - - // Handle background task completion - function onCompleted() { - try { - // If the background task threw an exception, display the exception in - // the error text box. - visitTask.checkResult(); - - // add visit event to listbox - fillEventListBoxWithExistingEvents(); - } catch (ex) { - // The background task had an error - WinJS.log && WinJS.log(ex.toString(), "sample", "error"); - } - } - - function registerBackgroundTask() { - // Get permission for a background task from the user. If the user has already answered once, - // this does nothing and the user must manually update their preference via PC Settings. - Background.BackgroundExecutionManager.requestAccessAsync().done(function (backgroundAccessStatus) { - var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder(); - - // Regardless of the answer, register the background task. If the user later adds this application - // to the lock screen, the background task will be ready to run. - // Create a new background task builder - builder.name = sampleBackgroundTaskName; - builder.taskEntryPoint = sampleBackgroundTaskEntryPoint; - - // Create a new visit trigger - var trigger = new Windows.ApplicationModel.Background.GeovisitTrigger(); - - // Set the desired monitoring scope. - // For higher granularity such as venue/building level changes, choose venue. - // For lower granularity more or less in the range of zipcode level changes, choose city. - // Choosing Venue here as an example. - trigger.monitoringScope = Windows.Devices.Geolocation.VisitMonitoringScope.venue; - - // Associate the trigger with the background task builder - builder.setTrigger(trigger); - - // If it is important that there is user presence and/or - // internet connection when OnCompleted is called - // the following could be called before calling Register() - // var condition = new SystemCondition(SystemConditionType.userPresent | SystemConditionType.internetAvailable); - // builder.addCondition(condition); - - // Register the background task - visitTask = builder.register(); - - // Associate an event handler with the new background task - visitTask.addEventListener("completed", onCompleted); - - updateButtonStates(/*registered:*/ true); - - switch (backgroundAccessStatus) { - case Background.BackgroundAccessStatus.alwaysAllowed: - case Background.BackgroundAccessStatus.allowedSubjectToSystemPolicy: - WinJS.log && WinJS.log("Background task registered.", "sample", "status"); - - // Need to request access to location - // This must be done with the background task registration - // because the background task cannot display UI. - requestLocationAccess(); - break; - - default: - WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "error"); - break; - } - }); - } - - function unregisterBackgroundTask() { - // Unregister the background task - if (visitTask) { - visitTask.unregister(true); - visitTask = null; - } - - WinJS.log && WinJS.log("Background task unregistered", "sample", "status"); - - clearExistingEvents(); - - updateButtonStates(/*registered:*/ false); - } - - function requestLocationAccess() { - Windows.Devices.Geolocation.Geolocator.requestAccessAsync().done(function (accessStatus) { - switch (accessStatus) { - case Windows.Devices.Geolocation.GeolocationAccessStatus.allowed: - break; - - case Windows.Devices.Geolocation.GeolocationAccessStatus.denied: - WinJS.log && WinJS.log("Access to location is denied.", "sample", "error"); - break; - - default: - case Windows.Devices.Geolocation.GeolocationAccessStatus.unspecified: - WinJS.log && WinJS.log("Unspecified error!", "sample", "error"); - break; - } - }); - } - - // Update the enable state of the register/unregister buttons. - function updateButtonStates(registered) { - registerBackgroundTaskButton.disabled = registered; - unregisterBackgroundTaskButton.disabled = !registered; - } - - function fillEventListBoxWithExistingEvents() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - if (settings.values.hasKey("BackgroundVisitEventCollection")) { - var visitEvent = settings.values["BackgroundVisitEventCollection"].toString(); - - if (0 !== visitEvent.length) { - // remove all entries and repopulate - visitBackgroundEvents.splice(0, visitBackgroundEvents.length); - - var events = JSON.parse(visitEvent); - - events.forEach(function (element) { - visitBackgroundEvents.push(element.toString()); - }); - } - } - } - - function clearExistingEvents() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - settings.values["BackgroundVisitEventCollection"] = ""; - - // remove all background events - visitBackgroundEvents.splice(0, visitBackgroundEvents.length); - } -})(); diff --git a/archived/Geolocation/js/geolocationjs/js/visitbackgroundtask.js b/archived/Geolocation/js/geolocationjs/js/visitbackgroundtask.js deleted file mode 100644 index 29314af54d..0000000000 --- a/archived/Geolocation/js/geolocationjs/js/visitbackgroundtask.js +++ /dev/null @@ -1,165 +0,0 @@ -//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF -//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO -//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A -//// PARTICULAR PURPOSE. -//// -//// Copyright (c) Microsoft Corporation. All rights reserved -//// This code is licensed under the MIT License (MIT). - -// A JavaScript background task runs a specified JavaScript file. -(function () { - "use strict"; - var cancel = false; - - // Get the background task instance's activation parameters - var backgroundTaskInstance = Windows.UI.WebUI.WebUIBackgroundTaskInstance.current; - - // Trigger details contain the information surrounding the reason why the task was triggered. - var triggerDetails = backgroundTaskInstance.triggerDetails; - - var visitBackgroundEvents = []; - var maxEventDescriptors = 42; // Value determined by how many max length event descriptors (91 chars) - // stored as a JSON string can fit in 8K (max allowed for local settings) - - function run() { - backgroundTaskInstance.succeeded = false; - - // Get the visit reports from the trigger details. - getVisitReports(triggerDetails); - - backgroundTaskInstance.succeeded = true; - - // A JavaScript background task must call close when it is done - close(); - } - - function toStateChangeString(stateChange) { - switch (stateChange) { - case Windows.Devices.Geolocation.VisitStateChange.arrived: - return "Arrived"; - case Windows.Devices.Geolocation.VisitStateChange.departed: - return "Departed"; - case Windows.Devices.Geolocation.VisitStateChange.otherMovement: - return "Other Movement"; - case Windows.Devices.Geolocation.VisitStateChange.trackingLost: - return "Tracking Lost"; - default: - return "unknown"; - } - } - - function getVisitReports(triggerDetails) { - - var formatterLongTimeBackground = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("{hour.integer}:{minute.integer(2)}:{second.integer(2)}", ["en-US"], "US", Windows.Globalization.CalendarIdentifiers.gregorian, Windows.Globalization.ClockIdentifiers.twentyFourHour); - - // First, fill visitbackground reports with the previously saved reports from local settings. - fillReportCollectionWithExistingReports(); - - var eventItem; - - // Now read the new visit reports from triggerDetails. - var reports = triggerDetails.readReports(); - var numReports = reports.length; - - reports.forEach(function (report) { - - eventItem = formatterLongTimeBackground.format(report.timestamp); - - eventItem += " " + toStateChangeString(report.stateChange); - - if (report.position) { - eventItem += "(" + - String(report.position.coordinate.point.position.latitude) + "," + - String(report.position.coordinate.point.position.longitude) + - ")"; - } - - // Add each new visit report to visitbackground reports. - addVisitReport(eventItem); - }); - - if (numReports) { - saveExistingReports(); - - // NOTE: Other notification mechanisms can be used here, such as Badge and/or Tile updates. - doToast(numReports, eventItem); - } - - } - - function doToast(numReportsArg, eventName) { - // pop a toast for each visit event - var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.createToastNotifier(); - - // Create a two line toast and add audio reminder - - // Here the xml that will be passed to the - // ToastNotification for the toast is retrieved - // toastXml is an XmlDocument object - var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(Windows.UI.Notifications.ToastTemplateType.toastText02); - - // Set both lines of text - // nodeList is an XmlNodeList object - var nodeList = toastXml.getElementsByTagName("text"); - nodeList.item(0).appendChild(toastXml.createTextNode("Geolocation Sample")); - - if (1 === numReportsArg) { - nodeList.item(1).appendChild(toastXml.createTextNode(eventName)); - } else { - var secondLine = "There are " + numReportsArg + " new visit events"; - nodeList.item(1).appendChild(toastXml.createTextNode(secondLine)); - } - - // now create a xml node for the audio source - // toastNode is an IXmlNode object - var toastNode = toastXml.selectSingleNode("/toast"); - // audio is an XmlElement - var audio = toastXml.createElement("audio"); - audio.setAttribute("src", "ms-winsoundevent:Notification.SMS"); - - // toast is a ToastNotification object - var toast = new Windows.UI.Notifications.ToastNotification(toastXml); - toastNotifier.show(toast); - } - - function fillReportCollectionWithExistingReports() { - // empty the background event array and repopulate - while (visitBackgroundEvents.length > 0) { - visitBackgroundEvents.pop(); - } - - var settings = Windows.Storage.ApplicationData.current.localSettings; - if (settings.values.hasKey("BackgroundVisitEventCollection")) { - var visitEvent = settings.values["BackgroundVisitEventCollection"].toString(); - - if (0 !== visitEvent.length) { - var events = JSON.parse(visitEvent); - - // NOTE: the events are accessed in reverse order - // because the events were added to JSON from - // newer to older. addVisitReport() adds - // each new entry to the beginning of the collection - // and throws away the last entry if the collection gets too large. - for (var pos = events.length - 1; pos >= 0; pos--) { - var element = events[pos].toString(); - addVisitReport(element); - } - } - } - } - - function saveExistingReports() { - var settings = Windows.Storage.ApplicationData.current.localSettings; - settings.values["BackgroundVisitEventCollection"] = JSON.stringify(visitBackgroundEvents); - } - - function addVisitReport(eventDescription) { - if (visitBackgroundEvents.length === maxEventDescriptors) { - visitBackgroundEvents.pop(); - } - visitBackgroundEvents.unshift(eventDescription); - } - - // Do the background task work. - run(); -})(); diff --git a/archived/Geolocation/js/geolocationjs/sample-utils/placeholder.txt b/archived/Geolocation/js/geolocationjs/sample-utils/placeholder.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/archived/PhoneCall/README.md b/archived/PhoneCall/README.md deleted file mode 100644 index aec4d71ae0..0000000000 --- a/archived/PhoneCall/README.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -topic: sample -languages: -- csharp -products: -- windows -- windows-uwp -urlFragment: PhoneCall -extendedZipContent: -- path: SharedContent - target: SharedContent -- path: LICENSE - target: LICENSE -description: "Shows how to use the Calls APIs." ---- - - - -# Phone call sample - -Shows how to use the [Calls](https://msdn.microsoft.com/library/windows/apps/windows.applicationmodel.calls.aspx) APIs. -This sample does not follow the typical sample template pattern, it is a sample app that uses the MWC pattern to give you a working E2E phone call application to start with. - -> **Note:** This sample is part of a large collection of UWP feature samples. -> You can download this sample as a standalone ZIP file -> [from docs.microsoft.com](https://docs.microsoft.com/samples/microsoft/windows-universal-samples/phonecall/), -> or you can download the entire collection as a single -> [ZIP file](https://github.com/Microsoft/Windows-universal-samples/archive/master.zip), but be -> sure to unzip everything to access shared dependencies. For more info on working with the ZIP file, -> the samples collection, and GitHub, see [Get the UWP samples from GitHub](https://aka.ms/ovu2uq). -> For more samples, see the [Samples portal](https://aka.ms/winsamples) on the Windows Dev Center. - -**Note:** This is a mobile only sample. - -This sample allows the user to: - -- Query phone line information -- Query phone call status -- Query voice mail information -- Place phone calls (Single and Multi-SIM) - -The app UI represents the following tabs: - -### Status tab - -This focuses on accessing basic phone line information. - -### Contacts tab - -This focuses on contacts integration with your own phone call app. - -### Dialer tab - -This is a dialer that allows users to place a phone call. - -### Voice mail tab - -This focuses on accessing voice mail information and placing calls to the user's voice mail. - -## System requirements - -**Client:** Not supported - -**Server:** Not supported - -**Phone:** Windows 10 - -## Build the sample - -1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. -2. Start Microsoft Visual Studio and select **File** \> **Open** \> **Project/Solution**. -3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio Solution (.sln) file. -4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. - -## Run the sample - -The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it. - -### Deploying the sample - -- Select Build > Deploy Solution. - -### Deploying and running the sample - -- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or selectDebug > Start Without Debugging. - diff --git a/archived/PhoneCall/cs/App.xaml b/archived/PhoneCall/cs/App.xaml deleted file mode 100644 index 649ff2d196..0000000000 --- a/archived/PhoneCall/cs/App.xaml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - diff --git a/archived/PhoneCall/cs/App.xaml.cs b/archived/PhoneCall/cs/App.xaml.cs deleted file mode 100644 index 67f1731c1d..0000000000 --- a/archived/PhoneCall/cs/App.xaml.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.UI.Core; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - -namespace PhoneCall -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - // Enables the old back button behavior by overriding the hardware button - private void App_BackRequested(object sender, BackRequestedEventArgs e) - { - Frame rootFrame = Window.Current.Content as Frame; - if (rootFrame == null) - return; - - // If we can go back and the event has not already been handled, do so. - if (rootFrame.CanGoBack && e.Handled == false) - { - e.Handled = true; - rootFrame.GoBack(); - } - } - - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs e) - { - -#if DEBUG - if (System.Diagnostics.Debugger.IsAttached) - { - this.DebugSettings.EnableFrameRateCounter = true; - } -#endif - - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active - Window.Current.Activate(); - - // Registering the back button behavior - SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity - deferral.Complete(); - } - } -} diff --git a/archived/PhoneCall/cs/Assets/defaultContact.png b/archived/PhoneCall/cs/Assets/defaultContact.png deleted file mode 100644 index a9ede744b3a781252e16c0daf7eec2a99077518d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 377 zcmeAS@N?(olHy`uVBq!ia0vp^av;pX1|+Qw)-3{3Ea{HEjtmSN`?>!lvI6;>1s;*b z3=DjSK$uZf!>a)(C{f}XQ4*Y=R#Ki=l*&+$n3-3imzP?iV4`QBXPVk-lnPYy-P6S} z#KZgT)Qw!t1_BPhpU*52C@B(Vm%S5mA@E?nrihgX_d=_wW^YCLgLd9X>RoEW&fhfs zPWPk=>0>i~u(|D#a@)hPEw{W-=KUdqH!EyDOuX^gW?t&eg{xK-Up8UNydCCnU`7FW=EKqboA$^rk9} zxM@#0xfCiAwsgib&gI?}7JFU1GWnCgYj;HJ9k0tKdxMG_jvjrVbY%6%{3Nx!wF?gZ VeRQ_#CNKyXJYD@<);T3K0RU~Dmr?)# diff --git a/archived/PhoneCall/cs/Controls/ContactsPanel.xaml b/archived/PhoneCall/cs/Controls/ContactsPanel.xaml deleted file mode 100644 index 0b98c92161..0000000000 --- a/archived/PhoneCall/cs/Controls/ContactsPanel.xaml +++ /dev/null @@ -1,201 +0,0 @@ - - - - - - - - - - - - - - - - - - - - This is a sample showing contact integration into your phone app. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archived/PhoneCall/cs/Controls/ContactsPanel.xaml.cs b/archived/PhoneCall/cs/Controls/ContactsPanel.xaml.cs deleted file mode 100644 index a056cf88fc..0000000000 --- a/archived/PhoneCall/cs/Controls/ContactsPanel.xaml.cs +++ /dev/null @@ -1,60 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using PhoneCall.Helpers; -using PhoneCall.ViewModels; -using Windows.UI.Xaml.Controls; - -// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 - -namespace PhoneCall.Controls -{ - public sealed partial class ContactsPanel : UserControl - { - ContactsViewModel contactsVM; - - /// - /// A user control that hosts the contacts panel within the main pivot/tab. - /// - public ContactsPanel() - { - this.InitializeComponent(); - contactsVM = ViewModelDispatcher.ContactsViewModel; - DataContext = contactsVM; - } - - /// - /// Gets the string from the text box in the contacts pane - /// and sendds it to the VM to processes contact search. - /// - private void OnSearchInputchanged(object sender, TextChangedEventArgs e) - { - contactsVM.ProcessContactSearchAsync(ContactSearchBox.Text); - } - - /// - /// Open a contacts page upon click. - /// - private void OnContactItemClick(object sender, ItemClickEventArgs e) - { - contactsVM.ProcessOpenContactAsync((ContactItem)e.ClickedItem); - } - - /// - /// Collapses all unncessary elements when the user is in semantic zoom out mode - /// This allows the alphabet grid to be displayed in a bigger space. - /// - private void UpdateCollapseState(object sender, SemanticZoomViewChangedEventArgs e) - { - contactsVM.MaximizeSemanticZoomOut(ContactGroupView.IsZoomedInViewActive); - } - } -} diff --git a/archived/PhoneCall/cs/Controls/DialerPanel.xaml b/archived/PhoneCall/cs/Controls/DialerPanel.xaml deleted file mode 100644 index 31ce004f7a..0000000000 --- a/archived/PhoneCall/cs/Controls/DialerPanel.xaml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/archived/PhoneCall/cs/Controls/DialerPanel.xaml.cs b/archived/PhoneCall/cs/Controls/DialerPanel.xaml.cs deleted file mode 100644 index 96f24c0992..0000000000 --- a/archived/PhoneCall/cs/Controls/DialerPanel.xaml.cs +++ /dev/null @@ -1,65 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Controls; -using PhoneCall.ViewModels; - -// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 - -namespace PhoneCall.Controls -{ - public sealed partial class DialerPanel : UserControl - { - /// - /// A user control that hosts the dial panel within the main pivot/tab. - /// - public DialerPanel() - { - this.InitializeComponent(); - DataContext = ViewModelDispatcher.DialerViewModel; - setDialPadHeight(); - } - - /// - /// sets the dialpad control height based on screen resolution. - /// - private void setDialPadHeight() - { - var bounds = Window.Current.Bounds; - int windowHeight = (int)bounds.Height; - Dialpad.Height = windowHeight - 350; - } - - /// - /// Auto scrolls the dialer number heap to the end for long phone numbers. - /// - private void OnDialerNumberControlSizeChanged(object sender, SizeChangedEventArgs e) - { - double scrollToEndOffset = dialerNumberControlScrollviewer.ScrollableWidth; - dialerNumberControlScrollviewer.ChangeView(scrollToEndOffset,null,null); - } - - /// - /// Processes press and hold for the back button - /// This clears the dialer number heap all at once. - /// - private void OnBackspaceHolding(object sender, HoldingRoutedEventArgs e) - { - DialerViewModel vm = (DialerViewModel)DataContext; - if ((vm != null) && (e.HoldingState == Windows.UI.Input.HoldingState.Started)) - { - vm.ProcessBackSpaceHolding.Execute(null); - } - } - } -} diff --git a/archived/PhoneCall/cs/Controls/Dialpad.xaml b/archived/PhoneCall/cs/Controls/Dialpad.xaml deleted file mode 100644 index 2bbc2f3a57..0000000000 --- a/archived/PhoneCall/cs/Controls/Dialpad.xaml +++ /dev/null @@ -1,146 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/archived/PhoneCall/cs/Controls/Dialpad.xaml.cs b/archived/PhoneCall/cs/Controls/Dialpad.xaml.cs deleted file mode 100644 index 2af86d0026..0000000000 --- a/archived/PhoneCall/cs/Controls/Dialpad.xaml.cs +++ /dev/null @@ -1,47 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using PhoneCall.ViewModels; -using Windows.UI.Xaml.Controls; - -// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 - -namespace PhoneCall.Controls -{ - public sealed partial class Dialpad : UserControl - { - /// - /// A user control that hosts the dial pad in the dial panel. - /// - public Dialpad() - { - this.InitializeComponent(); - } - - /// - /// Processes press and hold for the buttons that supports press and hold. E.g - /// 1 -> Voicemail - /// 0 -> + - /// * -> , (pause) - /// # -> ; (wait) - /// - private void OnDialPadHolding(object sender, Windows.UI.Xaml.Input.HoldingRoutedEventArgs e) - { - Button button = (Button)sender; - DialerViewModel vm = (DialerViewModel)DataContext; - if ((vm != null) && (e.HoldingState == Windows.UI.Input.HoldingState.Started)) - { - vm.ProcessDialPadHolding.Execute(button.Tag); - } - - } - } -} diff --git a/archived/PhoneCall/cs/Controls/LinePicker.xaml b/archived/PhoneCall/cs/Controls/LinePicker.xaml deleted file mode 100644 index f9d0cd3946..0000000000 --- a/archived/PhoneCall/cs/Controls/LinePicker.xaml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/archived/PhoneCall/cs/Controls/LinePicker.xaml.cs b/archived/PhoneCall/cs/Controls/LinePicker.xaml.cs deleted file mode 100644 index 53d5742264..0000000000 --- a/archived/PhoneCall/cs/Controls/LinePicker.xaml.cs +++ /dev/null @@ -1,61 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using System; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using PhoneCall.ViewModels; - - -// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 - -namespace PhoneCall.Controls -{ - public sealed partial class LinePicker : UserControl - { - LinePickerViewModel linePickerVM; - - /// - /// A user control that hosts the line picker used in all the panels but contact. - /// - public LinePicker() - { - this.InitializeComponent(); - linePickerVM = ViewModelDispatcher.LinePickerViewModel; - DataContext = linePickerVM; - } - - /// - /// Tap event that shows our custom bindable fly out. - /// - private void ShowLinePickerFlyout(object sender, TappedRoutedEventArgs e) - { - FrameworkElement senderElement = sender as FrameworkElement; - FlyoutBase flyoutBase = FlyoutBase.GetAttachedFlyout(senderElement); - - flyoutBase.Placement = FlyoutPlacementMode.Bottom; - flyoutBase.ShowAt(senderElement); - } - - /// - /// upddates the line in calling info when the user switches the line in the UI. - /// - private void onLinePickerChange(object sender, RoutedEventArgs e) - { - MenuFlyoutItem LinePickerItem = (MenuFlyoutItem)sender; - Guid LineGuid = (Guid)LinePickerItem.CommandParameter; - linePickerVM.ChangePhoneLine(LineGuid); - LinePickerFlyout.Hide(); - } - } -} diff --git a/archived/PhoneCall/cs/Controls/StatusPanel.xaml b/archived/PhoneCall/cs/Controls/StatusPanel.xaml deleted file mode 100644 index 5bb87e3afa..0000000000 --- a/archived/PhoneCall/cs/Controls/StatusPanel.xaml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - This is a sample of accessing basic calling information. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/archived/PhoneCall/cs/Controls/StatusPanel.xaml.cs b/archived/PhoneCall/cs/Controls/StatusPanel.xaml.cs deleted file mode 100644 index 9331809edd..0000000000 --- a/archived/PhoneCall/cs/Controls/StatusPanel.xaml.cs +++ /dev/null @@ -1,32 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using Windows.UI.Xaml.Controls; -using PhoneCall.ViewModels; - -// The User Control item template is documented at http://go.microsoft.com/fwlink/?LinkId=234236 - -namespace PhoneCall.Controls -{ - public sealed partial class StatusPanel : UserControl - { - StatusViewModel statusVM; - - /// - /// A user control that hosts the status panel in the main pivot/tab. - /// - public StatusPanel() - { - this.InitializeComponent(); - statusVM = ViewModelDispatcher.StatusViewModel; - } - } -} diff --git a/archived/PhoneCall/cs/Controls/VoicemailPanel.xaml b/archived/PhoneCall/cs/Controls/VoicemailPanel.xaml deleted file mode 100644 index 0c58c428fd..0000000000 --- a/archived/PhoneCall/cs/Controls/VoicemailPanel.xaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - This is a sample of accessing voicemail information. - - - - - - - - - - - - - -