From 17b1dbd0985d3241582381fb50608e0449cc2537 Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Mon, 30 Nov 2015 10:54:43 -0800 Subject: [PATCH] Windows 10 Version 1511 Samples --- README.md | 5 +- .../ActivitySensor/js/ActivitySensor.jsproj | 138 +++++ Samples/ActivitySensor/js/ActivitySensor.sln | 40 ++ .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-us}/placeholder.txt | 0 .../ActivitySensor/js/Package.appxmanifest | 57 ++ .../js/css/placeholder.txt | 0 .../js/html/scenario1-currentActivity.html | 26 + .../js/html/scenario2-history.html | 29 + .../js/html/scenario3-changeEvents.html | 27 + .../js/html/scenario4-backgroundActivity.html | 30 ++ .../js/images/placeholder.txt | 0 .../js/js/activitySensorBackgroundTask.js | 55 ++ .../js/js/sample-configuration.js | 92 ++++ .../js/js/scenario1-currentActivity.js | 37 ++ .../ActivitySensor/js/js/scenario2-history.js | 46 ++ .../js/js/scenario3-changeEvents.js | 70 +++ .../js/js/scenario4-backgroundActivity.js | 138 +++++ .../js/sample-utils/placeholder.txt | 0 .../cpp/BackgroundTask/BackgroundTask.vcxproj | 4 +- .../cpp/BackgroundTask/Package.appxmanifest | 2 +- .../Scenario5_ApplicationTriggerTask.xaml.cpp | 3 +- .../BackgroundTask/cpp/Tasks/Tasks.vcxproj | 4 +- .../Scenario5_ApplicationTriggerTask.xaml.cs | 3 +- .../Scenario5_ApplicationTriggerTask.xaml.vb | 2 +- .../cs/CompositionVisual.csproj | 6 +- .../CompositionVisual/cs/Package.appxmanifest | 6 +- .../CompositionVisual/cs/VisualProperties.cs | 10 +- .../vb/CompositionVisual.vbproj | 4 +- .../CompositionVisual/vb/Package.appxmanifest | 6 +- .../CompositionVisual/vb/VisualProperties.vb | 10 +- .../AdventureWorks.Shared.vcxproj | 4 +- .../cpp/AdventureWorks/AdventureWorks.vcxproj | 23 +- .../AdventureWorks.vcxproj.filters | 20 +- .../cpp/AdventureWorks/Package.appxmanifest | 6 +- .../Strings/en-AU/placeholder.txt | 0 .../Strings/en-CA/placeholder.txt | 0 .../Strings/en-IN/placeholder.txt | 0 .../AdventureWorks/adventureworkscommands.xml | 253 --------- .../AdventureworksVoiceCommandService.cpp | 38 +- .../AdventureworksVoiceCommandService.h | 10 +- .../VoiceCommandService.vcxproj | 4 +- .../AdventureWorks.Model.csproj | 4 +- .../cs/AdventureWorks/AdventureWorks.csproj | 23 +- .../cs/AdventureWorks/Package.appxmanifest | 2 +- .../Strings/en-AU/placeholder.txt | 0 .../Strings/en-CA/placeholder.txt | 0 .../Strings/en-IN/placeholder.txt | 0 .../AdventureWorksVoiceCommandService.cs | 3 + .../VoiceCommandService.csproj | 6 +- .../js/AdventureWorks/AdventureWorks.jsproj | 29 +- .../Strings/en-AU/placeholder.txt | 0 .../Strings/en-CA/placeholder.txt | 0 .../Strings/en-IN/placeholder.txt | 0 .../AdventureWorks/adventureworkscommands.xml | 253 --------- .../AdventureWorks/js/voiceCommandService.js | 3 + .../js/AdventureWorks/package.appxmanifest | 2 +- .../AdventureWorksCommands.xml | 108 ++++ .../shared/Strings/en-AU/Resources.resjson | 16 + .../shared/Strings/en-AU/Resources.resw | 162 ++++++ .../shared/Strings/en-CA/Resources.resjson | 16 + .../shared/Strings/en-CA/Resources.resw | 162 ++++++ .../shared/Strings/en-IN/Resources.resjson | 16 + .../shared/Strings/en-IN/Resources.resw | 162 ++++++ Samples/DeviceEnumeration/README.md | 63 --- .../DeviceEnumerationCpp/DisplayHelpers.cpp | 225 -------- .../cs/DeviceEnumerationCs/DisplayHelpers.cs | 288 ---------- .../DeviceEnumeration/js/Package.appxmanifest | 62 --- .../DeviceEnumeration/js/js/displayhelpers.js | 131 ----- Samples/DeviceEnumerationAndPairing/README.md | 71 +++ .../cpp/DeviceEnumeration.sln} | 4 +- .../cpp/DeviceEnumeration.vcxproj} | 51 +- .../cpp/DeviceEnumeration.vcxproj.filters} | 31 +- .../cpp/DisplayHelpers.cpp | 357 +++++++++++++ .../cpp}/DisplayHelpers.h | 155 +++++- .../cpp/Package.appxmanifest | 38 ++ .../cpp}/SampleConfiguration.cpp | 7 +- .../cpp}/SampleConfiguration.h | 2 +- .../cpp}/Scenario1_DevicePicker.xaml | 0 .../cpp}/Scenario1_DevicePicker.xaml.cpp | 6 +- .../cpp}/Scenario1_DevicePicker.xaml.h | 0 .../cpp}/Scenario2_DeviceWatcher.xaml | 0 .../cpp}/Scenario2_DeviceWatcher.xaml.cpp | 17 +- .../cpp}/Scenario2_DeviceWatcher.xaml.h | 0 .../Scenario3_BackgroundDeviceWatcher.xaml | 2 +- ...Scenario3_BackgroundDeviceWatcher.xaml.cpp | 19 +- .../Scenario3_BackgroundDeviceWatcher.xaml.h | 0 .../cpp}/Scenario4_Snapshot.xaml | 0 .../cpp}/Scenario4_Snapshot.xaml.cpp | 2 +- .../cpp}/Scenario4_Snapshot.xaml.h | 0 .../cpp}/Scenario5_GetSingleDevice.xaml | 0 .../cpp}/Scenario5_GetSingleDevice.xaml.cpp | 0 .../cpp}/Scenario5_GetSingleDevice.xaml.h | 0 .../Scenario6_CustomFilterAddedProps.xaml | 0 .../Scenario6_CustomFilterAddedProps.xaml.cpp | 3 +- .../Scenario6_CustomFilterAddedProps.xaml.h | 0 .../cpp}/Scenario7_DeviceInformationKind.xaml | 0 .../Scenario7_DeviceInformationKind.xaml.cpp | 0 .../Scenario7_DeviceInformationKind.xaml.h | 0 .../cpp}/Scenario8_PairDevice.xaml | 59 +- .../cpp}/Scenario8_PairDevice.xaml.cpp | 99 +++- .../cpp}/Scenario8_PairDevice.xaml.h | 3 + .../cpp/Scenario9_CustomPairDevice.xaml | 159 ++++++ .../cpp/Scenario9_CustomPairDevice.xaml.cpp | 502 ++++++++++++++++++ .../cpp/Scenario9_CustomPairDevice.xaml.h | 65 +++ .../Tasks/BackgroundDeviceWatcherTask.cpp} | 2 +- .../cpp/Tasks/BackgroundDeviceWatcherTask.h} | 0 .../cpp/Tasks/Tasks.vcxproj} | 10 +- .../cpp/Tasks}/pch.cpp | 0 .../cpp/Tasks}/pch.h | 0 .../cpp}/pch.cpp | 0 .../cpp}/pch.h | 0 .../cs/DeviceEnumeration.csproj} | 49 +- .../cs/DeviceEnumeration.sln} | 4 +- .../cs/DisplayHelpers.cs | 495 +++++++++++++++++ .../cs}/Package.appxmanifest | 42 +- .../cs}/SampleConfiguration.cs | 9 +- .../cs}/Scenario1_DevicePicker.xaml | 0 .../cs}/Scenario1_DevicePicker.xaml.cs | 6 +- .../cs}/Scenario2_DeviceWatcher.xaml | 0 .../cs}/Scenario2_DeviceWatcher.xaml.cs | 17 +- .../Scenario3_BackgroundDeviceWatcher.xaml | 2 +- .../Scenario3_BackgroundDeviceWatcher.xaml.cs | 19 +- .../cs}/Scenario4_Snapshot.xaml | 0 .../cs}/Scenario4_Snapshot.xaml.cs | 2 +- .../cs}/Scenario5_GetSingleDevice.xaml | 0 .../cs}/Scenario5_GetSingleDevice.xaml.cs | 3 +- .../cs}/Scenario6_CustomFilterAddedProps.xaml | 0 .../Scenario6_CustomFilterAddedProps.xaml.cs | 3 +- .../cs}/Scenario7_DeviceInformationKind.xaml | 0 .../Scenario7_DeviceInformationKind.xaml.cs | 0 .../cs}/Scenario8_PairDevice.xaml | 61 ++- .../cs}/Scenario8_PairDevice.xaml.cs | 93 +++- .../cs/Scenario9_CustomPairDevice.xaml | 158 ++++++ .../cs/Scenario9_CustomPairDevice.xaml.cs | 479 +++++++++++++++++ .../cs/Tasks}/BackgroundDeviceWatcher.cs | 0 .../cs/Tasks}/Properties/AssemblyInfo.cs | 0 .../cs/Tasks/Tasks.csproj} | 4 +- .../cs/Tasks}/project.json | 0 .../cs}/project.json | 0 .../js/DeviceEnumeration.jsproj} | 6 +- .../js/DeviceEnumeration.sln} | 2 +- .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-US/placeholder.txt | 0 .../js/Package.appxmanifest | 38 ++ .../js/css/placeholder.txt | 0 .../js/html/scenario1_devicepicker.html | 0 .../js/html/scenario2_devicewatcher.html | 0 .../scenario3_backgrounddevicewatcher.html | 0 .../js/html/scenario4_snapshot.html | 0 .../js/html/scenario5_getsingledevice.html | 0 .../scenario6_customfilteraddedprops.html | 0 .../html/scenario7_deviceinformationkind.html | 0 .../js/html/scenario8_pairdevice.html | 7 +- .../js/html/scenario9_custompairdevice.html | 84 +++ .../js/images/placeholder.txt | 0 .../js/js/BackgroundDeviceWatcher.js | 0 .../js/js/displayhelpers.js | 184 +++++++ .../js/js/sample-configuration.js | 5 +- .../js/js/scenario1_devicepicker.js | 4 +- .../js/js/scenario2_devicewatcher.js | 19 +- .../js/scenario3_backgrounddevicewatcher.js | 19 +- .../js/js/scenario4_snapshot.js | 4 +- .../js/js/scenario5_getsingledevice.js | 0 .../js/js/scenario6_customfilteraddedprops.js | 0 .../js/js/scenario7_deviceinformationkind.js | 0 .../js/js/scenario8_pairdevice.js | 103 +++- .../js/js/scenario9_custompairdevice.js | 396 ++++++++++++++ .../js/sample-utils/placeholder.txt | 0 Samples/EnterpriseDataProtection/README.md | 2 +- .../cs/EnterpriseDataProtection.csproj | 17 +- .../cs/Package.appxmanifest | 2 +- .../cs/Scenario16_NetworkResource.xaml | 8 +- .../cs/Scenario16_NetworkResource.xaml.cs | 118 +++- .../cs/Tasks/Tasks.csproj | 9 +- Samples/FileAccess/README.md | 6 +- Samples/FileAccess/cpp/FileAccess.vcxproj | 4 +- .../FileAccess/cpp/FileAccess.vcxproj.filters | 5 +- Samples/FileAccess/cpp/Package.appxmanifest | 2 +- .../FileAccess/cpp/SampleConfiguration.cpp | 6 +- ...ryToGetAFileWithoutGettingAnError.xaml.cpp | 7 +- ...1_CreateAFileInThePicturesLibrary.xaml.cpp | 5 +- .../cpp/Scenario8_CopyAFile.xaml.cpp | 8 +- Samples/FileAccess/cs/FileAccess.csproj | 4 +- Samples/FileAccess/cs/Package.appxmanifest | 2 +- Samples/FileAccess/cs/SampleConfiguration.cs | 3 +- ...TryToGetAFileWithoutGettingAnError.xaml.cs | 2 +- ...o1_CreateAFileInThePicturesLibrary.xaml.cs | 2 +- .../FileAccess/cs/Scenario8_CopyAFile.xaml.cs | 3 +- Samples/FileAccess/js/FileAccess.jsproj | 4 +- Samples/FileAccess/js/Package.appxmanifest | 3 +- .../FileAccess/js/js/sample-configuration.js | 4 +- ...io11_TryToGetAFileWithoutGettingAnError.js | 4 +- ...enario1_CreateAFileInThePicturesLibrary.js | 4 +- .../FileAccess/js/js/scenario8_CopyAFile.js | 4 +- Samples/FileSearch/README.md | 6 +- Samples/FileSearch/cpp/FileSearch.vcxproj | 4 +- Samples/FileSearch/cpp/Package.appxmanifest | 2 +- Samples/FileSearch/cpp/Scenario1.xaml.cpp | 12 +- Samples/FileSearch/cs/FileSearch.csproj | 4 +- Samples/FileSearch/cs/FileSearch.sln | 67 ++- Samples/FileSearch/cs/Package.appxmanifest | 2 +- Samples/FileSearch/cs/Scenario1.xaml.cs | 4 +- Samples/FileSearch/js/FileSearch.jsproj | 4 +- Samples/FileSearch/js/Package.appxmanifest | 3 +- Samples/FileSearch/js/js/scenario1.js | 12 +- Samples/FolderEnumeration/README.md | 6 +- .../cpp/FolderEnumeration.vcxproj | 4 +- .../cpp/Package.appxmanifest | 2 +- .../FolderEnumeration/cpp/Scenario1.xaml.cpp | 27 +- .../FolderEnumeration/cpp/Scenario2.xaml.cpp | 9 +- .../FolderEnumeration/cpp/Scenario3.xaml.cpp | 7 +- .../cs/FolderEnumeration.csproj | 4 +- .../FolderEnumeration/cs/Package.appxmanifest | 2 +- .../FolderEnumeration/cs/Scenario1.xaml.cs | 2 +- .../FolderEnumeration/cs/Scenario2.xaml.cs | 2 +- .../FolderEnumeration/cs/Scenario3.xaml.cs | 3 +- .../js/FolderEnumeration.jsproj | 4 +- .../FolderEnumeration/js/Package.appxmanifest | 3 +- Samples/FolderEnumeration/js/js/scenario1.js | 10 +- Samples/FolderEnumeration/js/js/scenario2.js | 27 +- Samples/FolderEnumeration/js/js/scenario3.js | 46 +- .../cs/HttpClient/HttpClient.csproj | 17 +- .../cs/HttpClient/Package.appxmanifest | 2 +- .../cs/HttpClient/SampleConfiguration.cs | 3 +- .../HttpClient/Scenario12_DisableCookies.xaml | 70 +++ .../Scenario12_DisableCookies.xaml.cs | 181 +++++++ ...> Scenario14_MeteredConnectionFilter.xaml} | 2 +- ...cenario14_MeteredConnectionFilter.xaml.cs} | 4 +- Samples/JumpList/README.md | 59 ++ Samples/JumpList/cpp/App.xaml.cpp | 140 +++++ Samples/JumpList/cpp/App.xaml.h | 34 ++ Samples/JumpList/cpp/JumpList.sln | 40 ++ Samples/JumpList/cpp/JumpList.vcxproj | 248 +++++++++ Samples/JumpList/cpp/JumpList.vcxproj.filters | 74 +++ Samples/JumpList/cpp/Package.appxmanifest | 58 ++ Samples/JumpList/cpp/SampleConfiguration.cpp | 39 ++ Samples/JumpList/cpp/SampleConfiguration.h | 58 ++ .../JumpList/cpp/Scenario1_Launched.xaml.cpp | 38 ++ .../JumpList/cpp/Scenario1_Launched.xaml.h | 28 + .../JumpList/cpp/Scenario2_Remove.xaml.cpp | 37 ++ Samples/JumpList/cpp/Scenario2_Remove.xaml.h | 28 + .../cpp/Scenario3_CustomItems.xaml.cpp | 62 +++ .../JumpList/cpp/Scenario3_CustomItems.xaml.h | 31 ++ .../cpp/Scenario4_ChangeSystemGroup.xaml.cpp | 101 ++++ .../cpp/Scenario4_ChangeSystemGroup.xaml.h | 34 ++ .../cpp/Scenario5_IsSupported.xaml.cpp | 31 ++ .../JumpList/cpp/Scenario5_IsSupported.xaml.h | 28 + Samples/JumpList/cpp/pch.cpp | 5 + Samples/JumpList/cpp/pch.h | 10 + Samples/JumpList/cs/App.xaml.cs | 127 +++++ Samples/JumpList/cs/JumpList.csproj | 205 +++++++ Samples/JumpList/cs/JumpList.sln | 40 ++ Samples/JumpList/cs/Package.appxmanifest | 37 ++ Samples/JumpList/cs/SampleConfiguration.cs | 75 +++ .../JumpList/cs/Scenario1_Launched.xaml.cs | 37 ++ Samples/JumpList/cs/Scenario2_Remove.xaml.cs | 34 ++ .../JumpList/cs/Scenario3_CustomItems.xaml.cs | 58 ++ .../cs/Scenario4_ChangeSystemGroup.xaml.cs | 85 +++ .../JumpList/cs/Scenario5_IsSupported.xaml.cs | 30 ++ Samples/JumpList/cs/project.json | 16 + Samples/JumpList/js/JumpList.jsproj | 150 ++++++ Samples/JumpList/js/JumpList.sln | 48 ++ .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../Microsoft.WinJS.4.0/fonts/placeholder.txt | 0 .../js/en-US/placeholder.txt | 0 Samples/JumpList/js/Package.appxmanifest | 37 ++ Samples/JumpList/js/css/placeholder.txt | 0 .../JumpList/js/html/scenario1-launched.html | 32 ++ .../JumpList/js/html/scenario2-remove.html | 34 ++ .../js/html/scenario3-customitems.html | 78 +++ .../js/html/scenario4-changesystemgroup.html | 52 ++ .../js/html/scenario5-issupported.html | 33 ++ Samples/JumpList/js/images/placeholder.txt | 0 .../JumpList/js/js/sample-configuration.js | 20 + Samples/JumpList/js/js/scenario1-launched.js | 33 ++ Samples/JumpList/js/js/scenario2-remove.js | 23 + .../JumpList/js/js/scenario3-customitems.js | 48 ++ .../js/js/scenario4-changesystemgroup.js | 87 +++ .../JumpList/js/js/scenario5-issupported.js | 14 + Samples/JumpList/js/resources.resjson | 6 + .../JumpList/js/sample-utils/placeholder.txt | 0 Samples/JumpList/shared/Resources.resw | 129 +++++ .../JumpList/shared/Scenario1_Launched.xaml | 44 ++ Samples/JumpList/shared/Scenario2_Remove.xaml | 48 ++ .../shared/Scenario3_CustomItems.xaml | 71 +++ .../shared/Scenario4_ChangeSystemGroup.xaml | 54 ++ .../shared/Scenario5_IsSupported.xaml | 45 ++ Samples/Pedometer/README.md | 12 +- Samples/Pedometer/cpp/Package.appxmanifest | 11 +- Samples/Pedometer/cpp/Pedometer.sln | 16 +- Samples/Pedometer/cpp/Pedometer.vcxproj | 18 +- .../Pedometer/cpp/Pedometer.vcxproj.filters | 1 + Samples/Pedometer/cpp/SampleConfiguration.cpp | 3 +- .../cpp/Scenario3_CurrentStepCount.xaml | 2 +- .../cpp/Scenario3_CurrentStepCount.xaml.cpp | 48 +- .../cpp/Scenario3_CurrentStepCount.xaml.h | 2 + .../cpp/Scenario4_BackgroundTask.xaml | 70 +++ .../cpp/Scenario4_BackgroundTask.xaml.cpp | 264 +++++++++ .../cpp/Scenario4_BackgroundTask.xaml.h | 48 ++ .../cpp/Tasks/PedometerBackgroundTask.cpp | 106 ++++ .../cpp/Tasks/PedometerBackgroundTask.h | 36 ++ Samples/Pedometer/cpp/Tasks/Tasks.vcxproj | 227 ++++++++ .../Pedometer/cpp/Tasks/Tasks.vcxproj.filters | 17 + Samples/Pedometer/cpp/Tasks/pch.cpp | 1 + Samples/Pedometer/cpp/Tasks/pch.h | 4 + Samples/Pedometer/cs/Package.appxmanifest | 9 +- Samples/Pedometer/cs/Pedometer.csproj | 17 +- Samples/Pedometer/cs/Pedometer.sln | 24 +- Samples/Pedometer/cs/SampleConfiguration.cs | 8 +- .../cs/Scenario3_CurrentStepCount.xaml | 2 +- .../cs/Scenario3_CurrentStepCount.xaml.cs | 65 +-- .../cs/Scenario4_BackgroundTask.xaml | 71 +++ .../cs/Scenario4_BackgroundTask.xaml.cs | 252 +++++++++ .../cs/Tasks/PedometerBackgroundTask.cs | 86 +++ .../cs/Tasks}/Properties/AssemblyInfo.cs | 12 +- Samples/Pedometer/cs/Tasks/Tasks.csproj | 125 +++++ Samples/Pedometer/cs/Tasks/project.json | 16 + .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-us/placeholder.txt | 0 Samples/Pedometer/js/Package.appxmanifest | 57 ++ Samples/Pedometer/js/Pedometer.jsproj | 146 +++++ Samples/Pedometer/js/Pedometer.sln | 48 ++ Samples/Pedometer/js/css/placeholder.txt | 0 .../Pedometer/js/html/scenario1-events.html | 53 ++ .../Pedometer/js/html/scenario2-history.html | 78 +++ .../js/html/scenario3-currentStepCount.html | 26 + .../html/scenario4-backgroundPedometer.html | 40 ++ Samples/Pedometer/js/images/placeholder.txt | 0 .../js/js/pedometerBackgroundTask.js | 62 +++ .../Pedometer/js/js/sample-configuration.js | 26 + Samples/Pedometer/js/js/scenario1-events.js | 121 +++++ Samples/Pedometer/js/js/scenario2-history.js | 140 +++++ .../js/js/scenario3-currentStepCount.js | 52 ++ .../js/js/scenario4-backgroundPedometer.js | 232 ++++++++ .../Pedometer/js/sample-utils/placeholder.txt | 0 Samples/ProximitySensor/README.md | 12 +- .../ProximitySensor/cpp/Package.appxmanifest | 9 +- .../ProximitySensor/cpp/ProximitySensor.sln | 16 +- .../cpp/ProximitySensor.vcxproj | 18 +- .../cpp/ProximitySensor.vcxproj.filters | 1 + .../cpp/SampleConfiguration.cpp | 3 +- .../Scenario4_BackgroundProximitySensor.xaml | 59 ++ ...enario4_BackgroundProximitySensor.xaml.cpp | 223 ++++++++ ...Scenario4_BackgroundProximitySensor.xaml.h | 50 ++ .../Tasks/ProximitySensorBackgroundTask.cpp | 84 +++ .../cpp/Tasks/ProximitySensorBackgroundTask.h | 33 ++ .../ProximitySensor/cpp/Tasks/Tasks.vcxproj | 227 ++++++++ .../cpp/Tasks/Tasks.vcxproj.filters | 17 + Samples/ProximitySensor/cpp/Tasks/pch.cpp | 1 + Samples/ProximitySensor/cpp/Tasks/pch.h | 4 + .../ProximitySensor/cs/Package.appxmanifest | 12 +- .../ProximitySensor/cs/ProximitySensor.csproj | 15 +- .../ProximitySensor/cs/ProximitySensor.sln | 89 ++-- .../ProximitySensor/cs/SampleConfiguration.cs | 3 +- .../Scenario4_BackgroundProximitySensor.xaml | 59 ++ ...cenario4_BackgroundProximitySensor.xaml.cs | 214 ++++++++ .../cs/Tasks/Properties/AssemblyInfo.cs | 29 + .../cs/Tasks/ProximitySensorBackgroundTask.cs | 65 +++ Samples/ProximitySensor/cs/Tasks/Tasks.csproj | 125 +++++ Samples/ProximitySensor/cs/Tasks/project.json | 16 + .../ProximitySensor/js/Package.appxmanifest | 13 +- .../ProximitySensor/js/ProximitySensor.jsproj | 8 +- .../scenario4_BackgroundProximitySensor.css | 14 + .../scenario4_BackgroundProximitySensor.html | 40 ++ .../js/js/proximitySensorBackgroundTask.js | 46 ++ .../js/js/sample-configuration.js | 1 + .../js/scenario4_BackgroundProximitySensor.js | 190 +++++++ .../cpp/Package.appxmanifest | 2 +- .../cpp/SpeechAndTTS.vcxproj | 28 +- .../cpp/SpeechAndTTS.vcxproj.filters | 39 ++ .../cs/Package.appxmanifest | 2 +- .../cs/SpeechAndTTS.csproj | 38 +- .../js/SRGS/en-AU/placeholder.txt | 0 .../js/SRGS/en-CA/placeholder.txt | 0 .../js/SRGS/en-IN/placeholder.txt | 0 .../js/SpeechAndTTS.jsproj | 41 +- .../js/package.appxmanifest | 2 +- .../shared/SRGS/en-AU/SRGSColors.xml | 195 +++++++ .../shared/SRGS/en-CA/SRGSColors.xml | 195 +++++++ .../shared/SRGS/en-IN/SRGSColors.xml | 195 +++++++ .../en-AU/LocalizationSpeechResources.resjson | 23 + .../en-AU/LocalizationSpeechResources.resw | 201 +++++++ .../en-AU/LocalizationTTSResources.resjson | 4 + .../en-AU/LocalizationTTSResources.resw | 140 +++++ .../en-CA/LocalizationSpeechResources.resjson | 23 + .../en-CA/LocalizationSpeechResources.resw | 201 +++++++ .../en-CA/LocalizationTTSResources.resjson | 4 + .../en-CA/LocalizationTTSResources.resw | 140 +++++ .../en-IN/LocalizationSpeechResources.resjson | 23 + .../en-IN/LocalizationSpeechResources.resw | 201 +++++++ Samples/TouchKeyboardTextInput/README.md | 9 +- .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/en-US/placeholder.txt | 0 .../js/TouchKeyboardTextInput.jsproj | 146 +++++ .../js/TouchKeyboardTextInput.sln | 48 ++ .../css/Scenario1_SpellingTextSuggestions.css | 6 + .../js/css/Scenario2_ScopedViews.css | 14 + .../TouchKeyboardTextInput/js/css/default.css | 114 ++++ .../Scenario1_SpellingTextSuggestions.html | 46 ++ .../js/html/Scenario2_ScopedViews.html | 61 +++ .../js/images/placeholder.txt | 0 .../js/Scenario1_SpellingTextSuggestions.js | 10 + .../js/js/Scenario2_ScopedViews.js | 10 + .../TouchKeyboardTextInput/js/js/default.js | 105 ++++ .../js/js/sample-configuration.js | 17 + .../js/package.appxmanifest | 48 ++ .../js/sample-utils/placeholder.txt | 0 Samples/UserInfo/js/Package.appxmanifest | 3 +- Samples/UserInfo/js/UserInfo.jsproj | 4 +- Samples/UserInfo/js/js/scenario1-findUsers.js | 15 +- .../VoIP/cs/Voip/Helpers/VoipCallHelper.cs | 4 +- Samples/VoIP/cs/Voip/Package.appxmanifest | 3 +- Samples/VoIP/cs/Voip/Voip.csproj | 4 +- .../Templates/InstallSDKTemplates.cmd | 23 + SharedContent/Templates/README.md | 25 + SharedContent/Templates/Shared/README.md | 72 +++ .../UWPSDKSampleCPP}/Package.appxmanifest | 27 +- .../UWPSDKSampleCPP/SampleConfiguration.cpp | 23 + .../UWPSDKSampleCPP/SampleConfiguration.h | 47 ++ .../UWPSDKSampleCPP/Scenario1_ShortName.xaml | 44 ++ .../Scenario1_ShortName.xaml.cpp | 45 ++ .../Scenario1_ShortName.xaml.h | 34 ++ .../UWPSDKSampleCPP/Scenario2_ShortName.xaml | 45 ++ .../Scenario2_ShortName.xaml.cpp | 31 ++ .../Scenario2_ShortName.xaml.h | 31 ++ .../UWPSDKSampleCPP/Scenario3_ShortName.xaml | 44 ++ .../Scenario3_ShortName.xaml.cpp | 32 ++ .../Scenario3_ShortName.xaml.h | 31 ++ .../UWPSDKSampleCPP/UWPSDKSampleCPP.sln | 40 ++ .../UWPSDKSampleCPP/UWPSDKSampleCPP.vcxproj | 225 ++++++++ .../UWPSDKSampleCPP.vcxproj.filters | 68 +++ .../UWPSDKSampleCPP.vstemplate | 40 ++ .../Templates/UWPSDKSampleCPP/pch.cpp | 5 + SharedContent/Templates/UWPSDKSampleCPP/pch.h | 10 + .../UWPSDKSampleCS/Package.appxmanifest | 53 ++ .../UWPSDKSampleCS/SampleConfiguration.cs | 35 ++ .../UWPSDKSampleCS/Scenario1_ShortName.xaml | 43 ++ .../Scenario1_ShortName.xaml.cs | 50 ++ .../UWPSDKSampleCS/Scenario2_ShortName.xaml | 40 ++ .../Scenario2_ShortName.xaml.cs | 26 + .../UWPSDKSampleCS/Scenario3_ShortName.xaml | 40 ++ .../Scenario3_ShortName.xaml.cs | 26 + .../UWPSDKSampleCS/UWPSDKSampleCS.csproj | 187 +++++++ .../UWPSDKSampleCS/UWPSDKSampleCS.sln | 40 ++ .../UWPSDKSampleCS/UWPSDKSampleCS.vstemplate | 44 ++ .../Templates/UWPSDKSampleCS/project.json | 16 + .../Templates/UWPSDKSampleJS/App.jsproj | 146 +++++ .../UWPSDKSampleJS/MyTemplate.vstemplate | 72 +++ .../UWPSDKSampleJS/__TemplateIcon.png | Bin 0 -> 2997 bytes .../UWPSDKSampleJS/css/scenario1.css | 6 + .../UWPSDKSampleJS/css/scenario2.css | 14 + .../UWPSDKSampleJS/css/scenario3.css | 14 + .../UWPSDKSampleJS/html/scenario1.html | 25 + .../UWPSDKSampleJS/html/scenario2.html | 29 + .../UWPSDKSampleJS/html/scenario3.html | 26 + .../js/Microsoft.WinJS.4.0/css/placeholder | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/Microsoft.WinJS.4.0/js/placeholder | 0 .../UWPSDKSampleJS/js/sample-configuration.js | 18 + .../Templates/UWPSDKSampleJS/js/scenario1.js | 10 + .../Templates/UWPSDKSampleJS/js/scenario2.js | 14 + .../Templates/UWPSDKSampleJS/js/scenario3.js | 14 + .../UWPSDKSampleJS/package.appxmanifest | 53 ++ .../Scenario1_ShortName.xaml | 44 ++ .../Scenario1_ShortName.xaml.cpp | 45 ++ .../Scenario1_ShortName.xaml.h | 34 ++ .../ScenarioItemTemplate.vstemplate | 19 + .../Scenario1_ShortName.xaml | 43 ++ .../Scenario1_ShortName.xaml.cs | 50 ++ .../ScenarioItemTemplate.vstemplate | 19 + 474 files changed, 17599 insertions(+), 2085 deletions(-) create mode 100644 Samples/ActivitySensor/js/ActivitySensor.jsproj create mode 100644 Samples/ActivitySensor/js/ActivitySensor.sln rename Samples/{DeviceEnumeration => ActivitySensor}/js/Microsoft.WinJS.4.0/css/placeholder.txt (100%) rename Samples/{DeviceEnumeration => ActivitySensor}/js/Microsoft.WinJS.4.0/fonts/placeholder (100%) rename Samples/{DeviceEnumeration/js/Microsoft.WinJS.4.0/js/en-US => ActivitySensor/js/Microsoft.WinJS.4.0/js/en-us}/placeholder.txt (100%) create mode 100644 Samples/ActivitySensor/js/Package.appxmanifest rename Samples/{DeviceEnumeration => ActivitySensor}/js/css/placeholder.txt (100%) create mode 100644 Samples/ActivitySensor/js/html/scenario1-currentActivity.html create mode 100644 Samples/ActivitySensor/js/html/scenario2-history.html create mode 100644 Samples/ActivitySensor/js/html/scenario3-changeEvents.html create mode 100644 Samples/ActivitySensor/js/html/scenario4-backgroundActivity.html rename Samples/{DeviceEnumeration => ActivitySensor}/js/images/placeholder.txt (100%) create mode 100644 Samples/ActivitySensor/js/js/activitySensorBackgroundTask.js create mode 100644 Samples/ActivitySensor/js/js/sample-configuration.js create mode 100644 Samples/ActivitySensor/js/js/scenario1-currentActivity.js create mode 100644 Samples/ActivitySensor/js/js/scenario2-history.js create mode 100644 Samples/ActivitySensor/js/js/scenario3-changeEvents.js create mode 100644 Samples/ActivitySensor/js/js/scenario4-backgroundActivity.js rename Samples/{DeviceEnumeration => ActivitySensor}/js/sample-utils/placeholder.txt (100%) create mode 100644 Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-AU/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-CA/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-IN/placeholder.txt delete mode 100644 Samples/CortanaVoiceCommand/cpp/AdventureWorks/adventureworkscommands.xml create mode 100644 Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-AU/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-CA/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-IN/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-AU/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-CA/placeholder.txt create mode 100644 Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-IN/placeholder.txt delete mode 100644 Samples/CortanaVoiceCommand/js/AdventureWorks/adventureworkscommands.xml rename Samples/CortanaVoiceCommand/{cs/AdventureWorks => shared}/AdventureWorksCommands.xml (70%) create mode 100644 Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resjson create mode 100644 Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resw create mode 100644 Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resjson create mode 100644 Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resw create mode 100644 Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resjson create mode 100644 Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resw delete mode 100644 Samples/DeviceEnumeration/README.md delete mode 100644 Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.cpp delete mode 100644 Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DisplayHelpers.cs delete mode 100644 Samples/DeviceEnumeration/js/Package.appxmanifest delete mode 100644 Samples/DeviceEnumeration/js/js/displayhelpers.js create mode 100644 Samples/DeviceEnumerationAndPairing/README.md rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp.sln => DeviceEnumerationAndPairing/cpp/DeviceEnumeration.sln} (90%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj => DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj} (87%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj.filters => DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj.filters} (71%) create mode 100644 Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/DisplayHelpers.h (54%) create mode 100644 Samples/DeviceEnumerationAndPairing/cpp/Package.appxmanifest rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/SampleConfiguration.cpp (68%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/SampleConfiguration.h (91%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario1_DevicePicker.xaml (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario1_DevicePicker.xaml.cpp (95%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario1_DevicePicker.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario2_DeviceWatcher.xaml (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario2_DeviceWatcher.xaml.cpp (92%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario2_DeviceWatcher.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario3_BackgroundDeviceWatcher.xaml (95%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario3_BackgroundDeviceWatcher.xaml.cpp (87%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario3_BackgroundDeviceWatcher.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario4_Snapshot.xaml (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario4_Snapshot.xaml.cpp (97%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario4_Snapshot.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario5_GetSingleDevice.xaml (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario5_GetSingleDevice.xaml.cpp (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario5_GetSingleDevice.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario6_CustomFilterAddedProps.xaml (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario6_CustomFilterAddedProps.xaml.cpp (99%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario6_CustomFilterAddedProps.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario7_DeviceInformationKind.xaml (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario7_DeviceInformationKind.xaml.cpp (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario7_DeviceInformationKind.xaml.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario8_PairDevice.xaml (67%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario8_PairDevice.xaml.cpp (71%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/Scenario8_PairDevice.xaml.h (94%) create mode 100644 Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml create mode 100644 Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.cpp create mode 100644 Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.h rename Samples/{DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.cpp => DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.cpp} (97%) rename Samples/{DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.h => DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.h} (100%) rename Samples/{DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.vcxproj => DeviceEnumerationAndPairing/cpp/Tasks/Tasks.vcxproj} (97%) rename Samples/{DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp => DeviceEnumerationAndPairing/cpp/Tasks}/pch.cpp (100%) rename Samples/{DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp => DeviceEnumerationAndPairing/cpp/Tasks}/pch.h (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/pch.cpp (100%) rename Samples/{DeviceEnumeration/cpp/DeviceEnumerationCpp => DeviceEnumerationAndPairing/cpp}/pch.h (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs/DeviceEnumerationCs.csproj => DeviceEnumerationAndPairing/cs/DeviceEnumeration.csproj} (84%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs.sln => DeviceEnumerationAndPairing/cs/DeviceEnumeration.sln} (90%) create mode 100644 Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Package.appxmanifest (75%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/SampleConfiguration.cs (73%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario1_DevicePicker.xaml (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario1_DevicePicker.xaml.cs (96%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario2_DeviceWatcher.xaml (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario2_DeviceWatcher.xaml.cs (93%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario3_BackgroundDeviceWatcher.xaml (95%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario3_BackgroundDeviceWatcher.xaml.cs (88%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario4_Snapshot.xaml (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario4_Snapshot.xaml.cs (99%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario5_GetSingleDevice.xaml (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario5_GetSingleDevice.xaml.cs (95%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario6_CustomFilterAddedProps.xaml (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario6_CustomFilterAddedProps.xaml.cs (99%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario7_DeviceInformationKind.xaml (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario7_DeviceInformationKind.xaml.cs (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario8_PairDevice.xaml (67%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/Scenario8_PairDevice.xaml.cs (70%) create mode 100644 Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml create mode 100644 Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml.cs rename Samples/{DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs => DeviceEnumerationAndPairing/cs/Tasks}/BackgroundDeviceWatcher.cs (100%) rename Samples/{DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs => DeviceEnumerationAndPairing/cs/Tasks}/Properties/AssemblyInfo.cs (100%) rename Samples/{DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/BackgroundDeviceWatcherTaskCs.csproj => DeviceEnumerationAndPairing/cs/Tasks/Tasks.csproj} (97%) rename Samples/{DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs => DeviceEnumerationAndPairing/cs/Tasks}/project.json (100%) rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => DeviceEnumerationAndPairing/cs}/project.json (100%) rename Samples/{DeviceEnumeration/js/DeviceEnumerationJs.jsproj => DeviceEnumerationAndPairing/js/DeviceEnumeration.jsproj} (96%) rename Samples/{DeviceEnumeration/js/DeviceEnumerationJs.sln => DeviceEnumerationAndPairing/js/DeviceEnumeration.sln} (96%) create mode 100644 Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/css/placeholder.txt create mode 100644 Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/fonts/placeholder create mode 100644 Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt create mode 100644 Samples/DeviceEnumerationAndPairing/js/Package.appxmanifest create mode 100644 Samples/DeviceEnumerationAndPairing/js/css/placeholder.txt rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario1_devicepicker.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario2_devicewatcher.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario3_backgrounddevicewatcher.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario4_snapshot.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario5_getsingledevice.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario6_customfilteraddedprops.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario7_deviceinformationkind.html (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/html/scenario8_pairdevice.html (73%) create mode 100644 Samples/DeviceEnumerationAndPairing/js/html/scenario9_custompairdevice.html create mode 100644 Samples/DeviceEnumerationAndPairing/js/images/placeholder.txt rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/BackgroundDeviceWatcher.js (100%) create mode 100644 Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/sample-configuration.js (80%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario1_devicepicker.js (95%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario2_devicewatcher.js (86%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario3_backgrounddevicewatcher.js (83%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario4_snapshot.js (94%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario5_getsingledevice.js (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario6_customfilteraddedprops.js (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario7_deviceinformationkind.js (100%) rename Samples/{DeviceEnumeration => DeviceEnumerationAndPairing}/js/js/scenario8_pairdevice.js (60%) create mode 100644 Samples/DeviceEnumerationAndPairing/js/js/scenario9_custompairdevice.js create mode 100644 Samples/DeviceEnumerationAndPairing/js/sample-utils/placeholder.txt create mode 100644 Samples/HttpClient/cs/HttpClient/Scenario12_DisableCookies.xaml create mode 100644 Samples/HttpClient/cs/HttpClient/Scenario12_DisableCookies.xaml.cs rename Samples/HttpClient/cs/HttpClient/{Scenario12_MeteredConnectionFilter.xaml => Scenario14_MeteredConnectionFilter.xaml} (98%) rename Samples/HttpClient/cs/HttpClient/{Scenario12_MeteredConnectionFilter.xaml.cs => Scenario14_MeteredConnectionFilter.xaml.cs} (98%) create mode 100644 Samples/JumpList/README.md create mode 100644 Samples/JumpList/cpp/App.xaml.cpp create mode 100644 Samples/JumpList/cpp/App.xaml.h create mode 100644 Samples/JumpList/cpp/JumpList.sln create mode 100644 Samples/JumpList/cpp/JumpList.vcxproj create mode 100644 Samples/JumpList/cpp/JumpList.vcxproj.filters create mode 100644 Samples/JumpList/cpp/Package.appxmanifest create mode 100644 Samples/JumpList/cpp/SampleConfiguration.cpp create mode 100644 Samples/JumpList/cpp/SampleConfiguration.h create mode 100644 Samples/JumpList/cpp/Scenario1_Launched.xaml.cpp create mode 100644 Samples/JumpList/cpp/Scenario1_Launched.xaml.h create mode 100644 Samples/JumpList/cpp/Scenario2_Remove.xaml.cpp create mode 100644 Samples/JumpList/cpp/Scenario2_Remove.xaml.h create mode 100644 Samples/JumpList/cpp/Scenario3_CustomItems.xaml.cpp create mode 100644 Samples/JumpList/cpp/Scenario3_CustomItems.xaml.h create mode 100644 Samples/JumpList/cpp/Scenario4_ChangeSystemGroup.xaml.cpp create mode 100644 Samples/JumpList/cpp/Scenario4_ChangeSystemGroup.xaml.h create mode 100644 Samples/JumpList/cpp/Scenario5_IsSupported.xaml.cpp create mode 100644 Samples/JumpList/cpp/Scenario5_IsSupported.xaml.h create mode 100644 Samples/JumpList/cpp/pch.cpp create mode 100644 Samples/JumpList/cpp/pch.h create mode 100644 Samples/JumpList/cs/App.xaml.cs create mode 100644 Samples/JumpList/cs/JumpList.csproj create mode 100644 Samples/JumpList/cs/JumpList.sln create mode 100644 Samples/JumpList/cs/Package.appxmanifest create mode 100644 Samples/JumpList/cs/SampleConfiguration.cs create mode 100644 Samples/JumpList/cs/Scenario1_Launched.xaml.cs create mode 100644 Samples/JumpList/cs/Scenario2_Remove.xaml.cs create mode 100644 Samples/JumpList/cs/Scenario3_CustomItems.xaml.cs create mode 100644 Samples/JumpList/cs/Scenario4_ChangeSystemGroup.xaml.cs create mode 100644 Samples/JumpList/cs/Scenario5_IsSupported.xaml.cs create mode 100644 Samples/JumpList/cs/project.json create mode 100644 Samples/JumpList/js/JumpList.jsproj create mode 100644 Samples/JumpList/js/JumpList.sln create mode 100644 Samples/JumpList/js/Microsoft.WinJS.4.0/css/placeholder.txt create mode 100644 Samples/JumpList/js/Microsoft.WinJS.4.0/fonts/placeholder.txt create mode 100644 Samples/JumpList/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt create mode 100644 Samples/JumpList/js/Package.appxmanifest create mode 100644 Samples/JumpList/js/css/placeholder.txt create mode 100644 Samples/JumpList/js/html/scenario1-launched.html create mode 100644 Samples/JumpList/js/html/scenario2-remove.html create mode 100644 Samples/JumpList/js/html/scenario3-customitems.html create mode 100644 Samples/JumpList/js/html/scenario4-changesystemgroup.html create mode 100644 Samples/JumpList/js/html/scenario5-issupported.html create mode 100644 Samples/JumpList/js/images/placeholder.txt create mode 100644 Samples/JumpList/js/js/sample-configuration.js create mode 100644 Samples/JumpList/js/js/scenario1-launched.js create mode 100644 Samples/JumpList/js/js/scenario2-remove.js create mode 100644 Samples/JumpList/js/js/scenario3-customitems.js create mode 100644 Samples/JumpList/js/js/scenario4-changesystemgroup.js create mode 100644 Samples/JumpList/js/js/scenario5-issupported.js create mode 100644 Samples/JumpList/js/resources.resjson create mode 100644 Samples/JumpList/js/sample-utils/placeholder.txt create mode 100644 Samples/JumpList/shared/Resources.resw create mode 100644 Samples/JumpList/shared/Scenario1_Launched.xaml create mode 100644 Samples/JumpList/shared/Scenario2_Remove.xaml create mode 100644 Samples/JumpList/shared/Scenario3_CustomItems.xaml create mode 100644 Samples/JumpList/shared/Scenario4_ChangeSystemGroup.xaml create mode 100644 Samples/JumpList/shared/Scenario5_IsSupported.xaml create mode 100644 Samples/Pedometer/cpp/Scenario4_BackgroundTask.xaml create mode 100644 Samples/Pedometer/cpp/Scenario4_BackgroundTask.xaml.cpp create mode 100644 Samples/Pedometer/cpp/Scenario4_BackgroundTask.xaml.h create mode 100644 Samples/Pedometer/cpp/Tasks/PedometerBackgroundTask.cpp create mode 100644 Samples/Pedometer/cpp/Tasks/PedometerBackgroundTask.h create mode 100644 Samples/Pedometer/cpp/Tasks/Tasks.vcxproj create mode 100644 Samples/Pedometer/cpp/Tasks/Tasks.vcxproj.filters create mode 100644 Samples/Pedometer/cpp/Tasks/pch.cpp create mode 100644 Samples/Pedometer/cpp/Tasks/pch.h create mode 100644 Samples/Pedometer/cs/Scenario4_BackgroundTask.xaml create mode 100644 Samples/Pedometer/cs/Scenario4_BackgroundTask.xaml.cs create mode 100644 Samples/Pedometer/cs/Tasks/PedometerBackgroundTask.cs rename Samples/{DeviceEnumeration/cs/DeviceEnumerationCs => Pedometer/cs/Tasks}/Properties/AssemblyInfo.cs (73%) create mode 100644 Samples/Pedometer/cs/Tasks/Tasks.csproj create mode 100644 Samples/Pedometer/cs/Tasks/project.json create mode 100644 Samples/Pedometer/js/Microsoft.WinJS.4.0/css/placeholder.txt create mode 100644 Samples/Pedometer/js/Microsoft.WinJS.4.0/fonts/placeholder create mode 100644 Samples/Pedometer/js/Microsoft.WinJS.4.0/js/en-us/placeholder.txt create mode 100644 Samples/Pedometer/js/Package.appxmanifest create mode 100644 Samples/Pedometer/js/Pedometer.jsproj create mode 100644 Samples/Pedometer/js/Pedometer.sln create mode 100644 Samples/Pedometer/js/css/placeholder.txt create mode 100644 Samples/Pedometer/js/html/scenario1-events.html create mode 100644 Samples/Pedometer/js/html/scenario2-history.html create mode 100644 Samples/Pedometer/js/html/scenario3-currentStepCount.html create mode 100644 Samples/Pedometer/js/html/scenario4-backgroundPedometer.html create mode 100644 Samples/Pedometer/js/images/placeholder.txt create mode 100644 Samples/Pedometer/js/js/pedometerBackgroundTask.js create mode 100644 Samples/Pedometer/js/js/sample-configuration.js create mode 100644 Samples/Pedometer/js/js/scenario1-events.js create mode 100644 Samples/Pedometer/js/js/scenario2-history.js create mode 100644 Samples/Pedometer/js/js/scenario3-currentStepCount.js create mode 100644 Samples/Pedometer/js/js/scenario4-backgroundPedometer.js create mode 100644 Samples/Pedometer/js/sample-utils/placeholder.txt create mode 100644 Samples/ProximitySensor/cpp/Scenario4_BackgroundProximitySensor.xaml create mode 100644 Samples/ProximitySensor/cpp/Scenario4_BackgroundProximitySensor.xaml.cpp create mode 100644 Samples/ProximitySensor/cpp/Scenario4_BackgroundProximitySensor.xaml.h create mode 100644 Samples/ProximitySensor/cpp/Tasks/ProximitySensorBackgroundTask.cpp create mode 100644 Samples/ProximitySensor/cpp/Tasks/ProximitySensorBackgroundTask.h create mode 100644 Samples/ProximitySensor/cpp/Tasks/Tasks.vcxproj create mode 100644 Samples/ProximitySensor/cpp/Tasks/Tasks.vcxproj.filters create mode 100644 Samples/ProximitySensor/cpp/Tasks/pch.cpp create mode 100644 Samples/ProximitySensor/cpp/Tasks/pch.h create mode 100644 Samples/ProximitySensor/cs/Scenario4_BackgroundProximitySensor.xaml create mode 100644 Samples/ProximitySensor/cs/Scenario4_BackgroundProximitySensor.xaml.cs create mode 100644 Samples/ProximitySensor/cs/Tasks/Properties/AssemblyInfo.cs create mode 100644 Samples/ProximitySensor/cs/Tasks/ProximitySensorBackgroundTask.cs create mode 100644 Samples/ProximitySensor/cs/Tasks/Tasks.csproj create mode 100644 Samples/ProximitySensor/cs/Tasks/project.json create mode 100644 Samples/ProximitySensor/js/css/scenario4_BackgroundProximitySensor.css create mode 100644 Samples/ProximitySensor/js/html/scenario4_BackgroundProximitySensor.html create mode 100644 Samples/ProximitySensor/js/js/proximitySensorBackgroundTask.js create mode 100644 Samples/ProximitySensor/js/js/scenario4_BackgroundProximitySensor.js create mode 100644 Samples/SpeechRecognitionAndSynthesis/js/SRGS/en-AU/placeholder.txt create mode 100644 Samples/SpeechRecognitionAndSynthesis/js/SRGS/en-CA/placeholder.txt create mode 100644 Samples/SpeechRecognitionAndSynthesis/js/SRGS/en-IN/placeholder.txt create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/SRGS/en-AU/SRGSColors.xml create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/SRGS/en-CA/SRGSColors.xml create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/SRGS/en-IN/SRGSColors.xml create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-AU/LocalizationSpeechResources.resjson create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-AU/LocalizationSpeechResources.resw create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-AU/LocalizationTTSResources.resjson create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-AU/LocalizationTTSResources.resw create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-CA/LocalizationSpeechResources.resjson create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-CA/LocalizationSpeechResources.resw create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-CA/LocalizationTTSResources.resjson create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-CA/LocalizationTTSResources.resw create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-IN/LocalizationSpeechResources.resjson create mode 100644 Samples/SpeechRecognitionAndSynthesis/shared/Strings/en-IN/LocalizationSpeechResources.resw create mode 100644 Samples/TouchKeyboardTextInput/js/Microsoft.WinJS.4.0/css/placeholder.txt create mode 100644 Samples/TouchKeyboardTextInput/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt create mode 100644 Samples/TouchKeyboardTextInput/js/TouchKeyboardTextInput.jsproj create mode 100644 Samples/TouchKeyboardTextInput/js/TouchKeyboardTextInput.sln create mode 100644 Samples/TouchKeyboardTextInput/js/css/Scenario1_SpellingTextSuggestions.css create mode 100644 Samples/TouchKeyboardTextInput/js/css/Scenario2_ScopedViews.css create mode 100644 Samples/TouchKeyboardTextInput/js/css/default.css create mode 100644 Samples/TouchKeyboardTextInput/js/html/Scenario1_SpellingTextSuggestions.html create mode 100644 Samples/TouchKeyboardTextInput/js/html/Scenario2_ScopedViews.html create mode 100644 Samples/TouchKeyboardTextInput/js/images/placeholder.txt create mode 100644 Samples/TouchKeyboardTextInput/js/js/Scenario1_SpellingTextSuggestions.js create mode 100644 Samples/TouchKeyboardTextInput/js/js/Scenario2_ScopedViews.js create mode 100644 Samples/TouchKeyboardTextInput/js/js/default.js create mode 100644 Samples/TouchKeyboardTextInput/js/js/sample-configuration.js create mode 100644 Samples/TouchKeyboardTextInput/js/package.appxmanifest create mode 100644 Samples/TouchKeyboardTextInput/js/sample-utils/placeholder.txt create mode 100644 SharedContent/Templates/InstallSDKTemplates.cmd create mode 100644 SharedContent/Templates/README.md create mode 100644 SharedContent/Templates/Shared/README.md rename {Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp => SharedContent/Templates/UWPSDKSampleCPP}/Package.appxmanifest (64%) create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/SampleConfiguration.cpp create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/SampleConfiguration.h create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario1_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario1_ShortName.xaml.cpp create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario1_ShortName.xaml.h create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario2_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario2_ShortName.xaml.cpp create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario2_ShortName.xaml.h create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario3_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario3_ShortName.xaml.cpp create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/Scenario3_ShortName.xaml.h create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/UWPSDKSampleCPP.sln create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/UWPSDKSampleCPP.vcxproj create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/UWPSDKSampleCPP.vcxproj.filters create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/UWPSDKSampleCPP.vstemplate create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/pch.cpp create mode 100644 SharedContent/Templates/UWPSDKSampleCPP/pch.h create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Package.appxmanifest create mode 100644 SharedContent/Templates/UWPSDKSampleCS/SampleConfiguration.cs create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Scenario1_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Scenario1_ShortName.xaml.cs create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Scenario2_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Scenario2_ShortName.xaml.cs create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Scenario3_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleCS/Scenario3_ShortName.xaml.cs create mode 100644 SharedContent/Templates/UWPSDKSampleCS/UWPSDKSampleCS.csproj create mode 100644 SharedContent/Templates/UWPSDKSampleCS/UWPSDKSampleCS.sln create mode 100644 SharedContent/Templates/UWPSDKSampleCS/UWPSDKSampleCS.vstemplate create mode 100644 SharedContent/Templates/UWPSDKSampleCS/project.json create mode 100755 SharedContent/Templates/UWPSDKSampleJS/App.jsproj create mode 100755 SharedContent/Templates/UWPSDKSampleJS/MyTemplate.vstemplate create mode 100755 SharedContent/Templates/UWPSDKSampleJS/__TemplateIcon.png create mode 100755 SharedContent/Templates/UWPSDKSampleJS/css/scenario1.css create mode 100755 SharedContent/Templates/UWPSDKSampleJS/css/scenario2.css create mode 100755 SharedContent/Templates/UWPSDKSampleJS/css/scenario3.css create mode 100755 SharedContent/Templates/UWPSDKSampleJS/html/scenario1.html create mode 100755 SharedContent/Templates/UWPSDKSampleJS/html/scenario2.html create mode 100755 SharedContent/Templates/UWPSDKSampleJS/html/scenario3.html create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/Microsoft.WinJS.4.0/css/placeholder create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/Microsoft.WinJS.4.0/fonts/placeholder create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/Microsoft.WinJS.4.0/js/placeholder create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/sample-configuration.js create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/scenario1.js create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/scenario2.js create mode 100755 SharedContent/Templates/UWPSDKSampleJS/js/scenario3.js create mode 100755 SharedContent/Templates/UWPSDKSampleJS/package.appxmanifest create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCPP/Scenario1_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCPP/Scenario1_ShortName.xaml.cpp create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCPP/Scenario1_ShortName.xaml.h create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCPP/ScenarioItemTemplate.vstemplate create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCS/Scenario1_ShortName.xaml create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCS/Scenario1_ShortName.xaml.cs create mode 100644 SharedContent/Templates/UWPSDKSampleScenarioItemCS/ScenarioItemTemplate.vstemplate diff --git a/README.md b/README.md index 99b97ccba9..f62c73588b 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,10 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. App services + Jump list customization Sharing content source app + + Sharing content target app @@ -275,7 +278,7 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. Custom USB device - Device enumeration + Device enumeration and pairing General Purpose Input/Output (GPIO) Gyrometer diff --git a/Samples/ActivitySensor/js/ActivitySensor.jsproj b/Samples/ActivitySensor/js/ActivitySensor.jsproj new file mode 100644 index 0000000000..b6ab7bc0b6 --- /dev/null +++ b/Samples/ActivitySensor/js/ActivitySensor.jsproj @@ -0,0 +1,138 @@ + + + + + Debug + ARM + + + Debug + x64 + + + Debug + x86 + + + Release + ARM + + + Release + x64 + + + Release + x86 + + + + c2adb9af-edb3-4e57-8056-9d0531d4a6b2 + + + + 14.0 + + + + + UAP + 10.0.10586.0 + 10.0.10586.0 + $(VersionNumberMajor).$(VersionNumberMinor) + en-US + + + + Designer + + + default.html + + + + + + + images\microsoft-sdk.png + + + images\smallTile-sdk.png + + + images\splash-sdk.png + + + images\storeLogo-sdk.png + + + images\tile-sdk.png + + + images\windows-sdk.png + + + js\default.js + + + css\default.css + + + + + + + + + Microsoft.WinJS.4.0\css\ui-dark.css + + + Microsoft.WinJS.4.0\css\ui-light.css + + + Microsoft.WinJS.4.0\js\en-US\ui.strings.js + + + Microsoft.WinJS.4.0\js\WinJS.intellisense-setup.js + + + Microsoft.WinJS.4.0\js\WinJS.intellisense.js + + + Microsoft.WinJS.4.0\fonts\Symbols.ttf + + + Microsoft.WinJS.4.0\js\base.js + + + Microsoft.WinJS.4.0\js\ui.js + + + sample-utils\footer.html + + + sample-utils\header.html + + + sample-utils\sample-utils.js + + + sample-utils\scenario-select.css + + + sample-utils\scenario-select.html + + + + + \ No newline at end of file diff --git a/Samples/ActivitySensor/js/ActivitySensor.sln b/Samples/ActivitySensor/js/ActivitySensor.sln new file mode 100644 index 0000000000..a2985e6a8c --- /dev/null +++ b/Samples/ActivitySensor/js/ActivitySensor.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "ActivitySensor", "ActivitySensor.jsproj", "{C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}" +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 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.ActiveCfg = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Build.0 = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|ARM.Deploy.0 = Debug|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.ActiveCfg = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Build.0 = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x64.Deploy.0 = Debug|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.ActiveCfg = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Build.0 = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Debug|x86.Deploy.0 = Debug|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.ActiveCfg = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Build.0 = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|ARM.Deploy.0 = Release|ARM + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.ActiveCfg = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Build.0 = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x64.Deploy.0 = Release|x64 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.ActiveCfg = Release|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Build.0 = Release|x86 + {C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/DeviceEnumeration/js/Microsoft.WinJS.4.0/css/placeholder.txt b/Samples/ActivitySensor/js/Microsoft.WinJS.4.0/css/placeholder.txt similarity index 100% rename from Samples/DeviceEnumeration/js/Microsoft.WinJS.4.0/css/placeholder.txt rename to Samples/ActivitySensor/js/Microsoft.WinJS.4.0/css/placeholder.txt diff --git a/Samples/DeviceEnumeration/js/Microsoft.WinJS.4.0/fonts/placeholder b/Samples/ActivitySensor/js/Microsoft.WinJS.4.0/fonts/placeholder similarity index 100% rename from Samples/DeviceEnumeration/js/Microsoft.WinJS.4.0/fonts/placeholder rename to Samples/ActivitySensor/js/Microsoft.WinJS.4.0/fonts/placeholder diff --git a/Samples/DeviceEnumeration/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt b/Samples/ActivitySensor/js/Microsoft.WinJS.4.0/js/en-us/placeholder.txt similarity index 100% rename from Samples/DeviceEnumeration/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt rename to Samples/ActivitySensor/js/Microsoft.WinJS.4.0/js/en-us/placeholder.txt diff --git a/Samples/ActivitySensor/js/Package.appxmanifest b/Samples/ActivitySensor/js/Package.appxmanifest new file mode 100644 index 0000000000..9e5a1da412 --- /dev/null +++ b/Samples/ActivitySensor/js/Package.appxmanifest @@ -0,0 +1,57 @@ + + + + + + + + + Activity Sensor JS Sample + Microsoft Corporation + images\storelogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/DeviceEnumeration/js/css/placeholder.txt b/Samples/ActivitySensor/js/css/placeholder.txt similarity index 100% rename from Samples/DeviceEnumeration/js/css/placeholder.txt rename to Samples/ActivitySensor/js/css/placeholder.txt diff --git a/Samples/ActivitySensor/js/html/scenario1-currentActivity.html b/Samples/ActivitySensor/js/html/scenario1-currentActivity.html new file mode 100644 index 0000000000..48bd7c4ec8 --- /dev/null +++ b/Samples/ActivitySensor/js/html/scenario1-currentActivity.html @@ -0,0 +1,26 @@ + + + + + + + + + + +
+

Gets the default activity sensor and displays its current activity reading.

+

+ +

+
+ + + + + + + + \ No newline at end of file diff --git a/Samples/ActivitySensor/js/html/scenario2-history.html b/Samples/ActivitySensor/js/html/scenario2-history.html new file mode 100644 index 0000000000..b90b2f5331 --- /dev/null +++ b/Samples/ActivitySensor/js/html/scenario2-history.html @@ -0,0 +1,29 @@ + + + + + + + + + + +
+

Gets the activity history from at most 1 day ago. Displays the first entry, last entry, and count of entries.

+

+ +

+
+ + + + + + + + + + + \ No newline at end of file diff --git a/Samples/ActivitySensor/js/html/scenario3-changeEvents.html b/Samples/ActivitySensor/js/html/scenario3-changeEvents.html new file mode 100644 index 0000000000..1005d6f686 --- /dev/null +++ b/Samples/ActivitySensor/js/html/scenario3-changeEvents.html @@ -0,0 +1,27 @@ + + + + + + + + + + +
+

Subscribes to reading events and displays the updated reading.

+

+ + +

+
+ + + + +
Activity:
Confidence:
Timestamp:
+ + + \ No newline at end of file diff --git a/Samples/ActivitySensor/js/html/scenario4-backgroundActivity.html b/Samples/ActivitySensor/js/html/scenario4-backgroundActivity.html new file mode 100644 index 0000000000..d5208a592a --- /dev/null +++ b/Samples/ActivitySensor/js/html/scenario4-backgroundActivity.html @@ -0,0 +1,30 @@ + + + + + + + + + + +
+

Registers a background task for activity changes. The background task runs whenever the most likely activity changes to/from any of the subscribed activities.

+

+ + +

+
+ + + + + + + +
Task Registration:
Task Status:
Report Count:
Last Activity:
Last Confidence:
Last Timestamp:
+ + + \ No newline at end of file diff --git a/Samples/DeviceEnumeration/js/images/placeholder.txt b/Samples/ActivitySensor/js/images/placeholder.txt similarity index 100% rename from Samples/DeviceEnumeration/js/images/placeholder.txt rename to Samples/ActivitySensor/js/images/placeholder.txt diff --git a/Samples/ActivitySensor/js/js/activitySensorBackgroundTask.js b/Samples/ActivitySensor/js/js/activitySensorBackgroundTask.js new file mode 100644 index 0000000000..d80287a2ba --- /dev/null +++ b/Samples/ActivitySensor/js/js/activitySensorBackgroundTask.js @@ -0,0 +1,55 @@ +//// 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"; + + // This var is used to get information about the current instance of the background task. + var backgroundTaskInstance = Windows.UI.WebUI.WebUIBackgroundTaskInstance.current; + + // Trigger details contain the information surrounding the reason why the this task was triggered + var details = backgroundTaskInstance.triggerDetails; + + function run() { + // read the reports from the trigger details + var reports = details.readReports(); + var values = Windows.Storage.ApplicationData.current.localSettings.values; + + // cache details from this trigger in application data + values["ReportCount"] = reports.length.toString(); + if(reports.length > 0) { + var lastReading = reports[reports.length - 1].reading; + var options = { + year: "numeric", month: "2-digit", + day: "numeric", hour: "2-digit", minute: "2-digit", second: "2-digit" + }; + for (var activity in Windows.Devices.Sensors.ActivityType) { + if (Windows.Devices.Sensors.ActivityType[activity] == lastReading.activity) { + values["LastActivity"] = activity.toString(); + } + } + for (var confidence in Windows.Devices.Sensors.ActivitySensorReadingConfidence) { + if (Windows.Devices.Sensors.ActivitySensorReadingConfidence[confidence] == lastReading.confidence) { + values["LastConfidence"] = confidence.toString(); + } + } + values["LastTimestamp"] = lastReading.timestamp.toLocaleTimeString("en-US", options); + } else { + values["LastActivity"] = "No data"; + values["LastConfidence"] = "No data"; + values["LastTimestamp"] = "No data"; + } + + var dt = new Date(); + values["TaskStatus"] = "Completed at " + dt.toLocaleTimeString("en-US", options); + // A JavaScript background task must call close when done + close(); + } + + run(); +})(); diff --git a/Samples/ActivitySensor/js/js/sample-configuration.js b/Samples/ActivitySensor/js/js/sample-configuration.js new file mode 100644 index 0000000000..13abada3af --- /dev/null +++ b/Samples/ActivitySensor/js/js/sample-configuration.js @@ -0,0 +1,92 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var sampleTitle = "Activity Sensor JS Sample"; + + var scenarios = [ + { url: "/html/scenario1-currentActivity.html", title: "Current activity" }, + { url: "/html/scenario2-history.html", title: "History" }, + { url: "/html/scenario3-changeEvents.html", title: "Events" }, + { url: "/html/scenario4-backgroundActivity.html", title: "Background activity" } + ]; + + WinJS.Namespace.define("SdkSample", { + sampleTitle: sampleTitle, + scenarios: new WinJS.Binding.List(scenarios) + }); + + /// + /// Converts an ActivityType to string. + /// + /// + function activityTypeToString(activityType) { + var result = ""; + switch (activityType) { + case Windows.Devices.Sensors.ActivityType.unknown: + result = "Unknown"; + break; + case Windows.Devices.Sensors.ActivityType.stationary: + result = "Stationary"; + break; + case Windows.Devices.Sensors.ActivityType.fidgeting: + result = "Fidgeting"; + break; + case Windows.Devices.Sensors.ActivityType.walking: + result = "Walking"; + break; + case Windows.Devices.Sensors.ActivityType.running: + result = "Running"; + break; + case Windows.Devices.Sensors.ActivityType.inVehicle: + result = "In vehicle"; + break; + case Windows.Devices.Sensors.ActivityType.biking: + result = "Biking"; + break; + default: + result = "Unrecognized activity type: " + activityType; + break; + } + return result; + } + + /// + /// Converts an ActivitySensorReadingConfidence to string. + /// + /// + function readingConfidenceToString(readingConfidence) { + var result = ""; + switch (readingConfidence) { + case Windows.Devices.Sensors.ActivitySensorReadingConfidence.high: + result = "High"; + break; + case Windows.Devices.Sensors.ActivitySensorReadingConfidence.low: + result = "Low"; + break; + default: + result = "Unrecognized reading confidence: " + readingConfidence; + break; + } + return result; + } + + var dateTimeFormatter = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate longtime"); + + WinJS.Namespace.define("ActivitySensorSdkSample", { + /// + /// Formats an activity reading into a series of named child elements. + /// + /// + /// + /// + /// + /// + formatActivity: function formatActivity(reading, parentElement, activitySelector, confidenceSelector, timestampSelector) { + parentElement.querySelector(activitySelector).innerText = activityTypeToString(reading.activity); + parentElement.querySelector(confidenceSelector).innerText = readingConfidenceToString(reading.confidence); + parentElement.querySelector(timestampSelector).innerText = dateTimeFormatter.format(reading.timestamp); + }, + }); +})(); \ No newline at end of file diff --git a/Samples/ActivitySensor/js/js/scenario1-currentActivity.js b/Samples/ActivitySensor/js/js/scenario1-currentActivity.js new file mode 100644 index 0000000000..4b13f533ed --- /dev/null +++ b/Samples/ActivitySensor/js/js/scenario1-currentActivity.js @@ -0,0 +1,37 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var scenarioOutput; + + var page = WinJS.UI.Pages.define("/html/scenario1-currentActivity.html", { + ready: function (element, options) { + scenarioOutput = document.getElementById("scenarioOutput"); + + document.getElementById("getCurrentActivity").addEventListener("click", getCurrentActivity, false); + } + }); + + /// + /// This is the click handler for the 'Get current activity' button. + /// + function getCurrentActivity() { + + // Reset fields and status + scenarioOutput.style.display = "none"; + WinJS.log && WinJS.log("", "sample", "status"); + + Windows.Devices.Sensors.ActivitySensor.getDefaultAsync().done(function (activitySensor) { + if (activitySensor) { + activitySensor.getCurrentReadingAsync().done(function (reading) { + ActivitySensorSdkSample.formatActivity(reading, scenarioOutput, "#activity", "#confidence", "#timestamp"); + scenarioOutput.style.display = "block"; + }); + } else { + WinJS.log && WinJS.log("No activity sensor found", "sample", "error"); + } + }); + } + +})(); diff --git a/Samples/ActivitySensor/js/js/scenario2-history.js b/Samples/ActivitySensor/js/js/scenario2-history.js new file mode 100644 index 0000000000..740d8b8525 --- /dev/null +++ b/Samples/ActivitySensor/js/js/scenario2-history.js @@ -0,0 +1,46 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var scenarioOutput; + + var page = WinJS.UI.Pages.define("/html/scenario2-history.html", { + ready: function (element, options) { + scenarioOutput = document.getElementById("scenarioOutput"); + + document.getElementById("getActivityHistory").addEventListener("click", getActivityHistory, false); + } + }); + + /// + /// This is the click handler for the 'Get activity history' button. + /// + function getActivityHistory() { + + // Reset fields and status + scenarioOutput.style.display = "none"; + WinJS.log && WinJS.log("", "sample", "status"); + + var calendar = new Windows.Globalization.Calendar(); + calendar.setToNow(); + calendar.addDays(-1); + var yesterday = calendar.getDateTime(); + + // Get history from yesterday onwards + var history = Windows.Devices.Sensors.ActivitySensor.getSystemHistoryAsync(yesterday).done(function (history) { + if (history.length > 0) { + var reading1 = history[0]; + ActivitySensorSdkSample.formatActivity(reading1, scenarioOutput, "#activity1", "#confidence1", "#timestamp1"); + + var readingN = history[history.length - 1]; + ActivitySensorSdkSample.formatActivity(readingN, scenarioOutput, "#activityN", "#confidenceN", "#timestampN"); + + scenarioOutput.style.display = "block"; + + } + WinJS.log && WinJS.log("Readings retrieved: " + history.length, "sample", "status"); + }); + } + +})(); diff --git a/Samples/ActivitySensor/js/js/scenario3-changeEvents.js b/Samples/ActivitySensor/js/js/scenario3-changeEvents.js new file mode 100644 index 0000000000..cea87ab963 --- /dev/null +++ b/Samples/ActivitySensor/js/js/scenario3-changeEvents.js @@ -0,0 +1,70 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + var activitySensor; + + var enableReadingChanged; + var disableReadingChanged; + var scenarioOutput; + + var page = WinJS.UI.Pages.define("/html/scenario3-changeEvents.html", { + ready: function (element, options) { + enableReadingChanged = document.getElementById("enableReadingChanged"); + disableReadingChanged = document.getElementById("disableReadingChanged"); + scenarioOutput = document.getElementById("scenarioOutput"); + + enableReadingChanged.addEventListener("click", enableReadingChangedScenario, false); + disableReadingChanged.addEventListener("click", disableReadingChangedScenario, false); + }, + unload: function () { + if (activitySensor) { + activitySensor.removeEventListener("readingchanged", onReadingChanged); + } + } + }); + + /// + /// This is the event handler for ReadingChanged events. + /// + /// + function onReadingChanged(e) { + var reading = e.reading; + ActivitySensorSdkSample.formatActivity(reading, scenarioOutput, "#activity", "#confidence", "#timestamp"); + } + + /// + /// This is the click handler for the 'Reading Changed On' button. + /// + function enableReadingChangedScenario() { + enableReadingChanged.disabled = true; + Windows.Devices.Sensors.ActivitySensor.getDefaultAsync().done(function (sensor) { + if (sensor) { + activitySensor = sensor; + + activitySensor.subscribedActivities.push( + Windows.Devices.Sensors.ActivityType.walking, + Windows.Devices.Sensors.ActivityType.running, + Windows.Devices.Sensors.ActivityType.inVehicle, + Windows.Devices.Sensors.ActivityType.biking, + Windows.Devices.Sensors.ActivityType.fidgeting); + + activitySensor.addEventListener("readingchanged", onReadingChanged); + disableReadingChanged.disabled = false; + } else { + WinJS.log && WinJS.log("No activity sensor found", "sample", "error"); + enableReadingChanged.disabled = false; + } + }); + } + + /// + /// This is the click handler for the 'Reading Changed Off' button. + /// + function disableReadingChangedScenario() { + activitySensor.removeEventListener("readingchanged", onReadingChanged); + activitySensor = null; + enableReadingChanged.disabled = false; + disableReadingChanged.disabled = true; + } +})(); diff --git a/Samples/ActivitySensor/js/js/scenario4-backgroundActivity.js b/Samples/ActivitySensor/js/js/scenario4-backgroundActivity.js new file mode 100644 index 0000000000..73e6e9ae9b --- /dev/null +++ b/Samples/ActivitySensor/js/js/scenario4-backgroundActivity.js @@ -0,0 +1,138 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +/// args,iter,unregister +(function () { + "use strict"; + + var Background = Windows.ApplicationModel.Background; + var BackgroundExecutionManager = Background.BackgroundExecutionManager; + var BackgroundTaskRegistration = Background.BackgroundTaskRegistration; + var BackgroundAccessStatus = Background.BackgroundAccessStatus; + + var sampleBackgroundTaskName = "ActivitySensorBackgroundTask"; + var sampleBackgroundTaskEntryPoint = "js\\activitySensorBackgroundTask.js"; + var backgroundTask; + + var registerTaskButton; + var unregisterTaskButton; + var scenarioOutput; + var taskRegistrationOutput; + + var page = WinJS.UI.Pages.define("/html/scenario4-backgroundActivity.html", { + ready: function (element, options) { + registerTaskButton = document.getElementById("registerTask"); + unregisterTaskButton = document.getElementById("unregisterTask"); + scenarioOutput = document.getElementById("scenarioOutput"); + + registerTaskButton.addEventListener("click", registerTaskScenario, false); + unregisterTaskButton.addEventListener("click", unregisterTaskScenario, false); + + // Look for the background task. + for (var iter = BackgroundTaskRegistration.allTasks.first(); iter.hasCurrent; iter.moveNext) { + var task = iter.current.value; + if (task.name == sampleBackgroundTaskName) { + backgroundTask = task; + break; + } + } + + if (backgroundTask) { + backgroundTask.addEventListener("completed", onBackgroundTaskCompleted); + updateUI("Registered"); + } else { + updateUI("Unregistered"); + } + } + }); + + /// + /// This is the click handler for the 'Register Task' button. + /// + function registerTaskScenario() { + registerTaskButton.disabled = true; + BackgroundExecutionManager.requestAccessAsync().done(function (status) { + if (BackgroundAccessStatus.allowedWithAlwaysOnRealTimeConnectivity === status || + BackgroundAccessStatus.allowedMayUseActiveRealTimeConnectivity === status) { + registerBackgroundTask(); + } else { + WinJS.log && WinJS.log("Background tasks may be disabled for this app", "sample", "error"); + registerTaskButton.disabled = false; + } + }); + } + + /// + /// This is the click handler for the 'Unregister Task' button. + /// + function unregisterTaskScenario() { + backgroundTask.unregister(true /*cancelTask*/); + backgroundTask = null; + updateUI("Unregistered"); + } + + /// + /// This is the event handler for background task completion. + /// + /// The task that is reporting completion. + /// The completion report arguments. + function onBackgroundTaskCompleted(args) { + var status = "Completed"; + try { + args.checkResult(); + } catch (e) { + status = e.message; + } + updateUI(status); + } + + /// + /// Registers the background task. + /// + function registerBackgroundTask() { + var builder = new Background.BackgroundTaskBuilder(); + builder.name = sampleBackgroundTaskName; + builder.taskEntryPoint = sampleBackgroundTaskEntryPoint; + + var reportIntervalMs = 3000; // 3 seconds + var trigger = new Background.ActivitySensorTrigger(reportIntervalMs); + + trigger.subscribedActivities.push( + Windows.Devices.Sensors.ActivityType.walking, + Windows.Devices.Sensors.ActivityType.running, + Windows.Devices.Sensors.ActivityType.biking); + + builder.setTrigger(trigger); + backgroundTask = builder.register(); + backgroundTask.addEventListener("completed", onBackgroundTaskCompleted); + + updateUI("Registered"); + } + + /// + /// Updates the scenario UI. + /// + /// The status text to display. + function updateUI(statusText) { + registerTaskButton.disabled = backgroundTask; + unregisterTaskButton.disabled = !backgroundTask; + + scenarioOutput.querySelector("#taskRegistration").innerText = statusText; + + var values = Windows.Storage.ApplicationData.current.localSettings.values; + if (values.hasKey("reportCount")) { + scenarioOutput.querySelector("#reportCount").innerText = values["reportCount"]; + } + if (values.hasKey("taskStatus")) { + scenarioOutput.querySelector("#taskStatus").innerText = values["taskStatus"]; + } + if (values.hasKey("lastActivity")) { + scenarioOutput.querySelector("#lastActivity").innerText = values["lastActivity"]; + } + if (values.hasKey("lastConfidence")) { + scenarioOutput.querySelector("#lastConfidence").innerText = values["lastConfidence"]; + } + if (values.hasKey("lastTimestamp")) { + scenarioOutput.querySelector("#lastTimestamp").innerText = values["lastTimestamp"]; + } + } +})(); diff --git a/Samples/DeviceEnumeration/js/sample-utils/placeholder.txt b/Samples/ActivitySensor/js/sample-utils/placeholder.txt similarity index 100% rename from Samples/DeviceEnumeration/js/sample-utils/placeholder.txt rename to Samples/ActivitySensor/js/sample-utils/placeholder.txt diff --git a/Samples/BackgroundTask/cpp/BackgroundTask/BackgroundTask.vcxproj b/Samples/BackgroundTask/cpp/BackgroundTask/BackgroundTask.vcxproj index 9408a3d734..95e04a2ce8 100644 --- a/Samples/BackgroundTask/cpp/BackgroundTask/BackgroundTask.vcxproj +++ b/Samples/BackgroundTask/cpp/BackgroundTask/BackgroundTask.vcxproj @@ -8,8 +8,8 @@ true Windows Store 10.0 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 true diff --git a/Samples/BackgroundTask/cpp/BackgroundTask/Package.appxmanifest b/Samples/BackgroundTask/cpp/BackgroundTask/Package.appxmanifest index 5d692e3a54..a548da4b5f 100644 --- a/Samples/BackgroundTask/cpp/BackgroundTask/Package.appxmanifest +++ b/Samples/BackgroundTask/cpp/BackgroundTask/Package.appxmanifest @@ -20,7 +20,7 @@ - + diff --git a/Samples/BackgroundTask/cpp/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cpp b/Samples/BackgroundTask/cpp/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cpp index 2067080fc5..24408cb3d6 100644 --- a/Samples/BackgroundTask/cpp/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cpp +++ b/Samples/BackgroundTask/cpp/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cpp @@ -60,6 +60,7 @@ void ApplicationTriggerTask::OnNavigatedTo(NavigationEventArgs^ e) hascur = iter->MoveNext(); } + trigger = ref new ApplicationTrigger(); UpdateUI(); } @@ -91,8 +92,6 @@ void ApplicationTriggerTask::AttachProgressAndCompletedHandlers(IBackgroundTaskR /// void ApplicationTriggerTask::RegisterBackgroundTask(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { - trigger = ref new ApplicationTrigger(); - auto task = BackgroundTaskSample::RegisterBackgroundTask(SampleBackgroundTaskEntryPoint, ApplicationTriggerTaskName, trigger, diff --git a/Samples/BackgroundTask/cpp/Tasks/Tasks.vcxproj b/Samples/BackgroundTask/cpp/Tasks/Tasks.vcxproj index a452e8e669..7d29ad19bb 100644 --- a/Samples/BackgroundTask/cpp/Tasks/Tasks.vcxproj +++ b/Samples/BackgroundTask/cpp/Tasks/Tasks.vcxproj @@ -36,8 +36,8 @@ true Windows Store 10.0 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 true diff --git a/Samples/BackgroundTask/cs/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cs b/Samples/BackgroundTask/cs/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cs index 1dab288804..c93a61bc8c 100644 --- a/Samples/BackgroundTask/cs/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cs +++ b/Samples/BackgroundTask/cs/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.cs @@ -56,6 +56,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) } } + trigger = new ApplicationTrigger(); UpdateUI(); } @@ -66,8 +67,6 @@ protected override void OnNavigatedTo(NavigationEventArgs e) /// private async void RegisterBackgroundTask(object sender, RoutedEventArgs e) { - trigger = new ApplicationTrigger(); - var task = BackgroundTaskSample.RegisterBackgroundTask(BackgroundTaskSample.SampleBackgroundTaskEntryPoint, BackgroundTaskSample.ApplicationTriggerTaskName, trigger, diff --git a/Samples/BackgroundTask/vb/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.vb b/Samples/BackgroundTask/vb/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.vb index 2221301c02..8ac2d8a6e6 100644 --- a/Samples/BackgroundTask/vb/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.vb +++ b/Samples/BackgroundTask/vb/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.vb @@ -47,6 +47,7 @@ Namespace Global.SDKTemplate End If Next + trigger = New ApplicationTrigger() UpdateUI() End Sub @@ -56,7 +57,6 @@ Namespace Global.SDKTemplate ''' ''' Private Async Sub RegisterBackgroundTask(sender As Object, e As RoutedEventArgs) - trigger = New ApplicationTrigger() Dim task = BackgroundTaskSample.RegisterBackgroundTask(BackgroundTaskSample.SampleBackgroundTaskEntryPoint, BackgroundTaskSample.ApplicationTriggerTaskName, trigger, Nothing) Await task AttachProgressAndCompletedHandlers(task.Result) diff --git a/Samples/CompositionVisual/cs/CompositionVisual.csproj b/Samples/CompositionVisual/cs/CompositionVisual.csproj index ebd377bd52..7d274c646f 100644 --- a/Samples/CompositionVisual/cs/CompositionVisual.csproj +++ b/Samples/CompositionVisual/cs/CompositionVisual.csproj @@ -11,8 +11,8 @@ CompositionVisual en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 @@ -98,7 +98,7 @@ Designer - + Properties\Default.rd.xml diff --git a/Samples/CompositionVisual/cs/Package.appxmanifest b/Samples/CompositionVisual/cs/Package.appxmanifest index 139a03fdc3..95b784035d 100644 --- a/Samples/CompositionVisual/cs/Package.appxmanifest +++ b/Samples/CompositionVisual/cs/Package.appxmanifest @@ -21,7 +21,7 @@ - + @@ -47,8 +47,4 @@ - - - - \ No newline at end of file diff --git a/Samples/CompositionVisual/cs/VisualProperties.cs b/Samples/CompositionVisual/cs/VisualProperties.cs index 1cb25cf446..a1faff6e6e 100644 --- a/Samples/CompositionVisual/cs/VisualProperties.cs +++ b/Samples/CompositionVisual/cs/VisualProperties.cs @@ -144,7 +144,7 @@ void OnPointerMoved(CoreWindow window, PointerEventArgs args) // foreach (var child in _currentVisual.Children) { - child.RotationAngle = 45.0f; + child.RotationAngleInDegrees = 45.0f; child.CenterPoint = new Vector3(_currentVisual.Size.X / 2, _currentVisual.Size.Y / 2, 0); break; } @@ -311,15 +311,15 @@ Visual CreateChildElement() // // The outer rectangle is always white // - var visual = _compositor.CreateSolidColorVisual(); + var visual = _compositor.CreateSpriteVisual(); element.Children.InsertAtTop(visual); - visual.Color = Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF); + visual.Brush = _compositor.CreateColorBrush(Color.FromArgb(0xFF, 0xFF, 0xFF, 0xFF)); visual.Size = new Vector2(100.0f, 100.0f); // // The inner rectangle is inset from the outer by three pixels all around // - var child = _compositor.CreateSolidColorVisual(); + var child = _compositor.CreateSpriteVisual(); visual.Children.InsertAtTop(child); child.Offset = new Vector3(3.0f, 3.0f, 0.0f); child.Size = new Vector2(94.0f, 94.0f); @@ -330,7 +330,7 @@ Visual CreateChildElement() byte red = (byte)(0xFF * (0.2f + (_random.NextDouble() / 0.8f))); byte green = (byte)(0xFF * (0.2f + (_random.NextDouble() / 0.8f))); byte blue = (byte)(0xFF * (0.2f + (_random.NextDouble() / 0.8f))); - child.Color = Color.FromArgb(0xFF, red, green, blue); + child.Brush = _compositor.CreateColorBrush(Color.FromArgb(0xFF, red, green, blue)); // // Make the subtree root visual partially transparent. This will cause each visual in the subtree diff --git a/Samples/CompositionVisual/vb/CompositionVisual.vbproj b/Samples/CompositionVisual/vb/CompositionVisual.vbproj index 91a64bdce7..e60d5cf120 100644 --- a/Samples/CompositionVisual/vb/CompositionVisual.vbproj +++ b/Samples/CompositionVisual/vb/CompositionVisual.vbproj @@ -11,8 +11,8 @@ CompositionVisual en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 diff --git a/Samples/CompositionVisual/vb/Package.appxmanifest b/Samples/CompositionVisual/vb/Package.appxmanifest index 20ef90ae06..50f001aff3 100644 --- a/Samples/CompositionVisual/vb/Package.appxmanifest +++ b/Samples/CompositionVisual/vb/Package.appxmanifest @@ -21,7 +21,7 @@ - + @@ -47,8 +47,4 @@ - - - - \ No newline at end of file diff --git a/Samples/CompositionVisual/vb/VisualProperties.vb b/Samples/CompositionVisual/vb/VisualProperties.vb index 5098a27bd1..dc6522539b 100644 --- a/Samples/CompositionVisual/vb/VisualProperties.vb +++ b/Samples/CompositionVisual/vb/VisualProperties.vb @@ -67,7 +67,7 @@ Namespace Global.CompositionVisual If Not _dragging Then _currentVisual.Opacity = 1.0f For Each child In _currentVisual.Children - child.RotationAngle = 45.0f + child.RotationAngleInDegrees = 45.0F child.CenterPoint = New Vector3(_currentVisual.Size.X / 2, _currentVisual.Size.Y / 2, 0) Exit For Next @@ -142,14 +142,14 @@ Namespace Global.CompositionVisual ' ' The outer rectangle is always white ' - Dim visual = _compositor.CreateSolidColorVisual() + Dim visual = _compositor.CreateSpriteVisual() element.Children.InsertAtTop(visual) - visual.Color = Color.FromArgb(&HFF, &HFF, &HFF, &HFF) + visual.Brush = _compositor.CreateColorBrush(Color.FromArgb(&HFF, &HFF, &HFF, &HFF)) visual.Size = New Vector2(100.0f, 100.0f) ' ' The inner rectangle is inset from the outer by three pixels all around ' - Dim child = _compositor.CreateSolidColorVisual() + Dim child = _compositor.CreateSpriteVisual() visual.Children.InsertAtTop(child) child.Offset = New Vector3(3.0f, 3.0f, 0.0f) child.Size = New Vector2(94.0f, 94.0f) @@ -159,7 +159,7 @@ Namespace Global.CompositionVisual Dim red As Byte = CType((&HFF * (0.2f + (_random.NextDouble() / 0.8f))), Byte) Dim green As Byte = CType((&HFF * (0.2f + (_random.NextDouble() / 0.8f))), Byte) Dim blue As Byte = CType((&HFF * (0.2f + (_random.NextDouble() / 0.8f))), Byte) - child.Color = Color.FromArgb(&HFF, red, green, blue) + child.Brush = _compositor.CreateColorBrush(Color.FromArgb(&HFF, red, green, blue)) element.Opacity = 0.8f Return element End Function diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks.Shared/AdventureWorks.Shared.vcxproj b/Samples/CortanaVoiceCommand/cpp/AdventureWorks.Shared/AdventureWorks.Shared.vcxproj index 99f69802c1..72ea562099 100644 --- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks.Shared/AdventureWorks.Shared.vcxproj +++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks.Shared/AdventureWorks.Shared.vcxproj @@ -36,8 +36,8 @@ true Windows Store 8.2 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj index 0d1dd3685c..614d2ba5ff 100644 --- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj +++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj @@ -8,8 +8,8 @@ true Windows Store 8.2 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 @@ -236,6 +236,21 @@ Strings\en-GB\Resources.resw + + + Strings\en-CA\Resources.resw + + + + + Strings\en-IN\Resources.resw + + + + + Strings\en-AU\Resources.resw + + Strings\en-US\Resources.resw @@ -262,7 +277,9 @@ - + + Designer + diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj.filters b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj.filters index 4e4c7f57b8..f44fabdcb0 100644 --- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj.filters +++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/AdventureWorks.vcxproj.filters @@ -41,6 +41,15 @@ {d96499de-5568-402a-b7e7-b82f61c7bc06} + + {5d522ece-8345-43d9-a598-73fa960c0697} + + + {108fefa4-0454-423e-b055-4acfb792e332} + + + {576b2b47-ecc9-4220-890b-df20c7f2e7be} + @@ -139,7 +148,7 @@ - + @@ -154,6 +163,15 @@ Strings\en-GB + + Strings\en-CA + + + Strings\en-AU + + + Strings\en-IN + Strings\es-ES diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Package.appxmanifest b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Package.appxmanifest index d07531a4f8..44f7e7c4a6 100644 --- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Package.appxmanifest +++ b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Package.appxmanifest @@ -20,7 +20,7 @@ - + @@ -45,8 +45,8 @@ - - + + diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-AU/placeholder.txt b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-AU/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-CA/placeholder.txt b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-CA/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-IN/placeholder.txt b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/Strings/en-IN/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/adventureworkscommands.xml b/Samples/CortanaVoiceCommand/cpp/AdventureWorks/adventureworkscommands.xml deleted file mode 100644 index 650270f4bb..0000000000 --- a/Samples/CortanaVoiceCommand/cpp/AdventureWorks/adventureworkscommands.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - Adventure Works - Show trip to London - - - Show trip to London - show [my] trip to {destination} - show [my] {builtin:AppName} trip to {destination} - Showing trip to {destination} - - - - - When is my trip to Las Vegas? - when is [my] trip to {destination} - when is [my] {builtin:AppName} trip to {destination} - Looking for trip to {destination} - - - - - Cancel my trip to Las Vegas - cancel [my] trip to {destination} - cancel [my] {builtin:AppName} trip to {destination} - Cancelling trip to {destination} - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - Show trip to London - - - Show trip to London - show [my] trip to {destination} - show [my] {builtin:AppName} trip to {destination} - Showing trip to {destination} - - - - - When is my trip to Las Vegas? - when is [my] trip to {destination} - when is [my] {builtin:AppName} trip to {destination} - Looking for trip to {destination} - - - - - Cancel my trip to Las Vegas - cancel [my] trip to {destination} - cancel [my] {builtin:AppName} trip to {destination} - Cancelling trip to {destination} - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - Montrer mon voyage à Londres - - - Montrer mon voyage à Londres - montrer [mon] voyage à {destination} - montrer [mon] {builtin:AppName} voyage à {destination} - Voici les détails du votre voyage à {destination} - - - - - Quand a lieu mon voyage à Las Vegas? - quand a lieu [mon] voyage à {destination} - quand a lieu [mon] {builtin:AppName} voyage à {destination} - Le chercher pour votre voyage à {destination} est en cours - - - - - Annuler mon voyage à Las Vegas - annuler [mon] voyage à {destination} - annuler [mon] {builtin:AppName} voyage à {destination} - L'annulation du votre voyage à {destination} est en cours - - - - - London - Melbourne - Yosemite National Park - - - - - Adventure Works - Mostra il viaggio a Londra - - - Mostra viaggio Londra - mostra il [mio] viaggio a {destination} - mostra il [mio] viaggio di {builtin:AppName} a {destination} - Mostro il viaggio a {destination} - - - - - Quando è il mio viaggio a Las Vegas? - quando è il [mio] viaggio a {destination} - quando è il [mio] viaggio di {builtin:AppName} a {destination} - Ricerca del viaggio a {destination} in corso - - - - - Annulla il mio viaggio a Las Vegas - annulla il [mio] viaggio a {destination} - annulla il [mio] viaggio di {builtin:AppName} a {destination} - Sto annullando il viaggio a {destination} - - - - - London - Melbourne - Yosemite National Park - - - - - - Adventure Works - Zeige Reise nach London - - - Meine Reise nach London zeigen - [Meine] Reise nach {destination} zeigen. - [Meine] {builtin:AppName} Reise nach {destination} zeigen. - Zeige Reise nach {destination} - - - - - Wann ist meine Reise nach Las Vegas? - wann ist [meine] Reise nach {destination} - wann ist [meine] {builtin:AppName} Reise nach {destination} - Auf der Suche nach Reise nach {destination} - - - - - Meine Reise nach Las Vegas abbrechen - [Meine] Reise nach {destination} abbrechen - [Meine] {builtin:AppName} Reise nach {destination} abbrechen - Reise nach {destination} abbrechen - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - Mostrar viaje a Londres - - - Mostrar viaje a Londres - mostrar [mi] viaje a {destination} - mostrar [mi] {builtin:AppName} viaje a {destination} - Mostrando viaje a {destination} - - - - - ¿Cuándo es mi viaje a Las Vegas? - cuando es [mi] viaje a {destination} - cuando es [mi] {builtin:AppName} viaje a {destination} - Buscando viaje a {destination} - - - - - Cancelar mi viaje a Las Vegas - cancelar [mi] viaje a {destination} - cancelar [mi] {builtin:AppName} viaje a {destination} - Viaje a {destination} cancelado - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - 显示伦敦之行 - - - 显示伦敦之行 - 显示[我]去{destination}的旅行 - 显示[我]{builtin:AppName}去{destination}的旅行 - 显示{destination}之行 - - - - - 我的拉斯维加斯之旅的时间? - [我]前往{destination}的旅行是什么时候 - 显示[我]{builtin:AppName}前往{destination}的旅行是什么时候 - 查询{destination}之行 - - - - - 取消我的拉斯维加斯之旅 - 取消[我的]{destination}之旅 - 取消[我的]{builtin:AppName}{destination}之旅 - 取消{destination}之行 - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - \ No newline at end of file diff --git a/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.cpp b/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.cpp index a3bd264175..cf827039ec 100644 --- a/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.cpp +++ b/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.cpp @@ -9,7 +9,7 @@ // //********************************************************* #include "pch.h" -#include "AdventureworksVoiceCommandService.h" +#include "AdventureWorksVoiceCommandService.h" using namespace VoiceCommandService; @@ -46,7 +46,7 @@ using namespace Windows::Storage; /// be required. /// /// Connection to the hosting background service process. -void AdventureworksVoiceCommandService::Run(IBackgroundTaskInstance ^taskInstance) +void AdventureWorksVoiceCommandService::Run(IBackgroundTaskInstance ^taskInstance) { serviceDeferral = taskInstance->GetDeferral(); @@ -56,14 +56,14 @@ void AdventureworksVoiceCommandService::Run(IBackgroundTaskInstance ^taskInstanc taskCancelledToken = taskInstance->Canceled += ref new BackgroundTaskCanceledEventHandler( this, - &AdventureworksVoiceCommandService::OnCanceled); + &AdventureWorksVoiceCommandService::OnCanceled); AppServiceTriggerDetails^ triggerDetails = dynamic_cast(taskInstance->TriggerDetails); // This should match the uap:AppService and VoiceCommandService references from the // package manifest and VCD files, respectively. Make sure we've been launched by // a Cortana Voice Command. - if (triggerDetails != nullptr && triggerDetails->Name == "AdventureworksVoiceCommandService") + if (triggerDetails != nullptr && triggerDetails->Name == "AdventureWorksVoiceCommandService") { try { @@ -74,13 +74,15 @@ void AdventureworksVoiceCommandService::Run(IBackgroundTaskInstance ^taskInstanc VoiceCommandServiceConnection ^, VoiceCommandCompletedEventArgs ^>( this, - &AdventureworksVoiceCommandService::OnVoiceCommandCompleted); + &AdventureWorksVoiceCommandService::OnVoiceCommandCompleted); - resourceMap = ResourceManager::Current->MainResourceMap->GetSubtree("Resources"); - - // Select the system language, which is what Cortana should be running as. - context = ResourceContext::GetForViewIndependentUse(); + resourceMap = ResourceManager::Current->MainResourceMap->GetSubtree("Resources"); + // Select the system language, which is what Cortana should be running as. + context = ResourceContext::GetForViewIndependentUse(); + // GetVoiceCommandAsync establishes initial connection to Cortana, and must be called prior to any + // messages sent to Cortana. Attempting to use ReportSuccessAsync, ReportProgressAsync, etc + // prior to calling this will produce undefined behavior. // Note, since this is running synchronously, and not part of the UI thread, blocking // with .wait() is ideal in most cases. create_task(voiceServiceConnection->GetVoiceCommandAsync()) @@ -121,7 +123,7 @@ void AdventureworksVoiceCommandService::Run(IBackgroundTaskInstance ^taskInstanc /// /// This background task instance /// Contains an enumeration with the reason for task cancellation -void AdventureworksVoiceCommandService::OnCanceled(IBackgroundTaskInstance ^sender, BackgroundTaskCancellationReason reason) +void AdventureWorksVoiceCommandService::OnCanceled(IBackgroundTaskInstance ^sender, BackgroundTaskCancellationReason reason) { OutputDebugStringW(L"Task cancelled, cleaning up"); if (this->serviceDeferral.Get() != nullptr) @@ -138,7 +140,7 @@ void AdventureworksVoiceCommandService::OnCanceled(IBackgroundTaskInstance ^send /// /// The voice connection associated with the command. /// Contains an Enumeration indicating why the command was terminated. -void AdventureworksVoiceCommandService::OnVoiceCommandCompleted(VoiceCommandServiceConnection ^sender, VoiceCommandCompletedEventArgs ^args) +void AdventureWorksVoiceCommandService::OnVoiceCommandCompleted(VoiceCommandServiceConnection ^sender, VoiceCommandCompletedEventArgs ^args) { if (this->serviceDeferral.Get() != nullptr) { @@ -153,7 +155,7 @@ void AdventureworksVoiceCommandService::OnVoiceCommandCompleted(VoiceCommandServ /// /// The name of a destination, expected to match the phrase list. /// -void AdventureworksVoiceCommandService::SendCompletionMessageForDestination(String^ destination) +void AdventureWorksVoiceCommandService::SendCompletionMessageForDestination(String^ destination) { // Begin loading data to search for the target trip. If this operation is going to take // a non-trivial amount of time, show a progress screen in order to prevent Cortana @@ -245,7 +247,7 @@ void AdventureworksVoiceCommandService::SendCompletionMessageForDestination(Stri /// /// The name of a destination, expected to match the phrase list. /// -void AdventureworksVoiceCommandService::SendCompletionMessageForCancellation(String^ destination) +void AdventureWorksVoiceCommandService::SendCompletionMessageForCancellation(String^ destination) { // Begin loading data to search for the target trip. If this operation is going to take // a non-trivial amount of time, show a progress screen in order to prevent Cortana @@ -353,7 +355,7 @@ void AdventureworksVoiceCommandService::SendCompletionMessageForCancellation(Str /// The initial disambiguation message /// Repeat prompt retry message /// -Trip^ VoiceCommandService::AdventureworksVoiceCommandService::DisambiguateTrips(std::vector trips, Platform::String ^ disambiguationMessage, String ^ secondDisambiguationMessage) +Trip^ VoiceCommandService::AdventureWorksVoiceCommandService::DisambiguateTrips(std::vector trips, Platform::String ^ disambiguationMessage, String ^ secondDisambiguationMessage) { auto userPrompt = ref new VoiceCommandUserMessage(); userPrompt->DisplayMessage = disambiguationMessage; @@ -412,7 +414,7 @@ Trip^ VoiceCommandService::AdventureworksVoiceCommandService::DisambiguateTrips( /// Provide a simple response that launches the app. Expected to be used in the /// case where the voice command could not be recognized (eg, a VCD/code mismatch.) /// -void VoiceCommandService::AdventureworksVoiceCommandService::LaunchAppInForeground() +void VoiceCommandService::AdventureWorksVoiceCommandService::LaunchAppInForeground() { auto userProgressMessage = ref new VoiceCommandUserMessage(); userProgressMessage->SpokenMessage = GetResourceString(L"LaunchingAdventureWorks"); @@ -429,7 +431,7 @@ void VoiceCommandService::AdventureworksVoiceCommandService::LaunchAppInForegrou /// /// The message to display, relating to the task being performed. /// -void VoiceCommandService::AdventureworksVoiceCommandService::ShowProgressScreen(Platform::String ^ progressMessage) +void VoiceCommandService::AdventureWorksVoiceCommandService::ShowProgressScreen(Platform::String ^ progressMessage) { auto userProgressMessage = ref new VoiceCommandUserMessage(); userProgressMessage->DisplayMessage = progressMessage; @@ -441,14 +443,14 @@ void VoiceCommandService::AdventureworksVoiceCommandService::ShowProgressScreen( /// Look up a resource string and return it. /// The resource string requested for the current context -String ^ AdventureworksVoiceCommandService::GetResourceString(String ^ resourceName) +String ^ AdventureWorksVoiceCommandService::GetResourceString(String ^ resourceName) { return resourceMap->GetValue(resourceName, context)->ValueAsString; } /// Look up a resource string and replace {0} with the parameter provided (simple string.format) /// The resource string requested for the current context, with substitution -String ^ AdventureworksVoiceCommandService::GetResourceStringAndFormat(String ^ resourceName, Platform::String ^ param) +String ^ AdventureWorksVoiceCommandService::GetResourceStringAndFormat(String ^ resourceName, Platform::String ^ param) { String^ resource = GetResourceString(resourceName); std::wstring str = resource->Data(); diff --git a/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.h b/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.h index e760283a20..9d69f5e530 100644 --- a/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.h +++ b/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/AdventureworksVoiceCommandService.h @@ -12,15 +12,15 @@ namespace VoiceCommandService { [Windows::Foundation::Metadata::WebHostHidden] - public ref class AdventureworksVoiceCommandService sealed : public Windows::ApplicationModel::Background::IBackgroundTask + public ref class AdventureWorksVoiceCommandService sealed : public Windows::ApplicationModel::Background::IBackgroundTask { public: // Inherited via IBackgroundTask virtual void Run(Windows::ApplicationModel::Background::IBackgroundTaskInstance ^taskInstance); private: - Windows::ApplicationModel::Resources::Core::ResourceContext^ context; - Windows::ApplicationModel::Resources::Core::ResourceMap^ resourceMap; + Windows::ApplicationModel::Resources::Core::ResourceContext^ context; + Windows::ApplicationModel::Resources::Core::ResourceMap^ resourceMap; Windows::Foundation::EventRegistrationToken taskCancelledToken; Windows::ApplicationModel::VoiceCommands::VoiceCommandServiceConnection^ voiceServiceConnection; @@ -40,7 +40,7 @@ namespace VoiceCommandService void ShowProgressScreen(Platform::String^ progressMessage); - Platform::String^ GetResourceString(Platform::String^ resourceName); - Platform::String^ GetResourceStringAndFormat(Platform::String^ resourceName, Platform::String^ param); + Platform::String^ GetResourceString(Platform::String^ resourceName); + Platform::String^ GetResourceStringAndFormat(Platform::String^ resourceName, Platform::String^ param); }; } diff --git a/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/VoiceCommandService.vcxproj b/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/VoiceCommandService.vcxproj index acc1948202..fdffd1dae2 100644 --- a/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/VoiceCommandService.vcxproj +++ b/Samples/CortanaVoiceCommand/cpp/VoiceCommandService/VoiceCommandService.vcxproj @@ -36,8 +36,8 @@ true Windows Store 8.2 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks.shared/AdventureWorks.Model.csproj b/Samples/CortanaVoiceCommand/cs/AdventureWorks.shared/AdventureWorks.Model.csproj index 8f98a0efe2..dab835df5f 100644 --- a/Samples/CortanaVoiceCommand/cs/AdventureWorks.shared/AdventureWorks.Model.csproj +++ b/Samples/CortanaVoiceCommand/cs/AdventureWorks.shared/AdventureWorks.Model.csproj @@ -11,8 +11,8 @@ AdventureWorks.Shared en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorks.csproj b/Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorks.csproj index 91eaa3b9c5..3634023f8d 100644 --- a/Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorks.csproj +++ b/Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorks.csproj @@ -11,8 +11,8 @@ AdventureWorks en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 @@ -145,7 +145,7 @@ Properties\Default.rd.xml - + PreserveNewest Designer @@ -191,6 +191,21 @@ Strings\en-GB\Resources.resw + + + Strings\en-CA\Resources.resw + + + + + Strings\en-AU\Resources.resw + + + + + Strings\en-IN\Resources.resw + + Strings\en-US\Resources.resw @@ -227,4 +242,4 @@ --> - + \ No newline at end of file diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Package.appxmanifest b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Package.appxmanifest index 8980254711..bedc2966c4 100644 --- a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Package.appxmanifest +++ b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Package.appxmanifest @@ -21,7 +21,7 @@ - + diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-AU/placeholder.txt b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-AU/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-CA/placeholder.txt b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-CA/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-IN/placeholder.txt b/Samples/CortanaVoiceCommand/cs/AdventureWorks/Strings/en-IN/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/cs/VoiceCommandService/AdventureWorksVoiceCommandService.cs b/Samples/CortanaVoiceCommand/cs/VoiceCommandService/AdventureWorksVoiceCommandService.cs index 274031d383..db5de4c098 100644 --- a/Samples/CortanaVoiceCommand/cs/VoiceCommandService/AdventureWorksVoiceCommandService.cs +++ b/Samples/CortanaVoiceCommand/cs/VoiceCommandService/AdventureWorksVoiceCommandService.cs @@ -116,6 +116,9 @@ public async void Run(IBackgroundTaskInstance taskInstance) voiceServiceConnection.VoiceCommandCompleted += OnVoiceCommandCompleted; + // GetVoiceCommandAsync establishes initial connection to Cortana, and must be called prior to any + // messages sent to Cortana. Attempting to use ReportSuccessAsync, ReportProgressAsync, etc + // prior to calling this will produce undefined behavior. VoiceCommand voiceCommand = await voiceServiceConnection.GetVoiceCommandAsync(); // Depending on the operation (defined in AdventureWorks:AdventureWorksCommands.xml) diff --git a/Samples/CortanaVoiceCommand/cs/VoiceCommandService/VoiceCommandService.csproj b/Samples/CortanaVoiceCommand/cs/VoiceCommandService/VoiceCommandService.csproj index d596d30816..4ac17431af 100644 --- a/Samples/CortanaVoiceCommand/cs/VoiceCommandService/VoiceCommandService.csproj +++ b/Samples/CortanaVoiceCommand/cs/VoiceCommandService/VoiceCommandService.csproj @@ -11,8 +11,8 @@ VoiceCommandService en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 @@ -134,4 +134,4 @@ --> - + \ No newline at end of file diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/AdventureWorks.jsproj b/Samples/CortanaVoiceCommand/js/AdventureWorks/AdventureWorks.jsproj index d5b2f9089e..5966488c4a 100644 --- a/Samples/CortanaVoiceCommand/js/AdventureWorks/AdventureWorks.jsproj +++ b/Samples/CortanaVoiceCommand/js/AdventureWorks/AdventureWorks.jsproj @@ -37,8 +37,8 @@ UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 $(VersionNumberMajor).$(VersionNumberMinor) en-US @@ -46,7 +46,8 @@ Designer - + + AdventureWorksCommands.xml Never @@ -60,22 +61,22 @@ - images\microsoft-sdk.png + images\microsoft-sdk.png - images\smallTile-sdk.png + images\smallTile-sdk.png - images\splash-sdk.png + images\splash-sdk.png - images\storeLogo-sdk.png + images\storeLogo-sdk.png - images\tile-sdk.png + images\tile-sdk.png - images\windows-sdk.png + images\windows-sdk.png @@ -84,19 +85,19 @@ - Microsoft.WinJS.4.0\css\ui-dark.css + Microsoft.WinJS.4.0\css\ui-dark.css - Microsoft.WinJS.4.0\css\ui-light.css + Microsoft.WinJS.4.0\css\ui-light.css - Microsoft.WinJS.4.0\js\en-US\ui.strings.js + Microsoft.WinJS.4.0\js\en-US\ui.strings.js - Microsoft.WinJS.4.0\js\WinJS.intellisense-setup.js + Microsoft.WinJS.4.0\js\WinJS.intellisense-setup.js - Microsoft.WinJS.4.0\js\WinJS.intellisense.js + Microsoft.WinJS.4.0\js\WinJS.intellisense.js Microsoft.WinJS.4.0\fonts\Symbols.ttf diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-AU/placeholder.txt b/Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-AU/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-CA/placeholder.txt b/Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-CA/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-IN/placeholder.txt b/Samples/CortanaVoiceCommand/js/AdventureWorks/Strings/en-IN/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/adventureworkscommands.xml b/Samples/CortanaVoiceCommand/js/AdventureWorks/adventureworkscommands.xml deleted file mode 100644 index 5b5dd1de39..0000000000 --- a/Samples/CortanaVoiceCommand/js/AdventureWorks/adventureworkscommands.xml +++ /dev/null @@ -1,253 +0,0 @@ - - - - Adventure Works - Show trip to London - - - Show trip to London - show [my] trip to {destination} - show [my] {builtin:AppName} trip to {destination} - Showing trip to {destination} - - - - - When is my trip to Las Vegas? - when is [my] trip to {destination} - when is [my] {builtin:AppName} trip to {destination} - Looking for trip to {destination} - - - - - Cancel my trip to Las Vegas - cancel [my] trip to {destination} - cancel [my] {builtin:AppName} trip to {destination} - Cancelling trip to {destination} - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - Show trip to London - - - Show trip to London - show [my] trip to {destination} - show [my] {builtin:AppName} trip to {destination} - Showing trip to {destination} - - - - - When is my trip to Las Vegas? - when is [my] trip to {destination} - when is [my] {builtin:AppName} trip to {destination} - Looking for trip to {destination} - - - - - Cancel my trip to Las Vegas - cancel [my] trip to {destination} - cancel [my] {builtin:AppName} trip to {destination} - Cancelling trip to {destination} - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - Montrer mon voyage à Londres - - - Montrer mon voyage à Londres - montrer [mon] voyage à {destination} - montrer [mon] {builtin:AppName} voyage à {destination} - Voici les détails du votre voyage à {destination} - - - - - Quand a lieu mon voyage à Las Vegas? - quand a lieu [mon] voyage à {destination} - quand a lieu [mon] {builtin:AppName} voyage à {destination} - Le chercher pour votre voyage à {destination} est en cours - - - - - Annuler mon voyage à Las Vegas - annuler [mon] voyage à {destination} - annuler [mon] {builtin:AppName} voyage à {destination} - L'annulation du votre voyage à {destination} est en cours - - - - - London - Melbourne - Yosemite National Park - - - - - Adventure Works - Mostra il viaggio a Londra - - - Mostra viaggio Londra - mostra il [mio] viaggio a {destination} - mostra il [mio] viaggio di {builtin:AppName} a {destination} - Mostro il viaggio a {destination} - - - - - Quando è il mio viaggio a Las Vegas? - quando è il [mio] viaggio a {destination} - quando è il [mio] viaggio di {builtin:AppName} a {destination} - Ricerca del viaggio a {destination} in corso - - - - - Annulla il mio viaggio a Las Vegas - annulla il [mio] viaggio a {destination} - annulla il [mio] viaggio di {builtin:AppName} a {destination} - Sto annullando il viaggio a {destination} - - - - - London - Melbourne - Yosemite National Park - - - - - - Adventure Works - Zeige Reise nach London - - - Meine Reise nach London zeigen - [Meine] Reise nach {destination} zeigen. - [Meine] {builtin:AppName} Reise nach {destination} zeigen. - Zeige Reise nach {destination} - - - - - Wann ist meine Reise nach Las Vegas? - wann ist [meine] Reise nach {destination} - wann ist [meine] {builtin:AppName} Reise nach {destination} - Auf der Suche nach Reise nach {destination} - - - - - Meine Reise nach Las Vegas abbrechen - [Meine] Reise nach {destination} abbrechen - [Meine] {builtin:AppName} Reise nach {destination} abbrechen - Reise nach {destination} abbrechen - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - Mostrar viaje a Londres - - - Mostrar viaje a Londres - mostrar [mi] viaje a {destination} - mostrar [mi] {builtin:AppName} viaje a {destination} - Mostrando viaje a {destination} - - - - - ¿Cuándo es mi viaje a Las Vegas? - cuando es [mi] viaje a {destination} - cuando es [mi] {builtin:AppName} viaje a {destination} - Buscando viaje a {destination} - - - - - Cancelar mi viaje a Las Vegas - cancelar [mi] viaje a {destination} - cancelar [mi] {builtin:AppName} viaje a {destination} - Viaje a {destination} cancelado - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - - - Adventure Works - 显示伦敦之行 - - - 显示伦敦之行 - 显示[我]去{destination}的旅行 - 显示[我]{builtin:AppName}去{destination}的旅行 - 显示{destination}之行 - - - - - 我的拉斯维加斯之旅的时间? - [我]前往{destination}的旅行是什么时候 - 显示[我]{builtin:AppName}前往{destination}的旅行是什么时候 - 查询{destination}之行 - - - - - 取消我的拉斯维加斯之旅 - 取消[我的]{destination}之旅 - 取消[我的]{builtin:AppName}{destination}之旅 - 取消{destination}之行 - - - - - London - Las Vegas - Melbourne - Yosemite National Park - - - \ No newline at end of file diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/js/voiceCommandService.js b/Samples/CortanaVoiceCommand/js/AdventureWorks/js/voiceCommandService.js index d6ada873bd..b32b643163 100644 --- a/Samples/CortanaVoiceCommand/js/AdventureWorks/js/voiceCommandService.js +++ b/Samples/CortanaVoiceCommand/js/AdventureWorks/js/voiceCommandService.js @@ -66,6 +66,9 @@ var appService = Windows.ApplicationModel.AppService; voiceServiceConnection = voiceCommands.VoiceCommandServiceConnection.fromAppServiceTriggerDetails(details); voiceServiceConnection.addEventListener("voiceCommandCompleted", onVoiceCommandCompleted); + // getVoiceCommandAsync establishes initial connection to Cortana, and must be called prior to any + // messages sent to Cortana. Attempting to use reportSuccessAsync, reportProgressAsync, etc + // prior to calling this will produce undefined behavior. voiceServiceConnection.getVoiceCommandAsync().then(function completed(voiceCommand) { switch (voiceCommand.commandName) { diff --git a/Samples/CortanaVoiceCommand/js/AdventureWorks/package.appxmanifest b/Samples/CortanaVoiceCommand/js/AdventureWorks/package.appxmanifest index adc28e2215..693fcbdbdd 100644 --- a/Samples/CortanaVoiceCommand/js/AdventureWorks/package.appxmanifest +++ b/Samples/CortanaVoiceCommand/js/AdventureWorks/package.appxmanifest @@ -19,7 +19,7 @@ - + diff --git a/Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorksCommands.xml b/Samples/CortanaVoiceCommand/shared/AdventureWorksCommands.xml similarity index 70% rename from Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorksCommands.xml rename to Samples/CortanaVoiceCommand/shared/AdventureWorksCommands.xml index 00fb03cf31..1b4f0193a0 100644 --- a/Samples/CortanaVoiceCommand/cs/AdventureWorks/AdventureWorksCommands.xml +++ b/Samples/CortanaVoiceCommand/shared/AdventureWorksCommands.xml @@ -72,6 +72,114 @@ + + Adventure Works + Show trip to London + + + Show trip to London + show [my] trip to {destination} + show [my] {builtin:AppName} trip to {destination} + Showing trip to {destination} + + + + + When is my trip to Las Vegas? + when is [my] trip to {destination} + when is [my] {builtin:AppName} trip to {destination} + Looking for trip to {destination} + + + + + Cancel my trip to Las Vegas + cancel [my] trip to {destination} + cancel [my] {builtin:AppName} trip to {destination} + Cancelling trip to {destination} + + + + + London + Las Vegas + Melbourne + Yosemite National Park + + + + + Adventure Works + Show trip to London + + + Show trip to London + show [my] trip to {destination} + show [my] {builtin:AppName} trip to {destination} + Showing trip to {destination} + + + + + When is my trip to Las Vegas? + when is [my] trip to {destination} + when is [my] {builtin:AppName} trip to {destination} + Looking for trip to {destination} + + + + + Cancel my trip to Las Vegas + cancel [my] trip to {destination} + cancel [my] {builtin:AppName} trip to {destination} + Cancelling trip to {destination} + + + + + London + Las Vegas + Melbourne + Yosemite National Park + + + + + Adventure Works + Show trip to London + + + Show trip to London + show [my] trip to {destination} + show [my] {builtin:AppName} trip to {destination} + Showing trip to {destination} + + + + + When is my trip to Las Vegas? + when is [my] trip to {destination} + when is [my] {builtin:AppName} trip to {destination} + Looking for trip to {destination} + + + + + Cancel my trip to Las Vegas + cancel [my] trip to {destination} + cancel [my] {builtin:AppName} trip to {destination} + Cancelling trip to {destination} + + + + + London + Las Vegas + Melbourne + Yosemite National Park + + + Adventure Works Montrer mon voyage à Londres diff --git a/Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resjson b/Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resjson new file mode 100644 index 0000000000..93d45437ea --- /dev/null +++ b/Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resjson @@ -0,0 +1,16 @@ +{ + "CancelledTripToDestination": "Cancelled the trip to {0}", + "CancellingTripToDestination": "Cancelling the trip to {0}", + "CancelTripToDestination": "Cancel this trip to {0}?", + "ConfirmCancelTripToDestination": "Did you want to cancel this trip to {0}?", + "DisambiguationRepeat": "Which one do you want to cancel?", + "DisambiguationWhichTripToDest": "Which trip to {0} did you want to cancel?", + "FoundNoTripToDestination": "Sorry, you don\u0027t have any trips to {0}", + "KeepingTripToDestination": "Okay, keeping the trip to {0}", + "LaunchingAdventureWorks": "Launching Adventure Works", + "LoadingTripToDestination": "Looking for trip to {0}", + "NoSuchTripToDestination": "Sorry, you don\u0027t have any trips to {0}", + "PluralUpcomingTrips": "Here are your upcoming trips.", + "ProgressLookingForTripToDest": "Looking for a trip to {0}", + "SingularUpcomingTrip": "Here\u0027s your upcoming trip." +} diff --git a/Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resw b/Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resw new file mode 100644 index 0000000000..8ac0f73f7f --- /dev/null +++ b/Samples/CortanaVoiceCommand/shared/Strings/en-AU/Resources.resw @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cancelled the trip to {0} + + + Cancelling the trip to {0} + + + Cancel this trip to {0}? + + + Did you want to cancel this trip to {0}? + + + Which one do you want to cancel? + + + Which trip to {0} did you want to cancel? + + + Sorry, you don't have any trips to {0} + + + Okay, keeping the trip to {0} + + + Launching Adventure Works + + + Looking for trip to {0} + + + Sorry, you don't have any trips to {0} + + + Here are your upcoming trips. + + + Looking for a trip to {0} + + + Here's your upcoming trip. + + \ No newline at end of file diff --git a/Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resjson b/Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resjson new file mode 100644 index 0000000000..93d45437ea --- /dev/null +++ b/Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resjson @@ -0,0 +1,16 @@ +{ + "CancelledTripToDestination": "Cancelled the trip to {0}", + "CancellingTripToDestination": "Cancelling the trip to {0}", + "CancelTripToDestination": "Cancel this trip to {0}?", + "ConfirmCancelTripToDestination": "Did you want to cancel this trip to {0}?", + "DisambiguationRepeat": "Which one do you want to cancel?", + "DisambiguationWhichTripToDest": "Which trip to {0} did you want to cancel?", + "FoundNoTripToDestination": "Sorry, you don\u0027t have any trips to {0}", + "KeepingTripToDestination": "Okay, keeping the trip to {0}", + "LaunchingAdventureWorks": "Launching Adventure Works", + "LoadingTripToDestination": "Looking for trip to {0}", + "NoSuchTripToDestination": "Sorry, you don\u0027t have any trips to {0}", + "PluralUpcomingTrips": "Here are your upcoming trips.", + "ProgressLookingForTripToDest": "Looking for a trip to {0}", + "SingularUpcomingTrip": "Here\u0027s your upcoming trip." +} diff --git a/Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resw b/Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resw new file mode 100644 index 0000000000..8ac0f73f7f --- /dev/null +++ b/Samples/CortanaVoiceCommand/shared/Strings/en-CA/Resources.resw @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cancelled the trip to {0} + + + Cancelling the trip to {0} + + + Cancel this trip to {0}? + + + Did you want to cancel this trip to {0}? + + + Which one do you want to cancel? + + + Which trip to {0} did you want to cancel? + + + Sorry, you don't have any trips to {0} + + + Okay, keeping the trip to {0} + + + Launching Adventure Works + + + Looking for trip to {0} + + + Sorry, you don't have any trips to {0} + + + Here are your upcoming trips. + + + Looking for a trip to {0} + + + Here's your upcoming trip. + + \ No newline at end of file diff --git a/Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resjson b/Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resjson new file mode 100644 index 0000000000..93d45437ea --- /dev/null +++ b/Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resjson @@ -0,0 +1,16 @@ +{ + "CancelledTripToDestination": "Cancelled the trip to {0}", + "CancellingTripToDestination": "Cancelling the trip to {0}", + "CancelTripToDestination": "Cancel this trip to {0}?", + "ConfirmCancelTripToDestination": "Did you want to cancel this trip to {0}?", + "DisambiguationRepeat": "Which one do you want to cancel?", + "DisambiguationWhichTripToDest": "Which trip to {0} did you want to cancel?", + "FoundNoTripToDestination": "Sorry, you don\u0027t have any trips to {0}", + "KeepingTripToDestination": "Okay, keeping the trip to {0}", + "LaunchingAdventureWorks": "Launching Adventure Works", + "LoadingTripToDestination": "Looking for trip to {0}", + "NoSuchTripToDestination": "Sorry, you don\u0027t have any trips to {0}", + "PluralUpcomingTrips": "Here are your upcoming trips.", + "ProgressLookingForTripToDest": "Looking for a trip to {0}", + "SingularUpcomingTrip": "Here\u0027s your upcoming trip." +} diff --git a/Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resw b/Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resw new file mode 100644 index 0000000000..8ac0f73f7f --- /dev/null +++ b/Samples/CortanaVoiceCommand/shared/Strings/en-IN/Resources.resw @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Cancelled the trip to {0} + + + Cancelling the trip to {0} + + + Cancel this trip to {0}? + + + Did you want to cancel this trip to {0}? + + + Which one do you want to cancel? + + + Which trip to {0} did you want to cancel? + + + Sorry, you don't have any trips to {0} + + + Okay, keeping the trip to {0} + + + Launching Adventure Works + + + Looking for trip to {0} + + + Sorry, you don't have any trips to {0} + + + Here are your upcoming trips. + + + Looking for a trip to {0} + + + Here's your upcoming trip. + + \ No newline at end of file diff --git a/Samples/DeviceEnumeration/README.md b/Samples/DeviceEnumeration/README.md deleted file mode 100644 index 2eb36edc9b..0000000000 --- a/Samples/DeviceEnumeration/README.md +++ /dev/null @@ -1,63 +0,0 @@ - - -# Device enumeration sample - -This sample shows how to use the Windows.Devices.Enumeration APIs find devices internally connected to the system, externally connected, or nearby over wireless or networking protocols and get information about them. It also shows how to pair wireless and networking devices with the system. - -The sample demonstrates eight scenarios: - -1. Device Picker Common Control: This scenario demonstrates the use of the Windows.Devices.Enumeration.DevicePicker. DevicePicker is a UI control that allows users of your app to pick a device. After they pick a device you can get information from it and start using it through the appropriate device API. - -2. Enumerate and Watch Devices: This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceWatcher. Device Watcher allows you to find and recieve updates for devices you're interested in. Even if you don't need updates for devices as the arrive, depart, or change, this method still has advantages over FindAllAsync in that the results come back one-by-one has they are discovered, rather than waiting for all results to be retreived and then returned in a single collection. - -3. Enumerate and Watch Devices in a Background Task: This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceWatcherTrigger. DeviceWatcherTrigger is similar to DeviceWatcher, but is performed in a background task. First you create a DeviceWatcher object, but instead of starting the DeviceWatcher in the foreground, you get the background trigger and then register it. Your background task is called with initial results and then called repeatedly over time as the device you're watching arrive, depart, or change. - -4. Enumerate Snapshot of Devices: This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceInformation.FindAllAsync. Use for grabbing a quick snapshot of devices you're interested in. This method is simplier to use than the DeviceWatcher, but doesn't allow you to process results as they arrive. Rather all results are internally added to a collection until the enumeration is complete, then the collection is returned when the async operation completes. - -5. Get Single Device: This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceInformation.CreateFromIdAsync. This would typically be used when you have a device id saved, and want to retrieve information about that device again. Other uses would be if you have a DeviceInformation.Id from another API and need to obtain a DeviceInformation object. - -6. Custom Filter with Additional Properties: This scenario demonstrates using custom filters and/or requesting additional properties with the DeviceWatcher. A custom filter and/or requested additional properties can also be done with the DevicePicker, FindAllAsync, and DeviceWatcherTrigger - -7. Request Specific DeviceInformationKind: This scenario demonstrates requesting various DeviceInformationKinds. Methods without the DeviceInformationKind parameter default to DeviceInterface. - -8. Pair Device: This scenario demonstrates how to pair a device with the system. It uses DeviceInformation.PairAsync on a DeviceInformation which is of kind DeviceInformationKind.AssociationEndpoint. e.g. This method can be used to pair devices like WiFi Direct, WSD, or UPnP device. Bluetooth is not supported at this time, but will be in a future release. - - -## Related topics - -[Enumerating devices article](http://msdn.microsoft.com/en-us/library/windows/apps/Hh464977) - -[Windows.Devices.Enumeration reference](http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.enumeration.aspx) - -[Windows Universal App Samples](https://github.com/Microsoft/Windows-universal-samples) - -## System requirements - -**Client:** Windows 10 - -**Server:** Windows Server 2016 Technical Preview - -**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 2015 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 2015 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/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.cpp b/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.cpp deleted file mode 100644 index 5d4c2c7bff..0000000000 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.cpp +++ /dev/null @@ -1,225 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -#include "pch.h" -#include "MainPage.xaml.h" -#include -#include - -using namespace SDKTemplate; -using namespace Platform; -using namespace Platform::Collections; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Core; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Interop; -using namespace Windows::UI::Xaml::Media::Imaging; -using namespace Windows::Devices::Enumeration; - -// NOTE: The following using statements are only needed in order to demonstrate many of the -// different device selectors available from Windows Runtime APIs. You will only need to include -// the namespace for the Windows Runtime API your actual scenario needs. -using namespace Windows::Devices::HumanInterfaceDevice; -using namespace Windows::Networking::Proximity; -using namespace Windows::Devices::Bluetooth; -using namespace Windows::Devices::Bluetooth::Rfcomm; -using namespace Windows::Devices::Bluetooth::GenericAttributeProfile; -using namespace Windows::Devices::WiFiDirect; -using namespace Windows::Media::Casting; -using namespace Windows::Media::DialProtocol; -using namespace Windows::Devices::Sensors; - -namespace SDKTemplate -{ - // DeviceSelectorChoices - - IVectorView^ DeviceSelectorChoices::Selectors::get() - { - Vector^ selectors = ref new Vector(); - - // Pre-canned device class selectors - selectors->Append(ref new DeviceSelectorInfo("All Device Interfaces", DeviceClass::All, nullptr)); - selectors->Append(ref new DeviceSelectorInfo("Audio Capture Devices", DeviceClass::AudioCapture, nullptr)); - selectors->Append(ref new DeviceSelectorInfo("Audio Render Devices", DeviceClass::AudioRender, nullptr)); - selectors->Append(ref new DeviceSelectorInfo("Image Scanner Devices", DeviceClass::ImageScanner, nullptr)); - selectors->Append(ref new DeviceSelectorInfo("Location Devices", DeviceClass::Location, nullptr)); - selectors->Append(ref new DeviceSelectorInfo("Portable Storage Devices", DeviceClass::PortableStorageDevice, nullptr)); - selectors->Append(ref new DeviceSelectorInfo("Video Capture Devices", DeviceClass::VideoCapture, nullptr)); - - selectors->Append(ref new DeviceSelectorInfo("Proximity Devices", DeviceClass::All, ProximityDevice::GetDeviceSelector())); - selectors->Append(ref new DeviceSelectorInfo("Human Interface Devices", DeviceClass::All, HidDevice::GetDeviceSelector(0, 0))); - selectors->Append(ref new DeviceSelectorInfo("Bluetooth Rfcomm Chat Services", DeviceClass::All, RfcommDeviceService::GetDeviceSelector(RfcommServiceId::SerialPort))); - selectors->Append(ref new DeviceSelectorInfo("Bluetooth Gatt Heart Rate Devices", DeviceClass::All, GattDeviceService::GetDeviceSelectorFromUuid(GattServiceUuids::HeartRate))); - selectors->Append(ref new DeviceSelectorInfo("WiFi Direct Devices", DeviceClass::All, WiFiDirectDevice::GetDeviceSelector())); - selectors->Append(ref new DeviceSelectorInfo("Video Casting Devices", DeviceClass::All, CastingDevice::GetDeviceSelector(CastingPlaybackTypes::Video))); - // Using an empty string for the app name for the DIAL selector which returns all DIAL devices. For typical scenarios you would specify the App name. - selectors->Append(ref new DeviceSelectorInfo("DIAL Devices (All apps)", DeviceClass::All, DialDevice::GetDeviceSelector(""))); - selectors->Append(ref new DeviceSelectorInfo("Activity Sensor", DeviceClass::All, ActivitySensor::GetDeviceSelector())); - selectors->Append(ref new DeviceSelectorInfo("Pedometer", DeviceClass::All, Pedometer::GetDeviceSelector())); - selectors->Append(ref new DeviceSelectorInfo("Proximity Sensor", DeviceClass::All, ProximityDevice::GetDeviceSelector())); - - return selectors->GetView(); - } - - - // DeviceInformationKindChoices - - IVectorView^ DeviceInformationKindChoices::Choices::get() - { - Vector^ choices = ref new Vector(); - - Vector^ kinds; - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::DeviceContainer); - choices->Append(ref new DeviceInformationKindChoice("DeviceContainer", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::Device); - choices->Append(ref new DeviceInformationKindChoice("Device", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::DeviceInterface); - choices->Append(ref new DeviceInformationKindChoice("DeviceInterface", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::DeviceInterfaceClass); - choices->Append(ref new DeviceInformationKindChoice("DeviceInterfaceClass", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::AssociationEndpointContainer); - choices->Append(ref new DeviceInformationKindChoice("AssociationEndpointContainer", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::AssociationEndpoint); - choices->Append(ref new DeviceInformationKindChoice("AssociationEndpoint", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::AssociationEndpointService); - choices->Append(ref new DeviceInformationKindChoice("AssociationEndpointService", kinds->GetView())); - - kinds = ref new Vector(); - kinds->Append(DeviceInformationKind::AssociationEndpointService); - kinds->Append(DeviceInformationKind::DeviceInterface); - choices->Append(ref new DeviceInformationKindChoice("AssociationEndpointService and DeviceInterface", kinds->GetView())); - - return choices->GetView(); - } - - // ProtocolSelectorChoices - - IVectorView^ ProtocolSelectorChoices::Selectors::get() - { - Vector^ selectors = ref new Vector(); - - // Pre-canned device class selectors - selectors->Append(ref new ProtocolSelectorInfo("Wi-Fi Direct", "System.Devices.Aep.ProtocolId:=\"{0407d24e-53de-4c9a-9ba1-9ced54641188}\"")); - selectors->Append(ref new ProtocolSelectorInfo("WSD", "System.Devices.Aep.ProtocolId:=\"{782232aa-a2f9-4993-971b-aedc551346b0}\"")); - selectors->Append(ref new ProtocolSelectorInfo("UPnP", "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"")); - selectors->Append(ref new ProtocolSelectorInfo("Point of Service", "System.Devices.Aep.ProtocolId:=\"{D4BF61B3-442E-4ADA-882D-FA7B70C832D9}\"")); - - return selectors->GetView(); - } - - - // DeviceInformationDisplay - - DeviceInformationDisplay::DeviceInformationDisplay(DeviceInformation^ deviceInfoIn) - { - deviceInfo = deviceInfoIn; - UpdateGlyphBitmapImage(); - } - - String^ DeviceInformationDisplay::KindString::get() - { - String^ str; - switch (deviceInfo->Kind) - { - case DeviceInformationKind::DeviceContainer: - str = "DeviceContainer"; - break; - case DeviceInformationKind::Device: - str = "Device"; - break; - case DeviceInformationKind::DeviceInterface: - str = "DeviceInterface"; - break; - case DeviceInformationKind::DeviceInterfaceClass: - str = "DeviceInterfaceClass"; - break; - case DeviceInformationKind::AssociationEndpointContainer: - str = "AssociationEndpointContainer"; - break; - case DeviceInformationKind::AssociationEndpoint: - str = "AssociationEndpoint"; - break; - case DeviceInformationKind::AssociationEndpointService: - str = "AssociationEndpointService"; - break; - }; - - return str; - } - - void DeviceInformationDisplay::Update(DeviceInformationUpdate^ deviceInfoUpdateIn) - { - deviceInfo->Update(deviceInfoUpdateIn); - - OnPropertyChanged("Kind"); - OnPropertyChanged("Id"); - OnPropertyChanged("Name"); - OnPropertyChanged("DeviceInformation"); - OnPropertyChanged("CanPair"); - OnPropertyChanged("IsPaired"); - - UpdateGlyphBitmapImage(); - } - - void DeviceInformationDisplay::UpdateGlyphBitmapImage() - { - BitmapImage^ glyphBitmapImage; - glyphBitmapImage = ref new BitmapImage(); - - concurrency::create_task(deviceInfo->GetGlyphThumbnailAsync()).then( - [glyphBitmapImage](DeviceThumbnail^ result) - { - return glyphBitmapImage->SetSourceAsync(result); - }).then( - [this, glyphBitmapImage]() - { - GlyphBitmapImage = glyphBitmapImage; - OnPropertyChanged("GlyphBitmapImage"); - }); - } - - void DeviceInformationDisplay::OnPropertyChanged(String^ name) - { - MainPage::Current->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler( - [this, name]() - { - PropertyChanged(this, ref new PropertyChangedEventArgs(name)); - })); - } - - - // GeneralPropertyValueConverter - - Object^ GeneralPropertyValueConverter::Convert( - Object^ value, - TypeName targetType, - Object^ parameter, - String^ language) - { - Object^ property = nullptr; - String^ strParameter = safe_cast(parameter); - - if (nullptr != strParameter && !strParameter->IsEmpty()) - { - IMapView^ properties = safe_cast^>(value); - - property = properties->Lookup(strParameter); - } - - return property; - } -} \ No newline at end of file diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DisplayHelpers.cs b/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DisplayHelpers.cs deleted file mode 100644 index 485f13697c..0000000000 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DisplayHelpers.cs +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using Windows.Devices.Enumeration; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Media.Imaging; - -// NOTE: The following using statements are only needed in order to demonstrate many of the -// different device selectors available from Windows Runtime APIs. You will only need to include -// the namespace for the Windows Runtime API your actual scenario needs. -using Windows.Devices.HumanInterfaceDevice; -using Windows.Networking.Proximity; -using Windows.Devices.Bluetooth.Rfcomm; -using Windows.Devices.Bluetooth.GenericAttributeProfile; -using Windows.Devices.WiFiDirect; -using Windows.Media.Casting; -using Windows.Media.DialProtocol; -using Windows.Devices.Sensors; - -namespace DeviceEnumeration -{ - public struct DeviceSelectorInfo - { - public string DisplayName - { - get; - set; - } - - public DeviceClass DeviceClassSelector - { - get; - set; - } - - public string Selector - { - get; - set; - } - } - - public static class DeviceSelectorChoices - { - // The Chat Server's custom service Uuid: 34B1CF4D-1069-4AD6-89B6-E161D79BE4D8 - private static readonly Guid RfcommChatServiceUuid = Guid.Parse("34B1CF4D-1069-4AD6-89B6-E161D79BE4D8"); - - public static List Selectors - { - get - { - List selectors = new List(); - - // Pre-canned device class selectors - selectors.Add(new DeviceSelectorInfo() { DisplayName = "All Device Interfaces", DeviceClassSelector = DeviceClass.All, Selector = null }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Audio Capture Devices", DeviceClassSelector = DeviceClass.AudioCapture, Selector = null }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Audio Render Devices", DeviceClassSelector = DeviceClass.AudioRender, Selector = null }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Image Scanner Devices", DeviceClassSelector = DeviceClass.ImageScanner, Selector = null }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Location Devices", DeviceClassSelector = DeviceClass.Location, Selector = null }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Portable Storage Devices", DeviceClassSelector = DeviceClass.PortableStorageDevice, Selector = null }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Video Capture Devices", DeviceClassSelector = DeviceClass.VideoCapture, Selector = null }); - - // A few examples of selectors built dynamically by windows runtime apis. - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Proximity Devices", Selector = ProximityDevice.GetDeviceSelector() }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Human Interface Devices", Selector = HidDevice.GetDeviceSelector(0, 0) }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Bluetooth Rfcomm Chat Services", Selector = RfcommDeviceService.GetDeviceSelector(RfcommServiceId.FromUuid(RfcommChatServiceUuid)) }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Bluetooth Gatt Heart Rate Devices", Selector = GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.HeartRate) }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "WiFi Direct Devices", Selector = WiFiDirectDevice.GetDeviceSelector() }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Video Casting Devices", Selector = CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video)}); - // Using an empty string for the app name for the DIAL selector which returns all DIAL devices. For typical scenarios you would specify the App name. - selectors.Add(new DeviceSelectorInfo() { DisplayName = "DIAL Devices (All apps)", Selector = DialDevice.GetDeviceSelector("")}); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Activity Sensor", Selector = ActivitySensor.GetDeviceSelector() }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Pedometer", Selector = Pedometer.GetDeviceSelector() }); - selectors.Add(new DeviceSelectorInfo() { DisplayName = "Proximity Sensor", Selector = ProximitySensor.GetDeviceSelector() }); - - return selectors; - } - } - } - - public struct DeviceInformationKindChoice - { - public string DisplayName - { - get; - set; - } - - public DeviceInformationKind[] DeviceInformationKinds - { - get; - set; - } - } - - public static class DeviceInformationKindChoices - { - public static List Choices - { - get - { - List choices = new List(); - - choices.Add(new DeviceInformationKindChoice() { DisplayName = "DeviceContainer", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.DeviceContainer } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "Device", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.Device } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "DeviceInterface (Default)", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.DeviceInterface } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "DeviceInterfaceClass", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.DeviceInterfaceClass } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpointContainer", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpointContainer } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpoint", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpoint } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpointService", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpointService } }); - choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpointService and DeviceInterface", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpointService, DeviceInformationKind.DeviceInterface} }); - - return choices; - } - } - } - - public struct ProtocolSelectorInfo - { - public string DisplayName - { - get; - set; - } - - public string Selector - { - get; - set; - } - } - - public static class ProtocolSelectorChoices - { - public static List Selectors - { - get - { - List selectors = new List(); - - selectors.Add(new ProtocolSelectorInfo() { DisplayName = "Wi-Fi Direct", Selector = "System.Devices.Aep.ProtocolId:=\"{0407d24e-53de-4c9a-9ba1-9ced54641188}\"" }); - selectors.Add(new ProtocolSelectorInfo() { DisplayName = "WSD", Selector = "System.Devices.Aep.ProtocolId:=\"{782232aa-a2f9-4993-971b-aedc551346b0}\"" }); - selectors.Add(new ProtocolSelectorInfo() { DisplayName = "UPnP", Selector = "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"" }); - selectors.Add(new ProtocolSelectorInfo() { DisplayName = "Point of Service", Selector = "System.Devices.Aep.ProtocolId:=\"{D4BF61B3-442E-4ADA-882D-FA7B70C832D9}\"" }); - - return selectors; - } - } - } - - public class DeviceInformationDisplay : INotifyPropertyChanged - { - private DeviceInformation deviceInfo; - - public DeviceInformationDisplay(DeviceInformation deviceInfoIn) - { - deviceInfo = deviceInfoIn; - UpdateGlyphBitmapImage(); - } - - public DeviceInformationKind Kind - { - get - { - return deviceInfo.Kind; - } - } - - public string Id - { - get - { - return deviceInfo.Id; - } - } - - public string Name - { - get - { - return deviceInfo.Name; - } - } - - public BitmapImage GlyphBitmapImage - { - get; - private set; - } - - public bool CanPair - { - get - { - return deviceInfo.Pairing.CanPair; - } - } - - public bool IsPaired - { - get - { - return deviceInfo.Pairing.IsPaired; - } - } - - public IReadOnlyDictionary Properties - { - get - { - return deviceInfo.Properties; - } - } - - public DeviceInformation DeviceInformation - { - get - { - return deviceInfo; - } - - private set - { - deviceInfo = value; - } - } - - public void Update(DeviceInformationUpdate deviceInfoUpdate) - { - deviceInfo.Update(deviceInfoUpdate); - - OnPropertyChanged("Kind"); - OnPropertyChanged("Id"); - OnPropertyChanged("Name"); - OnPropertyChanged("DeviceInformation"); - OnPropertyChanged("CanPair"); - OnPropertyChanged("IsPaired"); - - UpdateGlyphBitmapImage(); - } - - private async void UpdateGlyphBitmapImage() - { - DeviceThumbnail deviceThumbnail = await deviceInfo.GetGlyphThumbnailAsync(); - BitmapImage glyphBitmapImage = new BitmapImage(); - await glyphBitmapImage.SetSourceAsync(deviceThumbnail); - GlyphBitmapImage = glyphBitmapImage; - OnPropertyChanged("GlyphBitmapImage"); - } - - public event PropertyChangedEventHandler PropertyChanged; - protected void OnPropertyChanged(string name) - { - PropertyChangedEventHandler handler = PropertyChanged; - if (handler != null) - { - handler(this, new PropertyChangedEventArgs(name)); - } - } - } - - public class GeneralPropertyValueConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, string language) - { - object property = null; - - if (value is IReadOnlyDictionary && - parameter is string && - false == String.IsNullOrEmpty((string)parameter)) - { - IReadOnlyDictionary properties = value as IReadOnlyDictionary; - string propertyName = parameter as string; - - property = properties[propertyName]; - } - - return property; - } - - public object ConvertBack(object value, Type targetType, object parameter, string language) - { - throw new NotImplementedException(); - } - } -} diff --git a/Samples/DeviceEnumeration/js/Package.appxmanifest b/Samples/DeviceEnumeration/js/Package.appxmanifest deleted file mode 100644 index 02a85697e2..0000000000 --- a/Samples/DeviceEnumeration/js/Package.appxmanifest +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - DeviceEnumeration JS Sample - Microsoft Corporation - images\storelogo-sdk.png - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/DeviceEnumeration/js/js/displayhelpers.js b/Samples/DeviceEnumeration/js/js/displayhelpers.js deleted file mode 100644 index 760eaf76d0..0000000000 --- a/Samples/DeviceEnumeration/js/js/displayhelpers.js +++ /dev/null @@ -1,131 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved - -(function () { - "use strict"; - - var bt = Windows.Devices.Bluetooth; - var rfcommChatServiceUuid = "34B1CF4D-1069-4AD6-89B6-E161D79BE4D8"; - - var selectorsArray = [ - - // Pre-canned device class selectors - { displayName: "All Device Interfaces", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.all }, - { displayName: "Audio Capture Devices", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.audioCapture }, - { displayName: "Audio Render Devices", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.audioRender }, - { displayName: "Image Scanner Devices", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.imageScanner }, - { displayName: "Location Devices", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.location }, - { displayName: "Portable Storage Devices", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.portableStorageDevice }, - { displayName: "Video Capture Devices", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.videoCapture }, - - // A few examples of selectors built dynamically by windows runtime apis. - { displayName: "Proximity Devices", selector: Windows.Networking.Proximity.ProximityDevice.getDeviceSelector() }, - { displayName: "Human Interface Devices", selector: Windows.Devices.HumanInterfaceDevice.HidDevice.getDeviceSelector(0,0) }, - { displayName: "Bluetooth Rfcomm Chat Services", selector: bt.Rfcomm.RfcommDeviceService.getDeviceSelector(bt.Rfcomm.RfcommServiceId.fromUuid(rfcommChatServiceUuid)) }, - { displayName: "Bluetooth Gatt Heart Rate Devices", selector: bt.GenericAttributeProfile.GattDeviceService.getDeviceSelectorFromUuid(bt.GenericAttributeProfile.GattServiceUuids.heartRate) }, - { displayName: "WiFi Direct Devices", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector() }, - { displayName: "Video Casting Devices", selector: Windows.Media.Casting.CastingDevice.getDeviceSelector(Windows.Media.Casting.CastingPlaybackTypes.video) }, - // Using an empty string for the app name for the DIAL selector which returns all DIAL devices. For typical scenarios you would specify the App name. - { displayName: "DIAL Devices (All apps)", selector: Windows.Media.DialProtocol.DialDevice.getDeviceSelector("") }, - { displayName: "Activity Sensor", selector: Windows.Devices.Sensors.ActivitySensor.getDeviceSelector() }, - { displayName: "Pedometer", selector: Windows.Devices.Sensors.Pedometer.getDeviceSelector() }, - { displayName: "Proximity Sensor", selector: Windows.Devices.Sensors.ProximitySensor.getDeviceSelector() } - ]; - - var selectorsList = new WinJS.Binding.List(selectorsArray); - - var kindArray = [ - - { displayName: "DeviceContainer", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.deviceContainer }, - { displayName: "Device", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.device }, - { displayName: "DeviceInterface (default)", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.deviceInterface }, - { displayName: "DeviceInterfaceClass", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.deviceInterfaceClass }, - { displayName: "AssociationEndpointContainer", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpointContainer }, - { displayName: "AssociationEndpoint", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpoint }, - { displayName: "AssociationEndpointService", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpointService }, - ]; - - var kindList = new WinJS.Binding.List(kindArray); - - var protocolArray = [ - - { displayName: "Wi-Fi Direct", selector: "System.Devices.Aep.ProtocolId:=\"{0407d24e-53de-4c9a-9ba1-9ced54641188}\"" }, - { displayName: "WSD", selector: "System.Devices.Aep.ProtocolId:=\"{782232aa-a2f9-4993-971b-aedc551346b0}\"" }, - { displayName: "UPnP", selector: "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"" }, - { displayName: "Point of Service", selector: "System.Devices.Aep.ProtocolId:=\"{D4BF61B3-442E-4ADA-882D-FA7B70C832D9}\"" } - ]; - - var protocolList = new WinJS.Binding.List(protocolArray); - - // Define a bindable "display" version of the DeviceInformation class. WinJS.Binding.as won't work directly - // on the DeviceInformation object, so we use this new class and make it a mix of observable and non-observable - // properties. Notice the main properties are made observable, but deviceInfo is not. - var DeviceInformationDisplay = WinJS.Class.define( - function (deviceInfo) { - this._initObservable(); - - this.id = deviceInfo.id; - this.kind = kindStringFromType(deviceInfo.kind); - this.name = deviceInfo.name; - if (null != deviceInfo.pairing) { - this.canPair = deviceInfo.pairing.canPair; - this.isPaired = deviceInfo.pairing.isPaired; - } - this.deviceInfo = deviceInfo; - - // These two properties are only valid for scenario 6, but won't hurt other scenarios - this.interfaceClass = deviceInfo.properties["System.Devices.InterfaceClassGuid"]; - this.itemNameDisplay = deviceInfo.properties["System.ItemNameDisplay"]; - }, { - update: function (deviceInfoUpdate) { - this.deviceInfo.update(deviceInfoUpdate); - this.name = this.deviceInfo.name; - - if (null != this.deviceInfo.pairing) { - this.canPair = this.deviceInfo.pairing.canPair; - this.isPaired = this.deviceInfo.pairing.isPaired; - } - - // These two properties are only valid for scenario 6, but won't hurt other scenarios - this.interfaceClass = this.deviceInfo.properties["System.Devices.InterfaceClassGuid"]; - this.itemNameDisplay = this.deviceInfo.properties["System.ItemNameDisplay"]; - } - } - ); - - var DeviceInformationDisplayMix = WinJS.Class.mix( - DeviceInformationDisplay, - WinJS.Binding.mixin, - WinJS.Binding.expandProperties({ id: "", kind: "", name: "", canPair: "", isPaired: "", interfaceClass: "", itemNameDisplay: "" })); - - var publicMembers = - { - selectorsList: selectorsList, - kindList: kindList, - protocolList: protocolList, - DeviceInformationDisplay: DeviceInformationDisplayMix - }; - - WinJS.Namespace.define("DisplayHelpers", publicMembers); -})(); - - -function kindStringFromType(kindType) { - var DevEnum = Windows.Devices.Enumeration; - - switch (kindType) { - case DevEnum.DeviceInformationKind.associationEndpoint: - return "AssociationEndpoint"; - case DevEnum.DeviceInformationKind.associationEndpointContainer: - return "AssociationEndpointContainer"; - case DevEnum.DeviceInformationKind.associationEndpointService: - return "AssociationEndpointService"; - case DevEnum.DeviceInformationKind.device: - return "Device"; - case DevEnum.DeviceInformationKind.deviceContainer: - return "DeviceContainer"; - case DevEnum.DeviceInformationKind.deviceInterface: - return "DeviceInterface"; - case DevEnum.DeviceInformationKind.deviceInterfaceClass: - return "DeviceInterfaceClass"; - } -}; diff --git a/Samples/DeviceEnumerationAndPairing/README.md b/Samples/DeviceEnumerationAndPairing/README.md new file mode 100644 index 0000000000..a76b54e38f --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/README.md @@ -0,0 +1,71 @@ + + +# Device enumeration and pairing sample + +This sample shows how to use the Windows.Devices.Enumeration APIs find devices internally connected to the system, externally connected, or nearby over wireless or networking protocols and get information about them. It also shows how to pair wireless and networking devices with the system. + +The sample demonstrates eight scenarios: + +1. **Device Picker Common Control:** This scenario demonstrates the use of the Windows.Devices.Enumeration.DevicePicker. DevicePicker is a UI control that allows users of your app to pick a device. After they pick a device you can get information from it and start using it through the appropriate device API. + +2. **Enumerate and Watch Devices:** This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceWatcher. Device Watcher allows you to find and recieve updates for devices you're interested in. Even if you don't need updates for devices as the arrive, depart, or change, this method still has advantages over FindAllAsync in that the results come back one-by-one has they are discovered, rather than waiting for all results to be retreived and then returned in a single collection. + +3. **Enumerate and Watch Devices in a Background Task:** This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceWatcherTrigger. DeviceWatcherTrigger is similar to DeviceWatcher, but is performed in a background task. First you create a DeviceWatcher object, but instead of starting the DeviceWatcher in the foreground, you get the background trigger and then register it. Your background task is called with initial results and then called repeatedly over time as the device you're watching arrive, depart, or change. + +4. **Enumerate Snapshot of Devices:** This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceInformation.FindAllAsync. Use for grabbing a quick snapshot of devices you're interested in. This method is simplier to use than the DeviceWatcher, but doesn't allow you to process results as they arrive. Rather all results are internally added to a collection until the enumeration is complete, then the collection is returned when the async operation completes. + +5. **Get Single Device:** This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceInformation.CreateFromIdAsync. This would typically be used when you have a device id saved, and want to retrieve information about that device again. Other uses would be if you have a DeviceInformation.Id from another API and need to obtain a DeviceInformation object. + +6. **Custom Filter with Additional Properties:** This scenario demonstrates using custom filters and/or requesting additional properties with the DeviceWatcher. A custom filter and/or requested additional properties can also be done with the DevicePicker, FindAllAsync, and DeviceWatcherTrigger + +7. **Request Specific DeviceInformationKind:** This scenario demonstrates requesting various DeviceInformationKinds. Methods without the DeviceInformationKind parameter default to DeviceInterface. + +8. **Basic Device Pairing:** This scenario demonstrates how to perform basic pairing. Basic pairing allows you to tell Windows which device you want paired, and then Windows will handle the ceremony and the UI. If you want to display your own UI and be involved in the pairing ceremony, please see the Custom Pairing scenario. This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. + +9. **Custom Device Pairing:** This scenario demonstrates how to perform custom pairing. Custom pairing allows your app to be involved in the pairing ceremony and use your on UI. If you want Windows to control the ceremony and display system UI, please look at the basic pairing scenario. This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. + + +## Related topics + +### Reference + + + +[**Enumerating devices article**](http://msdn.microsoft.com/en-us/library/windows/apps/Hh464977) + +[**Windows.Devices.Enumeration reference**](http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.enumeration.aspx) + +[**Windows Universal App Samples**](https://github.com/Microsoft/Windows-universal-samples) + + +## System requirements + +**Client:** Windows 10 + +**Server:** Windows Server 2016 Technical Preview + +**Phone:** Windows 10 + + +## Build the sample + +1. Start Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**. +2. Go to the directory to which you unzipped the sample. Then go to the subdirectory containing the sample in the language you desire - either C++, C\#, or JavaScript. Double-click the Visual Studio Solution (.sln) file. +3. Select the appropriate target: x86, x64, ARM. 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 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**. + diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp.sln b/Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.sln similarity index 90% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp.sln rename to Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.sln index e2eda9bf23..193e6e4d74 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp.sln +++ b/Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.22609.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeviceEnumerationCpp", "DeviceEnumerationCpp\DeviceEnumerationCpp.vcxproj", "{F710B9FD-4E6B-42D7-A99A-6D48888D48B0}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeviceEnumeration", "DeviceEnumeration.vcxproj", "{F710B9FD-4E6B-42D7-A99A-6D48888D48B0}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BackgroundDeviceWatcherTaskCpp", "BackgroundDeviceWatcherTaskCpp\BackgroundDeviceWatcherTaskCpp.vcxproj", "{6E323CA9-B536-4BAD-8B98-36B9D2E0F0AF}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tasks", "Tasks\Tasks.vcxproj", "{6E323CA9-B536-4BAD-8B98-36B9D2E0F0AF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj b/Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj similarity index 87% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj rename to Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj index 583b8ff48f..46c9f3e1cf 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj +++ b/Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj @@ -8,8 +8,8 @@ true Windows Store 10.0 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 true @@ -100,7 +100,7 @@ - $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);..\..\..\..\SharedContent\cpp + $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);..\..\..\SharedContent\cpp @@ -141,11 +141,11 @@ - - ..\..\..\..\SharedContent\xaml\App.xaml + + ..\..\..\SharedContent\xaml\App.xaml - - ..\..\..\..\SharedContent\cpp\MainPage.xaml + + ..\..\..\SharedContent\cpp\MainPage.xaml @@ -172,12 +172,15 @@ Scenario8_PairDevice.xaml + + Scenario9_CustomPairDevice.xaml + - + Designer - + Designer @@ -188,9 +191,10 @@ - + Styles\Styles.xaml + @@ -198,12 +202,12 @@ - - ..\..\..\..\SharedContent\xaml\App.xaml + + ..\..\..\SharedContent\xaml\App.xaml - - ..\..\..\..\SharedContent\cpp\MainPage.xaml + + ..\..\..\SharedContent\cpp\MainPage.xaml Create @@ -238,32 +242,35 @@ Scenario8_PairDevice.xaml + + Scenario9_CustomPairDevice.xaml + - + 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 - + {6e323ca9-b536-4bad-8b98-36b9d2e0f0af} diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj.filters b/Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj.filters similarity index 71% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj.filters rename to Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj.filters index 5631a1e582..906d528b95 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DeviceEnumerationCpp.vcxproj.filters +++ b/Samples/DeviceEnumerationAndPairing/cpp/DeviceEnumeration.vcxproj.filters @@ -10,11 +10,11 @@ - + - - + + @@ -26,11 +26,12 @@ + - - + + @@ -41,13 +42,14 @@ + - - + + Styles @@ -58,27 +60,28 @@ + - + Assets - + Assets - + Assets - + Assets - + Assets - + Assets - + Assets diff --git a/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp b/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp new file mode 100644 index 0000000000..173c217aa5 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp @@ -0,0 +1,357 @@ +// Copyright (c) Microsoft. All rights reserved. + +#include "pch.h" +#include "MainPage.xaml.h" +#include +#include + +using namespace SDKTemplate; +using namespace Platform; +using namespace Platform::Collections; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Core; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Interop; +using namespace Windows::UI::Xaml::Media::Imaging; +using namespace Windows::Devices::Enumeration; + +// NOTE: The following using statements are only needed in order to demonstrate many of the +// different device selectors available from Windows Runtime APIs. You will only need to include +// the namespace for the Windows Runtime API your actual scenario needs. +using namespace Windows::Devices::HumanInterfaceDevice; +using namespace Windows::Networking::Proximity; +using namespace Windows::Devices::Bluetooth; +using namespace Windows::Devices::WiFiDirect; +using namespace Windows::Media::Casting; +using namespace Windows::Media::DialProtocol; +using namespace Windows::Devices::Sensors; +using namespace Windows::Devices::PointOfService; + +namespace SDKTemplate +{ + // DeviceSelectorChoices + + Windows::Foundation::Collections::IVectorView^ DeviceSelectorChoices::CommonDeviceSelectors::get() + { + Vector^ selectors = ref new Vector(); + + // Pre-canned device class selectors + selectors->Append(ref new DeviceSelectorInfo("All Device Interfaces (default)", DeviceClass::All, nullptr)); + selectors->Append(ref new DeviceSelectorInfo("Audio Capture", DeviceClass::AudioCapture, nullptr)); + selectors->Append(ref new DeviceSelectorInfo("Audio Render", DeviceClass::AudioRender, nullptr)); + selectors->Append(ref new DeviceSelectorInfo("Image Scanner", DeviceClass::ImageScanner, nullptr)); + selectors->Append(ref new DeviceSelectorInfo("Location", DeviceClass::Location, nullptr)); + selectors->Append(ref new DeviceSelectorInfo("Portable Storage", DeviceClass::PortableStorageDevice, nullptr)); + selectors->Append(ref new DeviceSelectorInfo("Video Capture", DeviceClass::VideoCapture, nullptr)); + + // A few examples of selectors built dynamically by windows runtime apis. + selectors->Append(ref new DeviceSelectorInfo("Human Interface (HID)", DeviceClass::All, HidDevice::GetDeviceSelector(0, 0))); + selectors->Append(ref new DeviceSelectorInfo("Activity Sensor", DeviceClass::All, ActivitySensor::GetDeviceSelector())); + selectors->Append(ref new DeviceSelectorInfo("Pedometer", DeviceClass::All, Pedometer::GetDeviceSelector())); + selectors->Append(ref new DeviceSelectorInfo("Proximity", DeviceClass::All, ProximityDevice::GetDeviceSelector())); + selectors->Append(ref new DeviceSelectorInfo("Proximity Sensor", DeviceClass::All, ProximityDevice::GetDeviceSelector())); + + return selectors->GetView(); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::Bluetooth::get() + { + // Currently Bluetooth APIs don't provide a selector to get ALL devices that are both paired and non-paired. Typically you wouldn't need this for common scenarios, but it's convenient to demonstrate the + // various sample scenarios. + return ref new DeviceSelectorInfo("Bluetooth", DeviceClass::All, "System.Devices.Aep.ProtocolId:=\"{e0cbf06c-cd8b-4647-bb8a-263b43f0f974}\"", DeviceInformationKind::AssociationEndpoint); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::BluetoothUnpairedOnly::get() + { + return ref new DeviceSelectorInfo("Bluetooth (unpaired)", DeviceClass::All, BluetoothDevice::GetDeviceSelectorFromPairingState(false)); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::BluetoothPairedOnly::get() + { + return ref new DeviceSelectorInfo("Bluetooth (paired)", DeviceClass::All, BluetoothDevice::GetDeviceSelectorFromPairingState(true)); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::BluetoothLE::get() + { + // Currently Bluetooth APIs don't provide a selector to get ALL devices that are both paired and non-paired. Typically you wouldn't need this for common scenarios, but it's convenient to demonstrate the + // various sample scenarios. + return ref new DeviceSelectorInfo("Bluetooth LE", DeviceClass::All, "System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\"", DeviceInformationKind::AssociationEndpoint); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::BluetoothLEUnpairedOnly::get() + { + return ref new DeviceSelectorInfo("Bluetooth LE (unpaired)", DeviceClass::All, BluetoothLEDevice::GetDeviceSelectorFromPairingState(false)); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::BluetoothLEPairedOnly::get() + { + return ref new DeviceSelectorInfo("Bluetooth LE (paired)", DeviceClass::All, BluetoothLEDevice::GetDeviceSelectorFromPairingState(true)); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::WiFiDirect::get() + { + return ref new DeviceSelectorInfo("Wi-Fi Direct", DeviceClass::All, WiFiDirectDevice::GetDeviceSelector(WiFiDirectDeviceSelectorType::AssociationEndpoint)); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::WiFiDirectPairedOnly::get() + { + return ref new DeviceSelectorInfo("Wi-Fi Direct (paired)", DeviceClass::All, WiFiDirectDevice::GetDeviceSelector()); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::PointOfServicePrinter::get() + { + return ref new DeviceSelectorInfo("Point of Service Printer", DeviceClass::All, PosPrinter::GetDeviceSelector()); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::VideoCasting::get() + { + return ref new DeviceSelectorInfo("Video Casting", DeviceClass::All, CastingDevice::GetDeviceSelector(CastingPlaybackTypes::Video)); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::DialAllApps::get() + { + return ref new DeviceSelectorInfo("DIAL (All apps)", DeviceClass::All, DialDevice::GetDeviceSelector("")); + } + + // WSD and UPnP are unique in that there are currently no general WSD or UPnP APIs to USE the devices once you've discovered them. + // You can pair the devices using DeviceInformation.Pairing.PairAsync etc, and you can USE them with the sockets APIs. However, since + // there's no specific API right now, there's no *.GetDeviceSelector available. That's why we just simply build the device selector + // ourselves and specify the correct DeviceInformationKind (AssociationEndpoint). + DeviceSelectorInfo^ DeviceSelectorChoices::Wsd::get() + { + return ref new DeviceSelectorInfo("Web Services on Devices (WSD)", DeviceClass::All, "System.Devices.Aep.ProtocolId:=\"{782232aa-a2f9-4993-971b-aedc551346b0}\"", DeviceInformationKind::AssociationEndpoint); + } + + DeviceSelectorInfo^ DeviceSelectorChoices::Upnp::get() + { + return ref new DeviceSelectorInfo("UPnP", DeviceClass::All, "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"", DeviceInformationKind::AssociationEndpoint); + } + + + IVectorView^ DeviceSelectorChoices::DevicePickerSelectors::get() + { + Vector^ selectors = ref new Vector(begin(CommonDeviceSelectors), end(CommonDeviceSelectors)); + selectors->Append(BluetoothPairedOnly); + selectors->Append(BluetoothUnpairedOnly); + selectors->Append(BluetoothLEPairedOnly); + selectors->Append(BluetoothLEUnpairedOnly); + selectors->Append(WiFiDirect); + selectors->Append(PointOfServicePrinter); + selectors->Append(VideoCasting); + selectors->Append(DialAllApps); + + return selectors->GetView(); + } + + IVectorView^ DeviceSelectorChoices::FindAllAsyncSelectors::get() + { + Vector^ selectors = ref new Vector(begin(CommonDeviceSelectors), end(CommonDeviceSelectors)); + selectors->Append(BluetoothPairedOnly); + selectors->Append(BluetoothLEPairedOnly); + selectors->Append(WiFiDirectPairedOnly); + + return selectors->GetView(); + } + + IVectorView^ DeviceSelectorChoices::DeviceWatcherSelectors::get() + { + Vector^ selectors = ref new Vector(begin(CommonDeviceSelectors), end(CommonDeviceSelectors)); + selectors->Append(Bluetooth); + selectors->Append(BluetoothLE); + selectors->Append(WiFiDirect); + selectors->Append(PointOfServicePrinter); + selectors->Append(VideoCasting); + selectors->Append(DialAllApps); + selectors->Append(Wsd); + selectors->Append(Upnp); + + return selectors->GetView(); + } + + IVectorView^ DeviceSelectorChoices::BackgroundDeviceWatcherSelectors::get() + { + Vector^ selectors = ref new Vector(begin(CommonDeviceSelectors), end(CommonDeviceSelectors)); + selectors->Append(BluetoothPairedOnly); + selectors->Append(BluetoothLEPairedOnly); + selectors->Append(WiFiDirectPairedOnly); + selectors->Append(PointOfServicePrinter); + selectors->Append(VideoCasting); + selectors->Append(DialAllApps); + selectors->Append(Wsd); + selectors->Append(Upnp); + + return selectors->GetView(); + } + + IVectorView^ DeviceSelectorChoices::PairingSelectors::get() + { + Vector^ selectors = ref new Vector(); + selectors->Append(Bluetooth); + selectors->Append(BluetoothLE); + selectors->Append(WiFiDirect); + selectors->Append(PointOfServicePrinter); + selectors->Append(VideoCasting); + selectors->Append(Wsd); + selectors->Append(Upnp); + + return selectors->GetView(); + } + + // DeviceInformationKindChoices + + IVectorView^ DeviceInformationKindChoices::Choices::get() + { + Vector^ choices = ref new Vector(); + + Vector^ kinds; + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::DeviceContainer); + choices->Append(ref new DeviceInformationKindChoice("DeviceContainer", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::Device); + choices->Append(ref new DeviceInformationKindChoice("Device", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::DeviceInterface); + choices->Append(ref new DeviceInformationKindChoice("DeviceInterface", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::DeviceInterfaceClass); + choices->Append(ref new DeviceInformationKindChoice("DeviceInterfaceClass", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::AssociationEndpointContainer); + choices->Append(ref new DeviceInformationKindChoice("AssociationEndpointContainer", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::AssociationEndpoint); + choices->Append(ref new DeviceInformationKindChoice("AssociationEndpoint", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::AssociationEndpointService); + choices->Append(ref new DeviceInformationKindChoice("AssociationEndpointService", kinds->GetView())); + + kinds = ref new Vector(); + kinds->Append(DeviceInformationKind::AssociationEndpointService); + kinds->Append(DeviceInformationKind::DeviceInterface); + choices->Append(ref new DeviceInformationKindChoice("AssociationEndpointService and DeviceInterface", kinds->GetView())); + + return choices->GetView(); + } + + IVectorView^ ProtectionSelectorChoices::Selectors::get() + { + Vector^ selectors = ref new Vector(); + + selectors->Append(ref new ProtectionLevelSelectorInfo("Default", Windows::Devices::Enumeration::DevicePairingProtectionLevel::Default )); + selectors->Append(ref new ProtectionLevelSelectorInfo("None", Windows::Devices::Enumeration::DevicePairingProtectionLevel::None )); + selectors->Append(ref new ProtectionLevelSelectorInfo("Encryption", Windows::Devices::Enumeration::DevicePairingProtectionLevel::Encryption )); + selectors->Append(ref new ProtectionLevelSelectorInfo("Encryption and authentication", Windows::Devices::Enumeration::DevicePairingProtectionLevel::EncryptionAndAuthentication )); + + return selectors->GetView(); + } + + // DeviceInformationDisplay + + DeviceInformationDisplay::DeviceInformationDisplay(DeviceInformation^ deviceInfoIn) + { + deviceInfo = deviceInfoIn; + UpdateGlyphBitmapImage(); + } + + String^ DeviceInformationDisplay::KindString::get() + { + String^ str; + switch (deviceInfo->Kind) + { + case DeviceInformationKind::DeviceContainer: + str = "DeviceContainer"; + break; + case DeviceInformationKind::Device: + str = "Device"; + break; + case DeviceInformationKind::DeviceInterface: + str = "DeviceInterface"; + break; + case DeviceInformationKind::DeviceInterfaceClass: + str = "DeviceInterfaceClass"; + break; + case DeviceInformationKind::AssociationEndpointContainer: + str = "AssociationEndpointContainer"; + break; + case DeviceInformationKind::AssociationEndpoint: + str = "AssociationEndpoint"; + break; + case DeviceInformationKind::AssociationEndpointService: + str = "AssociationEndpointService"; + break; + }; + + return str; + } + + void DeviceInformationDisplay::Update(DeviceInformationUpdate^ deviceInfoUpdateIn) + { + deviceInfo->Update(deviceInfoUpdateIn); + + OnPropertyChanged("Kind"); + OnPropertyChanged("Id"); + OnPropertyChanged("Name"); + OnPropertyChanged("DeviceInformation"); + OnPropertyChanged("CanPair"); + OnPropertyChanged("IsPaired"); + + UpdateGlyphBitmapImage(); + } + + void DeviceInformationDisplay::UpdateGlyphBitmapImage() + { + BitmapImage^ glyphBitmapImage; + glyphBitmapImage = ref new BitmapImage(); + + concurrency::create_task(deviceInfo->GetGlyphThumbnailAsync()).then( + [glyphBitmapImage](DeviceThumbnail^ result) + { + return glyphBitmapImage->SetSourceAsync(result); + }).then( + [this, glyphBitmapImage]() + { + GlyphBitmapImage = glyphBitmapImage; + OnPropertyChanged("GlyphBitmapImage"); + }); + } + + void DeviceInformationDisplay::OnPropertyChanged(String^ name) + { + MainPage::Current->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler( + [this, name]() + { + PropertyChanged(this, ref new PropertyChangedEventArgs(name)); + })); + } + + + // GeneralPropertyValueConverter + + Object^ GeneralPropertyValueConverter::Convert( + Object^ value, + TypeName targetType, + Object^ parameter, + String^ language) + { + Object^ property = nullptr; + String^ strParameter = safe_cast(parameter); + + if (nullptr != strParameter && !strParameter->IsEmpty()) + { + IMapView^ properties = safe_cast^>(value); + + property = properties->Lookup(strParameter); + } + + return property; + } +} \ No newline at end of file diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.h b/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.h similarity index 54% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.h rename to Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.h index 749674f2f4..6b1289efd3 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/DisplayHelpers.h +++ b/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.h @@ -7,22 +7,52 @@ namespace SDKTemplate { [Windows::UI::Xaml::Data::Bindable] - public ref struct DeviceSelectorInfo sealed + public ref class DeviceSelectorInfo sealed { public: DeviceSelectorInfo( Platform::String^ displayName, Windows::Devices::Enumeration::DeviceClass deviceClassSelector, - Platform::String^ selector - ) + Platform::String^ selector) { - DisplayName = displayName; - DeviceClassSelector = deviceClassSelector; - Selector = selector; + Initialize( + displayName, + deviceClassSelector, + selector, + Windows::Devices::Enumeration::DeviceInformationKind::Unknown); } + + DeviceSelectorInfo( + Platform::String^ displayName, + Windows::Devices::Enumeration::DeviceClass deviceClassSelector, + Platform::String^ selector, + Windows::Devices::Enumeration::DeviceInformationKind kind) + { + Initialize( + displayName, + deviceClassSelector, + selector, + kind); + } + property Platform::String^ DisplayName; property Windows::Devices::Enumeration::DeviceClass DeviceClassSelector; + property Windows::Devices::Enumeration::DeviceInformationKind Kind; property Platform::String^ Selector; + + private: + + void Initialize( + Platform::String^ displayName, + Windows::Devices::Enumeration::DeviceClass deviceClassSelector, + Platform::String^ selector, + Windows::Devices::Enumeration::DeviceInformationKind kind) + { + DisplayName = displayName; + DeviceClassSelector = deviceClassSelector; + Kind = kind; + Selector = selector; + } }; @@ -31,7 +61,97 @@ namespace SDKTemplate { public: - static property Windows::Foundation::Collections::IVectorView^ Selectors + static property Windows::Foundation::Collections::IVectorView^ CommonDeviceSelectors + { + Windows::Foundation::Collections::IVectorView^ get(); + } + + static property DeviceSelectorInfo^ Bluetooth + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ BluetoothUnpairedOnly + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ BluetoothPairedOnly + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ BluetoothLE + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ BluetoothLEUnpairedOnly + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ BluetoothLEPairedOnly + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ WiFiDirect + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ WiFiDirectPairedOnly + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ PointOfServicePrinter + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ VideoCasting + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ DialAllApps + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ Wsd + { + DeviceSelectorInfo^ get(); + } + + static property DeviceSelectorInfo^ Upnp + { + DeviceSelectorInfo^ get(); + } + + static property Windows::Foundation::Collections::IVectorView^ DevicePickerSelectors + { + Windows::Foundation::Collections::IVectorView^ get(); + } + + static property Windows::Foundation::Collections::IVectorView^ FindAllAsyncSelectors + { + Windows::Foundation::Collections::IVectorView^ get(); + } + + static property Windows::Foundation::Collections::IVectorView^ DeviceWatcherSelectors + { + Windows::Foundation::Collections::IVectorView^ get(); + } + + static property Windows::Foundation::Collections::IVectorView^ BackgroundDeviceWatcherSelectors + { + Windows::Foundation::Collections::IVectorView^ get(); + } + + static property Windows::Foundation::Collections::IVectorView^ PairingSelectors { Windows::Foundation::Collections::IVectorView^ get(); } @@ -44,8 +164,7 @@ namespace SDKTemplate public: DeviceInformationKindChoice( Platform::String^ displayName, - Windows::Foundation::Collections::IVectorView^ deviceInformationKinds - ) + Windows::Foundation::Collections::IVectorView^ deviceInformationKinds) { DisplayName = displayName; DeviceInformationKinds = deviceInformationKinds; @@ -67,30 +186,28 @@ namespace SDKTemplate }; [Windows::UI::Xaml::Data::Bindable] - public ref struct ProtocolSelectorInfo sealed + public ref struct ProtectionLevelSelectorInfo sealed { public: - ProtocolSelectorInfo( + ProtectionLevelSelectorInfo( Platform::String^ displayName, - Platform::String^ selector - ) + Windows::Devices::Enumeration::DevicePairingProtectionLevel protectionLevel) { DisplayName = displayName; - Selector = selector; + ProtectionLevel = protectionLevel; } property Platform::String^ DisplayName; - property Platform::String^ Selector; + property Windows::Devices::Enumeration::DevicePairingProtectionLevel ProtectionLevel; }; - [Windows::UI::Xaml::Data::Bindable] - public ref struct ProtocolSelectorChoices sealed + public ref struct ProtectionSelectorChoices sealed { public: - static property Windows::Foundation::Collections::IVectorView^ Selectors + static property Windows::Foundation::Collections::IVectorView^ Selectors { - Windows::Foundation::Collections::IVectorView^ get(); + Windows::Foundation::Collections::IVectorView^ get(); } }; diff --git a/Samples/DeviceEnumerationAndPairing/cpp/Package.appxmanifest b/Samples/DeviceEnumerationAndPairing/cpp/Package.appxmanifest new file mode 100644 index 0000000000..64c9e3eab3 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cpp/Package.appxmanifest @@ -0,0 +1,38 @@ + + + + + + Device Enumeration and Pairing C++ sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/SampleConfiguration.cpp b/Samples/DeviceEnumerationAndPairing/cpp/SampleConfiguration.cpp similarity index 68% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/SampleConfiguration.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/SampleConfiguration.cpp index 80099f938e..8d5890b899 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/SampleConfiguration.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/SampleConfiguration.cpp @@ -13,7 +13,8 @@ Platform::Array^ MainPage::scenariosInner = ref new Platform::Array(); - selectorComboBox->ItemsSource = DeviceSelectorChoices::Selectors; + selectorComboBox->ItemsSource = DeviceSelectorChoices::DevicePickerSelectors; selectorComboBox->SelectedIndex = 0; DataContext = this; @@ -56,15 +56,13 @@ void Scenario1::ShowDevicePickerButton_Click(Platform::Object^ sender, Windows:: void Scenario1::ShowDevicePicker(bool pickSingle) { - DeviceSelectorInfo^ deviceSelectorInfo; - showDevicePickerButton->IsEnabled = false; ResultCollection->Clear(); devicePicker = ref new DevicePicker(); // First get the device selector chosen by the UI. - deviceSelectorInfo = safe_cast(selectorComboBox->SelectedItem); + DeviceSelectorInfo^ deviceSelectorInfo = safe_cast(selectorComboBox->SelectedItem); if (nullptr == deviceSelectorInfo->Selector) { diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario1_DevicePicker.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario1_DevicePicker.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario1_DevicePicker.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario1_DevicePicker.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml.cpp similarity index 92% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml.cpp index da67aaf22a..bca33b288d 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml.cpp @@ -30,7 +30,7 @@ void Scenario2::OnNavigatedTo(NavigationEventArgs^ e) { ResultCollection = ref new Vector(); - selectorComboBox->ItemsSource = DeviceSelectorChoices::Selectors; + selectorComboBox->ItemsSource = DeviceSelectorChoices::DeviceWatcherSelectors; selectorComboBox->SelectedIndex = 0; DataContext = this; @@ -53,27 +53,34 @@ void Scenario2::StopWatcherButton_Click(Platform::Object^ sender, Windows::UI::X void Scenario2::StartWatcher() { - DeviceSelectorInfo^ deviceSelectorInfo; - startWatcherButton->IsEnabled = false; ResultCollection->Clear(); // First get the device selector chosen by the UI. - deviceSelectorInfo = safe_cast(selectorComboBox->SelectedItem); + DeviceSelectorInfo^ deviceSelectorInfo = safe_cast(selectorComboBox->SelectedItem); if (nullptr == deviceSelectorInfo->Selector) { // If the a pre-canned device class selector was chosen, call the DeviceClass overload deviceWatcher = DeviceInformation::CreateWatcher(deviceSelectorInfo->DeviceClassSelector); } - else + else if (deviceSelectorInfo->Kind == DeviceInformationKind::Unknown) { // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call + // Kind will be determined by the selector deviceWatcher = DeviceInformation::CreateWatcher( deviceSelectorInfo->Selector, nullptr // don't request additional properties for this sample ); } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation::CreateWatcher( + deviceSelectorInfo->Selector, + nullptr, // don't request additional properties for this sample + deviceSelectorInfo->Kind); + } // Hook up handlers for the watcher events before starting the watcher handlerAdded = ref new TypedEventHandler( diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario2_DeviceWatcher.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario2_DeviceWatcher.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario3_BackgroundDeviceWatcher.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario3_BackgroundDeviceWatcher.xaml similarity index 95% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario3_BackgroundDeviceWatcher.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario3_BackgroundDeviceWatcher.xaml index 6d0283816d..ad056fb682 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario3_BackgroundDeviceWatcher.xaml +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario3_BackgroundDeviceWatcher.xaml @@ -27,7 +27,7 @@ + Text="This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceWatcherTrigger. DeviceWatcherTrigger is similar to DeviceWatcher, but is performed in a background task. Note that Bluetooth and Wi-Fi Direct selectors that perform 'live' protocol queries aren't support for perforfance reasons." /> ItemsSource = DeviceSelectorChoices::Selectors; + selectorComboBox->ItemsSource = DeviceSelectorChoices::BackgroundDeviceWatcherSelectors; selectorComboBox->SelectedIndex = 0; DataContext = this; @@ -59,35 +59,42 @@ void Scenario3::StopWatcherButton_Click(Platform::Object^ sender, Windows::UI::X void Scenario3::StartWatcher() { - DeviceSelectorInfo^ deviceSelectorInfo; Vector^ triggerEventKinds = ref new Vector({ DeviceWatcherEventKind::Add, DeviceWatcherEventKind::Remove, DeviceWatcherEventKind::Update }); DeviceWatcher^ deviceWatcher = nullptr; - DeviceWatcherTrigger^ deviceWatcherTrigger = nullptr; startWatcherButton->IsEnabled = false; // First get the device selector chosen by the UI. - deviceSelectorInfo = safe_cast(selectorComboBox->SelectedItem); + DeviceSelectorInfo^ deviceSelectorInfo = safe_cast(selectorComboBox->SelectedItem); if (nullptr == deviceSelectorInfo->Selector) { // If the a pre-canned device class selector was chosen, call the DeviceClass overload deviceWatcher = DeviceInformation::CreateWatcher(deviceSelectorInfo->DeviceClassSelector); } - else + else if (deviceSelectorInfo->Kind == DeviceInformationKind::Unknown) { // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call + // Kind will be determined by the selector deviceWatcher = DeviceInformation::CreateWatcher( deviceSelectorInfo->Selector, nullptr // don't request additional properties for this sample ); } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation::CreateWatcher( + deviceSelectorInfo->Selector, + nullptr, // don't request additional properties for this sample + deviceSelectorInfo->Kind); + } // Get the background trigger for this watcher - deviceWatcherTrigger = deviceWatcher->GetBackgroundTrigger(triggerEventKinds); + DeviceWatcherTrigger^ deviceWatcherTrigger = deviceWatcher->GetBackgroundTrigger(triggerEventKinds); rootPage->NotifyUser("Starting Watcher...", NotifyType::StatusMessage); diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario3_BackgroundDeviceWatcher.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario3_BackgroundDeviceWatcher.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario3_BackgroundDeviceWatcher.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario3_BackgroundDeviceWatcher.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml.cpp similarity index 97% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml.cpp index 079d697dec..b4d0e48e25 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml.cpp @@ -30,7 +30,7 @@ void Scenario4::OnNavigatedTo(NavigationEventArgs^ e) { ResultCollection = ref new Vector(); - selectorComboBox->ItemsSource = DeviceSelectorChoices::Selectors; + selectorComboBox->ItemsSource = DeviceSelectorChoices::FindAllAsyncSelectors; selectorComboBox->SelectedIndex = 0; DataContext = this; diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario4_Snapshot.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario4_Snapshot.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario5_GetSingleDevice.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario5_GetSingleDevice.xaml similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario5_GetSingleDevice.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario5_GetSingleDevice.xaml diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario5_GetSingleDevice.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario5_GetSingleDevice.xaml.cpp similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario5_GetSingleDevice.xaml.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario5_GetSingleDevice.xaml.cpp diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario5_GetSingleDevice.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario5_GetSingleDevice.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario5_GetSingleDevice.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario5_GetSingleDevice.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml.cpp similarity index 99% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml.cpp index 45a8fe19ac..7d963916d5 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml.cpp @@ -63,8 +63,7 @@ void Scenario6::StartWatcher() // Use AQS string filter from the text box deviceWatcher = DeviceInformation::CreateWatcher( aqsFilterTextBox->Text, - requestedProperties - ); + requestedProperties); // Hook up handlers for the watcher events before starting the watcher handlerAdded = ref new TypedEventHandler( diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario6_CustomFilterAddedProps.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario6_CustomFilterAddedProps.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario7_DeviceInformationKind.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario7_DeviceInformationKind.xaml similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario7_DeviceInformationKind.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario7_DeviceInformationKind.xaml diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario7_DeviceInformationKind.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario7_DeviceInformationKind.xaml.cpp similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario7_DeviceInformationKind.xaml.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario7_DeviceInformationKind.xaml.cpp diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario7_DeviceInformationKind.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario7_DeviceInformationKind.xaml.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario7_DeviceInformationKind.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario7_DeviceInformationKind.xaml.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml similarity index 67% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml index 73b209a113..53d366248b 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml @@ -52,16 +52,20 @@ - - - + + + - + + This scenario demonstrates how to perform basic pairing. Basic pairing allows you to tell Windows which device you want paired, and then Windows will + handle the ceremony and the UI. If you want to display your own UI and be involved in the pairing ceremony, please see the Custom Pairing scenario. + This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. + Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. + - - + + - - - - - - + + + + SelectionChanged="ResultsListView_SelectionChanged" + MaxHeight="450"> diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml.cpp similarity index 71% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml.cpp index e38acef46c..954c711e35 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml.cpp @@ -30,7 +30,7 @@ void Scenario8::OnNavigatedTo(NavigationEventArgs^ e) { ResultCollection = ref new Vector(); - selectorComboBox->ItemsSource = ProtocolSelectorChoices::Selectors; + selectorComboBox->ItemsSource = DeviceSelectorChoices::PairingSelectors; selectorComboBox->SelectedIndex = 0; DataContext = this; @@ -53,26 +53,30 @@ void Scenario8::StopWatcherButton_Click(Platform::Object^ sender, Windows::UI::X void Scenario8::StartWatcher() { - ProtocolSelectorInfo^ protocolSelectorInfo; - String^ aqsFilter; - startWatcherButton->IsEnabled = false; ResultCollection->Clear(); - // Request the IsPaired property so we can display the paired status in the UI - Vector^ requestedProperties = ref new Vector(); - requestedProperties->Append("System.Devices.Aep.IsPaired"); - - // Get the device selector chosen by the UI, then 'AND' it with the 'CanPair' property - protocolSelectorInfo = (ProtocolSelectorInfo^)selectorComboBox->SelectedItem; - aqsFilter = protocolSelectorInfo->Selector + " AND System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True"; - - deviceWatcher = DeviceInformation::CreateWatcher( - aqsFilter, - requestedProperties, - DeviceInformationKind::AssociationEndpoint - ); + // Get the device selector chosen by the UI then add additional constraints for devices that + // can be paired or are already paired. + DeviceSelectorInfo^ deviceSelectorInfo = (DeviceSelectorInfo^)selectorComboBox->SelectedItem; + String^ selector = "(" + deviceSelectorInfo->Selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; + if (deviceSelectorInfo->Kind == DeviceInformationKind::Unknown) + { + // Kind will be determined by the selector + deviceWatcher = DeviceInformation::CreateWatcher( + selector, + nullptr // don't request additional properties for this sample + ); + } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation::CreateWatcher( + selector, + nullptr, // don't request additional properties for this sample + deviceSelectorInfo->Kind); + } // Hook up handlers for the watcher events before starting the watcher handlerAdded = ref new TypedEventHandler( @@ -107,6 +111,13 @@ void Scenario8::StartWatcher() if (foundDeviceInfo != end(ResultCollection)) { (*foundDeviceInfo)->Update(deviceInfoUpdate); + + // If the item being updated is currently "selected", then update the pairing buttons + DeviceInformationDisplay^ selectedDeviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; + if ((*foundDeviceInfo) == selectedDeviceInfoDisp) + { + UpdatePairingButtons(); + } } })); }); @@ -196,9 +207,12 @@ void Scenario8::StopWatcher() void Scenario8::PairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) { - DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; - + // Gray out the pair button and results view while pairing is in progress. + resultsListView->IsEnabled = false; pairButton->IsEnabled = false; + rootPage->NotifyUser("Pairing started. Please wait...", NotifyType::StatusMessage); + + DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; concurrency::create_task(deviceInfoDisp->DeviceInfo->Pairing->PairAsync()).then( [this](DevicePairingResult^ pairingResult) @@ -210,16 +224,49 @@ void Scenario8::PairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::Ro "Pairing result = " + (pairingResult->Status == DevicePairingResultStatus::Paired ? "Paired" : "NotPaired"), pairingResult->Status == DevicePairingResultStatus::Paired ? NotifyType::StatusMessage : NotifyType::ErrorMessage); })); + + UpdatePairingButtons(); + resultsListView->IsEnabled = true; + }, concurrency::task_continuation_context::use_current()); +} + +void Scenario8::UnpairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + // Gray out the unpair button and results view while unpairing is in progress. + resultsListView->IsEnabled = false; + unpairButton->IsEnabled = false; + rootPage->NotifyUser("Unpairing started. Please wait...", NotifyType::StatusMessage); + + DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; + + concurrency::create_task(deviceInfoDisp->DeviceInfo->Pairing->UnpairAsync()).then( + [this](DeviceUnpairingResult^ unpairingResult) + { + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, unpairingResult]() + { + rootPage->NotifyUser( + "Unpairing result = " + (unpairingResult->Status == DeviceUnpairingResultStatus::Unpaired ? "Unpaired" : "Failed"), + unpairingResult->Status == DeviceUnpairingResultStatus::Unpaired ? NotifyType::StatusMessage : NotifyType::ErrorMessage); + })); + + UpdatePairingButtons(); + resultsListView->IsEnabled = true; }, concurrency::task_continuation_context::use_current()); } void Scenario8::ResultsListView_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e) +{ + UpdatePairingButtons(); +} + +void Scenario8::UpdatePairingButtons() { DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; if (nullptr != deviceInfoDisp && - true == deviceInfoDisp->DeviceInfo->Pairing->CanPair && - false == deviceInfoDisp->DeviceInfo->Pairing->IsPaired) + deviceInfoDisp->DeviceInfo->Pairing->CanPair && + !deviceInfoDisp->DeviceInfo->Pairing->IsPaired) { pairButton->IsEnabled = true; } @@ -227,6 +274,16 @@ void Scenario8::ResultsListView_SelectionChanged(Platform::Object^ sender, Windo { pairButton->IsEnabled = false; } + + if (nullptr != deviceInfoDisp && + deviceInfoDisp->DeviceInfo->Pairing->IsPaired) + { + unpairButton->IsEnabled = true; + } + else + { + unpairButton->IsEnabled = false; + } } diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml.h similarity index 94% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml.h rename to Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml.h index d7ddc5d3fd..6d958295e6 100644 --- a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/Scenario8_PairDevice.xaml.h +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario8_PairDevice.xaml.h @@ -28,12 +28,15 @@ namespace SDKTemplate void StartWatcherButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void StopWatcherButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void PairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void UnpairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); void ResultsListView_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); void StartWatcher(); void StopWatcher(); + void UpdatePairingButtons(); + SDKTemplate::MainPage^ rootPage; Windows::Devices::Enumeration::DeviceWatcher^ deviceWatcher; Windows::Foundation::TypedEventHandler^ handlerAdded; diff --git a/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml b/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml new file mode 100644 index 0000000000..6b96e1108c --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This scenario demonstrates how to perform custom pairing. Custom pairing allows your app to be involved in the pairing ceremony and use your on UI. + If you want Windows to control the ceremony and display system UI, please look at the basic pairing scenario. + This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. + Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.cpp new file mode 100644 index 0000000000..46c15e6994 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.cpp @@ -0,0 +1,502 @@ +// Copyright (c) Microsoft. All rights reserved. + +#include "pch.h" +#include "Scenario9_CustomPairDevice.xaml.h" + +using namespace SDKTemplate; + +using namespace concurrency; +using namespace Platform; +using namespace Platform::Collections; +using namespace Windows::Foundation; +using namespace Windows::Foundation::Collections; +using namespace Windows::UI::Core; +using namespace Windows::UI::Popups; +using namespace Windows::UI::Xaml; +using namespace Windows::UI::Xaml::Controls; +using namespace Windows::UI::Xaml::Controls::Primitives; +using namespace Windows::UI::Xaml::Data; +using namespace Windows::UI::Xaml::Input; +using namespace Windows::UI::Xaml::Media; +using namespace Windows::UI::Xaml::Navigation; +using namespace Windows::Devices::Enumeration; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 + +Scenario9::Scenario9() : rootPage(MainPage::Current) +{ + InitializeComponent(); +} + +void Scenario9::OnNavigatedTo(NavigationEventArgs^ e) +{ + ResultCollection = ref new Vector(); + + selectorComboBox->ItemsSource = DeviceSelectorChoices::PairingSelectors; + selectorComboBox->SelectedIndex = 0; + + protectionLevelComboBox->ItemsSource = ProtectionSelectorChoices::Selectors; + protectionLevelComboBox->SelectedIndex = 0; + + DataContext = this; +} + +void Scenario9::OnNavigatedFrom(NavigationEventArgs^ e) +{ + StopWatcher(); +} + +void Scenario9::StartWatcherButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + StartWatcher(); +} + +void Scenario9::StopWatcherButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + StopWatcher(); +} + +void Scenario9::StartWatcher() +{ + startWatcherButton->IsEnabled = false; + ResultCollection->Clear(); + + // Get the device selector chosen by the UI then add additional constraints for devices that + // can be paired or are already paired. + DeviceSelectorInfo^ deviceSelectorInfo = (DeviceSelectorInfo^)selectorComboBox->SelectedItem; + String^ selector = "(" + deviceSelectorInfo->Selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; + + if (deviceSelectorInfo->Kind == DeviceInformationKind::Unknown) + { + // Kind will be determined by the selector + deviceWatcher = DeviceInformation::CreateWatcher( + selector, + nullptr // don't request additional properties for this sample + ); + } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation::CreateWatcher( + selector, + nullptr, // don't request additional properties for this sample + deviceSelectorInfo->Kind); + } + + // Hook up handlers for the watcher events before starting the watcher + auto handlerAdded = ref new TypedEventHandler( + [this](DeviceWatcher^ sender, DeviceInformation^ deviceInfo) + { + // Since we have the collection databound to a UI element, we need to update the collection on the UI thread. + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, deviceInfo]() + { + ResultCollection->Append(ref new DeviceInformationDisplay(deviceInfo)); + + rootPage->NotifyUser( + ResultCollection->Size.ToString() + " devices found.", + NotifyType::StatusMessage); + })); + }); + handlerAddedToken = deviceWatcher->Added += handlerAdded; + + auto handlerUpdated = ref new TypedEventHandler( + [this](DeviceWatcher^ sender, DeviceInformationUpdate^ deviceInfoUpdate) + { + // Since we have the collection databound to a UI element, we need to update the collection on the UI thread. + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, deviceInfoUpdate]() + { + // Find the corresponding updated DeviceInformation in the collection and pass the update object + // to the Update method of the existing DeviceInformation. This automatically updates the object + // for us. + auto foundDeviceInfo = std::find_if(begin(ResultCollection), end(ResultCollection), [&](DeviceInformationDisplay^ di) { return (di->Id == deviceInfoUpdate->Id); }); + + uint32 index = 0; + if (foundDeviceInfo != end(ResultCollection)) + { + (*foundDeviceInfo)->Update(deviceInfoUpdate); + + // If the item being updated is currently "selected", then update the pairing buttons + DeviceInformationDisplay^ selectedDeviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; + if ((*foundDeviceInfo) == selectedDeviceInfoDisp) + { + UpdatePairingButtons(); + } + } + })); + }); + handlerUpdatedToken = deviceWatcher->Updated += handlerUpdated; + + auto handlerRemoved = ref new TypedEventHandler( + [this](DeviceWatcher^ sender, DeviceInformationUpdate^ deviceInfoUpdate) + { + // Since we have the collection databound to a UI element, we need to update the collection on the UI thread. + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, deviceInfoUpdate]() + { + // Find the corresponding DeviceInformation in the collection and remove it + auto foundDeviceInfo = std::find_if(begin(ResultCollection), end(ResultCollection), [&](DeviceInformationDisplay^ di){return (di->Id == deviceInfoUpdate->Id);}); + + uint32 index = 0; + if (foundDeviceInfo != end(ResultCollection) && + ResultCollection->IndexOf(*foundDeviceInfo, &index)) + { + ResultCollection->RemoveAt(index); + } + + rootPage->NotifyUser( + ResultCollection->Size.ToString() + " devices found.", + NotifyType::StatusMessage); + })); + }); + handlerRemovedToken = deviceWatcher->Removed += handlerRemoved; + + auto handlerEnumCompleted = ref new TypedEventHandler( + [this](DeviceWatcher^ sender, Object^ obj) + { + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this]() + { + rootPage->NotifyUser( + ResultCollection->Size.ToString() + " devices found. Enumeration completed. Watching for updates...", + NotifyType::StatusMessage); + })); + }); + handlerEnumCompletedToken = deviceWatcher->EnumerationCompleted += handlerEnumCompleted; + + auto handlerStopped = ref new TypedEventHandler( + [this](DeviceWatcher^ sender, Object^ obj) + { + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, sender]() + { + String^ output = ResultCollection->Size.ToString(); + output += " devices found. Watcher "; + output += (DeviceWatcherStatus::Aborted == sender->Status) ? "aborted" : "stopped"; + + rootPage->NotifyUser(output, NotifyType::StatusMessage); + })); + }); + handlerStoppedAddedToken = deviceWatcher->Stopped += handlerStopped; + + rootPage->NotifyUser("Starting Watcher...", NotifyType::StatusMessage); + deviceWatcher->Start(); + stopWatcherButton->IsEnabled = true; +} + +void Scenario9::StopWatcher() +{ + stopWatcherButton->IsEnabled = false; + + if (nullptr != deviceWatcher) + { + // First unhook all event handlers except the stopped handler. This ensures our + // event handlers don't get called after stop, as stop won't block for any "in flight" + // event handler calls. We leave the stopped handler as it's guaranteed to only be called + // once and we'll use it to know when the query is completely stopped. + deviceWatcher->Added -= handlerAddedToken; + deviceWatcher->Updated -= handlerUpdatedToken; + deviceWatcher->Removed -= handlerRemovedToken; + deviceWatcher->EnumerationCompleted -= handlerEnumCompletedToken; + + if (DeviceWatcherStatus::Started == deviceWatcher->Status || + DeviceWatcherStatus::EnumerationCompleted == deviceWatcher->Status) + { + deviceWatcher->Stop(); + } + } + + startWatcherButton->IsEnabled = true; +} + +void Scenario9::PairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + // Gray out the pair button and results view while pairing is in progress. + resultsListView->IsEnabled = false; + pairButton->IsEnabled = false; + rootPage->NotifyUser("Pairing started. Please wait...", NotifyType::StatusMessage); + + DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; + + // Get ceremony type and protection level selections + DevicePairingKinds ceremoniesSelected = GetSelectedCeremonies(); + ProtectionLevelSelectorInfo^ protectionLevelInfo = (ProtectionLevelSelectorInfo^)protectionLevelComboBox->SelectedItem; + DevicePairingProtectionLevel protectionLevel = protectionLevelInfo->ProtectionLevel; + + DeviceInformationCustomPairing^ customPairing = deviceInfoDisp->DeviceInfo->Pairing->Custom; + + // Hook up handlers for the pairing events before starting the pairing + auto handlePairingRequested = ref new TypedEventHandler(this, &Scenario9::PairingRequestedHandler); + handlerPairingRequestedToken = customPairing->PairingRequested += handlePairingRequested; + + create_task(customPairing->PairAsync(ceremoniesSelected, protectionLevel)).then( + [this, customPairing](DevicePairingResult^ pairingResult) + { + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, pairingResult]() + { + rootPage->NotifyUser( + "Pairing result = " + (pairingResult->Status == DevicePairingResultStatus::Paired ? "Paired" : "NotPaired"), + pairingResult->Status == DevicePairingResultStatus::Paired ? NotifyType::StatusMessage : NotifyType::ErrorMessage); + })); + + customPairing->PairingRequested -= handlerPairingRequestedToken; + + HidePairingPanel(); + UpdatePairingButtons(); + resultsListView->IsEnabled = true; + }, task_continuation_context::use_current()); +} + +void Scenario9::UnpairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + // Gray out the unpair button and results view while unpairing is in progress. + resultsListView->IsEnabled = false; + unpairButton->IsEnabled = false; + rootPage->NotifyUser("Unpairing started. Please wait...", NotifyType::StatusMessage); + + DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; + + create_task(deviceInfoDisp->DeviceInfo->Pairing->UnpairAsync()).then( + [this](DeviceUnpairingResult^ unpairingResult) + { + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler( + [this, unpairingResult]() + { + rootPage->NotifyUser( + "Unpairing result = " + (unpairingResult->Status == DeviceUnpairingResultStatus::Unpaired ? "Unpaired" : "Failed"), + unpairingResult->Status == DeviceUnpairingResultStatus::Unpaired ? NotifyType::StatusMessage : NotifyType::ErrorMessage); + })); + + UpdatePairingButtons(); + resultsListView->IsEnabled = true; + }, task_continuation_context::use_current()); +} + +void Scenario9::PairingRequestedHandler(DeviceInformationCustomPairing^ sender, DevicePairingRequestedEventArgs^ args) +{ + switch (args->PairingKind) + { + case DevicePairingKinds::ConfirmOnly: + // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile + // If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation. + args->Accept(); + break; + + case DevicePairingKinds::DisplayPin: + // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN + // on the target device. We automatically accept here since we can't really "cancel" the operation + // from this side. + args->Accept(); + + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler( + [this, args]() + { + ShowPairingPanel( + "Please enter this PIN on the device you are pairing with: " + args->Pin, + args->PairingKind); + })); + break; + + case DevicePairingKinds::ProvidePin: + { + // A PIN may be shown on the target device and the user needs to enter the matching PIN on + // this Windows device. Get a deferral so we can perform the async request to the user. + auto collectPinDeferral = args->GetDeferral(); + + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler( + [this, collectPinDeferral, args]() + { + GetPinFromUserAsync().then([this, collectPinDeferral, args](String^ pin) + { + if (pin != nullptr) + { + args->Accept(pin); + } + + collectPinDeferral->Complete(); + }, task_continuation_context::use_current()); + })); + } + break; + + case DevicePairingKinds::ConfirmPinMatch: + { + // We show the PIN here and the user responds with whether the PIN matches what they see + // on the target device. Response comes back and we set it on the PinComparePairingRequestedData + // then complete the deferral. + auto displayMessageDeferral = args->GetDeferral(); + + rootPage->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler( + [this, displayMessageDeferral, args]() + { + GetUserConfirmationAsync(args->Pin).then([this, displayMessageDeferral, args](bool accept) + { + if (accept) + { + args->Accept(); + } + + displayMessageDeferral->Complete(); + }, task_continuation_context::use_current()); + })); + } + break; + } +} + + +void Scenario9::ShowPairingPanel(Platform::String^ text, Windows::Devices::Enumeration::DevicePairingKinds pairingKind) +{ + pairingPanel->Visibility = ::Visibility::Collapsed; + pinEntryTextBox->Visibility = ::Visibility::Collapsed; + okButton->Visibility = ::Visibility::Collapsed; + yesButton->Visibility = ::Visibility::Collapsed; + noButton->Visibility = ::Visibility::Collapsed; + pairingTextBlock->Text = text; + + switch (pairingKind) + { + case DevicePairingKinds::ConfirmOnly: + case DevicePairingKinds::DisplayPin: + // Don't need any buttons + break; + case DevicePairingKinds::ProvidePin: + pinEntryTextBox->Text = ""; + pinEntryTextBox->Visibility = ::Visibility::Visible; + okButton->Visibility = ::Visibility::Visible; + break; + case DevicePairingKinds::ConfirmPinMatch: + yesButton->Visibility = ::Visibility::Visible; + noButton->Visibility = ::Visibility::Visible; + break; + } + + pairingPanel->Visibility = ::Visibility::Visible; +} + +void Scenario9::HidePairingPanel() +{ + pairingPanel->Visibility = ::Visibility::Collapsed; + pairingTextBlock->Text = ""; +} + +concurrency::task Scenario9::GetPinFromUserAsync() +{ + HidePairingPanel(); + CompleteProvidePinTask(); + providePinTaskSrc.reset(new task_completion_event()); + + ShowPairingPanel( + "Please enter the PIN shown on the device you're pairing with", + DevicePairingKinds::ProvidePin); + + return concurrency::task(*providePinTaskSrc); +} + +void Scenario9::CompleteProvidePinTask(Platform::String^ pin) +{ + if (providePinTaskSrc) + { + providePinTaskSrc->set(pin); + providePinTaskSrc.reset(); + } +} + +concurrency::task Scenario9::GetUserConfirmationAsync(Platform::String^ pin) +{ + HidePairingPanel(); + CompleteConfirmPinTask(false); + confirmPinTaskSrc.reset(new task_completion_event()); + + ShowPairingPanel( + "Does the following PIN match the one shown on the device you are pairing?: " + pin, + DevicePairingKinds::ConfirmPinMatch); + + return concurrency::task(*confirmPinTaskSrc); +} + +void Scenario9::CompleteConfirmPinTask(bool accept) +{ + if (confirmPinTaskSrc) + { + confirmPinTaskSrc->set(accept); + confirmPinTaskSrc.reset(); + } +} + +void Scenario9::okButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + // OK button is only used for the ProvidePin scenario + CompleteProvidePinTask(pinEntryTextBox->Text); + HidePairingPanel(); +} + +void Scenario9::yesButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + CompleteConfirmPinTask(true); + HidePairingPanel(); +} + +void Scenario9::noButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) +{ + CompleteConfirmPinTask(false); + HidePairingPanel(); +} + +DevicePairingKinds Scenario9::GetSelectedCeremonies() +{ + DevicePairingKinds ceremonySelection = DevicePairingKinds::None; + + if (confirmOnlyOption->IsChecked->Value) + { + ceremonySelection = ceremonySelection | DevicePairingKinds::ConfirmOnly; + } + if (displayPinOption->IsChecked->Value) + { + ceremonySelection = ceremonySelection | DevicePairingKinds::DisplayPin; + } + if (providePinOption->IsChecked->Value) + { + ceremonySelection = ceremonySelection | DevicePairingKinds::ProvidePin; + } + if (confirmPinMatchOption->IsChecked->Value) + { + ceremonySelection = ceremonySelection | DevicePairingKinds::ConfirmOnly; + } + + return ceremonySelection; +} + +void Scenario9::ResultsListView_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e) +{ + UpdatePairingButtons(); +} + +void Scenario9::UpdatePairingButtons() +{ + DeviceInformationDisplay^ deviceInfoDisp = (DeviceInformationDisplay^)resultsListView->SelectedItem; + + if (nullptr != deviceInfoDisp && + deviceInfoDisp->DeviceInfo->Pairing->CanPair && + !deviceInfoDisp->DeviceInfo->Pairing->IsPaired) + { + pairButton->IsEnabled = true; + } + else + { + pairButton->IsEnabled = false; + } + + if (nullptr != deviceInfoDisp && + deviceInfoDisp->DeviceInfo->Pairing->IsPaired) + { + unpairButton->IsEnabled = true; + } + else + { + unpairButton->IsEnabled = false; + } +} + diff --git a/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.h b/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.h new file mode 100644 index 0000000000..f95cb56cf0 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cpp/Scenario9_CustomPairDevice.xaml.h @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft. All rights reserved. + +#pragma once + +#include "Scenario9_CustomPairDevice.g.h" +#include "MainPage.xaml.h" +#include "DisplayHelpers.h" + +namespace SDKTemplate +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + [Windows::Foundation::Metadata::WebHostHidden] + [Windows::UI::Xaml::Data::Bindable] + public ref class Scenario9 sealed + { + public: + Scenario9(); + + property Windows::Foundation::Collections::IObservableVector^ ResultCollection; + + protected: + virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; + virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override; + + private: + void StartWatcherButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void StopWatcherButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void PairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void UnpairButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + + void StartWatcher(); + void StopWatcher(); + + void ResultsListView_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e); + + void PairingRequestedHandler(Windows::Devices::Enumeration::DeviceInformationCustomPairing^ sender, Windows::Devices::Enumeration::DevicePairingRequestedEventArgs^ args); + + void ShowPairingPanel(Platform::String^ text, Windows::Devices::Enumeration::DevicePairingKinds pairingKind); + void HidePairingPanel(); + concurrency::task GetPinFromUserAsync(); + void CompleteProvidePinTask(Platform::String^ pin = nullptr); + concurrency::task GetUserConfirmationAsync(Platform::String^ pin); + void CompleteConfirmPinTask(bool accept); + void okButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void yesButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void noButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + + void UpdatePairingButtons(); + Windows::Devices::Enumeration::DevicePairingKinds GetSelectedCeremonies(); + + SDKTemplate::MainPage^ rootPage; + Windows::Devices::Enumeration::DeviceWatcher^ deviceWatcher; + Windows::Foundation::EventRegistrationToken handlerAddedToken; + Windows::Foundation::EventRegistrationToken handlerUpdatedToken; + Windows::Foundation::EventRegistrationToken handlerRemovedToken; + Windows::Foundation::EventRegistrationToken handlerEnumCompletedToken; + Windows::Foundation::EventRegistrationToken handlerStoppedAddedToken; + Windows::Foundation::EventRegistrationToken handlerPairingRequestedToken; + + std::unique_ptr> providePinTaskSrc; + std::unique_ptr> confirmPinTaskSrc; + }; +} diff --git a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.cpp similarity index 97% rename from Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.cpp index fbc927aa35..0a5eac19ed 100644 --- a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.cpp @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. #include "pch.h" -#include "BackgroundDeviceWatcherTaskCpp.h" +#include "BackgroundDeviceWatcherTask.h" using namespace Platform; using namespace Windows::Storage; diff --git a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.h b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.h rename to Samples/DeviceEnumerationAndPairing/cpp/Tasks/BackgroundDeviceWatcherTask.h diff --git a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.vcxproj b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/Tasks.vcxproj similarity index 97% rename from Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.vcxproj rename to Samples/DeviceEnumerationAndPairing/cpp/Tasks/Tasks.vcxproj index 8b92e66b9d..f40426ca58 100644 --- a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/BackgroundDeviceWatcherTaskCpp.vcxproj +++ b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/Tasks.vcxproj @@ -29,15 +29,15 @@ {6e323ca9-b536-4bad-8b98-36b9d2e0f0af} WindowsRuntimeComponent - BackgroundDeviceWatcherTaskCpp + Tasks BackgroundDeviceWatcherTaskCpp en-US 14.0 true Windows Store 10.0 - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 true @@ -217,11 +217,11 @@ - + - + Create Create diff --git a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/pch.cpp b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/pch.cpp similarity index 100% rename from Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/pch.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/Tasks/pch.cpp diff --git a/Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/pch.h b/Samples/DeviceEnumerationAndPairing/cpp/Tasks/pch.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/BackgroundDeviceWatcherTaskCpp/pch.h rename to Samples/DeviceEnumerationAndPairing/cpp/Tasks/pch.h diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/pch.cpp b/Samples/DeviceEnumerationAndPairing/cpp/pch.cpp similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/pch.cpp rename to Samples/DeviceEnumerationAndPairing/cpp/pch.cpp diff --git a/Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/pch.h b/Samples/DeviceEnumerationAndPairing/cpp/pch.h similarity index 100% rename from Samples/DeviceEnumeration/cpp/DeviceEnumerationCpp/pch.h rename to Samples/DeviceEnumerationAndPairing/cpp/pch.h diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DeviceEnumerationCs.csproj b/Samples/DeviceEnumerationAndPairing/cs/DeviceEnumeration.csproj similarity index 84% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DeviceEnumerationCs.csproj rename to Samples/DeviceEnumerationAndPairing/cs/DeviceEnumeration.csproj index 3771c7d901..8c8875d79c 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/DeviceEnumerationCs.csproj +++ b/Samples/DeviceEnumerationAndPairing/cs/DeviceEnumeration.csproj @@ -8,11 +8,11 @@ AppContainerExe Properties DeviceEnumerationCs - DeviceEnumerationCs + DeviceEnumeration en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 @@ -91,16 +91,18 @@ - + App.xaml.cs App.xaml - + MainPage.xaml.cs MainPage.xaml - + + Properties\AssemblyInfo.cs + Scenario1_DevicePicker.xaml @@ -123,6 +125,9 @@ Scenario7_DeviceInformationKind.xaml + + Scenario9_CustomPairDevice.xaml + Scenario8_PairDevice.xaml @@ -133,12 +138,12 @@ - + App.xaml MSBuild:Compile Designer - + MainPage.xaml MSBuild:Compile Designer @@ -171,46 +176,50 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer - + Styles\Styles.xaml MSBuild:Compile Designer - + Properties\Default.rd.xml - + 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 - + {268fca4c-effb-46da-a341-d4e3dd5496c4} - BackgroundDeviceWatcherTaskCs + Tasks @@ -224,4 +233,4 @@ --> - + \ No newline at end of file diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs.sln b/Samples/DeviceEnumerationAndPairing/cs/DeviceEnumeration.sln similarity index 90% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs.sln rename to Samples/DeviceEnumerationAndPairing/cs/DeviceEnumeration.sln index a718fd6503..ba65165c17 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs.sln +++ b/Samples/DeviceEnumerationAndPairing/cs/DeviceEnumeration.sln @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.22609.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceEnumerationCs", "DeviceEnumerationCs\DeviceEnumerationCs.csproj", "{DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceEnumeration", "DeviceEnumeration.csproj", "{DC30CE66-DAEE-4CCF-BD02-8837FE918B6F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundDeviceWatcherTaskCs", "BackgroundDeviceWatcherTaskCs\BackgroundDeviceWatcherTaskCs.csproj", "{268FCA4C-EFFB-46DA-A341-D4E3DD5496C4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tasks", "Tasks\Tasks.csproj", "{268FCA4C-EFFB-46DA-A341-D4E3DD5496C4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs b/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs new file mode 100644 index 0000000000..433b7da94a --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs @@ -0,0 +1,495 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using Windows.Devices.Enumeration; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Media.Imaging; + +// NOTE: The following using statements are only needed in order to demonstrate many of the +// different device selectors available from Windows Runtime APIs. You will only need to include +// the namespace for the Windows Runtime API your actual scenario needs. +using Windows.Devices.HumanInterfaceDevice; +using Windows.Networking.Proximity; +using Windows.Devices.Bluetooth; +using Windows.Devices.WiFiDirect; +using Windows.Media.Casting; +using Windows.Media.DialProtocol; +using Windows.Devices.Sensors; +using Windows.Devices.PointOfService; + +namespace DeviceEnumeration +{ + public class DeviceSelectorInfo + { + public DeviceSelectorInfo() + { + Kind = DeviceInformationKind.Unknown; + DeviceClassSelector = DeviceClass.All; + } + + public string DisplayName + { + get; + set; + } + + public DeviceClass DeviceClassSelector + { + get; + set; + } + + public DeviceInformationKind Kind + { + get; + set; + } + + public string Selector + { + get; + set; + } + } + + public static class DeviceSelectorChoices + { + + public static List CommonDeviceSelectors + { + get + { + List selectors = new List(); + + // Pre-canned device class selectors + selectors.Add(new DeviceSelectorInfo() { DisplayName = "All Device Interfaces (default)", DeviceClassSelector = DeviceClass.All, Selector = null }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Audio Capture", DeviceClassSelector = DeviceClass.AudioCapture, Selector = null }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Audio Render", DeviceClassSelector = DeviceClass.AudioRender, Selector = null }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Image Scanner", DeviceClassSelector = DeviceClass.ImageScanner, Selector = null }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Location", DeviceClassSelector = DeviceClass.Location, Selector = null }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Portable Storage", DeviceClassSelector = DeviceClass.PortableStorageDevice, Selector = null }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Video Capture", DeviceClassSelector = DeviceClass.VideoCapture, Selector = null }); + + // A few examples of selectors built dynamically by windows runtime apis. + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Human Interface (HID)", Selector = HidDevice.GetDeviceSelector(0, 0) }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Activity Sensor", Selector = ActivitySensor.GetDeviceSelector() }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Pedometer", Selector = Pedometer.GetDeviceSelector() }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Proximity", Selector = ProximityDevice.GetDeviceSelector() }); + selectors.Add(new DeviceSelectorInfo() { DisplayName = "Proximity Sensor", Selector = ProximitySensor.GetDeviceSelector() }); + + return selectors; + } + } + + public static DeviceSelectorInfo Bluetooth + { + get + { + // Currently Bluetooth APIs don't provide a selector to get ALL devices that are both paired and non-paired. Typically you wouldn't need this for common scenarios, but it's convenient to demonstrate the + // various sample scenarios. + return new DeviceSelectorInfo() { DisplayName = "Bluetooth", Selector = "System.Devices.Aep.ProtocolId:=\"{e0cbf06c-cd8b-4647-bb8a-263b43f0f974}\"", Kind = DeviceInformationKind.AssociationEndpoint }; + } + } + + public static DeviceSelectorInfo BluetoothUnpairedOnly + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Bluetooth (unpaired)", Selector = BluetoothDevice.GetDeviceSelectorFromPairingState(false) }; + } + } + + public static DeviceSelectorInfo BluetoothPairedOnly + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Bluetooth (paired)", Selector = BluetoothDevice.GetDeviceSelectorFromPairingState(true) }; + } + } + + public static DeviceSelectorInfo BluetoothLE + { + get + { + // Currently Bluetooth APIs don't provide a selector to get ALL devices that are both paired and non-paired. Typically you wouldn't need this for common scenarios, but it's convenient to demonstrate the + // various sample scenarios. + return new DeviceSelectorInfo() { DisplayName = "Bluetooth LE", Selector = "System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\"", Kind = DeviceInformationKind.AssociationEndpoint }; + } + } + + public static DeviceSelectorInfo BluetoothLEUnpairedOnly + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Bluetooth LE (unpaired)", Selector = BluetoothLEDevice.GetDeviceSelectorFromPairingState(false) }; + } + } + + public static DeviceSelectorInfo BluetoothLEPairedOnly + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Bluetooth LE (paired)", Selector = BluetoothLEDevice.GetDeviceSelectorFromPairingState(true) }; + } + } + + public static DeviceSelectorInfo WiFiDirect + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Wi-Fi Direct", Selector = WiFiDirectDevice.GetDeviceSelector(WiFiDirectDeviceSelectorType.AssociationEndpoint) }; + } + } + + public static DeviceSelectorInfo WiFiDirectPairedOnly + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Wi-Fi Direct (paired)", Selector = WiFiDirectDevice.GetDeviceSelector() }; + } + } + + public static DeviceSelectorInfo PointOfServicePrinter + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Point of Service Printer", Selector = PosPrinter.GetDeviceSelector() }; + } + } + + public static DeviceSelectorInfo VideoCasting + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Video Casting", Selector = CastingDevice.GetDeviceSelector(CastingPlaybackTypes.Video) }; + } + } + + public static DeviceSelectorInfo DialAllApps + { + get + { + return new DeviceSelectorInfo() { DisplayName = "DIAL (All apps)", Selector = DialDevice.GetDeviceSelector("") }; + } + } + + // WSD and UPnP are unique in that there are currently no general WSD or UPnP APIs to USE the devices once you've discovered them. + // You can pair the devices using DeviceInformation.Pairing.PairAsync etc, and you can USE them with the sockets APIs. However, since + // there's no specific API right now, there's no *.GetDeviceSelector available. That's why we just simply build the device selector + // ourselves and specify the correct DeviceInformationKind (AssociationEndpoint). + public static DeviceSelectorInfo Wsd + { + get + { + return new DeviceSelectorInfo() { DisplayName = "Web Services on Devices (WSD)", Selector = "System.Devices.Aep.ProtocolId:=\"{782232aa-a2f9-4993-971b-aedc551346b0}\"", Kind = DeviceInformationKind.AssociationEndpoint }; + } + } + + public static DeviceSelectorInfo Upnp + { + get + { + return new DeviceSelectorInfo() { DisplayName = "UPnP", Selector = "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"", Kind = DeviceInformationKind.AssociationEndpoint }; + } + } + + public static List DevicePickerSelectors + { + get + { + // Add all selectors that can be used with the DevicePicker + List selectors = new List(CommonDeviceSelectors); + selectors.Add(BluetoothPairedOnly); + selectors.Add(BluetoothUnpairedOnly); + selectors.Add(BluetoothLEPairedOnly); + selectors.Add(BluetoothLEUnpairedOnly); + selectors.Add(WiFiDirect); + selectors.Add(PointOfServicePrinter); + selectors.Add(VideoCasting); + selectors.Add(DialAllApps); + + return selectors; + } + } + + public static List FindAllAsyncSelectors + { + get + { + // Add all selectors that are reasonable to use with FindAllAsync + List selectors = new List(CommonDeviceSelectors); + selectors.Add(BluetoothPairedOnly); + selectors.Add(BluetoothLEPairedOnly); + selectors.Add(WiFiDirectPairedOnly); + + return selectors; + } + } + + public static List DeviceWatcherSelectors + { + get + { + // Add all selectors that can be used with the DeviceWatcher + List selectors = new List(CommonDeviceSelectors); + selectors.Add(Bluetooth); + selectors.Add(BluetoothLE); + selectors.Add(WiFiDirect); + selectors.Add(PointOfServicePrinter); + selectors.Add(VideoCasting); + selectors.Add(DialAllApps); + selectors.Add(Wsd); + selectors.Add(Upnp); + + return selectors; + } + } + + public static List BackgroundDeviceWatcherSelectors + { + get + { + // Add all selectors that can be used with the BackgroundDeviceWatcher + List selectors = new List(CommonDeviceSelectors); + selectors.Add(BluetoothPairedOnly); + selectors.Add(BluetoothLEPairedOnly); + selectors.Add(WiFiDirectPairedOnly); + selectors.Add(PointOfServicePrinter); + selectors.Add(VideoCasting); + selectors.Add(DialAllApps); + selectors.Add(Wsd); + selectors.Add(Upnp); + + return selectors; + } + } + + /// + /// Selectors for use in the pairing scenarios + /// + public static List PairingSelectors + { + get + { + // Add selectors that can be used in pairing scenarios + List selectors = new List(); + selectors.Add(Bluetooth); + selectors.Add(BluetoothLE); + selectors.Add(WiFiDirect); + selectors.Add(PointOfServicePrinter); + selectors.Add(VideoCasting); + selectors.Add(Wsd); + selectors.Add(Upnp); + + return selectors; + } + } + } + + public struct DeviceInformationKindChoice + { + public string DisplayName + { + get; + set; + } + + public DeviceInformationKind[] DeviceInformationKinds + { + get; + set; + } + } + + public static class DeviceInformationKindChoices + { + public static List Choices + { + get + { + List choices = new List(); + + choices.Add(new DeviceInformationKindChoice() { DisplayName = "DeviceContainer", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.DeviceContainer } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "Device", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.Device } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "DeviceInterface (Default)", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.DeviceInterface } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "DeviceInterfaceClass", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.DeviceInterfaceClass } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpointContainer", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpointContainer } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpoint", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpoint } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpointService", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpointService } }); + choices.Add(new DeviceInformationKindChoice() { DisplayName = "AssociationEndpointService and DeviceInterface", DeviceInformationKinds = new DeviceInformationKind[] { DeviceInformationKind.AssociationEndpointService, DeviceInformationKind.DeviceInterface} }); + + return choices; + } + } + } + + public struct ProtectionLevelSelectorInfo + { + public string DisplayName + { + get; + set; + } + + public Windows.Devices.Enumeration.DevicePairingProtectionLevel ProtectionLevel + { + get; + set; + } + } + + public static class ProtectionSelectorChoices + { + public static List Selectors + { + get + { + List selectors = new List(); + selectors.Add(new ProtectionLevelSelectorInfo() { DisplayName = "Default", ProtectionLevel= Windows.Devices.Enumeration.DevicePairingProtectionLevel.Default}); + selectors.Add(new ProtectionLevelSelectorInfo() { DisplayName = "None", ProtectionLevel = Windows.Devices.Enumeration.DevicePairingProtectionLevel.None}); + selectors.Add(new ProtectionLevelSelectorInfo() { DisplayName = "Encryption", ProtectionLevel = Windows.Devices.Enumeration.DevicePairingProtectionLevel.Encryption}); + selectors.Add(new ProtectionLevelSelectorInfo() { DisplayName = "Encryption and authentication", ProtectionLevel = Windows.Devices.Enumeration.DevicePairingProtectionLevel.EncryptionAndAuthentication}); + + return selectors; + } + } + } + + public class DeviceInformationDisplay : INotifyPropertyChanged + { + private DeviceInformation deviceInfo; + + public DeviceInformationDisplay(DeviceInformation deviceInfoIn) + { + deviceInfo = deviceInfoIn; + UpdateGlyphBitmapImage(); + } + + public DeviceInformationKind Kind + { + get + { + return deviceInfo.Kind; + } + } + + public string Id + { + get + { + return deviceInfo.Id; + } + } + + public string Name + { + get + { + return deviceInfo.Name; + } + } + + public BitmapImage GlyphBitmapImage + { + get; + private set; + } + + public bool CanPair + { + get + { + return deviceInfo.Pairing.CanPair; + } + } + + public bool IsPaired + { + get + { + return deviceInfo.Pairing.IsPaired; + } + } + + public IReadOnlyDictionary Properties + { + get + { + return deviceInfo.Properties; + } + } + + public DeviceInformation DeviceInformation + { + get + { + return deviceInfo; + } + + private set + { + deviceInfo = value; + } + } + + public void Update(DeviceInformationUpdate deviceInfoUpdate) + { + deviceInfo.Update(deviceInfoUpdate); + + OnPropertyChanged("Kind"); + OnPropertyChanged("Id"); + OnPropertyChanged("Name"); + OnPropertyChanged("DeviceInformation"); + OnPropertyChanged("CanPair"); + OnPropertyChanged("IsPaired"); + + UpdateGlyphBitmapImage(); + } + + private async void UpdateGlyphBitmapImage() + { + DeviceThumbnail deviceThumbnail = await deviceInfo.GetGlyphThumbnailAsync(); + BitmapImage glyphBitmapImage = new BitmapImage(); + await glyphBitmapImage.SetSourceAsync(deviceThumbnail); + GlyphBitmapImage = glyphBitmapImage; + OnPropertyChanged("GlyphBitmapImage"); + } + + public event PropertyChangedEventHandler PropertyChanged; + protected void OnPropertyChanged(string name) + { + PropertyChangedEventHandler handler = PropertyChanged; + if (handler != null) + { + handler(this, new PropertyChangedEventArgs(name)); + } + } + } + + public class GeneralPropertyValueConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, string language) + { + object property = null; + + if (value is IReadOnlyDictionary && + parameter is string && + !String.IsNullOrEmpty((string)parameter)) + { + IReadOnlyDictionary properties = value as IReadOnlyDictionary; + string propertyName = parameter as string; + + property = properties[propertyName]; + } + + return property; + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + throw new NotImplementedException(); + } + } +} diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Package.appxmanifest b/Samples/DeviceEnumerationAndPairing/cs/Package.appxmanifest similarity index 75% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Package.appxmanifest rename to Samples/DeviceEnumerationAndPairing/cs/Package.appxmanifest index b9470effee..ba67744387 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Package.appxmanifest +++ b/Samples/DeviceEnumerationAndPairing/cs/Package.appxmanifest @@ -1,46 +1,40 @@  - - - - - - + - DeviceEnumeration C# sample + Device Enumeration and Pairing C# sample Microsoft Corporation Assets\StoreLogo-sdk.png - - + - - - - - @@ -48,10 +42,8 @@ - - diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/SampleConfiguration.cs b/Samples/DeviceEnumerationAndPairing/cs/SampleConfiguration.cs similarity index 73% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/SampleConfiguration.cs rename to Samples/DeviceEnumerationAndPairing/cs/SampleConfiguration.cs index f18a0e206b..95053f18ce 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/SampleConfiguration.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/SampleConfiguration.cs @@ -18,7 +18,7 @@ namespace SDKTemplate { public partial class MainPage : Page { - public const string FEATURE_NAME = "Device Enumeration C# Sample"; + public const string FEATURE_NAME = "Device Enumeration and Pairing C# Sample"; List scenarios = new List { @@ -27,9 +27,10 @@ public partial class MainPage : Page new Scenario() { Title="Enumerate and Watch Devices in a Background Task", ClassType=typeof(Scenario3)}, new Scenario() { Title="Enumerate Snapshot of Devices", ClassType=typeof(Scenario4)}, new Scenario() { Title="Get Single Device", ClassType=typeof(Scenario5)}, - new Scenario() { Title= "Adv: Custom Filter with Additional Properties", ClassType=typeof(Scenario6)}, - new Scenario() { Title= "Adv: Request Specific DeviceInformationKind", ClassType=typeof(Scenario7)}, - new Scenario() { Title= "Adv: Pair Device", ClassType=typeof(Scenario8)} + new Scenario() { Title= "Custom Filter with Additional Properties", ClassType=typeof(Scenario6)}, + new Scenario() { Title= "Request Specific DeviceInformationKind", ClassType=typeof(Scenario7)}, + new Scenario() { Title= "Basic Device Pairing", ClassType=typeof(Scenario8)}, + new Scenario() { Title= "Custom Device Pairing", ClassType=typeof(Scenario9)} }; } diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario1_DevicePicker.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario1_DevicePicker.xaml similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario1_DevicePicker.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario1_DevicePicker.xaml diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario1_DevicePicker.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario1_DevicePicker.xaml.cs similarity index 96% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario1_DevicePicker.xaml.cs rename to Samples/DeviceEnumerationAndPairing/cs/Scenario1_DevicePicker.xaml.cs index 80d0c94205..44d46b599e 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario1_DevicePicker.xaml.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario1_DevicePicker.xaml.cs @@ -40,7 +40,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) rootPage = MainPage.Current; ResultCollection = new ObservableCollection(); - selectorComboBox.ItemsSource = DeviceSelectorChoices.Selectors; + selectorComboBox.ItemsSource = DeviceSelectorChoices.DevicePickerSelectors; selectorComboBox.SelectedIndex = 0; DataContext = this; @@ -66,15 +66,13 @@ private void ShowDevicePickerButton_Click(object sender, RoutedEventArgs e) private async void ShowDevicePicker(bool pickSingle) { - DeviceSelectorInfo deviceSelectorInfo; - showDevicePickerButton.IsEnabled = false; ResultCollection.Clear(); devicePicker = new DevicePicker(); // First get the device selector chosen by the UI. - deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; + DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; if (null == deviceSelectorInfo.Selector) { diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario2_DeviceWatcher.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario2_DeviceWatcher.xaml similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario2_DeviceWatcher.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario2_DeviceWatcher.xaml diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario2_DeviceWatcher.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario2_DeviceWatcher.xaml.cs similarity index 93% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario2_DeviceWatcher.xaml.cs rename to Samples/DeviceEnumerationAndPairing/cs/Scenario2_DeviceWatcher.xaml.cs index 65ca9bdf2a..ef8f9ecd8f 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario2_DeviceWatcher.xaml.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario2_DeviceWatcher.xaml.cs @@ -44,7 +44,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) rootPage = MainPage.Current; ResultCollection = new ObservableCollection(); - selectorComboBox.ItemsSource = DeviceSelectorChoices.Selectors; + selectorComboBox.ItemsSource = DeviceSelectorChoices.DeviceWatcherSelectors; selectorComboBox.SelectedIndex = 0; DataContext = this; @@ -67,27 +67,34 @@ private void StopWatcherButton_Click(object sender, RoutedEventArgs e) private void StartWatcher() { - DeviceSelectorInfo deviceSelectorInfo; - startWatcherButton.IsEnabled = false; ResultCollection.Clear(); // First get the device selector chosen by the UI. - deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; + DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; if (null == deviceSelectorInfo.Selector) { // If the a pre-canned device class selector was chosen, call the DeviceClass overload deviceWatcher = DeviceInformation.CreateWatcher(deviceSelectorInfo.DeviceClassSelector); } - else + else if (deviceSelectorInfo.Kind == DeviceInformationKind.Unknown) { // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call + // Kind will be determined by the selector deviceWatcher = DeviceInformation.CreateWatcher( deviceSelectorInfo.Selector, null // don't request additional properties for this sample ); } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation.CreateWatcher( + deviceSelectorInfo.Selector, + null, // don't request additional properties for this sample + deviceSelectorInfo.Kind); + } // Hook up handlers for the watcher events before starting the watcher diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario3_BackgroundDeviceWatcher.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario3_BackgroundDeviceWatcher.xaml similarity index 95% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario3_BackgroundDeviceWatcher.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario3_BackgroundDeviceWatcher.xaml index 47107a0138..145fb3e0a1 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario3_BackgroundDeviceWatcher.xaml +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario3_BackgroundDeviceWatcher.xaml @@ -27,7 +27,7 @@ + Text="This scenario demonstrates the use of the Windows.Devices.Enumeration DeviceWatcherTrigger. DeviceWatcherTrigger is similar to DeviceWatcher, but is performed in a background task. Note that Bluetooth and Wi-Fi Direct selectors that perform 'live' protocol queries aren't support for perforfance reasons." /> (); - selectorComboBox.ItemsSource = DeviceSelectorChoices.Selectors; + selectorComboBox.ItemsSource = DeviceSelectorChoices.FindAllAsyncSelectors; selectorComboBox.SelectedIndex = 0; DataContext = this; diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario5_GetSingleDevice.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario5_GetSingleDevice.xaml similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario5_GetSingleDevice.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario5_GetSingleDevice.xaml diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario5_GetSingleDevice.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario5_GetSingleDevice.xaml.cs similarity index 95% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario5_GetSingleDevice.xaml.cs rename to Samples/DeviceEnumerationAndPairing/cs/Scenario5_GetSingleDevice.xaml.cs index 43ea266bc9..cb0952da4d 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario5_GetSingleDevice.xaml.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario5_GetSingleDevice.xaml.cs @@ -57,7 +57,6 @@ private async void InterfaceIdTextBox_Loaded(object sender, RoutedEventArgs e) private async void GetButton_Click(object sender, RoutedEventArgs e) { - DeviceInformation deviceInfo; string interfaceId = interfaceIdTextBox.Text; interfaceIdTextBox.IsEnabled = false; @@ -70,7 +69,7 @@ private async void GetButton_Click(object sender, RoutedEventArgs e) { // When you want to "save" a DeviceInformation to get it back again later, // use both the DeviceInformation.Kind and the DeviceInformation.Id. - deviceInfo = await DeviceInformation.CreateFromIdAsync(interfaceId, null, deviceInformationKind); + DeviceInformation deviceInfo = await DeviceInformation.CreateFromIdAsync(interfaceId, null, deviceInformationKind); rootPage.NotifyUser("CreateFromIdAsync operation completed.", NotifyType.StatusMessage); diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario6_CustomFilterAddedProps.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario6_CustomFilterAddedProps.xaml similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario6_CustomFilterAddedProps.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario6_CustomFilterAddedProps.xaml diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario6_CustomFilterAddedProps.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario6_CustomFilterAddedProps.xaml.cs similarity index 99% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario6_CustomFilterAddedProps.xaml.cs rename to Samples/DeviceEnumerationAndPairing/cs/Scenario6_CustomFilterAddedProps.xaml.cs index ed81c3b064..43de89876e 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario6_CustomFilterAddedProps.xaml.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario6_CustomFilterAddedProps.xaml.cs @@ -78,8 +78,7 @@ private void StartWatcher() // Use AQS string filter from the text box deviceWatcher = DeviceInformation.CreateWatcher( aqsFilterTextBox.Text, - requestedProperties - ); + requestedProperties); // Hook up handlers for the watcher events before starting the watcher diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario7_DeviceInformationKind.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario7_DeviceInformationKind.xaml similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario7_DeviceInformationKind.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario7_DeviceInformationKind.xaml diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario7_DeviceInformationKind.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario7_DeviceInformationKind.xaml.cs similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario7_DeviceInformationKind.xaml.cs rename to Samples/DeviceEnumerationAndPairing/cs/Scenario7_DeviceInformationKind.xaml.cs diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario8_PairDevice.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario8_PairDevice.xaml similarity index 67% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario8_PairDevice.xaml rename to Samples/DeviceEnumerationAndPairing/cs/Scenario8_PairDevice.xaml index e32fd3a928..b71992312f 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario8_PairDevice.xaml +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario8_PairDevice.xaml @@ -52,16 +52,20 @@ - - - + + + - + + This scenario demonstrates how to perform basic pairing. Basic pairing allows you to tell Windows which device you want paired, and then Windows will + handle the ceremony and the UI. If you want to display your own UI and be involved in the pairing ceremony, please see the Custom Pairing scenario. + This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. + Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. + - - + + - - - - - - + + + + SelectionChanged="ResultsListView_SelectionChanged" + MaxHeight="450"> @@ -106,7 +125,7 @@ - + diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario8_PairDevice.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario8_PairDevice.xaml.cs similarity index 70% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario8_PairDevice.xaml.cs rename to Samples/DeviceEnumerationAndPairing/cs/Scenario8_PairDevice.xaml.cs index 0aa2974b9e..6fd62570b0 100644 --- a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/Scenario8_PairDevice.xaml.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario8_PairDevice.xaml.cs @@ -44,7 +44,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) rootPage = MainPage.Current; ResultCollection = new ObservableCollection(); - selectorComboBox.ItemsSource = ProtocolSelectorChoices.Selectors; + selectorComboBox.ItemsSource = DeviceSelectorChoices.PairingSelectors; selectorComboBox.SelectedIndex = 0; DataContext = this; @@ -67,24 +67,31 @@ private void StopWatcherButton_Click(object sender, RoutedEventArgs e) private void StartWatcher() { - ProtocolSelectorInfo protocolSelectorInfo; - string aqsFilter; - startWatcherButton.IsEnabled = false; - ResultCollection.Clear(); - - // Request the IsPaired property so we can display the paired status in the UI - string[] requestedProperties = {"System.Devices.Aep.IsPaired"}; + ResultCollection.Clear(); - // Get the device selector chosen by the UI, then 'AND' it with the 'CanPair' property - protocolSelectorInfo = (ProtocolSelectorInfo)selectorComboBox.SelectedItem; - aqsFilter = protocolSelectorInfo.Selector + " AND System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True"; + // Get the device selector chosen by the UI then add additional constraints for devices that + // can be paired or are already paired. + DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; + //string selector = "(" + deviceSelectorInfo.Selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; + string selector = deviceSelectorInfo.Selector; - deviceWatcher = DeviceInformation.CreateWatcher( - aqsFilter, - requestedProperties, - DeviceInformationKind.AssociationEndpoint - ); + if (deviceSelectorInfo.Kind == DeviceInformationKind.Unknown) + { + // Kind will be determined by the selector + deviceWatcher = DeviceInformation.CreateWatcher( + selector, + null // don't request additional properties for this sample + ); + } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation.CreateWatcher( + selector, + null, // don't request additional properties for this sample + deviceSelectorInfo.Kind); + } // Hook up handlers for the watcher events before starting the watcher @@ -115,6 +122,13 @@ await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => if (deviceInfoDisp.Id == deviceInfoUpdate.Id) { deviceInfoDisp.Update(deviceInfoUpdate); + + // If the item being updated is currently "selected", then update the pairing buttons + DeviceInformationDisplay selectedDeviceInfoDisp = (DeviceInformationDisplay)resultsListView.SelectedItem; + if (deviceInfoDisp == selectedDeviceInfoDisp) + { + UpdatePairingButtons(); + } break; } } @@ -200,23 +214,54 @@ private void StopWatcher() private async void PairButton_Click(object sender, RoutedEventArgs e) { + // Gray out the pair button and results view while pairing is in progress. + resultsListView.IsEnabled = false; + pairButton.IsEnabled = false; + rootPage.NotifyUser("Pairing started. Please wait...", NotifyType.StatusMessage); + DeviceInformationDisplay deviceInfoDisp = resultsListView.SelectedItem as DeviceInformationDisplay; - pairButton.IsEnabled = false; DevicePairingResult dpr = await deviceInfoDisp.DeviceInformation.Pairing.PairAsync(); rootPage.NotifyUser( "Pairing result = " + dpr.Status.ToString(), dpr.Status == DevicePairingResultStatus.Paired ? NotifyType.StatusMessage : NotifyType.ErrorMessage); + + UpdatePairingButtons(); + resultsListView.IsEnabled = true; + } + + private async void UnpairButton_Click(object sender, RoutedEventArgs e) + { + // Gray out the unpair button and results view while unpairing is in progress. + resultsListView.IsEnabled = false; + unpairButton.IsEnabled = false; + rootPage.NotifyUser("Unpairing started. Please wait...", NotifyType.StatusMessage); + + DeviceInformationDisplay deviceInfoDisp = resultsListView.SelectedItem as DeviceInformationDisplay; + + DeviceUnpairingResult dupr = await deviceInfoDisp.DeviceInformation.Pairing.UnpairAsync(); + + rootPage.NotifyUser( + "Unpairing result = " + dupr.Status.ToString(), + dupr.Status == DeviceUnpairingResultStatus.Unpaired ? NotifyType.StatusMessage : NotifyType.ErrorMessage); + + UpdatePairingButtons(); + resultsListView.IsEnabled = true; } private void ResultsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + UpdatePairingButtons(); + } + + private void UpdatePairingButtons() { DeviceInformationDisplay deviceInfoDisp = (DeviceInformationDisplay)resultsListView.SelectedItem; if (null != deviceInfoDisp && - true == deviceInfoDisp.DeviceInformation.Pairing.CanPair && - false == deviceInfoDisp.DeviceInformation.Pairing.IsPaired) + deviceInfoDisp.DeviceInformation.Pairing.CanPair && + !deviceInfoDisp.DeviceInformation.Pairing.IsPaired) { pairButton.IsEnabled = true; } @@ -224,6 +269,16 @@ private void ResultsListView_SelectionChanged(object sender, SelectionChangedEve { pairButton.IsEnabled = false; } + + if (null != deviceInfoDisp && + deviceInfoDisp.DeviceInformation.Pairing.IsPaired) + { + unpairButton.IsEnabled = true; + } + else + { + unpairButton.IsEnabled = false; + } } } } diff --git a/Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml b/Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml new file mode 100644 index 0000000000..c8c96c0c20 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml @@ -0,0 +1,158 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This scenario demonstrates how to perform custom pairing. Custom pairing allows your app to be involved in the pairing ceremony and use your on UI. + If you want Windows to control the ceremony and display system UI, please look at the basic pairing scenario. + This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. + Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml.cs b/Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml.cs new file mode 100644 index 0000000000..c9f3d20c94 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/cs/Scenario9_CustomPairDevice.xaml.cs @@ -0,0 +1,479 @@ +// Copyright (c) Microsoft. All rights reserved. + +using System; +using System.Collections.ObjectModel; +using System.Threading.Tasks; +using Windows.Devices.Enumeration; +using Windows.Foundation; +using Windows.UI.Core; +using Windows.UI.Popups; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; +using SDKTemplate; + +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 + +namespace DeviceEnumeration +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class Scenario9 : Page + { + private MainPage rootPage; + + private DeviceWatcher deviceWatcher = null; + private TypedEventHandler handlerAdded = null; + private TypedEventHandler handlerUpdated = null; + private TypedEventHandler handlerRemoved = null; + private TypedEventHandler handlerEnumCompleted = null; + private TypedEventHandler handlerStopped = null; + + TaskCompletionSource providePinTaskSrc; + TaskCompletionSource confirmPinTaskSrc; + + public ObservableCollection ResultCollection + { + get; + private set; + } + + public Scenario9() + { + this.InitializeComponent(); + } + + protected override void OnNavigatedTo(NavigationEventArgs e) + { + rootPage = MainPage.Current; + ResultCollection = new ObservableCollection(); + + selectorComboBox.ItemsSource = DeviceSelectorChoices.PairingSelectors; + selectorComboBox.SelectedIndex = 0; + + protectionLevelComboBox.ItemsSource = ProtectionSelectorChoices.Selectors; + protectionLevelComboBox.SelectedIndex = 0; + + DataContext = this; + } + + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + StopWatcher(); + } + + private void StartWatcherButton_Click(object sender, RoutedEventArgs e) + { + StartWatcher(); + } + + private void StopWatcherButton_Click(object sender, RoutedEventArgs e) + { + StopWatcher(); + } + + private void StartWatcher() + { + startWatcherButton.IsEnabled = false; + ResultCollection.Clear(); + + // Get the device selector chosen by the UI then add additional constraints for devices that + // can be paired or are already paired. + DeviceSelectorInfo deviceSelectorInfo = (DeviceSelectorInfo)selectorComboBox.SelectedItem; + string selector = "(" + deviceSelectorInfo.Selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; + + if (deviceSelectorInfo.Kind == DeviceInformationKind.Unknown) + { + // Kind will be determined by the selector + deviceWatcher = DeviceInformation.CreateWatcher( + selector, + null // don't request additional properties for this sample + ); + } + else + { + // Kind is specified in the selector info + deviceWatcher = DeviceInformation.CreateWatcher( + selector, + null, // don't request additional properties for this sample + deviceSelectorInfo.Kind); + } + + // Hook up handlers for the watcher events before starting the watcher + + handlerAdded = new TypedEventHandler(async (watcher, deviceInfo) => + { + // Since we have the collection databound to a UI element, we need to update the collection on the UI thread. + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => + { + ResultCollection.Add(new DeviceInformationDisplay(deviceInfo)); + + rootPage.NotifyUser( + String.Format("{0} devices found.", ResultCollection.Count), + NotifyType.StatusMessage); + }); + }); + deviceWatcher.Added += handlerAdded; + + handlerUpdated = new TypedEventHandler(async (watcher, deviceInfoUpdate) => + { + // Since we have the collection databound to a UI element, we need to update the collection on the UI thread. + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => + { + // Find the corresponding updated DeviceInformation in the collection and pass the update object + // to the Update method of the existing DeviceInformation. This automatically updates the object + // for us. + foreach (DeviceInformationDisplay deviceInfoDisp in ResultCollection) + { + if (deviceInfoDisp.Id == deviceInfoUpdate.Id) + { + deviceInfoDisp.Update(deviceInfoUpdate); + + // If the item being updated is currently "selected", then update the pairing buttons + DeviceInformationDisplay selectedDeviceInfoDisp = (DeviceInformationDisplay)resultsListView.SelectedItem; + if (deviceInfoDisp == selectedDeviceInfoDisp) + { + UpdatePairingButtons(); + } + break; + } + } + }); + }); + deviceWatcher.Updated += handlerUpdated; + + handlerRemoved = new TypedEventHandler(async (watcher, deviceInfoUpdate) => + { + // Since we have the collection databound to a UI element, we need to update the collection on the UI thread. + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => + { + // Find the corresponding DeviceInformation in the collection and remove it + foreach (DeviceInformationDisplay deviceInfoDisp in ResultCollection) + { + if (deviceInfoDisp.Id == deviceInfoUpdate.Id) + { + ResultCollection.Remove(deviceInfoDisp); + break; + } + } + + rootPage.NotifyUser( + String.Format("{0} devices found.", ResultCollection.Count), + NotifyType.StatusMessage); + }); + }); + deviceWatcher.Removed += handlerRemoved; + + handlerEnumCompleted = new TypedEventHandler(async (watcher, obj) => + { + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => + { + rootPage.NotifyUser( + String.Format("{0} devices found. Enumeration completed. Watching for updates...", ResultCollection.Count), + NotifyType.StatusMessage); + }); + }); + deviceWatcher.EnumerationCompleted += handlerEnumCompleted; + + handlerStopped = new TypedEventHandler(async (watcher, obj) => + { + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => + { + rootPage.NotifyUser( + String.Format("{0} devices found. Watcher {1}.", + ResultCollection.Count, + DeviceWatcherStatus.Aborted == watcher.Status ? "aborted" : "stopped"), + NotifyType.StatusMessage); + }); + }); + deviceWatcher.Stopped += handlerStopped; + + rootPage.NotifyUser("Starting Watcher...", NotifyType.StatusMessage); + deviceWatcher.Start(); + stopWatcherButton.IsEnabled = true; + } + + private void StopWatcher() + { + stopWatcherButton.IsEnabled = false; + + if (null != deviceWatcher) + { + // First unhook all event handlers except the stopped handler. This ensures our + // event handlers don't get called after stop, as stop won't block for any "in flight" + // event handler calls. We leave the stopped handler as it's guaranteed to only be called + // once and we'll use it to know when the query is completely stopped. + deviceWatcher.Added -= handlerAdded; + deviceWatcher.Updated -= handlerUpdated; + deviceWatcher.Removed -= handlerRemoved; + deviceWatcher.EnumerationCompleted -= handlerEnumCompleted; + + if (DeviceWatcherStatus.Started == deviceWatcher.Status || + DeviceWatcherStatus.EnumerationCompleted == deviceWatcher.Status) + { + deviceWatcher.Stop(); + } + } + + startWatcherButton.IsEnabled = true; + } + + private async void PairButton_Click(object sender, RoutedEventArgs e) + { + // Gray out the pair button and results view while pairing is in progress. + resultsListView.IsEnabled = false; + pairButton.IsEnabled = false; + rootPage.NotifyUser("Pairing started. Please wait...", NotifyType.StatusMessage); + + // Get the device selected for pairing + DeviceInformationDisplay deviceInfoDisp = resultsListView.SelectedItem as DeviceInformationDisplay; + + // Get ceremony type and protection level selections + DevicePairingKinds ceremoniesSelected = GetSelectedCeremonies(); + ProtectionLevelSelectorInfo protectionLevelInfo = (ProtectionLevelSelectorInfo)protectionLevelComboBox.SelectedItem; + DevicePairingProtectionLevel protectionLevel = protectionLevelInfo.ProtectionLevel; + + DeviceInformationCustomPairing customPairing = deviceInfoDisp.DeviceInformation.Pairing.Custom; + + customPairing.PairingRequested += PairingRequestedHandler; + DevicePairingResult result = await customPairing.PairAsync(ceremoniesSelected, protectionLevel); + customPairing.PairingRequested -= PairingRequestedHandler; + + rootPage.NotifyUser( + "Pairing result = " + result.Status.ToString(), + result.Status == DevicePairingResultStatus.Paired ? NotifyType.StatusMessage : NotifyType.ErrorMessage); + + HidePairingPanel(); + UpdatePairingButtons(); + resultsListView.IsEnabled = true; + } + + private async void UnpairButton_Click(object sender, RoutedEventArgs e) + { + // Gray out the unpair button and results view while unpairing is in progress. + resultsListView.IsEnabled = false; + unpairButton.IsEnabled = false; + rootPage.NotifyUser("Unpairing started. Please wait...", NotifyType.StatusMessage); + + DeviceInformationDisplay deviceInfoDisp = resultsListView.SelectedItem as DeviceInformationDisplay; + + DeviceUnpairingResult dupr = await deviceInfoDisp.DeviceInformation.Pairing.UnpairAsync(); + + rootPage.NotifyUser( + "Unpairing result = " + dupr.Status.ToString(), + dupr.Status == DeviceUnpairingResultStatus.Unpaired ? NotifyType.StatusMessage : NotifyType.ErrorMessage); + + UpdatePairingButtons(); + resultsListView.IsEnabled = true; + } + + private async void PairingRequestedHandler( + DeviceInformationCustomPairing sender, + DevicePairingRequestedEventArgs args) + { + switch (args.PairingKind) + { + case DevicePairingKinds.ConfirmOnly: + // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile + // If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation. + args.Accept(); + break; + + case DevicePairingKinds.DisplayPin: + // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN + // on the target device. We automatically except here since we can't really "cancel" the operation + // from this side. + args.Accept(); + + // No need for a deferral since we don't need any decision from the user + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => + { + ShowPairingPanel( + "Please enter this PIN on the device you are pairing with: " + args.Pin, + args.PairingKind); + + }); + break; + + case DevicePairingKinds.ProvidePin: + // A PIN may be shown on the target device and the user needs to enter the matching PIN on + // this Windows device. Get a deferral so we can perform the async request to the user. + var collectPinDeferral = args.GetDeferral(); + + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => + { + string pin = await GetPinFromUserAsync(); + if (!string.IsNullOrEmpty(pin)) + { + args.Accept(pin); + } + + collectPinDeferral.Complete(); + }); + break; + + case DevicePairingKinds.ConfirmPinMatch: + // We show the PIN here and the user responds with whether the PIN matches what they see + // on the target device. Response comes back and we set it on the PinComparePairingRequestedData + // then complete the deferral. + var displayMessageDeferral = args.GetDeferral(); + + await rootPage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => + { + bool accept = await GetUserConfirmationAsync(args.Pin); + if (accept) + { + args.Accept(); + } + + displayMessageDeferral.Complete(); + }); + break; + } + } + + private void ShowPairingPanel(string text, DevicePairingKinds pairingKind) + { + pairingPanel.Visibility = Visibility.Collapsed; + pinEntryTextBox.Visibility = Visibility.Collapsed; + okButton.Visibility = Visibility.Collapsed; + yesButton.Visibility = Visibility.Collapsed; + noButton.Visibility = Visibility.Collapsed; + pairingTextBlock.Text = text; + + switch (pairingKind) + { + case DevicePairingKinds.ConfirmOnly: + case DevicePairingKinds.DisplayPin: + // Don't need any buttons + break; + case DevicePairingKinds.ProvidePin: + pinEntryTextBox.Text = ""; + pinEntryTextBox.Visibility = Visibility.Visible; + okButton.Visibility = Visibility.Visible; + break; + case DevicePairingKinds.ConfirmPinMatch: + yesButton.Visibility = Visibility.Visible; + noButton.Visibility = Visibility.Visible; + break; + } + + pairingPanel.Visibility = Visibility.Visible; + } + + private void HidePairingPanel() + { + pairingPanel.Visibility = Visibility.Collapsed; + pairingTextBlock.Text = ""; + } + + private async Task GetPinFromUserAsync() + { + HidePairingPanel(); + CompleteProvidePinTask(); // Abandon any previous pin request. + + ShowPairingPanel( + "Please enter the PIN shown on the device you're pairing with", + DevicePairingKinds.ProvidePin); + + providePinTaskSrc = new TaskCompletionSource(); + + return await providePinTaskSrc.Task; + } + + // If pin is not provided, then any pending pairing request is abandoned. + private void CompleteProvidePinTask(string pin = null) + { + if (providePinTaskSrc != null) + { + providePinTaskSrc.SetResult(pin); + providePinTaskSrc = null; + } + } + + private async Task GetUserConfirmationAsync(string pin) + { + HidePairingPanel(); + CompleteConfirmPinTask(false); // Abandon any previous request. + + ShowPairingPanel( + "Does the following PIN match the one shown on the device you are pairing?: " + pin, + DevicePairingKinds.ConfirmPinMatch); + + confirmPinTaskSrc = new TaskCompletionSource(); + + return await confirmPinTaskSrc.Task; + } + + // If pin is not provided, then any pending pairing request is abandoned. + private void CompleteConfirmPinTask(bool accept) + { + if (confirmPinTaskSrc != null) + { + confirmPinTaskSrc.SetResult(accept); + confirmPinTaskSrc = null; + } + } + + private void okButton_Click(object sender, RoutedEventArgs e) + { + // OK button is only used for the ProvidePin scenario + CompleteProvidePinTask(pinEntryTextBox.Text); + HidePairingPanel(); + } + + private void yesButton_Click(object sender, RoutedEventArgs e) + { + CompleteConfirmPinTask(true); + HidePairingPanel(); + } + + private void noButton_Click(object sender, RoutedEventArgs e) + { + CompleteConfirmPinTask(false); + HidePairingPanel(); + } + + private DevicePairingKinds GetSelectedCeremonies() + { + DevicePairingKinds ceremonySelection = DevicePairingKinds.None; + if (confirmOnlyOption.IsChecked.Value) ceremonySelection |= DevicePairingKinds.ConfirmOnly; + if (displayPinOption.IsChecked.Value) ceremonySelection |= DevicePairingKinds.DisplayPin; + if (providePinOption.IsChecked.Value) ceremonySelection |= DevicePairingKinds.ProvidePin; + if (confirmPinMatchOption.IsChecked.Value) ceremonySelection |= DevicePairingKinds.ConfirmPinMatch; + return ceremonySelection; + } + + private void ResultsListView_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + UpdatePairingButtons(); + } + + private void UpdatePairingButtons() + { + DeviceInformationDisplay deviceInfoDisp = (DeviceInformationDisplay)resultsListView.SelectedItem; + + if (null != deviceInfoDisp && + deviceInfoDisp.DeviceInformation.Pairing.CanPair && + !deviceInfoDisp.DeviceInformation.Pairing.IsPaired) + { + pairButton.IsEnabled = true; + } + else + { + pairButton.IsEnabled = false; + } + + if (null != deviceInfoDisp && + deviceInfoDisp.DeviceInformation.Pairing.IsPaired) + { + unpairButton.IsEnabled = true; + } + else + { + unpairButton.IsEnabled = false; + } + } + } +} diff --git a/Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/BackgroundDeviceWatcher.cs b/Samples/DeviceEnumerationAndPairing/cs/Tasks/BackgroundDeviceWatcher.cs similarity index 100% rename from Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/BackgroundDeviceWatcher.cs rename to Samples/DeviceEnumerationAndPairing/cs/Tasks/BackgroundDeviceWatcher.cs diff --git a/Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/Properties/AssemblyInfo.cs b/Samples/DeviceEnumerationAndPairing/cs/Tasks/Properties/AssemblyInfo.cs similarity index 100% rename from Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/Properties/AssemblyInfo.cs rename to Samples/DeviceEnumerationAndPairing/cs/Tasks/Properties/AssemblyInfo.cs diff --git a/Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/BackgroundDeviceWatcherTaskCs.csproj b/Samples/DeviceEnumerationAndPairing/cs/Tasks/Tasks.csproj similarity index 97% rename from Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/BackgroundDeviceWatcherTaskCs.csproj rename to Samples/DeviceEnumerationAndPairing/cs/Tasks/Tasks.csproj index e43f0210a0..5387992605 100644 --- a/Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/BackgroundDeviceWatcherTaskCs.csproj +++ b/Samples/DeviceEnumerationAndPairing/cs/Tasks/Tasks.csproj @@ -11,8 +11,8 @@ BackgroundDeviceWatcherTaskCs en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 diff --git a/Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/project.json b/Samples/DeviceEnumerationAndPairing/cs/Tasks/project.json similarity index 100% rename from Samples/DeviceEnumeration/cs/BackgroundDeviceWatcherTaskCs/project.json rename to Samples/DeviceEnumerationAndPairing/cs/Tasks/project.json diff --git a/Samples/DeviceEnumeration/cs/DeviceEnumerationCs/project.json b/Samples/DeviceEnumerationAndPairing/cs/project.json similarity index 100% rename from Samples/DeviceEnumeration/cs/DeviceEnumerationCs/project.json rename to Samples/DeviceEnumerationAndPairing/cs/project.json diff --git a/Samples/DeviceEnumeration/js/DeviceEnumerationJs.jsproj b/Samples/DeviceEnumerationAndPairing/js/DeviceEnumeration.jsproj similarity index 96% rename from Samples/DeviceEnumeration/js/DeviceEnumerationJs.jsproj rename to Samples/DeviceEnumerationAndPairing/js/DeviceEnumeration.jsproj index 2a0250ed4b..682ff9c273 100644 --- a/Samples/DeviceEnumeration/js/DeviceEnumerationJs.jsproj +++ b/Samples/DeviceEnumerationAndPairing/js/DeviceEnumeration.jsproj @@ -45,8 +45,8 @@ UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 $(VersionNumberMajor).$(VersionNumberMinor) en-US @@ -61,6 +61,7 @@ + @@ -95,6 +96,7 @@ + diff --git a/Samples/DeviceEnumeration/js/DeviceEnumerationJs.sln b/Samples/DeviceEnumerationAndPairing/js/DeviceEnumeration.sln similarity index 96% rename from Samples/DeviceEnumeration/js/DeviceEnumerationJs.sln rename to Samples/DeviceEnumerationAndPairing/js/DeviceEnumeration.sln index db42b9d66b..5e3dd9b92f 100644 --- a/Samples/DeviceEnumeration/js/DeviceEnumerationJs.sln +++ b/Samples/DeviceEnumerationAndPairing/js/DeviceEnumeration.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.22810.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "DeviceEnumerationJs", "DeviceEnumerationJs.jsproj", "{C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}" +Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "DeviceEnumeration", "DeviceEnumeration.jsproj", "{C2ADB9AF-EDB3-4E57-8056-9D0531D4A6B2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/css/placeholder.txt b/Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/css/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/fonts/placeholder b/Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/fonts/placeholder new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt b/Samples/DeviceEnumerationAndPairing/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/DeviceEnumerationAndPairing/js/Package.appxmanifest b/Samples/DeviceEnumerationAndPairing/js/Package.appxmanifest new file mode 100644 index 0000000000..70003ca6a5 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/js/Package.appxmanifest @@ -0,0 +1,38 @@ + + + + + + Device Enumeration and Pairing JS Sample + Microsoft Corporation + images\storelogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/DeviceEnumerationAndPairing/js/css/placeholder.txt b/Samples/DeviceEnumerationAndPairing/js/css/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/DeviceEnumeration/js/html/scenario1_devicepicker.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario1_devicepicker.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario1_devicepicker.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario1_devicepicker.html diff --git a/Samples/DeviceEnumeration/js/html/scenario2_devicewatcher.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario2_devicewatcher.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario2_devicewatcher.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario2_devicewatcher.html diff --git a/Samples/DeviceEnumeration/js/html/scenario3_backgrounddevicewatcher.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario3_backgrounddevicewatcher.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario3_backgrounddevicewatcher.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario3_backgrounddevicewatcher.html diff --git a/Samples/DeviceEnumeration/js/html/scenario4_snapshot.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario4_snapshot.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario4_snapshot.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario4_snapshot.html diff --git a/Samples/DeviceEnumeration/js/html/scenario5_getsingledevice.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario5_getsingledevice.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario5_getsingledevice.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario5_getsingledevice.html diff --git a/Samples/DeviceEnumeration/js/html/scenario6_customfilteraddedprops.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario6_customfilteraddedprops.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario6_customfilteraddedprops.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario6_customfilteraddedprops.html diff --git a/Samples/DeviceEnumeration/js/html/scenario7_deviceinformationkind.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario7_deviceinformationkind.html similarity index 100% rename from Samples/DeviceEnumeration/js/html/scenario7_deviceinformationkind.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario7_deviceinformationkind.html diff --git a/Samples/DeviceEnumeration/js/html/scenario8_pairdevice.html b/Samples/DeviceEnumerationAndPairing/js/html/scenario8_pairdevice.html similarity index 73% rename from Samples/DeviceEnumeration/js/html/scenario8_pairdevice.html rename to Samples/DeviceEnumerationAndPairing/js/html/scenario8_pairdevice.html index 1bff1ad6cd..1c0dea534c 100644 --- a/Samples/DeviceEnumeration/js/html/scenario8_pairdevice.html +++ b/Samples/DeviceEnumerationAndPairing/js/html/scenario8_pairdevice.html @@ -25,8 +25,10 @@

Description:

- This scenario demonstrates how to pair a DeviceInformation object which is of kind DeviceInformationKind.AssociationEndpoint. e.g. This method can be used to pair devices like WiFi Direct, WSD, or UPnP device. Bluetooth is not supported at this time, - but will be in a future release. + This scenario demonstrates how to perform basic pairing. Basic pairing allows you to tell Windows which device you want paired, and then Windows will + handle the ceremony and the UI. If you want to display your own UI and be involved in the pairing ceremony, please see the Custom Pairing scenario. +
This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. +
Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint.
@@ -38,6 +40,7 @@

Description:

+
+ + + + + + + + +
+
+
Name:
+
Id:
+
CanPair:
+
IsPaired:
+
+
+ +
+
+

Description:

+
+ This scenario demonstrates how to perform custom pairing. Custom pairing allows your app to be involved in the pairing ceremony and use your on UI. + If you want Windows to control the ceremony and display system UI, please look at the basic pairing scenario. +
This method can be used to pair devices like WiFiDirect, WSD, UPnP, Bluetooth or Bluetooth LE devices. +
Pairing can only be performed on DeviceInformation objects of kind DeviceInformationKind.AssociationEndpoint. +
+
+
+

+ Choose a device selector: +
+ +

+

+ Select supported pairing ceremonies: +
+ + + + + + + + +

+

+ Choose a protection level: +
+ +

+ + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/Samples/DeviceEnumerationAndPairing/js/images/placeholder.txt b/Samples/DeviceEnumerationAndPairing/js/images/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/DeviceEnumeration/js/js/BackgroundDeviceWatcher.js b/Samples/DeviceEnumerationAndPairing/js/js/BackgroundDeviceWatcher.js similarity index 100% rename from Samples/DeviceEnumeration/js/js/BackgroundDeviceWatcher.js rename to Samples/DeviceEnumerationAndPairing/js/js/BackgroundDeviceWatcher.js diff --git a/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js b/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js new file mode 100644 index 0000000000..37febab114 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js @@ -0,0 +1,184 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var bt = Windows.Devices.Bluetooth; + var rfcommChatServiceUuid = "34B1CF4D-1069-4AD6-89B6-E161D79BE4D8"; + + var commonArray = new Array( + + // Pre-canned device class selectors + { displayName: "All Device Interfaces (default)", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.all }, + { displayName: "Audio Capture", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.audioCapture }, + { displayName: "Audio Render", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.audioRender }, + { displayName: "Image Scanner", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.imageScanner }, + { displayName: "Location", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.location }, + { displayName: "Portable Storage", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.portableStorageDevice }, + { displayName: "Video Capture", deviceClassSelector: Windows.Devices.Enumeration.DeviceClass.videoCapture }, + + // A few examples of selectors built dynamically by windows runtime apis. + { displayName: "Human Interface (HID)", selector: Windows.Devices.HumanInterfaceDevice.HidDevice.getDeviceSelector(0, 0) }, + { displayName: "Activity Sensor", selector: Windows.Devices.Sensors.ActivitySensor.getDeviceSelector() }, + { displayName: "Pedometer", selector: Windows.Devices.Sensors.Pedometer.getDeviceSelector() }, + { displayName: "Proximity", selector: Windows.Networking.Proximity.ProximityDevice.getDeviceSelector() }, + { displayName: "Proximity Sensor", selector: Windows.Devices.Sensors.ProximitySensor.getDeviceSelector() } + ); + + // Currently Bluetooth APIs don't provide a selector to get ALL devices that are both paired and non-paired. Typically you wouldn't need this for common scenarios, but it's convenient to demonstrate the + // various sample scenarios. + var bluetooth = { displayName: "Bluetooth", selector: "System.Devices.Aep.ProtocolId:=\"{e0cbf06c-cd8b-4647-bb8a-263b43f0f974}\"", kind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpoint }; + var bluetoothUnpairedOnly = { displayName: "Bluetooth (unpaired)", selector: Windows.Devices.Bluetooth.BluetoothDevice.getDeviceSelectorFromPairingState(false) }; + var bluetoothPairedOnly = { displayName: "Bluetooth (paired)", selector: Windows.Devices.Bluetooth.BluetoothDevice.getDeviceSelectorFromPairingState(true) }; + var bluetoothLE = { displayName: "Bluetooth LE", selector: "System.Devices.Aep.ProtocolId:=\"{bb7bb05e-5972-42b5-94fc-76eaa7084d49}\"", kind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpoint }; + var bluetoothLEUnpairedOnly = { displayName: "Bluetooth LE (unpaired)", selector: Windows.Devices.Bluetooth.BluetoothLEDevice.getDeviceSelectorFromPairingState(false) }; + var bluetoothLEPairedOnly = { displayName: "Bluetooth LE (paired)", selector: Windows.Devices.Bluetooth.BluetoothLEDevice.getDeviceSelectorFromPairingState(true) }; + var wiFiDirect = { displayName: "Wi-Fi Direct", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector(Windows.Devices.WiFiDirect.WiFiDirectDeviceSelectorType.associationEndpoint) }; + var wiFiDirectPairedOnly = { displayName: "Wi-Fi Direct (paired)", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector() }; + var pointOfServicePrinter = { displayName: "Point of Service Printer", selector: Windows.Devices.PointOfService.PosPrinter.getDeviceSelector() }; + var videoCasting = { displayName: "Video Casting", selector: Windows.Media.Casting.CastingDevice.getDeviceSelector(Windows.Media.Casting.CastingPlaybackTypes.video) }; + var dialAllApps = { displayName: "DIAL (All Apps)", selector: Windows.Media.DialProtocol.DialDevice.getDeviceSelector("") }; + + // WSD and UPnP are unique in that there are currently no general WSD or UPnP APIs to USE the devices once you've discovered them. + // You can pair the devices using DeviceInformation.Pairing.PairAsync etc, and you can USE them with the sockets APIs. However, since + // there's no specific API right now, there's no *.GetDeviceSelector available. That's why we just simply build the device selector + // ourselves and specify the correct DeviceInformationKind (AssociationEndpoint). + var wsd = { displayName: "Web Services on Devices (WSD)", selector: "System.Devices.Aep.ProtocolId:=\"{782232aa-a2f9-4993-971b-aedc551346b0}\"", kind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpoint }; + var upnp = { displayName: "UPnP", selector: "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"", kind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpoint }; + + var devicePickerArray = commonArray.slice(); + devicePickerArray.push(bluetoothPairedOnly); + devicePickerArray.push(bluetoothUnpairedOnly); + devicePickerArray.push(bluetoothLEPairedOnly); + devicePickerArray.push(bluetoothLEUnpairedOnly); + devicePickerArray.push(wiFiDirect); + devicePickerArray.push(pointOfServicePrinter); + devicePickerArray.push(videoCasting); + devicePickerArray.push(dialAllApps); + var devicePickerSelectors = new WinJS.Binding.List(devicePickerArray); + + var findAllAsyncArray = commonArray.slice(); + findAllAsyncArray.push(bluetoothPairedOnly); + findAllAsyncArray.push(bluetoothLEPairedOnly); + findAllAsyncArray.push(wiFiDirectPairedOnly); + var findAllAsyncSelectors = new WinJS.Binding.List(findAllAsyncArray); + + var deviceWatcherArray = commonArray.slice(); + deviceWatcherArray.push(bluetooth); + deviceWatcherArray.push(bluetoothLE); + deviceWatcherArray.push(wiFiDirect); + deviceWatcherArray.push(pointOfServicePrinter); + deviceWatcherArray.push(videoCasting); + deviceWatcherArray.push(dialAllApps); + deviceWatcherArray.push(wsd); + deviceWatcherArray.push(upnp); + var deviceWatcherSelectors = new WinJS.Binding.List(deviceWatcherArray); + + var backgroundDeviceWatcherArray = commonArray.slice(); + backgroundDeviceWatcherArray.push(bluetoothPairedOnly); + backgroundDeviceWatcherArray.push(bluetoothLEPairedOnly); + backgroundDeviceWatcherArray.push(wiFiDirectPairedOnly); + backgroundDeviceWatcherArray.push(pointOfServicePrinter); + backgroundDeviceWatcherArray.push(videoCasting); + backgroundDeviceWatcherArray.push(dialAllApps); + backgroundDeviceWatcherArray.push(wsd); + backgroundDeviceWatcherArray.push(upnp); + var backgroundDeviceWatcherSelectors = new WinJS.Binding.List(backgroundDeviceWatcherArray); + + var pairingArray = new Array(); + pairingArray.push(bluetooth); + pairingArray.push(bluetoothLE); + pairingArray.push(wiFiDirect); + pairingArray.push(pointOfServicePrinter); + pairingArray.push(videoCasting); + pairingArray.push(wsd); + pairingArray.push(upnp); + var pairingSelectors = new WinJS.Binding.List(pairingArray); + + var kindArray = [ + { displayName: "DeviceContainer", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.deviceContainer }, + { displayName: "Device", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.device }, + { displayName: "DeviceInterface (default)", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.deviceInterface }, + { displayName: "DeviceInterfaceClass", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.deviceInterfaceClass }, + { displayName: "AssociationEndpointContainer", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpointContainer }, + { displayName: "AssociationEndpoint", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpoint }, + { displayName: "AssociationEndpointService", deviceInformationKind: Windows.Devices.Enumeration.DeviceInformationKind.associationEndpointService }, + ]; + var kindList = new WinJS.Binding.List(kindArray); + + // Define a bindable "display" version of the DeviceInformation class. WinJS.Binding.as won't work directly + // on the DeviceInformation object, so we use this new class and make it a mix of observable and non-observable + // properties. Notice the main properties are made observable, but deviceInfo is not. + var DeviceInformationDisplay = WinJS.Class.define( + function (deviceInfo) { + this._initObservable(); + + this.id = deviceInfo.id; + this.kind = kindStringFromType(deviceInfo.kind); + this.name = deviceInfo.name; + if (null != deviceInfo.pairing) { + this.canPair = deviceInfo.pairing.canPair; + this.isPaired = deviceInfo.pairing.isPaired; + } + this.deviceInfo = deviceInfo; + + // These two properties are only valid for scenario 6, but won't hurt other scenarios + this.interfaceClass = deviceInfo.properties["System.Devices.InterfaceClassGuid"]; + this.itemNameDisplay = deviceInfo.properties["System.ItemNameDisplay"]; + }, { + update: function (deviceInfoUpdate) { + this.deviceInfo.update(deviceInfoUpdate); + this.name = this.deviceInfo.name; + + if (null != this.deviceInfo.pairing) { + this.canPair = this.deviceInfo.pairing.canPair; + this.isPaired = this.deviceInfo.pairing.isPaired; + } + + // These two properties are only valid for scenario 6, but won't hurt other scenarios + this.interfaceClass = this.deviceInfo.properties["System.Devices.InterfaceClassGuid"]; + this.itemNameDisplay = this.deviceInfo.properties["System.ItemNameDisplay"]; + } + } + ); + + var DeviceInformationDisplayMix = WinJS.Class.mix( + DeviceInformationDisplay, + WinJS.Binding.mixin, + WinJS.Binding.expandProperties({ id: "", kind: "", name: "", canPair: "", isPaired: "", interfaceClass: "", itemNameDisplay: "" })); + + var publicMembers = + { + devicePickerSelectors: devicePickerSelectors, + deviceWatcherSelectors: deviceWatcherSelectors, + backgroundDeviceWatcherSelectors: backgroundDeviceWatcherSelectors, + findAllAsyncSelectors: findAllAsyncSelectors, + pairingSelectors: pairingSelectors, + kindList: kindList, + DeviceInformationDisplay: DeviceInformationDisplayMix + }; + + WinJS.Namespace.define("DisplayHelpers", publicMembers); +})(); + + +function kindStringFromType(kindType) { + var DevEnum = Windows.Devices.Enumeration; + + switch (kindType) { + case DevEnum.DeviceInformationKind.associationEndpoint: + return "AssociationEndpoint"; + case DevEnum.DeviceInformationKind.associationEndpointContainer: + return "AssociationEndpointContainer"; + case DevEnum.DeviceInformationKind.associationEndpointService: + return "AssociationEndpointService"; + case DevEnum.DeviceInformationKind.device: + return "Device"; + case DevEnum.DeviceInformationKind.deviceContainer: + return "DeviceContainer"; + case DevEnum.DeviceInformationKind.deviceInterface: + return "DeviceInterface"; + case DevEnum.DeviceInformationKind.deviceInterfaceClass: + return "DeviceInterfaceClass"; + } +}; diff --git a/Samples/DeviceEnumeration/js/js/sample-configuration.js b/Samples/DeviceEnumerationAndPairing/js/js/sample-configuration.js similarity index 80% rename from Samples/DeviceEnumeration/js/js/sample-configuration.js rename to Samples/DeviceEnumerationAndPairing/js/js/sample-configuration.js index 0ac8fd850f..868551007e 100644 --- a/Samples/DeviceEnumeration/js/js/sample-configuration.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/sample-configuration.js @@ -3,7 +3,7 @@ (function () { "use strict"; - var sampleTitle = "Device Enumeration JS Sample"; + var sampleTitle = "Device Enumeration and Pairing JS Sample"; var scenarios = [ { url: "/html/scenario1_devicepicker.html", title: "Device Picker Common Control" }, @@ -13,7 +13,8 @@ { url: "/html/scenario5_getsingledevice.html", title: "Get Single Device" }, { url: "/html/scenario6_customfilteraddedprops.html", title: "Custom Filter with Additional Properties" }, { url: "/html/scenario7_deviceinformationkind.html", title: "Request Specific DeviceInformationKind" }, - { url: "/html/scenario8_pairdevice.html", title: "Pair Device" } + { url: "/html/scenario8_pairdevice.html", title: "Basic Device Pairing" }, + { url: "/html/scenario9_custompairdevice.html", title: "Custom Device Pairing" } ]; WinJS.Namespace.define("SdkSample", { diff --git a/Samples/DeviceEnumeration/js/js/scenario1_devicepicker.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario1_devicepicker.js similarity index 95% rename from Samples/DeviceEnumeration/js/js/scenario1_devicepicker.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario1_devicepicker.js index 686180ca86..729d7d2ac4 100644 --- a/Samples/DeviceEnumeration/js/js/scenario1_devicepicker.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/scenario1_devicepicker.js @@ -23,7 +23,7 @@ resultsListView.itemDataSource = resultCollection.dataSource; // Manually bind selector options - DisplayHelpers.selectorsList.forEach(function each(item) { + DisplayHelpers.devicePickerSelectors.forEach(function each(item) { var option = document.createElement("option"); option.textContent = item.displayName; selectorComboBox.appendChild(option); @@ -54,7 +54,7 @@ devicePicker = new DevEnum.DevicePicker(); - var selectedItem = DisplayHelpers.selectorsList.getAt(selectorComboBox.selectedIndex); + var selectedItem = DisplayHelpers.devicePickerSelectors.getAt(selectorComboBox.selectedIndex); // If the selected device selector is a pre-canned device class, call CreateWatcher with the device class // overload. Otherwise assume the device selector contains an AQS filter selector and use that overload. diff --git a/Samples/DeviceEnumeration/js/js/scenario2_devicewatcher.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario2_devicewatcher.js similarity index 86% rename from Samples/DeviceEnumeration/js/js/scenario2_devicewatcher.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario2_devicewatcher.js index 63b7cfa9bd..f99507ffb6 100644 --- a/Samples/DeviceEnumeration/js/js/scenario2_devicewatcher.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/scenario2_devicewatcher.js @@ -23,7 +23,7 @@ resultsListView.itemDataSource = resultCollection.dataSource; // Manually bind selector options - DisplayHelpers.selectorsList.forEach(function each(item) { + DisplayHelpers.deviceWatcherSelectors.forEach(function each(item) { var option = document.createElement("option"); option.textContent = item.displayName; selectorComboBox.appendChild(option); @@ -44,19 +44,28 @@ startWatcherButton.disabled = true; resultCollection.splice(0, resultCollection.length); - var selectedItem = DisplayHelpers.selectorsList.getAt(selectorComboBox.selectedIndex); + // First get the device selector chosen by the UI. + var selectedItem = DisplayHelpers.deviceWatcherSelectors.getAt(selectorComboBox.selectedIndex); - // If the selected device selector is a pre-canned device class, call CreateWatcher with the device class - // overload. Otherwise assume the device selector contains an AQS filter selector and use that overload. if (null != selectedItem.deviceClassSelector) { + // If the a pre-canned device class selector was chosen, call the DeviceClass overloa deviceWatcher = DevEnum.DeviceInformation.createWatcher(selectedItem.deviceClassSelector); } - else { + else if (selectedItem.kind == DevEnum.DeviceInformationKind.unknown){ + // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call + // Kind will be determined by the selector deviceWatcher = DevEnum.DeviceInformation.createWatcher( selectedItem.selector, null // don't request additional properties for this sample ); } + else { + // Kind is specified in the selector info + deviceWatcher = DevEnum.DeviceInformation.createWatcher( + selectedItem.selector, + null, // don't request additional properties for this sample + selectedItem.kind); + } // Add event handlers deviceWatcher.addEventListener("added", onAdded); diff --git a/Samples/DeviceEnumeration/js/js/scenario3_backgrounddevicewatcher.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario3_backgrounddevicewatcher.js similarity index 83% rename from Samples/DeviceEnumeration/js/js/scenario3_backgrounddevicewatcher.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario3_backgrounddevicewatcher.js index 2404d1a526..1feb3832d5 100644 --- a/Samples/DeviceEnumeration/js/js/scenario3_backgrounddevicewatcher.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/scenario3_backgrounddevicewatcher.js @@ -15,7 +15,7 @@ document.getElementById("stopWatcherButton").addEventListener("click", stopWatcher, false); // Manually bind selector options - DisplayHelpers.selectorsList.forEach(function each(item) { + DisplayHelpers.backgroundDeviceWatcherSelectors.forEach(function each(item) { var option = document.createElement("option"); option.textContent = item.displayName; selectorComboBox.appendChild(option); @@ -47,19 +47,28 @@ var deviceWatcher = null; startWatcherButton.disabled = true; - var selectedItem = DisplayHelpers.selectorsList.getAt(selectorComboBox.selectedIndex); + // First get the device selector chosen by the UI. + var selectedItem = DisplayHelpers.backgroundDeviceWatcherSelectors.getAt(selectorComboBox.selectedIndex); - // If the selected device selector is a pre-canned device class, call CreateWatcher with the device class - // overload. Otherwise assume the device selector contains an AQS filter selector and use that overload. if (null != selectedItem.deviceClassSelector) { + // If the a pre-canned device class selector was chosen, call the DeviceClass overloa deviceWatcher = DevEnum.DeviceInformation.createWatcher(selectedItem.deviceClassSelector); } - else { + else if (selectedItem.kind == DevEnum.DeviceInformationKind.unknown) { + // Use AQS string selector from dynamic call to a device api's GetDeviceSelector call + // Kind will be determined by the selector deviceWatcher = DevEnum.DeviceInformation.createWatcher( selectedItem.selector, null // don't request additional properties for this sample ); } + else { + // Kind is specified in the selector info + deviceWatcher = DevEnum.DeviceInformation.createWatcher( + selectedItem.selector, + null, // don't request additional properties for this sample + selectedItem.kind); + } // Get the background trigger for this watcher var triggerEventKinds = [DevEnum.DeviceWatcherEventKind.add, DevEnum.DeviceWatcherEventKind.update, DevEnum.DeviceWatcherEventKind.remove]; diff --git a/Samples/DeviceEnumeration/js/js/scenario4_snapshot.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario4_snapshot.js similarity index 94% rename from Samples/DeviceEnumeration/js/js/scenario4_snapshot.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario4_snapshot.js index 218a3ca928..51e8747d14 100644 --- a/Samples/DeviceEnumeration/js/js/scenario4_snapshot.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/scenario4_snapshot.js @@ -21,7 +21,7 @@ resultsListView.itemDataSource = resultCollection.dataSource; // Manually bind selector options - DisplayHelpers.selectorsList.forEach(function each(item) { + DisplayHelpers.findAllAsyncSelectors.forEach(function each(item) { var option = document.createElement("option"); option.textContent = item.displayName; selectorComboBox.appendChild(option); @@ -43,7 +43,7 @@ findButton.disabled = true; resultCollection.splice(0, resultCollection.length); - var selectedItem = DisplayHelpers.selectorsList.getAt(selectorComboBox.selectedIndex); + var selectedItem = DisplayHelpers.findAllAsyncSelectors.getAt(selectorComboBox.selectedIndex); WinJS.log && WinJS.log("FindAllAsync operation started...", "sample", "status"); diff --git a/Samples/DeviceEnumeration/js/js/scenario5_getsingledevice.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario5_getsingledevice.js similarity index 100% rename from Samples/DeviceEnumeration/js/js/scenario5_getsingledevice.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario5_getsingledevice.js diff --git a/Samples/DeviceEnumeration/js/js/scenario6_customfilteraddedprops.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario6_customfilteraddedprops.js similarity index 100% rename from Samples/DeviceEnumeration/js/js/scenario6_customfilteraddedprops.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario6_customfilteraddedprops.js diff --git a/Samples/DeviceEnumeration/js/js/scenario7_deviceinformationkind.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario7_deviceinformationkind.js similarity index 100% rename from Samples/DeviceEnumeration/js/js/scenario7_deviceinformationkind.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario7_deviceinformationkind.js diff --git a/Samples/DeviceEnumeration/js/js/scenario8_pairdevice.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario8_pairdevice.js similarity index 60% rename from Samples/DeviceEnumeration/js/js/scenario8_pairdevice.js rename to Samples/DeviceEnumerationAndPairing/js/js/scenario8_pairdevice.js index 1002aa2495..6c1a18effd 100644 --- a/Samples/DeviceEnumeration/js/js/scenario8_pairdevice.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/scenario8_pairdevice.js @@ -18,6 +18,7 @@ document.getElementById("startWatcherButton").addEventListener("click", startWatcher, false); document.getElementById("stopWatcherButton").addEventListener("click", stopWatcher, false); document.getElementById("pairButton").addEventListener("click", pairDevice, false); + document.getElementById("unpairButton").addEventListener("click", unpairDevice, false); // Hook up result list selection changed event handler resultsListView = element.querySelector("#resultsListView").winControl; @@ -26,11 +27,12 @@ resultsListView.itemDataSource = resultCollection.dataSource; // Manually bind selector options - DisplayHelpers.protocolList.forEach(function each(item) { + DisplayHelpers.pairingSelectors.forEach(function each(item) { var option = document.createElement("option"); option.textContent = item.displayName; selectorComboBox.appendChild(option); }); + selectorComboBox.selectedIndex = 0; // Process any data bindings WinJS.UI.processAll(); @@ -47,21 +49,25 @@ startWatcherButton.disabled = true; resultCollection.splice(0, resultCollection.length); - // Request the IsPaired property so we can display the paired status in the UI - var requestedProperties = [ - "System.Devices.Aep.IsPaired" - ]; - - var selectedItem = DisplayHelpers.protocolList.getAt(selectorComboBox.selectedIndex); - - // Get the device selector chosen by the UI, then 'AND' it with the 'CanPair' property - var aqsFilter = selectedItem.selector + " AND System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True"; - - deviceWatcher = DevEnum.DeviceInformation.createWatcher( - aqsFilter, - requestedProperties, - DevEnum.DeviceInformationKind.associationEndpoint - ); + // Get the device selector chosen by the UI then add additional constraints for devices that + // can be paired or are already paired. + var selectedItem = DisplayHelpers.pairingSelectors.getAt(selectorComboBox.selectedIndex); + var selector = "(" + selectedItem.selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; + + if (selectedItem.kind == DevEnum.DeviceInformationKind.unknown) { + // Kind will be determined by the selector + deviceWatcher = DevEnum.DeviceInformation.createWatcher( + selector, + null // don't request additional properties for this sample + ); + } + else { + // Kind will be determined by the selector + deviceWatcher = DevEnum.DeviceInformation.createWatcher( + selector, + null, // don't request additional properties for this sample + selectedItem.kind); + } // Add event handlers deviceWatcher.addEventListener("added", onAdded); @@ -116,6 +122,15 @@ resultCollection.forEach(function (value, index, array) { if (value.id == deviceInfoUpdate.id) { value.update(deviceInfoUpdate); + + // If the item being updated is currently "selected", then update the pairing buttons + var selectedItems = resultsListView.selection.getIndices(); + if (selectedItems && + selectedItems.length > 0 && + value == selectedItems[0]) + { + UpdatePairingButtons(); + } } }); } @@ -140,33 +155,75 @@ } function pairDevice() { + // Gray out the pair button and results view while pairing is in progress. + pairButton.disabled = true; + WinJS.log && WinJS.log("Pairing started. Please wait...", "sample", "status"); + var selectedItems = resultsListView.selection.getIndices(); if (selectedItems.length > 0) { var deviceDispInfo = resultCollection.getAt(selectedItems[0]); - pairButton.disabled = true; - deviceDispInfo.deviceInfo.pairing.pairAsync(); + deviceDispInfo.deviceInfo.pairing.pairAsync().done( + function (pairingResult) { + var statusType = (pairingResult.status == DevEnum.DevicePairingResultStatus.paired) ? "status" : "error"; + var message = (pairingResult.status == DevEnum.DevicePairingResultStatus.paired) ? "Paired" : "NotPaired"; + WinJS.log && WinJS.log("Pairing result = " + message, "sample", statusType); + + updatePairingButtons(); + }); + } + } + + function unpairDevice() { + // Gray out the pair button and results view while pairing is in progress. + unpairButton.disabled = true; + WinJS.log && WinJS.log("Unpairing started. Please wait...", "sample", "status"); + + var selectedItems = resultsListView.selection.getIndices(); + + if (selectedItems.length > 0) { + var deviceDispInfo = resultCollection.getAt(selectedItems[0]); + + deviceDispInfo.deviceInfo.pairing.unpairAsync().done( + function (unpairingResult) { + var message = (unpairingResult.status == DevEnum.DeviceUnpairingResultStatus.unpaired) ? "Unpaired" : "Failed"; + var statusType = (unpairingResult.status == DevEnum.DeviceUnpairingResultStatus.unpaired) ? "status" : "error"; + WinJS.log && WinJS.log("Unpairing result = " + message, "sample", statusType); + + updatePairingButtons(); + }); } } function onSelectionChanged() { + updatePairingButtons(); + } + + function updatePairingButtons() { + var selectedItems = resultsListView.selection.getIndices(); var deviceDispInfo = null; - + if (selectedItems.length > 0) { deviceDispInfo = resultCollection.getAt(selectedItems[0]); } if (null != deviceDispInfo && - true == deviceDispInfo.canPair && - false == deviceDispInfo.isPaired) { - + deviceDispInfo.canPair && + !deviceDispInfo.isPaired) { pairButton.disabled = false; } else { pairButton.disabled = true; } - } + if (null != deviceDispInfo && + deviceDispInfo.isPaired) { + unpairButton.disabled = false; + } + else { + unpairButton.disabled = true; + } + } })(); diff --git a/Samples/DeviceEnumerationAndPairing/js/js/scenario9_custompairdevice.js b/Samples/DeviceEnumerationAndPairing/js/js/scenario9_custompairdevice.js new file mode 100644 index 0000000000..c0d4e586f6 --- /dev/null +++ b/Samples/DeviceEnumerationAndPairing/js/js/scenario9_custompairdevice.js @@ -0,0 +1,396 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var DevEnum = Windows.Devices.Enumeration; + var deviceWatcher = null; + var resultCollection = new WinJS.Binding.List([]); + var resultsListView; + var providePinTaskSrc; + var confirmPinTaskSrc; + + var page = WinJS.UI.Pages.define("/html/scenario9_custompairdevice.html", { + ready: function (element, options) { + + // Setup beforeNavigate event + WinJS.Navigation.addEventListener("beforenavigate", onLeavingPage); + + // Hook up button event handlers + document.getElementById("startWatcherButton").addEventListener("click", startWatcher, false); + document.getElementById("stopWatcherButton").addEventListener("click", stopWatcher, false); + document.getElementById("pairButton").addEventListener("click", pairDevice, false); + document.getElementById("unpairButton").addEventListener("click", unpairDevice, false); + document.getElementById("okButton").addEventListener("click", okButton, false); + document.getElementById("yesButton").addEventListener("click", yesButton, false); + document.getElementById("noButton").addEventListener("click", noButton, false); + + // Hook up result list selection changed event handler + resultsListView = element.querySelector("#resultsListView").winControl; + resultsListView.addEventListener("selectionchanged", onSelectionChanged); + // Hook up result list data binding + resultsListView.itemDataSource = resultCollection.dataSource; + + // Manually bind selector options + DisplayHelpers.pairingSelectors.forEach(function each(item) { + var option = document.createElement("option"); + option.textContent = item.displayName; + selectorComboBox.appendChild(option); + }); + selectorComboBox.selectedIndex = 0; + + // Process any data bindings + WinJS.UI.processAll(); + } + }); + + function onLeavingPage() { + stopWatcher(); + WinJS.Navigation.removeEventListener("beforenavigate", onLeavingPage); + resultCollection.splice(0, resultCollection.length); + } + + function startWatcher() { + startWatcherButton.disabled = true; + resultCollection.splice(0, resultCollection.length); + + // Get the device selector chosen by the UI then add additional constraints for devices that + // can be paired or are already paired. + var selectedItem = DisplayHelpers.pairingSelectors.getAt(selectorComboBox.selectedIndex); + var selector = "(" + selectedItem.selector + ")" + " AND (System.Devices.Aep.CanPair:=System.StructuredQueryType.Boolean#True OR System.Devices.Aep.IsPaired:=System.StructuredQueryType.Boolean#True)"; + + if (selectedItem.kind == DevEnum.DeviceInformationKind.unknown) { + // Kind will be determined by the selector + deviceWatcher = DevEnum.DeviceInformation.createWatcher( + selector, + null // don't request additional properties for this sample + ); + } + else { + // Kind will be determined by the selector + deviceWatcher = DevEnum.DeviceInformation.createWatcher( + selector, + null, // don't request additional properties for this sample + selectedItem.kind); + } + + // Add event handlers + deviceWatcher.addEventListener("added", onAdded); + deviceWatcher.addEventListener("updated", onUpdated); + deviceWatcher.addEventListener("removed", onRemoved); + deviceWatcher.addEventListener("enumerationcompleted", onEnumerationCompleted); + deviceWatcher.addEventListener("stopped", onStopped); + + WinJS.log && WinJS.log("Starting watcher...", "sample", "status"); + deviceWatcher.start(); + stopWatcherButton.disabled = false; + } + + function stopWatcher() { + + stopWatcherButton.disabled = true; + + if (null != deviceWatcher) { + + // First unhook all event handlers except the stopped handler. This ensures our + // event handlers don't get called after stop, as stop won't block for any "in flight" + // event handler calls. We leave the stopped handler as it's guaranteed to only be called + // once and we'll use it to know when the query is completely stopped. + deviceWatcher.removeEventListener("added", onAdded); + deviceWatcher.removeEventListener("updated", onUpdated); + deviceWatcher.removeEventListener("removed", onRemoved); + deviceWatcher.removeEventListener("enumerationcompleted", onEnumerationCompleted); + + if (DevEnum.DeviceWatcherStatus.started == deviceWatcher.status || + DevEnum.DeviceWatcherStatus.enumerationCompleted == deviceWatcher.status) { + deviceWatcher.stop(); + } + } + + startWatcherButton.disabled = false; + } + + function onAdded(deviceInfo) { + // For simplicity, just creating a new "display object" on the fly since databinding directly with deviceInfo from + // the callback doesn't work. + resultCollection.push(new DisplayHelpers.DeviceInformationDisplay(deviceInfo)); + + if (deviceWatcher.status == DevEnum.DeviceWatcherStatus.enumerationCompleted) { + WinJS.log && WinJS.log(resultCollection.length + " devices found. Watching for updates...", "sample", "status"); + } + } + + function onUpdated(deviceInfoUpdate) { + // Find the corresponding updated DeviceInformation in the collection and pass the update object + // to the Update method of the existing DeviceInformation. This automatically updates the object + // for us. + resultCollection.forEach(function (value, index, array) { + if (value.id == deviceInfoUpdate.id) { + value.update(deviceInfoUpdate); + } + + // If the item being updated is currently "selected", then update the pairing buttons + var selectedItems = resultsListView.selection.getIndices(); + if (selectedItems && + selectedItems.length > 0 && + value == selectedItems[0]) { + UpdatePairingButtons(); + } + }); + } + + function onRemoved(deviceInfoUpdate) { + for (var i = 0; resultCollection.length; i++) { + if (resultCollection.getAt(i).id == deviceInfoUpdate.id) { + resultCollection.splice(i, 1); + break; + } + } + + WinJS.log && WinJS.log(resultCollection.length + " devices found. Watching for updates...", "sample", "status"); + } + + function onEnumerationCompleted(obj) { + WinJS.log && WinJS.log(resultCollection.length + " devices found. Enumeration completed. Watching for updates...", "sample", "status"); + } + + function onStopped(obj) { + WinJS.log && WinJS.log(resultCollection.length + " devices found. Watcher stopped", "sample", "status"); + } + + function pairDevice() { + // Gray out the pair button and results view while pairing is in progress. + pairButton.disabled = true; + WinJS.log && WinJS.log("Pairing started. Please wait...", "sample", "status"); + + var selectedItems = resultsListView.selection.getIndices(); + + if (selectedItems.length > 0) { + var deviceDispInfo = resultCollection.getAt(selectedItems[0]); + var ceremoniesSelected = GetSelectedCeremonies(); + var protectionLevel = protectionLevelComboBox.selectedIndex; + + var customPairing = deviceDispInfo.deviceInfo.pairing.custom; + customPairing.addEventListener("pairingrequested", pairingRequestHandler); + + customPairing.pairAsync(ceremoniesSelected, protectionLevel).done( + function (pairingResult) { + var statusType = (pairingResult.status == DevEnum.DevicePairingResultStatus.paired) ? "status" : "error"; + var message = (pairingResult.status == DevEnum.DevicePairingResultStatus.paired) ? "Paired" : "NotPaired"; + WinJS.log && WinJS.log("Pairing result = " + message, "sample", statusType); + + customPairing.removeEventListener("pairingrequested", pairingRequestHandler); + + hidePairingPanel(); + updatePairingButtons(); + }); + } + } + + function unpairDevice() { + // Gray out the pair button and results view while pairing is in progress. + unpairButton.disabled = true; + WinJS.log && WinJS.log("Unpairing started. Please wait...", "sample", "status"); + + var selectedItems = resultsListView.selection.getIndices(); + + if (selectedItems.length > 0) { + var deviceDispInfo = resultCollection.getAt(selectedItems[0]); + + unpairButton.disabled = true; + deviceDispInfo.deviceInfo.pairing.unpairAsync().done( + function (unpairingResult) { + var message = (unpairingResult.status == DevEnum.DeviceUnpairingResultStatus.unpaired) ? "Unpaired" : "Failed"; + var statusType = (unpairingResult.status == DevEnum.DeviceUnpairingResultStatus.unpaired) ? "status" : "error"; + WinJS.log && WinJS.log("Unpairing result = " + message, "sample", statusType); + + updatePairingButtons(); + }); + } + } + + function pairingRequestHandler(args) { + if (args.pairingKind == DevEnum.DevicePairingKinds.confirmOnly) { + // Windows itself will pop the confirmation dialog as part of "consent" if this is running on Desktop or Mobile + // If this is an App for 'Windows IoT Core' where there is no Windows Consent UX, you may want to provide your own confirmation. + args.accept(); + } + else if (args.pairingKind == DevEnum.DevicePairingKinds.displayPin) { + // We just show the PIN on this side. The ceremony is actually completed when the user enters the PIN + // on the target device. We automatically accept here since we can't really "cancel" the operation + // from this side. + args.accept(); + + showPairingPanel("Please enter this PIN on the device you are pairing with: " + args.pin, args.pairingKind); + } + else if (args.pairingKind == DevEnum.DevicePairingKinds.providePin) { + // A PIN may be shown on the target device and the user needs to enter the matching PIN on + // this Windows device. Get a deferral so we can perform the async request to the user. + var collectPinDeferral = args.getDeferral(); + + getPinFromUserAsync().then(function (pin) { + if (pin) { + args.accept(pin); + } + collectPinDeferral.complete(); + }); + } + else if (args.pairingKind == DevEnum.DevicePairingKinds.confirmPinMatch) { + // We show the PIN here and the user responds with whether the PIN matches what they see + // on the target device. Response comes back and we set it on the PinComparePairingRequestedData + // then complete the deferral. + var displayMessageDeferral = args.getDeferral(); + + getUserConfirmationAsync(args.pin).then(function (accept) { + if (accept) { + args.accept(); + } + displayMessageDeferral.complete(); + }); + } + } + + function showPairingPanel(text, pairingKind) { + document.getElementById("pairingPanel").style.display = "block"; + document.getElementById("pinEntryTextBox").style.display = "none"; + document.getElementById("okButton").style.display = "none"; + document.getElementById("yesButton").style.display = "none"; + document.getElementById("noButton").style.display = "none"; + pairingTextBlock.innerHTML = text; + + switch (pairingKind) { + case DevEnum.DevicePairingKinds.confirmOnly: + case DevEnum.DevicePairingKinds.displayPin: + // Don't need any buttons + break; + case DevEnum.DevicePairingKinds.providePin: + pinEntryTextBox.value = ""; + document.getElementById("pinEntryTextBox").style.display = "inline"; + document.getElementById("okButton").style.display = "inline"; + break; + case DevEnum.DevicePairingKinds.confirmPinMatch: + document.getElementById("yesButton").style.display = "inline"; + document.getElementById("noButton").style.display = "inline"; + break; + } + } + + function hidePairingPanel() { + document.getElementById("pairingPanel").style.display = "none"; + pairingTextBlock.innerHTML = ""; + } + + function getPinFromUserAsync() { + hidePairingPanel(); + completeProvidePinTask(); + + showPairingPanel( + "Please enter the PIN shown on the device you're pairing with", + DevEnum.DevicePairingKinds.providePin); + + return new WinJS.Promise(function (c) { + providePinTaskSrc = c; + }); + } + + // If pin is not provided, then any pending pairing request is abandoned. + function completeProvidePinTask(pin) { + if (providePinTaskSrc) { + providePinTaskSrc(pin); + providePinTaskSrc = null; + } + } + + function getUserConfirmationAsync(pin) { + hidePairingPanel(); + completeConfirmPinTask(false); + + showPairingPanel( + "Does the following PIN match the one shown on the device you are pairing?: " + pin, + DevEnum.DevicePairingKinds.confirmPinMatch); + + return new WinJS.Promise(function (c) { + confirmPinTaskSrc = c; + }); + } + + // If pin is not provided, then any pending pairing request is abandoned. + function completeConfirmPinTask(accept) { + if (confirmPinTaskSrc) { + confirmPinTaskSrc(accept); + confirmPinTaskSrc = null; + } + } + + function okButton() { + // OK button is only used for the ProvidePin scenario + completeProvidePinTask(pinEntryTextBox.value); + hidePairingPanel(); + } + + function yesButton() { + completeConfirmPinTask(true); + hidePairingPanel(); + } + + function noButton() { + completeConfirmPinTask(false); + hidePairingPanel(); + } + + function GetSelectedCeremonies() { + var ceremonySelection = DevEnum.DevicePairingKinds.none; + + WinJS.Utilities.query(".win-checkbox").forEach(function (checkbox) { + if (checkbox.checked) { + switch (checkbox.id) { + case "confirmOnlyOption": + ceremonySelection |= DevEnum.DevicePairingKinds.confirmOnly; + break; + case "displayPinOption": + ceremonySelection |= DevEnum.DevicePairingKinds.displayPin; + break; + case "providePinOption": + ceremonySelection |= DevEnum.DevicePairingKinds.providePin; + break; + case "confirmPinMatchOption": + ceremonySelection |= DevEnum.DevicePairingKinds.confirmPinMatch; + break; + } + } + }); + + return ceremonySelection; + } + + function onSelectionChanged() { + updatePairingButtons(); + } + + function updatePairingButtons() { + + var selectedItems = resultsListView.selection.getIndices(); + var deviceDispInfo = null; + + if (selectedItems.length > 0) { + deviceDispInfo = resultCollection.getAt(selectedItems[0]); + } + + if (null != deviceDispInfo && + deviceDispInfo.canPair && + !deviceDispInfo.isPaired) { + pairButton.disabled = false; + } + else { + pairButton.disabled = true; + } + + if (null != deviceDispInfo && + deviceDispInfo.isPaired) { + unpairButton.disabled = false; + } + else { + unpairButton.disabled = true; + } + } +})(); diff --git a/Samples/DeviceEnumerationAndPairing/js/sample-utils/placeholder.txt b/Samples/DeviceEnumerationAndPairing/js/sample-utils/placeholder.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Samples/EnterpriseDataProtection/README.md b/Samples/EnterpriseDataProtection/README.md index af8916f8ec..b31c8e4176 100644 --- a/Samples/EnterpriseDataProtection/README.md +++ b/Samples/EnterpriseDataProtection/README.md @@ -21,7 +21,7 @@ This sample will not pass WACK because it uses a special-use capability. ## System requirements -Windows 10 +Windows 10 build 10500 or higher ## Build the sample diff --git a/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj b/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj index 979b2b6c9a..c66fd3b5cd 100644 --- a/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj +++ b/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj @@ -11,8 +11,8 @@ EDPSamples en-US UAP - 10.0.10240.0 - 10.0.10240.0 + 10.0.10586.0 + 10.0.10586.0 14 true 512 @@ -238,20 +238,17 @@ Assets\windows-sdk.png - - - Microsoft Desktop Extension SDK for Universal App Platform - - - Microsoft Mobile Extension SDK for Universal App Platform - - {95949f93-d529-46bf-80c4-89bf27aa4d47} Tasks + + + Windows Mobile Extensions for the UWP + + 14.0 diff --git a/Samples/EnterpriseDataProtection/cs/Package.appxmanifest b/Samples/EnterpriseDataProtection/cs/Package.appxmanifest index 15d5df16a4..de969af2cf 100644 --- a/Samples/EnterpriseDataProtection/cs/Package.appxmanifest +++ b/Samples/EnterpriseDataProtection/cs/Package.appxmanifest @@ -23,7 +23,7 @@ - + diff --git a/Samples/EnterpriseDataProtection/cs/Scenario16_NetworkResource.xaml b/Samples/EnterpriseDataProtection/cs/Scenario16_NetworkResource.xaml index d92ec65a05..1dc2e62365 100644 --- a/Samples/EnterpriseDataProtection/cs/Scenario16_NetworkResource.xaml +++ b/Samples/EnterpriseDataProtection/cs/Scenario16_NetworkResource.xaml @@ -49,10 +49,10 @@ Please input Enterprise Uri in the box provided - Domain: - + Identity: + UserName: - + Password: