From 1f2633eb0309bbb40da7f5ea38997619139e9755 Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Wed, 14 Oct 2015 17:08:46 -0700 Subject: [PATCH] Windows 10 RTM Release - October 2015 Update 2 --- README.md | 3 + Samples/Accelerometer/vb/Accelerometer.sln | 40 + Samples/Accelerometer/vb/Accelerometer.vbproj | 242 ++++++ Samples/Accelerometer/vb/Package.appxmanifest | 51 ++ .../Accelerometer/vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_DataEvents.xaml.vb | 134 +++ .../vb/Scenario2_ShakeEvents.xaml.vb | 126 +++ .../vb/Scenario3_Polling.xaml.vb | 139 ++++ .../vb/Scenario4_OrientationChanged.xaml.vb | 183 +++++ .../vb/Scenario5_DataEventsBatching.xaml.vb | 140 ++++ Samples/Accelerometer/vb/project.json | 16 + Samples/ActivitySensor/vb/ActivitySensor.sln | 60 ++ .../ActivitySensor/vb/ActivitySensor.vbproj | 242 ++++++ .../ActivitySensor/vb/Package.appxmanifest | 60 ++ .../ActivitySensor/vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_CurrentActivity.xaml.vb | 61 ++ .../vb/Scenario2_History.xaml.vb | 77 ++ .../vb/Scenario3_ChangeEvents.xaml.vb | 141 ++++ .../vb/Scenario4_BackgroundActivity.xaml.vb | 169 ++++ .../vb/Tasks/ActivitySensorBackgroundTask.vb | 59 ++ .../vb/Tasks/ActivitySensorTasks.vbproj | 156 ++++ Samples/ActivitySensor/vb/Tasks/project.json | 16 + Samples/ActivitySensor/vb/project.json | 16 + .../cs/AdaptiveStreaming.csproj | 12 +- .../{cs => shared}/Scenario1.xaml | 0 .../{cs => shared}/Scenario2.xaml | 0 .../{cs => shared}/Scenario3.xaml | 0 .../{cs => shared}/Scenario4.xaml | 0 .../vb/AdaptiveStreaming.sln | 40 + .../vb/AdaptiveStreaming.vbproj | 245 ++++++ .../AdaptiveStreaming/vb/Package.appxmanifest | 31 + .../vb/PlayReady/CommonLicenseRequest.vb | 56 ++ .../vb/SampleConfiguration.vb | 32 + .../AdaptiveStreaming/vb/Scenario1.xaml.vb | 39 + .../AdaptiveStreaming/vb/Scenario2.xaml.vb | 179 ++++ .../AdaptiveStreaming/vb/Scenario3.xaml.vb | 90 ++ .../AdaptiveStreaming/vb/Scenario4.xaml.vb | 235 ++++++ Samples/AdaptiveStreaming/vb/project.json | 16 + .../AdvancedCasting/cs/AdvancedCasting.csproj | 40 +- .../cs/ProjectionViewPage.xaml.cs | 28 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../{cs => shared}/01_MediaElement.xaml | 0 .../02_Casting_API_CastButton.xaml | 0 .../{cs => shared}/03_DIAL_Sender_API.xaml | 0 .../{cs => shared}/04_DIAL_Receiver_App.xaml | 0 .../05_Multi_View_Media_Application.xaml | 0 .../06_Combine_Casting_Tech.xaml | 0 .../AdvancedCasting/{cs => shared}/App.xaml | 0 .../{cs => shared}/MainPage.xaml | 0 ...portControlWithCustomCastButtonStyles.xaml | 0 ...ProjectedMediaTransportControlsStyles.xaml | 0 .../{cs => shared}/ProjectionViewPage.xaml | 2 +- .../UnhandledExceptionPage.xaml | 0 .../vb/01_MediaElement.xaml.vb | 61 ++ .../vb/02_Casting_API_CastButton.xaml.vb | 139 ++++ .../vb/03_DIAL_Sender_API.xaml.vb | 176 ++++ .../vb/04_DIAL_Receiver_App.xaml.vb | 102 +++ .../05_Multi_View_Media_Application.xaml.vb | 189 +++++ .../vb/06_Combine_Casting_Tech.xaml.vb | 420 ++++++++++ .../AdvancedCasting/vb/AdvancedCasting.sln | 40 + .../AdvancedCasting/vb/AdvancedCasting.vbproj | 292 +++++++ Samples/AdvancedCasting/vb/App.xaml.vb | 122 +++ ...iaTransportControlsWithCustomCastButton.vb | 51 ++ .../ProjectedMediaTransportControls.vb | 56 ++ .../vb/Controls/ProjectionViewBroker.vb | 43 + .../vb/Data/Azure/AzureDataProvider.vb | 97 +++ .../vb/Data/Common/ItemsDataProvider.vb | 27 + .../vb/Data/Common/VideoMetaData.vb | 35 + Samples/AdvancedCasting/vb/MainPage.xaml.vb | 153 ++++ .../AdvancedCasting/vb/Package.appxmanifest | 37 + .../vb/ProjectionViewPage.xaml.vb | 108 +++ .../AdvancedCasting/vb/SampleConfiguration.vb | 42 + .../vb/UnhandledExceptionPage.xaml.vb | 66 ++ .../AdvancedCasting/vb/Util/ApiInformation.vb | 30 + .../vb/Util/CustomDevicePickerFilter.vb | 47 ++ .../vb/Util/DialLaunchArguments.vb | 56 ++ .../vb/Util/RequiredDeviceProperties.vb | 67 ++ .../vb/Util/ViewLifetimeControl.vb | 236 ++++++ Samples/AdvancedCasting/vb/project.json | 16 + .../cs/AllJoynConsumerExperiences.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 25 - .../cs/AllJoynProducerExperiences.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 25 - Samples/Altimeter/vb/Altimeter.sln | 40 + Samples/Altimeter/vb/Altimeter.vbproj | 224 +++++ Samples/Altimeter/vb/Package.appxmanifest | 54 ++ Samples/Altimeter/vb/SampleConfiguration.vb | 31 + .../Altimeter/vb/Scenario1_DataEvents.xaml.vb | 132 +++ .../Altimeter/vb/Scenario2_Polling.xaml.vb | 53 ++ Samples/Altimeter/vb/project.json | 16 + .../AnimationMetrics/vb/AnimationMetrics.sln | 39 + .../vb/AnimationMetrics.vbproj | 225 +++++ .../AnimationMetrics/vb/Package.appxmanifest | 50 ++ .../vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_Metrics.xaml.vb | 122 +++ Samples/AnimationMetrics/vb/project.json | 16 + .../AppServicesClient.csproj | 6 +- .../AppServicesProvider.csproj | 5 +- .../KeepConnectionOpenScenario.xaml | 0 .../OpenCloseConnectionScenario.xaml | 0 .../ShowPackageFamilyName.xaml | 0 Samples/AppServices/vb/AppServices.sln | 81 ++ .../AppServicesClient.vbproj | 228 ++++++ .../KeepConnectionOpenScenario.xaml.vb | 145 ++++ .../OpenCloseConnectionScenario.xaml.vb | 112 +++ .../vb/AppServicesClient/Package.appxmanifest | 54 ++ .../AppServicesClient/SampleConfiguration.vb | 32 + .../vb/AppServicesClient/project.json | 16 + .../AppServicesProvider.vbproj | 226 ++++++ .../AppServicesProvider/Package.appxmanifest | 59 ++ .../SampleConfiguration.vb | 32 + .../ShowPackageFamilyName.xaml.vb | 36 + .../vb/AppServicesProvider/project.json | 16 + .../RandomNumberGeneratorTask.vb | 49 ++ .../RandomNumberService.vbproj | 158 ++++ .../vb/RandomNumberService/project.json | 17 + .../ApplicationData/cs/ApplicationData.csproj | 36 +- .../ApplicationData/{cs => shared}/App.xaml | 0 .../{cs => shared}/MainPage.xaml | 0 .../{cs => shared}/Scenario1_Files.xaml | 0 .../{cs => shared}/Scenario2_Settings.xaml | 0 .../Scenario3_SettingContainer.xaml | 0 .../Scenario4_CompositeSettings.xaml | 0 .../Scenario5_DataChangedEvent.xaml | 0 .../Scenario6_HighPriority.xaml | 0 .../{cs => shared}/Scenario7_Msappdata.xaml | 0 .../Scenario8_ClearScenario.xaml | 0 .../{cs => shared}/Scenario9_SetVersion.xaml | 0 .../{cs/Styles => shared}/Styles.xaml | 0 Samples/ApplicationData/vb/App.xaml.vb | 82 ++ .../ApplicationData/vb/ApplicationData.sln | 43 + .../ApplicationData/vb/ApplicationData.vbproj | 292 +++++++ .../vb/Assets/appDataLocal.png | Bin 0 -> 934 bytes .../vb/Assets/appDataRoaming.png | Bin 0 -> 1111 bytes .../ApplicationData/vb/Assets/appDataTemp.png | Bin 0 -> 994 bytes Samples/ApplicationData/vb/MainPage.xaml.vb | 107 +++ .../ApplicationData/vb/Package.appxmanifest | 31 + .../ApplicationData/vb/SampleConfiguration.vb | 35 + .../vb/Scenario1_Files.xaml.vb | 167 ++++ .../vb/Scenario2_Settings.xaml.vb | 60 ++ .../vb/Scenario3_SettingContainer.xaml.vb | 80 ++ .../vb/Scenario4_CompositeSettings.xaml.vb | 74 ++ .../vb/Scenario5_DataChangedEvent.xaml.vb | 84 ++ .../vb/Scenario6_HighPriority.xaml.vb | 83 ++ .../vb/Scenario7_Msappdata.xaml.vb | 67 ++ .../vb/Scenario8_ClearScenario.xaml.vb | 48 ++ .../vb/Scenario9_SetVersion.xaml.vb | 91 +++ .../ApplicationData/vb/SuspensionManager.vb | 221 +++++ Samples/ApplicationData/vb/project.json | 16 + .../AppResourceClassLibrary.vbproj | 171 ++++ .../vb/AppResourceClassLibrary/class1.vb | 30 + .../vb/AppResourceClassLibrary/project.json | 17 + .../vb/ApplicationResources.sln | 59 ++ .../vb/ApplicationResources.vbproj | 584 +++++++++++++ .../vb/Package.appxmanifest | 31 + Samples/ApplicationResources/vb/constants.vb | 35 + .../vb/languageoverride.xaml | 17 + .../vb/languageoverride.xaml.vb | 89 ++ Samples/ApplicationResources/vb/project.json | 16 + .../ApplicationResources/vb/scenario1.xaml | 58 ++ .../ApplicationResources/vb/scenario1.xaml.vb | 38 + .../ApplicationResources/vb/scenario10.xaml | 114 +++ .../vb/scenario10.xaml.vb | 112 +++ .../ApplicationResources/vb/scenario11.xaml | 66 ++ .../vb/scenario11.xaml.vb | 53 ++ .../ApplicationResources/vb/scenario12.xaml | 86 ++ .../vb/scenario12.xaml.vb | 73 ++ .../ApplicationResources/vb/scenario13.xaml | 74 ++ .../vb/scenario13.xaml.vb | 66 ++ .../ApplicationResources/vb/scenario2.xaml | 91 +++ .../ApplicationResources/vb/scenario2.xaml.vb | 38 + .../ApplicationResources/vb/scenario3.xaml | 53 ++ .../ApplicationResources/vb/scenario3.xaml.vb | 54 ++ .../ApplicationResources/vb/scenario4.xaml | 55 ++ .../ApplicationResources/vb/scenario4.xaml.vb | 38 + .../ApplicationResources/vb/scenario5.xaml | 55 ++ .../ApplicationResources/vb/scenario5.xaml.vb | 54 ++ .../ApplicationResources/vb/scenario6.xaml | 58 ++ .../ApplicationResources/vb/scenario6.xaml.vb | 55 ++ .../ApplicationResources/vb/scenario7.xaml | 74 ++ .../ApplicationResources/vb/scenario7.xaml.vb | 61 ++ .../ApplicationResources/vb/scenario8.xaml | 89 ++ .../ApplicationResources/vb/scenario8.xaml.vb | 79 ++ .../ApplicationResources/vb/scenario9.xaml | 68 ++ .../ApplicationResources/vb/scenario9.xaml.vb | 85 ++ Samples/Appointments/cs/Appointments.csproj | 18 +- .../{cs => shared}/Scenario1_Define.xaml | 0 .../{cs => shared}/Scenario2_Add.xaml | 0 .../{cs => shared}/Scenario3_Replace.xaml | 0 .../{cs => shared}/Scenario4_Remove.xaml | 0 .../{cs => shared}/Scenario5_Show.xaml | 0 .../{cs => shared}/Scenario6_Recurrence.xaml | 0 Samples/Appointments/vb/Appointments.sln | 40 + Samples/Appointments/vb/Appointments.vbproj | 260 ++++++ Samples/Appointments/vb/Package.appxmanifest | 31 + .../Appointments/vb/SampleConfiguration.vb | 39 + .../Appointments/vb/Scenario1_Define.xaml.vb | 205 +++++ Samples/Appointments/vb/Scenario2_Add.xaml.vb | 48 ++ .../Appointments/vb/Scenario3_Replace.xaml.vb | 64 ++ .../Appointments/vb/Scenario4_Remove.xaml.vb | 60 ++ .../Appointments/vb/Scenario5_Show.xaml.vb | 39 + .../vb/Scenario6_Recurrence.xaml.vb | 113 +++ Samples/Appointments/vb/project.json | 16 + .../cs/AssociationLaunching.csproj | 12 +- .../cs/SampleConfiguration.cs | 11 + .../cs/Scenario1_LaunchFile.xaml.cs | 27 +- .../cs/Scenario2_LaunchUri.xaml.cs | 27 +- .../{cs => shared}/Scenario1_LaunchFile.xaml | 9 +- .../{cs => shared}/Scenario2_LaunchUri.xaml | 9 +- .../{cs => shared}/Scenario3_ReceiveFile.xaml | 0 .../{cs => shared}/Scenario4_ReceiveUri.xaml | 0 Samples/AssociationLaunching/vb/App.xaml.vb | 123 +++ .../vb/AssociationLaunching.sln | 40 + .../vb/AssociationLaunching.vbproj | 242 ++++++ .../AssociationLaunching/vb/MainPage.xaml.vb | 145 ++++ .../vb/Package.appxmanifest | 43 + .../vb/SampleConfiguration.vb | 42 + .../vb/Scenario1_LaunchFile.xaml.vb | 162 ++++ .../vb/Scenario2_LaunchUri.xaml.vb | 137 ++++ .../vb/Scenario3_ReceiveFile.xaml.vb | 49 ++ .../vb/Scenario4_ReceiveUri.xaml.vb | 43 + Samples/AssociationLaunching/vb/project.json | 16 + .../cs/AudioCategory/AudioCategory.csproj | 33 +- .../PlaybackControl.xaml | 0 .../AudioCategory => shared}/Scenario1.xaml | 2 +- .../AudioCategory => shared}/Scenario10.xaml | 2 +- .../AudioCategory => shared}/Scenario2.xaml | 2 +- .../AudioCategory => shared}/Scenario3.xaml | 2 +- .../AudioCategory => shared}/Scenario4.xaml | 2 +- .../AudioCategory => shared}/Scenario5.xaml | 2 +- .../AudioCategory => shared}/Scenario6.xaml | 2 +- .../AudioCategory => shared}/Scenario7.xaml | 2 +- .../AudioCategory => shared}/Scenario8.xaml | 2 +- .../AudioCategory => shared}/Scenario9.xaml | 2 +- .../vb/AudioCategory/AudioCategory.sln | 40 + .../vb/AudioCategory/AudioCategory.vbproj | 278 +++++++ .../vb/AudioCategory/Package.appxmanifest | 54 ++ .../vb/AudioCategory/PlaybackControl.xaml.vb | 186 +++++ .../vb/AudioCategory/SampleConfiguration.vb | 34 + .../vb/AudioCategory/Scenario1.xaml.vb | 34 + .../vb/AudioCategory/Scenario10.xaml.vb | 34 + .../vb/AudioCategory/Scenario2.xaml.vb | 34 + .../vb/AudioCategory/Scenario3.xaml.vb | 34 + .../vb/AudioCategory/Scenario4.xaml.vb | 34 + .../vb/AudioCategory/Scenario5.xaml.vb | 34 + .../vb/AudioCategory/Scenario6.xaml.vb | 34 + .../vb/AudioCategory/Scenario7.xaml.vb | 34 + .../vb/AudioCategory/Scenario8.xaml.vb | 34 + .../vb/AudioCategory/Scenario9.xaml.vb | 34 + .../vb/AudioCategory/project.json | 16 + .../AudioCategoryCompanion.sln | 40 + .../AudioCategoryCompanion.vbproj | 300 +++++++ .../Package.appxmanifest | 54 ++ .../vb/AudioCategoryCompanion/project.json | 16 + .../cs/AudioCreation/AudioCreation.csproj | 6 +- .../AudioCreation/Properties/AssemblyInfo.cs | 29 - Samples/BackButton/cs/SystemBack.csproj | 6 +- .../BackButton/{cs => shared}/Scenario1.xaml | 0 .../{cs => shared}/SecondaryPage.xaml | 0 Samples/BackButton/vb/App.xaml.vb | 96 +++ Samples/BackButton/vb/MainPage.xaml.vb | 116 +++ Samples/BackButton/vb/Package.appxmanifest | 54 ++ Samples/BackButton/vb/SampleConfiguration.vb | 31 + Samples/BackButton/vb/Scenario1.xaml.vb | 46 ++ Samples/BackButton/vb/SecondaryPage.xaml.vb | 43 + Samples/BackButton/vb/SystemBack.sln | 40 + Samples/BackButton/vb/SystemBack.vbproj | 223 +++++ Samples/BackButton/vb/project.json | 16 + .../cs/BackgroundAudio/BackgroundAudio.csproj | 12 +- .../Properties/AssemblyInfo.cs | 29 - .../cs/BackgroundAudio/Scenario1.xaml.cs | 130 ++- .../Views => shared}/PlaylistView.xaml | 0 .../BackgroundAudio => shared}/Scenario1.xaml | 0 .../BackgroundAudio/vb/BackgroundAudio.sln | 68 ++ .../vb/BackgroundAudio/BackgroundAudio.vbproj | 268 ++++++ .../vb/BackgroundAudio/Package.appxmanifest | 38 + .../vb/BackgroundAudio/SampleConfiguration.vb | 32 + .../vb/BackgroundAudio/Scenario1.xaml.vb | 362 +++++++++ .../Views/PlaylistView.xaml.vb | 95 +++ .../vb/BackgroundAudio/project.json | 16 + .../vb/BackgroundAudioShared/AppState.vb | 24 + .../ApplicationSettingsConstants.vb | 36 + .../ApplicationSettingsHelper.vb | 53 ++ .../BackgroundAudioShared.vbproj | 174 ++++ .../BackgroundTaskState.vb | 25 + .../vb/BackgroundAudioShared/EnumHelper.vb | 31 + .../vb/BackgroundAudioShared/JsonHelper.vb | 60 ++ .../Messages/AppResumedMessage.vb | 34 + .../Messages/AppSuspendedMessage.vb | 34 + .../BackgroundAudioTaskStartedMessage.vb | 23 + .../Messages/MessageService.vb | 74 ++ .../Messages/SkipNextMessage.vb | 23 + .../Messages/SkipPreviousMessage.vb | 23 + .../Messages/StartPlaybackMessage.vb | 23 + .../Messages/TrackChangedMessage.vb | 33 + .../Messages/UpdatePlaylistMessage.vb | 30 + .../BackgroundAudioShared/Models/SongModel.vb | 36 + .../vb/BackgroundAudioShared/project.json | 16 + .../BackgroundAudioTask.vbproj | 162 ++++ .../MyBackgroundAudioTask.vb | 409 ++++++++++ .../vb/BackgroundAudioTask/project.json | 16 + .../cs/BackgroundSensors.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../vb/BackgroundSensors.sln | 54 ++ .../vb/BackgroundSensors.vbproj | 226 ++++++ .../vb/BackgroundTask/BackgroundTask.vbproj | 156 ++++ .../Scenario1_BackgroundTask.vb | 80 ++ .../vb/BackgroundTask/project.json | 16 + .../BackgroundSensors/vb/Package.appxmanifest | 57 ++ .../vb/SampleConfiguration.vb | 29 + .../vb/Scenario1_DeviceUse.xaml.vb | 230 ++++++ Samples/BackgroundSensors/vb/project.json | 16 + Samples/BackgroundTask/vb/BackgroundTask.sln | 57 ++ .../vb/BackgroundTask/BackgroundTask.vbproj | 258 ++++++ .../vb/BackgroundTask/Package.appxmanifest | 70 ++ .../vb/BackgroundTask/SampleConfiguration.vb | 183 +++++ .../Scenario1_SampleBackgroundTask.xaml.vb | 116 +++ ..._SampleBackgroundTaskWithCondition.xaml.vb | 114 +++ .../Scenario3_ServicingCompleteTask.xaml.vb | 114 +++ .../Scenario4_TimeTriggeredTask.xaml.vb | 114 +++ .../Scenario5_ApplicationTriggerTask.xaml.vb | 135 +++ .../vb/BackgroundTask/project.json | 16 + .../vb/Tasks/SampleBackgroundTask.vb | 83 ++ .../vb/Tasks/ServicingComplete.vb | 58 ++ Samples/BackgroundTask/vb/Tasks/Tasks.vbproj | 160 ++++ Samples/BackgroundTask/vb/Tasks/project.json | 16 + .../BackgroundTransfer.csproj | 4 +- .../Properties/AssemblyInfo.cs | 29 - .../vb/BackgroundTransfer.sln | 57 ++ .../BackgroundTransfer.vbproj | 250 ++++++ .../BackgroundTransfer/Package.appxmanifest | 63 ++ .../BackgroundTransfer/SampleConfiguration.vb | 32 + .../Scenario1_Download.xaml.vb | 274 +++++++ .../Scenario2_Upload.xaml.vb | 270 ++++++ .../Scenario3_Notifications.xaml.vb | 218 +++++ .../Scenario4_CompletionGroups.xaml.vb | 86 ++ .../vb/BackgroundTransfer/project.json | 16 + .../vb/Server/RemoveServer.ps1 | 57 ++ .../vb/Server/SetupServer.ps1 | 77 ++ .../vb/Server/website/bitmap.aspx | 84 ++ .../vb/Server/website/data/windows-sdk.png | Bin 0 -> 2997 bytes .../vb/Server/website/download.aspx | 106 +++ .../vb/Server/website/notifications.aspx | 58 ++ .../vb/Server/website/upload.aspx | 55 ++ .../vb/Server/website/web.config | 21 + .../vb/Tasks/CompletionGroupTask.vb | 98 +++ .../BackgroundTransfer/vb/Tasks/Tasks.vbproj | 159 ++++ .../BackgroundTransfer/vb/Tasks/project.json | 16 + .../BarcodeScanner/cpp/BarcodeScanner.vcxproj | 12 +- .../cpp/BarcodeScanner.vcxproj.filters | 4 +- .../BarcodeScanner/cpp/Package.appxmanifest | 6 +- .../BarcodeScanner/cs/BarcodeScanner.csproj | 12 +- .../BarcodeScanner/cs/Package.appxmanifest | 6 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../BarcodeScanner/cs/SampleConfiguration.cs | 1 - .../cs/Scenario1_BasicFunctionality.xaml | 70 -- .../cs/Scenario1_BasicFunctionality.xaml.cs | 10 +- .../cs/Scenario2_MultipleScanners.xaml | 125 --- .../cs/Scenario2_MultipleScanners.xaml.cs | 14 +- .../Scenario1_BasicFunctionality.xaml | 0 .../Scenario2_MultipleScanners.xaml | 0 Samples/BarcodeScanner/vb/BarcodeScanner.sln | 40 + .../BarcodeScanner/vb/BarcodeScanner.vbproj | 228 ++++++ .../BarcodeScanner/vb/Package.appxmanifest | 54 ++ .../BarcodeScanner/vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_BasicFunctionality.xaml.vb | 218 +++++ .../vb/Scenario2_MultipleScanners.xaml.vb | 420 ++++++++++ Samples/BarcodeScanner/vb/project.json | 16 + Samples/Barometer/cpp/Barometer.vcxproj | 12 +- .../Barometer/cpp/Barometer.vcxproj.filters | 4 +- Samples/Barometer/cpp/Package.appxmanifest | 10 +- Samples/Barometer/cs/Barometer.csproj | 10 +- Samples/Barometer/cs/Package.appxmanifest | 10 +- Samples/Barometer/cs/SampleConfiguration.cs | 7 +- .../Barometer/cs/Scenario1_DataEvents.xaml | 34 - .../Barometer/cs/Scenario1_DataEvents.xaml.cs | 3 +- Samples/Barometer/cs/Scenario2_Polling.xaml | 33 - .../Barometer/cs/Scenario2_Polling.xaml.cs | 3 +- .../{cpp => shared}/Scenario1_DataEvents.xaml | 0 .../{cpp => shared}/Scenario2_Polling.xaml | 0 Samples/Barometer/vb/Barometer.sln | 40 + Samples/Barometer/vb/Barometer.vbproj | 224 +++++ Samples/Barometer/vb/Package.appxmanifest | 28 + Samples/Barometer/vb/SampleConfiguration.vb | 31 + .../Barometer/vb/Scenario1_DataEvents.xaml.vb | 132 +++ .../Barometer/vb/Scenario2_Polling.xaml.vb | 53 ++ Samples/Barometer/vb/project.json | 16 + .../cs/BasicFaceDetection.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 40 - .../vb/Assets/placeholder.txt | 0 .../vb/BasicFaceDetection.sln | 40 + .../vb/BasicFaceDetection.vbproj | 228 ++++++ .../vb/Package.appxmanifest | 54 ++ .../vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_DetectInPhoto.xaml.vb | 209 +++++ .../vb/Scenario2_DetectInWebcam.xaml.vb | 330 ++++++++ .../vb/Styles/placeholder.txt | 0 Samples/BasicFaceDetection/vb/project.json | 16 + .../cs/BasicFaceTracking.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 40 - .../vb/Assets/placeholder.txt | 0 .../vb/BasicFaceTracking.sln | 40 + .../vb/BasicFaceTracking.vbproj | 220 +++++ .../BasicFaceTracking/vb/Package.appxmanifest | 54 ++ .../vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_TrackInWebcam.xaml.vb | 272 +++++++ .../vb/Styles/placeholder.txt | 0 Samples/BasicFaceTracking/vb/project.json | 16 + Samples/BasicInput/cs/BasicInput.csproj | 15 +- .../{cs => shared}/1-InputEvents.xaml | 0 .../2-PointerPointProperties.xaml | 0 .../{cs => shared}/3-DeviceCapabilities.xaml | 0 .../{cs => shared}/4-XAMLManipulations.xaml | 0 .../{cs => shared}/5-GestureRecognizer.xaml | 0 Samples/BasicInput/vb/1-InputEvents.xaml.vb | 80 ++ .../vb/2-PointerPointProperties.xaml.vb | 174 ++++ .../vb/3-DeviceCapabilities.xaml.vb | 49 ++ .../BasicInput/vb/4-XAMLManipulations.xaml.vb | 113 +++ .../BasicInput/vb/5-GestureRecognizer.xaml.vb | 194 +++++ Samples/BasicInput/vb/BasicInput.sln | 40 + Samples/BasicInput/vb/BasicInput.vbproj | 251 ++++++ Samples/BasicInput/vb/Package.appxmanifest | 54 ++ Samples/BasicInput/vb/SampleConfiguration.vb | 32 + Samples/BasicInput/vb/project.json | 16 + .../cs/BasicMediaCasting.csproj | 9 +- .../Scenario1_BuiltInCasting.xaml | 0 .../Scenario2_CastingDevicePicker.xaml | 0 .../Scenario3_CustomPicker.xaml | 0 .../vb/BasicMediaCasting.sln | 40 + .../vb/BasicMediaCasting.vbproj | 236 ++++++ .../BasicMediaCasting/vb/Package.appxmanifest | 31 + .../vb/SampleConfiguration.vb | 32 + .../vb/Scenario1_BuiltInCasting.xaml.vb | 50 ++ .../vb/Scenario2_CastingDevicePicker.xaml.vb | 88 ++ .../vb/Scenario3_CustomPicker.xaml.vb | 160 ++++ Samples/BasicMediaCasting/vb/project.json | 16 + .../cs/BluetoothAdvertisement.csproj | 14 +- .../{cs => shared}/Scenario1_Watcher.xaml | 0 .../{cs => shared}/Scenario2_Publisher.xaml | 0 .../Scenario3_BackgroundWatcher.xaml | 0 .../Scenario4_BackgroundPublisher.xaml | 0 .../vb/BluetoothAdvertisement.sln | 54 ++ .../vb/BluetoothAdvertisement.vbproj | 251 ++++++ .../vb/Package.appxmanifest | 65 ++ .../vb/SampleConfiguration.vb | 32 + .../vb/Scenario1_Watcher.xaml.vb | 188 +++++ .../vb/Scenario2_Publisher.xaml.vb | 145 ++++ .../vb/Scenario3_BackgroundWatcher.xaml.vb | 222 +++++ .../vb/Scenario4_BackgroundPublisher.xaml.vb | 206 +++++ .../vb/Tasks/AdvertisementBackgroundTasks.vb | 102 +++ .../vb/Tasks/Tasks.vbproj | 159 ++++ .../vb/Tasks/project.json | 16 + .../BluetoothAdvertisement/vb/project.json | 16 + Samples/Calendar/vb/Calendar.sln | 40 + Samples/Calendar/vb/Calendar.vbproj | 250 ++++++ Samples/Calendar/vb/Package.appxmanifest | 50 ++ Samples/Calendar/vb/SampleConfiguration.vb | 31 + Samples/Calendar/vb/Scenario1_Data.xaml.vb | 44 + Samples/Calendar/vb/Scenario2_Stats.xaml.vb | 45 + Samples/Calendar/vb/Scenario3_Enum.xaml.vb | 104 +++ .../vb/Scenario4_UnicodeExtensions.xaml.vb | 51 ++ .../Calendar/vb/Scenario5_TimeZone.xaml.vb | 72 ++ Samples/Calendar/vb/project.json | 16 + .../cpp/CameraFaceDetection.vcxproj | 12 +- .../cpp/CameraFaceDetection.vcxproj.filters | 4 +- .../cpp/Package.appxmanifest | 6 +- Samples/CameraFaceDetection/cs/App.xaml.cs | 2 +- .../cs/CameraFaceDetection.csproj | 10 +- Samples/CameraFaceDetection/cs/MainPage.xaml | 80 -- .../CameraFaceDetection/cs/MainPage.xaml.cs | 2 +- .../cs/Package.appxmanifest | 6 +- .../{cpp => shared}/App.xaml | 0 .../{cpp => shared}/MainPage.xaml | 0 Samples/CameraFaceDetection/vb/App.xaml.vb | 65 ++ .../vb/CameraFaceDetection.sln | 39 + .../vb/CameraFaceDetection.vbproj | 203 +++++ .../CameraFaceDetection/vb/MainPage.xaml.vb | 767 ++++++++++++++++++ .../vb/Package.appxmanifest | 55 ++ Samples/CameraFaceDetection/vb/project.json | 16 + Samples/CameraHdr/cpp/CameraHdr.vcxproj | 15 +- .../CameraHdr/cpp/CameraHdr.vcxproj.filters | 4 +- Samples/CameraHdr/cpp/Package.appxmanifest | 6 +- Samples/CameraHdr/cs/App.xaml | 20 - Samples/CameraHdr/cs/CameraHdr.csproj | 8 +- Samples/CameraHdr/cs/MainPage.xaml | 86 -- Samples/CameraHdr/cs/Package.appxmanifest | 6 +- Samples/CameraHdr/{cpp => shared}/App.xaml | 0 .../CameraHdr/{cpp => shared}/MainPage.xaml | 0 Samples/CameraHdr/vb/App.xaml.vb | 65 ++ Samples/CameraHdr/vb/CameraHdr.sln | 39 + Samples/CameraHdr/vb/CameraHdr.vbproj | 204 +++++ Samples/CameraHdr/vb/MainPage.xaml.vb | 708 ++++++++++++++++ Samples/CameraHdr/vb/Package.appxmanifest | 55 ++ Samples/CameraHdr/vb/project.json | 16 + Samples/CameraResolution/README.md | 4 +- .../cpp/CameraStarterKit.vcxproj | 12 +- .../cpp/CameraStarterKit.vcxproj.filters | 4 +- .../CameraStarterKit/cpp/Package.appxmanifest | 6 +- .../cs/CameraStarterKit.csproj | 6 +- Samples/CameraStarterKit/cs/MainPage.xaml | 60 -- .../CameraStarterKit/cs/Package.appxmanifest | 6 +- .../CameraStarterKit/{cpp => shared}/App.xaml | 0 .../{cpp => shared}/MainPage.xaml | 0 Samples/CameraStarterKit/vb/App.xaml.vb | 65 ++ .../CameraStarterKit/vb/CameraStarterKit.sln | 39 + .../vb/CameraStarterKit.vbproj | 204 +++++ Samples/CameraStarterKit/vb/MainPage.xaml.vb | 584 +++++++++++++ .../CameraStarterKit/vb/Package.appxmanifest | 55 ++ Samples/CameraStarterKit/vb/project.json | 16 + .../cpp/CameraVideoStabilization.vcxproj | 12 +- .../CameraVideoStabilization.vcxproj.filters | 4 +- .../cpp/Package.appxmanifest | 6 +- .../cs/CameraVideoStabilization.csproj | 6 +- .../CameraVideoStabilization/cs/MainPage.xaml | 79 -- .../cs/Package.appxmanifest | 6 +- .../{cpp => shared}/App.xaml | 0 .../{cpp => shared}/MainPage.xaml | 0 .../CameraVideoStabilization/vb/App.xaml.vb | 65 ++ .../vb/CameraVideoStabilization.sln | 39 + .../vb/CameraVideoStabilization.vbproj | 204 +++++ .../vb/MainPage.xaml.vb | 640 +++++++++++++++ .../vb/Package.appxmanifest | 55 ++ .../CameraVideoStabilization/vb/project.json | 16 + Samples/CashDrawer/cpp/CashDrawer.vcxproj | 18 +- .../CashDrawer/cpp/CashDrawer.vcxproj.filters | 6 +- Samples/CashDrawer/cpp/Package.appxmanifest | 6 +- Samples/CashDrawer/cs/CashDrawer.csproj | 15 +- Samples/CashDrawer/cs/Package.appxmanifest | 6 +- .../CashDrawer/cs/Properties/AssemblyInfo.cs | 29 - Samples/CashDrawer/cs/SampleConfiguration.cs | 1 - .../CashDrawer/cs/Scenario1_OpenDrawer.xaml | 60 -- .../cs/Scenario1_OpenDrawer.xaml.cs | 6 +- .../CashDrawer/cs/Scenario2_CloseDrawer.xaml | 64 -- .../cs/Scenario2_CloseDrawer.xaml.cs | 5 +- .../cs/Scenario3_MultipleDrawers.xaml | 101 --- .../cs/Scenario3_MultipleDrawers.xaml.cs | 9 +- .../{cpp => shared}/Scenario1_OpenDrawer.xaml | 0 .../Scenario2_CloseDrawer.xaml | 0 .../Scenario3_MultipleDrawers.xaml | 0 Samples/CashDrawer/vb/CashDrawer.sln | 40 + Samples/CashDrawer/vb/CashDrawer.vbproj | 236 ++++++ Samples/CashDrawer/vb/Package.appxmanifest | 55 ++ Samples/CashDrawer/vb/SampleConfiguration.vb | 31 + .../vb/Scenario1_OpenDrawer.xaml.vb | 169 ++++ .../vb/Scenario2_CloseDrawer.xaml.vb | 208 +++++ .../vb/Scenario3_MultipleDrawers.xaml.vb | 282 +++++++ Samples/CashDrawer/vb/project.json | 16 + Samples/Clipboard/vb/Clipboard.sln | 39 + Samples/Clipboard/vb/Clipboard.vbproj | 244 ++++++ Samples/Clipboard/vb/CopyFiles.xaml.vb | 107 +++ Samples/Clipboard/vb/CopyImage.xaml.vb | 137 ++++ Samples/Clipboard/vb/CopyText.xaml.vb | 136 ++++ Samples/Clipboard/vb/Others.xaml.vb | 92 +++ Samples/Clipboard/vb/Package.appxmanifest | 54 ++ Samples/Clipboard/vb/SampleConfiguration.vb | 92 +++ Samples/Clipboard/vb/project.json | 16 + Samples/Compass/cpp/Compass.vcxproj | 24 +- Samples/Compass/cpp/Compass.vcxproj.filters | 8 +- Samples/Compass/cpp/Package.appxmanifest | 10 +- Samples/Compass/cs/CalibrationBar.xaml | 125 --- Samples/Compass/cs/CalibrationBar.xaml.cs | 2 +- Samples/Compass/cs/Compass.csproj | 16 +- Samples/Compass/cs/Package.appxmanifest | 10 +- Samples/Compass/cs/SampleConfiguration.cs | 7 +- Samples/Compass/cs/Scenario1_DataEvents.xaml | 40 - .../Compass/cs/Scenario1_DataEvents.xaml.cs | 11 +- Samples/Compass/cs/Scenario2_Polling.xaml | 40 - Samples/Compass/cs/Scenario2_Polling.xaml.cs | 11 +- Samples/Compass/cs/Scenario3_Calibration.xaml | 26 - .../Compass/cs/Scenario3_Calibration.xaml.cs | 12 +- .../{cpp => shared}/CalibrationBar.xaml | 0 .../{cpp => shared}/Scenario1_DataEvents.xaml | 0 .../{cpp => shared}/Scenario2_Polling.xaml | 0 .../Scenario3_Calibration.xaml | 0 Samples/Compass/vb/CalibrationBar.xaml.vb | 199 +++++ Samples/Compass/vb/Compass.sln | 40 + Samples/Compass/vb/Compass.vbproj | 239 ++++++ Samples/Compass/vb/Package.appxmanifest | 49 ++ Samples/Compass/vb/SampleConfiguration.vb | 31 + .../Compass/vb/Scenario1_DataEvents.xaml.vb | 150 ++++ Samples/Compass/vb/Scenario2_Polling.xaml.vb | 155 ++++ .../Compass/vb/Scenario3_Calibration.xaml.vb | 84 ++ Samples/Compass/vb/project.json | 16 + .../vb/CompositionVisual.sln | 39 + .../vb/CompositionVisual.vbproj | 188 +++++ .../CompositionVisual/vb/Package.appxmanifest | 54 ++ .../CompositionVisual/vb/VisualProperties.vb | 206 +++++ Samples/CompositionVisual/vb/project.json | 16 + Samples/Compression/cs/Compression.csproj | 4 +- .../Compression/cs/Properties/AssemblyInfo.cs | 29 - .../DatagramSocket/cs/DatagramSocket.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/DpiScaling/cs/DpiScaling.csproj | 4 +- .../DpiScaling/cs/Properties/AssemblyInfo.cs | 29 - .../cs/EnterpriseDataProtection.csproj | 6 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/FileAccess/cs/FileAccess.csproj | 4 +- .../FileAccess/cs/Properties/AssemblyInfo.cs | 29 - .../FullScreenMode/cs/FullScreenMode.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/Geotag/cs/Geotag.csproj | 4 +- Samples/Geotag/cs/Properties/AssemblyInfo.cs | 29 - .../cs/GlobalizationPreferences.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/HomeGroup/cs/HomeGroup.csproj | 4 +- .../HomeGroup/cs/Properties/AssemblyInfo.cs | 29 - .../cs/HttpClient/HttpClient.csproj | 6 +- .../cs/HttpClient/Properties/AssemblyInfo.cs | 29 - Samples/Json/cs/Json.csproj | 4 +- Samples/Json/cs/Properties/AssemblyInfo.cs | 29 - Samples/LiveDash/cs/LiveDash/LiveDash.csproj | 4 +- .../cs/LiveDash/Properties/AssemblyInfo.cs | 29 - Samples/Logging/cs/Logging.csproj | 4 +- Samples/Logging/cs/Properties/AssemblyInfo.cs | 29 - .../cs/MagneticStripeReader.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/MapControl/README.md | 2 +- Samples/MediaImport/cs/Import.csproj | 4 +- .../MediaImport/cs/Properties/AssemblyInfo.cs | 29 - Samples/Nfc/PcscSdk/PcscSdk.csproj | 4 +- .../Nfc/PcscSdk/Properties/AssemblyInfo.cs | 29 - .../cs/Notifications/Notifications.csproj | 10 +- .../Notifications/Properties/AssemblyInfo.cs | 29 - .../cs/NumberFormatting.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/Package/README.md | 6 +- Samples/PhoneCall/cs/PhoneCall.csproj | 12 +- .../PhoneCall/cs/Properties/AssemblyInfo.cs | 29 - .../PhoneCall/cs/Properties/Default.rd.xml | 31 - Samples/PosPrinter/cs/PosPrinter.csproj | 4 +- .../PosPrinter/cs/Properties/AssemblyInfo.cs | 29 - Samples/Printing/cs/Printing.csproj | 4 +- .../Printing/cs/Properties/AssemblyInfo.cs | 29 - .../Projection/cpp/ViewLifetimeControl.cpp | 7 +- Samples/Projection/cpp/ViewLifetimeControl.h | 7 + Samples/Projection/cs/App.xaml | 34 - Samples/Projection/cs/Projection.csproj | 10 +- .../Projection/cs/Properties/AssemblyInfo.cs | 29 - Samples/Projection/cs/ViewLifetimeControl.cs | 9 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/ResizeAppView/cs/ResizeAppView.csproj | 4 +- Samples/ShareSource/README.md | 2 +- Samples/ShareTarget/README.md | 2 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../Properties/AssemblyInfo.cs | 29 - .../SmsSendAndReceive.csproj | 6 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../cs/SpeechAndTTS.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/StreamSocket/cs/StreamSocket.csproj | 4 +- .../Syndication/cs/Properties/AssemblyInfo.cs | 29 - Samples/Syndication/cs/Syndication.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../cs/TextSegmentation.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../TextSuggestion/cs/TextSuggestion.csproj | 4 +- .../TitleBar/cs/Properties/AssemblyInfo.cs | 29 - Samples/TitleBar/cs/TitleBar.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - Samples/TouchKeyboard/cs/TouchKeyboard.csproj | 4 +- Samples/TouchKeyboardTextInput/README.md | 75 ++ .../Scenario1_SpellingTextSuggestions.xaml | 82 ++ .../Shared/Scenario2_ScopedViews.xaml | 146 ++++ .../cpp/Package.appxmanifest | 49 ++ .../cpp/SampleConfiguration.cpp} | 18 +- .../cpp/SampleConfiguration.h | 47 ++ ...Scenario1_SpellingTextSuggestions.xaml.cpp | 32 + .../Scenario1_SpellingTextSuggestions.xaml.h} | 24 +- .../cpp/Scenario2_ScopedViews.xaml.cpp | 33 + .../cpp/Scenario2_ScopedViews.xaml.h} | 24 +- .../cpp/TouchKeyboardTextInput.sln | 40 + .../cpp/TouchKeyboardTextInput.vcxproj | 230 ++++++ .../TouchKeyboardTextInput.vcxproj.filters | 65 ++ Samples/TouchKeyboardTextInput/cpp/pch.cpp | 5 + Samples/TouchKeyboardTextInput/cpp/pch.h | 10 + .../cs/Package.appxmanifest | 51 ++ .../cs/SampleConfiguration.cs | 34 + .../Scenario1_SpellingTextSuggestions.xaml.cs | 31 + .../cs/Scenario2_ScopedViews.xaml.cs | 28 + .../cs/TouchKeyboardTextInput.csproj | 182 +++++ .../cs/TouchKeyboardTextInput.sln | 40 + .../TouchKeyboardTextInput/cs/project.json | 16 + Samples/Unicode/cs/Properties/AssemblyInfo.cs | 29 - Samples/Unicode/cs/Unicode.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 29 - .../cs/UserInteractionMode.csproj | 4 +- .../VoIP/cs/Voip/Properties/AssemblyInfo.cs | 29 - Samples/VoIP/cs/Voip/Voip.csproj | 4 +- .../cs/Properties/AssemblyInfo.cs | 28 - .../cs/WebAccountManagement.csproj | 4 +- .../WebSocket/cs/Properties/AssemblyInfo.cs | 29 - Samples/WebSocket/cs/WebSocket.csproj | 4 +- .../cs/CustomMediaTransportControls.csproj | 4 +- .../cs/Properties/Default.rd.xml | 31 - Samples/XamlListView/cs/ListView.csproj | 4 +- .../XamlListView/cs/Properties/Default.rd.xml | 31 - .../XamlNavigation/cs/NavigationMenu.csproj | 4 +- .../cs/Properties/Default.rd.xml | 31 - .../cs/Properties/Default.rd.xml | 31 - .../XamlPullToRefresh/cs/PullToRefresh.csproj | 4 +- .../cs/Properties/Default.rd.xml | 31 - .../cs/ResponsiveTechniques.csproj | 4 +- .../cs/Properties/Default.rd.xml | 31 - .../XamlStateTriggers/cs/StateTriggers.csproj | 4 +- .../OneHandedUse_TailoredMultipleViews.csproj | 6 +- .../Properties/Default.rd.xml | 31 - .../cs/Properties/Default.rd.xml | 31 - .../cs/Transform3DAnimations.csproj | 4 +- SharedContent/vb/App.xaml.vb | 86 ++ SharedContent/vb/AssemblyInfo.vb | 15 + .../vb}/Default.rd.xml | 0 SharedContent/vb/Library.rd.xml | 10 + .../cs => SharedContent/vb}/MainPage.xaml | 10 +- SharedContent/vb/MainPage.xaml.vb | 112 +++ 714 files changed, 39806 insertions(+), 3269 deletions(-) create mode 100644 Samples/Accelerometer/vb/Accelerometer.sln create mode 100644 Samples/Accelerometer/vb/Accelerometer.vbproj create mode 100644 Samples/Accelerometer/vb/Package.appxmanifest create mode 100644 Samples/Accelerometer/vb/SampleConfiguration.vb create mode 100644 Samples/Accelerometer/vb/Scenario1_DataEvents.xaml.vb create mode 100644 Samples/Accelerometer/vb/Scenario2_ShakeEvents.xaml.vb create mode 100644 Samples/Accelerometer/vb/Scenario3_Polling.xaml.vb create mode 100644 Samples/Accelerometer/vb/Scenario4_OrientationChanged.xaml.vb create mode 100644 Samples/Accelerometer/vb/Scenario5_DataEventsBatching.xaml.vb create mode 100644 Samples/Accelerometer/vb/project.json create mode 100644 Samples/ActivitySensor/vb/ActivitySensor.sln create mode 100644 Samples/ActivitySensor/vb/ActivitySensor.vbproj create mode 100644 Samples/ActivitySensor/vb/Package.appxmanifest create mode 100644 Samples/ActivitySensor/vb/SampleConfiguration.vb create mode 100644 Samples/ActivitySensor/vb/Scenario1_CurrentActivity.xaml.vb create mode 100644 Samples/ActivitySensor/vb/Scenario2_History.xaml.vb create mode 100644 Samples/ActivitySensor/vb/Scenario3_ChangeEvents.xaml.vb create mode 100644 Samples/ActivitySensor/vb/Scenario4_BackgroundActivity.xaml.vb create mode 100644 Samples/ActivitySensor/vb/Tasks/ActivitySensorBackgroundTask.vb create mode 100644 Samples/ActivitySensor/vb/Tasks/ActivitySensorTasks.vbproj create mode 100644 Samples/ActivitySensor/vb/Tasks/project.json create mode 100644 Samples/ActivitySensor/vb/project.json rename Samples/AdaptiveStreaming/{cs => shared}/Scenario1.xaml (100%) rename Samples/AdaptiveStreaming/{cs => shared}/Scenario2.xaml (100%) rename Samples/AdaptiveStreaming/{cs => shared}/Scenario3.xaml (100%) rename Samples/AdaptiveStreaming/{cs => shared}/Scenario4.xaml (100%) create mode 100644 Samples/AdaptiveStreaming/vb/AdaptiveStreaming.sln create mode 100644 Samples/AdaptiveStreaming/vb/AdaptiveStreaming.vbproj create mode 100644 Samples/AdaptiveStreaming/vb/Package.appxmanifest create mode 100644 Samples/AdaptiveStreaming/vb/PlayReady/CommonLicenseRequest.vb create mode 100644 Samples/AdaptiveStreaming/vb/SampleConfiguration.vb create mode 100644 Samples/AdaptiveStreaming/vb/Scenario1.xaml.vb create mode 100644 Samples/AdaptiveStreaming/vb/Scenario2.xaml.vb create mode 100644 Samples/AdaptiveStreaming/vb/Scenario3.xaml.vb create mode 100644 Samples/AdaptiveStreaming/vb/Scenario4.xaml.vb create mode 100644 Samples/AdaptiveStreaming/vb/project.json delete mode 100644 Samples/AdvancedCasting/cs/Properties/AssemblyInfo.cs rename Samples/AdvancedCasting/{cs => shared}/01_MediaElement.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/02_Casting_API_CastButton.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/03_DIAL_Sender_API.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/04_DIAL_Receiver_App.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/05_Multi_View_Media_Application.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/06_Combine_Casting_Tech.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/App.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/MainPage.xaml (100%) rename Samples/AdvancedCasting/{cs/Styles => shared}/MediaTransportControlWithCustomCastButtonStyles.xaml (100%) rename Samples/AdvancedCasting/{cs/Styles => shared}/ProjectedMediaTransportControlsStyles.xaml (100%) rename Samples/AdvancedCasting/{cs => shared}/ProjectionViewPage.xaml (94%) rename Samples/AdvancedCasting/{cs => shared}/UnhandledExceptionPage.xaml (100%) create mode 100644 Samples/AdvancedCasting/vb/01_MediaElement.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/02_Casting_API_CastButton.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/03_DIAL_Sender_API.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/04_DIAL_Receiver_App.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/05_Multi_View_Media_Application.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/06_Combine_Casting_Tech.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/AdvancedCasting.sln create mode 100644 Samples/AdvancedCasting/vb/AdvancedCasting.vbproj create mode 100644 Samples/AdvancedCasting/vb/App.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/Controls/MediaTransportControlsWithCustomCastButton.vb create mode 100644 Samples/AdvancedCasting/vb/Controls/ProjectedMediaTransportControls.vb create mode 100644 Samples/AdvancedCasting/vb/Controls/ProjectionViewBroker.vb create mode 100644 Samples/AdvancedCasting/vb/Data/Azure/AzureDataProvider.vb create mode 100644 Samples/AdvancedCasting/vb/Data/Common/ItemsDataProvider.vb create mode 100644 Samples/AdvancedCasting/vb/Data/Common/VideoMetaData.vb create mode 100644 Samples/AdvancedCasting/vb/MainPage.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/Package.appxmanifest create mode 100644 Samples/AdvancedCasting/vb/ProjectionViewPage.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/SampleConfiguration.vb create mode 100644 Samples/AdvancedCasting/vb/UnhandledExceptionPage.xaml.vb create mode 100644 Samples/AdvancedCasting/vb/Util/ApiInformation.vb create mode 100644 Samples/AdvancedCasting/vb/Util/CustomDevicePickerFilter.vb create mode 100644 Samples/AdvancedCasting/vb/Util/DialLaunchArguments.vb create mode 100644 Samples/AdvancedCasting/vb/Util/RequiredDeviceProperties.vb create mode 100644 Samples/AdvancedCasting/vb/Util/ViewLifetimeControl.vb create mode 100644 Samples/AdvancedCasting/vb/project.json delete mode 100644 Samples/AllJoyn/ConsumerExperiences/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/AllJoyn/ProducerExperiences/cs/Properties/AssemblyInfo.cs create mode 100644 Samples/Altimeter/vb/Altimeter.sln create mode 100644 Samples/Altimeter/vb/Altimeter.vbproj create mode 100644 Samples/Altimeter/vb/Package.appxmanifest create mode 100644 Samples/Altimeter/vb/SampleConfiguration.vb create mode 100644 Samples/Altimeter/vb/Scenario1_DataEvents.xaml.vb create mode 100644 Samples/Altimeter/vb/Scenario2_Polling.xaml.vb create mode 100644 Samples/Altimeter/vb/project.json create mode 100644 Samples/AnimationMetrics/vb/AnimationMetrics.sln create mode 100644 Samples/AnimationMetrics/vb/AnimationMetrics.vbproj create mode 100644 Samples/AnimationMetrics/vb/Package.appxmanifest create mode 100644 Samples/AnimationMetrics/vb/SampleConfiguration.vb create mode 100644 Samples/AnimationMetrics/vb/Scenario1_Metrics.xaml.vb create mode 100644 Samples/AnimationMetrics/vb/project.json rename Samples/AppServices/{cs/AppServicesClient => shared}/KeepConnectionOpenScenario.xaml (100%) rename Samples/AppServices/{cs/AppServicesClient => shared}/OpenCloseConnectionScenario.xaml (100%) rename Samples/AppServices/{cs/AppServicesProvider => shared}/ShowPackageFamilyName.xaml (100%) create mode 100644 Samples/AppServices/vb/AppServices.sln create mode 100644 Samples/AppServices/vb/AppServicesClient/AppServicesClient.vbproj create mode 100644 Samples/AppServices/vb/AppServicesClient/KeepConnectionOpenScenario.xaml.vb create mode 100644 Samples/AppServices/vb/AppServicesClient/OpenCloseConnectionScenario.xaml.vb create mode 100644 Samples/AppServices/vb/AppServicesClient/Package.appxmanifest create mode 100644 Samples/AppServices/vb/AppServicesClient/SampleConfiguration.vb create mode 100644 Samples/AppServices/vb/AppServicesClient/project.json create mode 100644 Samples/AppServices/vb/AppServicesProvider/AppServicesProvider.vbproj create mode 100644 Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest create mode 100644 Samples/AppServices/vb/AppServicesProvider/SampleConfiguration.vb create mode 100644 Samples/AppServices/vb/AppServicesProvider/ShowPackageFamilyName.xaml.vb create mode 100644 Samples/AppServices/vb/AppServicesProvider/project.json create mode 100644 Samples/AppServices/vb/RandomNumberService/RandomNumberGeneratorTask.vb create mode 100644 Samples/AppServices/vb/RandomNumberService/RandomNumberService.vbproj create mode 100644 Samples/AppServices/vb/RandomNumberService/project.json rename Samples/ApplicationData/{cs => shared}/App.xaml (100%) rename Samples/ApplicationData/{cs => shared}/MainPage.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario1_Files.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario2_Settings.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario3_SettingContainer.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario4_CompositeSettings.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario5_DataChangedEvent.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario6_HighPriority.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario7_Msappdata.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario8_ClearScenario.xaml (100%) rename Samples/ApplicationData/{cs => shared}/Scenario9_SetVersion.xaml (100%) rename Samples/ApplicationData/{cs/Styles => shared}/Styles.xaml (100%) create mode 100644 Samples/ApplicationData/vb/App.xaml.vb create mode 100644 Samples/ApplicationData/vb/ApplicationData.sln create mode 100644 Samples/ApplicationData/vb/ApplicationData.vbproj create mode 100644 Samples/ApplicationData/vb/Assets/appDataLocal.png create mode 100644 Samples/ApplicationData/vb/Assets/appDataRoaming.png create mode 100644 Samples/ApplicationData/vb/Assets/appDataTemp.png create mode 100644 Samples/ApplicationData/vb/MainPage.xaml.vb create mode 100644 Samples/ApplicationData/vb/Package.appxmanifest create mode 100644 Samples/ApplicationData/vb/SampleConfiguration.vb create mode 100644 Samples/ApplicationData/vb/Scenario1_Files.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario2_Settings.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario3_SettingContainer.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario4_CompositeSettings.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario5_DataChangedEvent.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario6_HighPriority.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario7_Msappdata.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario8_ClearScenario.xaml.vb create mode 100644 Samples/ApplicationData/vb/Scenario9_SetVersion.xaml.vb create mode 100644 Samples/ApplicationData/vb/SuspensionManager.vb create mode 100644 Samples/ApplicationData/vb/project.json create mode 100644 Samples/ApplicationResources/vb/AppResourceClassLibrary/AppResourceClassLibrary.vbproj create mode 100644 Samples/ApplicationResources/vb/AppResourceClassLibrary/class1.vb create mode 100644 Samples/ApplicationResources/vb/AppResourceClassLibrary/project.json create mode 100644 Samples/ApplicationResources/vb/ApplicationResources.sln create mode 100644 Samples/ApplicationResources/vb/ApplicationResources.vbproj create mode 100644 Samples/ApplicationResources/vb/Package.appxmanifest create mode 100644 Samples/ApplicationResources/vb/constants.vb create mode 100644 Samples/ApplicationResources/vb/languageoverride.xaml create mode 100644 Samples/ApplicationResources/vb/languageoverride.xaml.vb create mode 100644 Samples/ApplicationResources/vb/project.json create mode 100644 Samples/ApplicationResources/vb/scenario1.xaml create mode 100644 Samples/ApplicationResources/vb/scenario1.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario10.xaml create mode 100644 Samples/ApplicationResources/vb/scenario10.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario11.xaml create mode 100644 Samples/ApplicationResources/vb/scenario11.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario12.xaml create mode 100644 Samples/ApplicationResources/vb/scenario12.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario13.xaml create mode 100644 Samples/ApplicationResources/vb/scenario13.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario2.xaml create mode 100644 Samples/ApplicationResources/vb/scenario2.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario3.xaml create mode 100644 Samples/ApplicationResources/vb/scenario3.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario4.xaml create mode 100644 Samples/ApplicationResources/vb/scenario4.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario5.xaml create mode 100644 Samples/ApplicationResources/vb/scenario5.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario6.xaml create mode 100644 Samples/ApplicationResources/vb/scenario6.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario7.xaml create mode 100644 Samples/ApplicationResources/vb/scenario7.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario8.xaml create mode 100644 Samples/ApplicationResources/vb/scenario8.xaml.vb create mode 100644 Samples/ApplicationResources/vb/scenario9.xaml create mode 100644 Samples/ApplicationResources/vb/scenario9.xaml.vb rename Samples/Appointments/{cs => shared}/Scenario1_Define.xaml (100%) rename Samples/Appointments/{cs => shared}/Scenario2_Add.xaml (100%) rename Samples/Appointments/{cs => shared}/Scenario3_Replace.xaml (100%) rename Samples/Appointments/{cs => shared}/Scenario4_Remove.xaml (100%) rename Samples/Appointments/{cs => shared}/Scenario5_Show.xaml (100%) rename Samples/Appointments/{cs => shared}/Scenario6_Recurrence.xaml (100%) create mode 100644 Samples/Appointments/vb/Appointments.sln create mode 100644 Samples/Appointments/vb/Appointments.vbproj create mode 100644 Samples/Appointments/vb/Package.appxmanifest create mode 100644 Samples/Appointments/vb/SampleConfiguration.vb create mode 100644 Samples/Appointments/vb/Scenario1_Define.xaml.vb create mode 100644 Samples/Appointments/vb/Scenario2_Add.xaml.vb create mode 100644 Samples/Appointments/vb/Scenario3_Replace.xaml.vb create mode 100644 Samples/Appointments/vb/Scenario4_Remove.xaml.vb create mode 100644 Samples/Appointments/vb/Scenario5_Show.xaml.vb create mode 100644 Samples/Appointments/vb/Scenario6_Recurrence.xaml.vb create mode 100644 Samples/Appointments/vb/project.json rename Samples/AssociationLaunching/{cs => shared}/Scenario1_LaunchFile.xaml (93%) rename Samples/AssociationLaunching/{cs => shared}/Scenario2_LaunchUri.xaml (92%) rename Samples/AssociationLaunching/{cs => shared}/Scenario3_ReceiveFile.xaml (100%) rename Samples/AssociationLaunching/{cs => shared}/Scenario4_ReceiveUri.xaml (100%) create mode 100644 Samples/AssociationLaunching/vb/App.xaml.vb create mode 100644 Samples/AssociationLaunching/vb/AssociationLaunching.sln create mode 100644 Samples/AssociationLaunching/vb/AssociationLaunching.vbproj create mode 100644 Samples/AssociationLaunching/vb/MainPage.xaml.vb create mode 100644 Samples/AssociationLaunching/vb/Package.appxmanifest create mode 100644 Samples/AssociationLaunching/vb/SampleConfiguration.vb create mode 100644 Samples/AssociationLaunching/vb/Scenario1_LaunchFile.xaml.vb create mode 100644 Samples/AssociationLaunching/vb/Scenario2_LaunchUri.xaml.vb create mode 100644 Samples/AssociationLaunching/vb/Scenario3_ReceiveFile.xaml.vb create mode 100644 Samples/AssociationLaunching/vb/Scenario4_ReceiveUri.xaml.vb create mode 100644 Samples/AssociationLaunching/vb/project.json rename Samples/AudioCategory/{cs/AudioCategory => shared}/PlaybackControl.xaml (100%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario1.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario10.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario2.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario3.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario4.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario5.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario6.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario7.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario8.xaml (95%) rename Samples/AudioCategory/{cs/AudioCategory => shared}/Scenario9.xaml (95%) create mode 100644 Samples/AudioCategory/vb/AudioCategory/AudioCategory.sln create mode 100644 Samples/AudioCategory/vb/AudioCategory/AudioCategory.vbproj create mode 100644 Samples/AudioCategory/vb/AudioCategory/Package.appxmanifest create mode 100644 Samples/AudioCategory/vb/AudioCategory/PlaybackControl.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/SampleConfiguration.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario1.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario10.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario2.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario3.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario4.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario5.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario6.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario7.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario8.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/Scenario9.xaml.vb create mode 100644 Samples/AudioCategory/vb/AudioCategory/project.json create mode 100644 Samples/AudioCategory/vb/AudioCategoryCompanion/AudioCategoryCompanion.sln create mode 100644 Samples/AudioCategory/vb/AudioCategoryCompanion/AudioCategoryCompanion.vbproj create mode 100644 Samples/AudioCategory/vb/AudioCategoryCompanion/Package.appxmanifest create mode 100644 Samples/AudioCategory/vb/AudioCategoryCompanion/project.json delete mode 100644 Samples/AudioCreation/cs/AudioCreation/Properties/AssemblyInfo.cs rename Samples/BackButton/{cs => shared}/Scenario1.xaml (100%) rename Samples/BackButton/{cs => shared}/SecondaryPage.xaml (100%) create mode 100644 Samples/BackButton/vb/App.xaml.vb create mode 100644 Samples/BackButton/vb/MainPage.xaml.vb create mode 100644 Samples/BackButton/vb/Package.appxmanifest create mode 100644 Samples/BackButton/vb/SampleConfiguration.vb create mode 100644 Samples/BackButton/vb/Scenario1.xaml.vb create mode 100644 Samples/BackButton/vb/SecondaryPage.xaml.vb create mode 100644 Samples/BackButton/vb/SystemBack.sln create mode 100644 Samples/BackButton/vb/SystemBack.vbproj create mode 100644 Samples/BackButton/vb/project.json delete mode 100644 Samples/BackgroundAudio/cs/BackgroundAudio/Properties/AssemblyInfo.cs rename Samples/BackgroundAudio/{cs/BackgroundAudio/Views => shared}/PlaylistView.xaml (100%) rename Samples/BackgroundAudio/{cs/BackgroundAudio => shared}/Scenario1.xaml (100%) create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio.sln create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio/BackgroundAudio.vbproj create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio/Package.appxmanifest create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio/SampleConfiguration.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio/Scenario1.xaml.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio/Views/PlaylistView.xaml.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudio/project.json create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/AppState.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/ApplicationSettingsConstants.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/ApplicationSettingsHelper.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/BackgroundAudioShared.vbproj create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/BackgroundTaskState.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/EnumHelper.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/JsonHelper.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/AppResumedMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/AppSuspendedMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/BackgroundAudioTaskStartedMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/MessageService.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/SkipNextMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/SkipPreviousMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/StartPlaybackMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/TrackChangedMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Messages/UpdatePlaylistMessage.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/Models/SongModel.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioShared/project.json create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioTask/BackgroundAudioTask.vbproj create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioTask/MyBackgroundAudioTask.vb create mode 100644 Samples/BackgroundAudio/vb/BackgroundAudioTask/project.json delete mode 100644 Samples/BackgroundSensors/cs/Properties/AssemblyInfo.cs create mode 100644 Samples/BackgroundSensors/vb/BackgroundSensors.sln create mode 100644 Samples/BackgroundSensors/vb/BackgroundSensors.vbproj create mode 100644 Samples/BackgroundSensors/vb/BackgroundTask/BackgroundTask.vbproj create mode 100644 Samples/BackgroundSensors/vb/BackgroundTask/Scenario1_BackgroundTask.vb create mode 100644 Samples/BackgroundSensors/vb/BackgroundTask/project.json create mode 100644 Samples/BackgroundSensors/vb/Package.appxmanifest create mode 100644 Samples/BackgroundSensors/vb/SampleConfiguration.vb create mode 100644 Samples/BackgroundSensors/vb/Scenario1_DeviceUse.xaml.vb create mode 100644 Samples/BackgroundSensors/vb/project.json create mode 100644 Samples/BackgroundTask/vb/BackgroundTask.sln create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/BackgroundTask.vbproj create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/Package.appxmanifest create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/SampleConfiguration.vb create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/Scenario1_SampleBackgroundTask.xaml.vb create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/Scenario2_SampleBackgroundTaskWithCondition.xaml.vb create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/Scenario3_ServicingCompleteTask.xaml.vb create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/Scenario4_TimeTriggeredTask.xaml.vb create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/Scenario5_ApplicationTriggerTask.xaml.vb create mode 100644 Samples/BackgroundTask/vb/BackgroundTask/project.json create mode 100644 Samples/BackgroundTask/vb/Tasks/SampleBackgroundTask.vb create mode 100644 Samples/BackgroundTask/vb/Tasks/ServicingComplete.vb create mode 100644 Samples/BackgroundTask/vb/Tasks/Tasks.vbproj create mode 100644 Samples/BackgroundTask/vb/Tasks/project.json delete mode 100644 Samples/BackgroundTransfer/cs/BackgroundTransfer/Properties/AssemblyInfo.cs create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer.sln create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/BackgroundTransfer.vbproj create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/Package.appxmanifest create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/SampleConfiguration.vb create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/Scenario1_Download.xaml.vb create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/Scenario2_Upload.xaml.vb create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/Scenario3_Notifications.xaml.vb create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/Scenario4_CompletionGroups.xaml.vb create mode 100644 Samples/BackgroundTransfer/vb/BackgroundTransfer/project.json create mode 100644 Samples/BackgroundTransfer/vb/Server/RemoveServer.ps1 create mode 100644 Samples/BackgroundTransfer/vb/Server/SetupServer.ps1 create mode 100644 Samples/BackgroundTransfer/vb/Server/website/bitmap.aspx create mode 100644 Samples/BackgroundTransfer/vb/Server/website/data/windows-sdk.png create mode 100644 Samples/BackgroundTransfer/vb/Server/website/download.aspx create mode 100644 Samples/BackgroundTransfer/vb/Server/website/notifications.aspx create mode 100644 Samples/BackgroundTransfer/vb/Server/website/upload.aspx create mode 100644 Samples/BackgroundTransfer/vb/Server/website/web.config create mode 100644 Samples/BackgroundTransfer/vb/Tasks/CompletionGroupTask.vb create mode 100644 Samples/BackgroundTransfer/vb/Tasks/Tasks.vbproj create mode 100644 Samples/BackgroundTransfer/vb/Tasks/project.json delete mode 100644 Samples/BarcodeScanner/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/BarcodeScanner/cs/Scenario1_BasicFunctionality.xaml delete mode 100644 Samples/BarcodeScanner/cs/Scenario2_MultipleScanners.xaml rename Samples/BarcodeScanner/{cpp => shared}/Scenario1_BasicFunctionality.xaml (100%) rename Samples/BarcodeScanner/{cpp => shared}/Scenario2_MultipleScanners.xaml (100%) create mode 100644 Samples/BarcodeScanner/vb/BarcodeScanner.sln create mode 100644 Samples/BarcodeScanner/vb/BarcodeScanner.vbproj create mode 100644 Samples/BarcodeScanner/vb/Package.appxmanifest create mode 100644 Samples/BarcodeScanner/vb/SampleConfiguration.vb create mode 100644 Samples/BarcodeScanner/vb/Scenario1_BasicFunctionality.xaml.vb create mode 100644 Samples/BarcodeScanner/vb/Scenario2_MultipleScanners.xaml.vb create mode 100644 Samples/BarcodeScanner/vb/project.json delete mode 100644 Samples/Barometer/cs/Scenario1_DataEvents.xaml delete mode 100644 Samples/Barometer/cs/Scenario2_Polling.xaml rename Samples/Barometer/{cpp => shared}/Scenario1_DataEvents.xaml (100%) rename Samples/Barometer/{cpp => shared}/Scenario2_Polling.xaml (100%) create mode 100644 Samples/Barometer/vb/Barometer.sln create mode 100644 Samples/Barometer/vb/Barometer.vbproj create mode 100644 Samples/Barometer/vb/Package.appxmanifest create mode 100644 Samples/Barometer/vb/SampleConfiguration.vb create mode 100644 Samples/Barometer/vb/Scenario1_DataEvents.xaml.vb create mode 100644 Samples/Barometer/vb/Scenario2_Polling.xaml.vb create mode 100644 Samples/Barometer/vb/project.json delete mode 100644 Samples/BasicFaceDetection/cs/Properties/AssemblyInfo.cs create mode 100644 Samples/BasicFaceDetection/vb/Assets/placeholder.txt create mode 100644 Samples/BasicFaceDetection/vb/BasicFaceDetection.sln create mode 100644 Samples/BasicFaceDetection/vb/BasicFaceDetection.vbproj create mode 100644 Samples/BasicFaceDetection/vb/Package.appxmanifest create mode 100644 Samples/BasicFaceDetection/vb/SampleConfiguration.vb create mode 100644 Samples/BasicFaceDetection/vb/Scenario1_DetectInPhoto.xaml.vb create mode 100644 Samples/BasicFaceDetection/vb/Scenario2_DetectInWebcam.xaml.vb create mode 100644 Samples/BasicFaceDetection/vb/Styles/placeholder.txt create mode 100644 Samples/BasicFaceDetection/vb/project.json delete mode 100644 Samples/BasicFaceTracking/cs/Properties/AssemblyInfo.cs create mode 100644 Samples/BasicFaceTracking/vb/Assets/placeholder.txt create mode 100644 Samples/BasicFaceTracking/vb/BasicFaceTracking.sln create mode 100644 Samples/BasicFaceTracking/vb/BasicFaceTracking.vbproj create mode 100644 Samples/BasicFaceTracking/vb/Package.appxmanifest create mode 100644 Samples/BasicFaceTracking/vb/SampleConfiguration.vb create mode 100644 Samples/BasicFaceTracking/vb/Scenario1_TrackInWebcam.xaml.vb create mode 100644 Samples/BasicFaceTracking/vb/Styles/placeholder.txt create mode 100644 Samples/BasicFaceTracking/vb/project.json rename Samples/BasicInput/{cs => shared}/1-InputEvents.xaml (100%) rename Samples/BasicInput/{cs => shared}/2-PointerPointProperties.xaml (100%) rename Samples/BasicInput/{cs => shared}/3-DeviceCapabilities.xaml (100%) rename Samples/BasicInput/{cs => shared}/4-XAMLManipulations.xaml (100%) rename Samples/BasicInput/{cs => shared}/5-GestureRecognizer.xaml (100%) create mode 100644 Samples/BasicInput/vb/1-InputEvents.xaml.vb create mode 100644 Samples/BasicInput/vb/2-PointerPointProperties.xaml.vb create mode 100644 Samples/BasicInput/vb/3-DeviceCapabilities.xaml.vb create mode 100644 Samples/BasicInput/vb/4-XAMLManipulations.xaml.vb create mode 100644 Samples/BasicInput/vb/5-GestureRecognizer.xaml.vb create mode 100644 Samples/BasicInput/vb/BasicInput.sln create mode 100644 Samples/BasicInput/vb/BasicInput.vbproj create mode 100644 Samples/BasicInput/vb/Package.appxmanifest create mode 100644 Samples/BasicInput/vb/SampleConfiguration.vb create mode 100644 Samples/BasicInput/vb/project.json rename Samples/BasicMediaCasting/{cs => shared}/Scenario1_BuiltInCasting.xaml (100%) rename Samples/BasicMediaCasting/{cs => shared}/Scenario2_CastingDevicePicker.xaml (100%) rename Samples/BasicMediaCasting/{cs => shared}/Scenario3_CustomPicker.xaml (100%) create mode 100644 Samples/BasicMediaCasting/vb/BasicMediaCasting.sln create mode 100644 Samples/BasicMediaCasting/vb/BasicMediaCasting.vbproj create mode 100644 Samples/BasicMediaCasting/vb/Package.appxmanifest create mode 100644 Samples/BasicMediaCasting/vb/SampleConfiguration.vb create mode 100644 Samples/BasicMediaCasting/vb/Scenario1_BuiltInCasting.xaml.vb create mode 100644 Samples/BasicMediaCasting/vb/Scenario2_CastingDevicePicker.xaml.vb create mode 100644 Samples/BasicMediaCasting/vb/Scenario3_CustomPicker.xaml.vb create mode 100644 Samples/BasicMediaCasting/vb/project.json rename Samples/BluetoothAdvertisement/{cs => shared}/Scenario1_Watcher.xaml (100%) rename Samples/BluetoothAdvertisement/{cs => shared}/Scenario2_Publisher.xaml (100%) rename Samples/BluetoothAdvertisement/{cs => shared}/Scenario3_BackgroundWatcher.xaml (100%) rename Samples/BluetoothAdvertisement/{cs => shared}/Scenario4_BackgroundPublisher.xaml (100%) create mode 100644 Samples/BluetoothAdvertisement/vb/BluetoothAdvertisement.sln create mode 100644 Samples/BluetoothAdvertisement/vb/BluetoothAdvertisement.vbproj create mode 100644 Samples/BluetoothAdvertisement/vb/Package.appxmanifest create mode 100644 Samples/BluetoothAdvertisement/vb/SampleConfiguration.vb create mode 100644 Samples/BluetoothAdvertisement/vb/Scenario1_Watcher.xaml.vb create mode 100644 Samples/BluetoothAdvertisement/vb/Scenario2_Publisher.xaml.vb create mode 100644 Samples/BluetoothAdvertisement/vb/Scenario3_BackgroundWatcher.xaml.vb create mode 100644 Samples/BluetoothAdvertisement/vb/Scenario4_BackgroundPublisher.xaml.vb create mode 100644 Samples/BluetoothAdvertisement/vb/Tasks/AdvertisementBackgroundTasks.vb create mode 100644 Samples/BluetoothAdvertisement/vb/Tasks/Tasks.vbproj create mode 100644 Samples/BluetoothAdvertisement/vb/Tasks/project.json create mode 100644 Samples/BluetoothAdvertisement/vb/project.json create mode 100644 Samples/Calendar/vb/Calendar.sln create mode 100644 Samples/Calendar/vb/Calendar.vbproj create mode 100644 Samples/Calendar/vb/Package.appxmanifest create mode 100644 Samples/Calendar/vb/SampleConfiguration.vb create mode 100644 Samples/Calendar/vb/Scenario1_Data.xaml.vb create mode 100644 Samples/Calendar/vb/Scenario2_Stats.xaml.vb create mode 100644 Samples/Calendar/vb/Scenario3_Enum.xaml.vb create mode 100644 Samples/Calendar/vb/Scenario4_UnicodeExtensions.xaml.vb create mode 100644 Samples/Calendar/vb/Scenario5_TimeZone.xaml.vb create mode 100644 Samples/Calendar/vb/project.json delete mode 100644 Samples/CameraFaceDetection/cs/MainPage.xaml rename Samples/CameraFaceDetection/{cpp => shared}/App.xaml (100%) rename Samples/CameraFaceDetection/{cpp => shared}/MainPage.xaml (100%) create mode 100644 Samples/CameraFaceDetection/vb/App.xaml.vb create mode 100644 Samples/CameraFaceDetection/vb/CameraFaceDetection.sln create mode 100644 Samples/CameraFaceDetection/vb/CameraFaceDetection.vbproj create mode 100644 Samples/CameraFaceDetection/vb/MainPage.xaml.vb create mode 100644 Samples/CameraFaceDetection/vb/Package.appxmanifest create mode 100644 Samples/CameraFaceDetection/vb/project.json delete mode 100644 Samples/CameraHdr/cs/App.xaml delete mode 100644 Samples/CameraHdr/cs/MainPage.xaml rename Samples/CameraHdr/{cpp => shared}/App.xaml (100%) rename Samples/CameraHdr/{cpp => shared}/MainPage.xaml (100%) create mode 100644 Samples/CameraHdr/vb/App.xaml.vb create mode 100644 Samples/CameraHdr/vb/CameraHdr.sln create mode 100644 Samples/CameraHdr/vb/CameraHdr.vbproj create mode 100644 Samples/CameraHdr/vb/MainPage.xaml.vb create mode 100644 Samples/CameraHdr/vb/Package.appxmanifest create mode 100644 Samples/CameraHdr/vb/project.json delete mode 100644 Samples/CameraStarterKit/cs/MainPage.xaml rename Samples/CameraStarterKit/{cpp => shared}/App.xaml (100%) rename Samples/CameraStarterKit/{cpp => shared}/MainPage.xaml (100%) create mode 100644 Samples/CameraStarterKit/vb/App.xaml.vb create mode 100644 Samples/CameraStarterKit/vb/CameraStarterKit.sln create mode 100644 Samples/CameraStarterKit/vb/CameraStarterKit.vbproj create mode 100644 Samples/CameraStarterKit/vb/MainPage.xaml.vb create mode 100644 Samples/CameraStarterKit/vb/Package.appxmanifest create mode 100644 Samples/CameraStarterKit/vb/project.json delete mode 100644 Samples/CameraVideoStabilization/cs/MainPage.xaml rename Samples/CameraVideoStabilization/{cpp => shared}/App.xaml (100%) rename Samples/CameraVideoStabilization/{cpp => shared}/MainPage.xaml (100%) create mode 100644 Samples/CameraVideoStabilization/vb/App.xaml.vb create mode 100644 Samples/CameraVideoStabilization/vb/CameraVideoStabilization.sln create mode 100644 Samples/CameraVideoStabilization/vb/CameraVideoStabilization.vbproj create mode 100644 Samples/CameraVideoStabilization/vb/MainPage.xaml.vb create mode 100644 Samples/CameraVideoStabilization/vb/Package.appxmanifest create mode 100644 Samples/CameraVideoStabilization/vb/project.json delete mode 100644 Samples/CashDrawer/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/CashDrawer/cs/Scenario1_OpenDrawer.xaml delete mode 100644 Samples/CashDrawer/cs/Scenario2_CloseDrawer.xaml delete mode 100644 Samples/CashDrawer/cs/Scenario3_MultipleDrawers.xaml rename Samples/CashDrawer/{cpp => shared}/Scenario1_OpenDrawer.xaml (100%) rename Samples/CashDrawer/{cpp => shared}/Scenario2_CloseDrawer.xaml (100%) rename Samples/CashDrawer/{cpp => shared}/Scenario3_MultipleDrawers.xaml (100%) create mode 100644 Samples/CashDrawer/vb/CashDrawer.sln create mode 100644 Samples/CashDrawer/vb/CashDrawer.vbproj create mode 100644 Samples/CashDrawer/vb/Package.appxmanifest create mode 100644 Samples/CashDrawer/vb/SampleConfiguration.vb create mode 100644 Samples/CashDrawer/vb/Scenario1_OpenDrawer.xaml.vb create mode 100644 Samples/CashDrawer/vb/Scenario2_CloseDrawer.xaml.vb create mode 100644 Samples/CashDrawer/vb/Scenario3_MultipleDrawers.xaml.vb create mode 100644 Samples/CashDrawer/vb/project.json create mode 100644 Samples/Clipboard/vb/Clipboard.sln create mode 100644 Samples/Clipboard/vb/Clipboard.vbproj create mode 100644 Samples/Clipboard/vb/CopyFiles.xaml.vb create mode 100644 Samples/Clipboard/vb/CopyImage.xaml.vb create mode 100644 Samples/Clipboard/vb/CopyText.xaml.vb create mode 100644 Samples/Clipboard/vb/Others.xaml.vb create mode 100644 Samples/Clipboard/vb/Package.appxmanifest create mode 100644 Samples/Clipboard/vb/SampleConfiguration.vb create mode 100644 Samples/Clipboard/vb/project.json delete mode 100644 Samples/Compass/cs/CalibrationBar.xaml delete mode 100644 Samples/Compass/cs/Scenario1_DataEvents.xaml delete mode 100644 Samples/Compass/cs/Scenario2_Polling.xaml delete mode 100644 Samples/Compass/cs/Scenario3_Calibration.xaml rename Samples/Compass/{cpp => shared}/CalibrationBar.xaml (100%) rename Samples/Compass/{cpp => shared}/Scenario1_DataEvents.xaml (100%) rename Samples/Compass/{cpp => shared}/Scenario2_Polling.xaml (100%) rename Samples/Compass/{cpp => shared}/Scenario3_Calibration.xaml (100%) create mode 100644 Samples/Compass/vb/CalibrationBar.xaml.vb create mode 100644 Samples/Compass/vb/Compass.sln create mode 100644 Samples/Compass/vb/Compass.vbproj create mode 100644 Samples/Compass/vb/Package.appxmanifest create mode 100644 Samples/Compass/vb/SampleConfiguration.vb create mode 100644 Samples/Compass/vb/Scenario1_DataEvents.xaml.vb create mode 100644 Samples/Compass/vb/Scenario2_Polling.xaml.vb create mode 100644 Samples/Compass/vb/Scenario3_Calibration.xaml.vb create mode 100644 Samples/Compass/vb/project.json create mode 100644 Samples/CompositionVisual/vb/CompositionVisual.sln create mode 100644 Samples/CompositionVisual/vb/CompositionVisual.vbproj create mode 100644 Samples/CompositionVisual/vb/Package.appxmanifest create mode 100644 Samples/CompositionVisual/vb/VisualProperties.vb create mode 100644 Samples/CompositionVisual/vb/project.json delete mode 100644 Samples/Compression/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/DatagramSocket/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/DpiScaling/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/EnterpriseDataProtection/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/FileAccess/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/FullScreenMode/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/Geotag/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/GlobalizationPreferences/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/HomeGroup/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/HttpClient/cs/HttpClient/Properties/AssemblyInfo.cs delete mode 100644 Samples/Json/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/LiveDash/cs/LiveDash/Properties/AssemblyInfo.cs delete mode 100644 Samples/Logging/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/MagneticStripeReader/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/MediaImport/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/Nfc/PcscSdk/Properties/AssemblyInfo.cs delete mode 100644 Samples/Notifications/cs/Notifications/Properties/AssemblyInfo.cs delete mode 100644 Samples/NumberFormatting/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/PhoneCall/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/PhoneCall/cs/Properties/Default.rd.xml delete mode 100644 Samples/PosPrinter/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/Printing/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/Projection/cs/App.xaml delete mode 100644 Samples/Projection/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/ResizeAppView/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/SimpleImaging/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/SmsSendAndReceive/cs/SmsSendAndReceive/Properties/AssemblyInfo.cs delete mode 100644 Samples/SpeechRecognitionAndSynthesis/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/StreamSocket/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/Syndication/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/TextSegmentation/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/TextSuggestion/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/TitleBar/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/TouchKeyboard/cs/Properties/AssemblyInfo.cs create mode 100644 Samples/TouchKeyboardTextInput/README.md create mode 100644 Samples/TouchKeyboardTextInput/Shared/Scenario1_SpellingTextSuggestions.xaml create mode 100644 Samples/TouchKeyboardTextInput/Shared/Scenario2_ScopedViews.xaml create mode 100644 Samples/TouchKeyboardTextInput/cpp/Package.appxmanifest rename Samples/{CameraFaceDetection/cs/App.xaml => TouchKeyboardTextInput/cpp/SampleConfiguration.cpp} (55%) create mode 100644 Samples/TouchKeyboardTextInput/cpp/SampleConfiguration.h create mode 100644 Samples/TouchKeyboardTextInput/cpp/Scenario1_SpellingTextSuggestions.xaml.cpp rename Samples/{CameraVideoStabilization/cs/App.xaml => TouchKeyboardTextInput/cpp/Scenario1_SpellingTextSuggestions.xaml.h} (51%) create mode 100644 Samples/TouchKeyboardTextInput/cpp/Scenario2_ScopedViews.xaml.cpp rename Samples/{CameraStarterKit/cs/App.xaml => TouchKeyboardTextInput/cpp/Scenario2_ScopedViews.xaml.h} (53%) create mode 100644 Samples/TouchKeyboardTextInput/cpp/TouchKeyboardTextInput.sln create mode 100644 Samples/TouchKeyboardTextInput/cpp/TouchKeyboardTextInput.vcxproj create mode 100644 Samples/TouchKeyboardTextInput/cpp/TouchKeyboardTextInput.vcxproj.filters create mode 100644 Samples/TouchKeyboardTextInput/cpp/pch.cpp create mode 100644 Samples/TouchKeyboardTextInput/cpp/pch.h create mode 100644 Samples/TouchKeyboardTextInput/cs/Package.appxmanifest create mode 100644 Samples/TouchKeyboardTextInput/cs/SampleConfiguration.cs create mode 100644 Samples/TouchKeyboardTextInput/cs/Scenario1_SpellingTextSuggestions.xaml.cs create mode 100644 Samples/TouchKeyboardTextInput/cs/Scenario2_ScopedViews.xaml.cs create mode 100644 Samples/TouchKeyboardTextInput/cs/TouchKeyboardTextInput.csproj create mode 100644 Samples/TouchKeyboardTextInput/cs/TouchKeyboardTextInput.sln create mode 100644 Samples/TouchKeyboardTextInput/cs/project.json delete mode 100644 Samples/Unicode/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/UserInteractionMode/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/VoIP/cs/Voip/Properties/AssemblyInfo.cs delete mode 100644 Samples/WebAccountManagement/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/WebSocket/cs/Properties/AssemblyInfo.cs delete mode 100644 Samples/XamlCustomMediaTransportControls/cs/Properties/Default.rd.xml delete mode 100644 Samples/XamlListView/cs/Properties/Default.rd.xml delete mode 100644 Samples/XamlNavigation/cs/Properties/Default.rd.xml delete mode 100644 Samples/XamlPullToRefresh/cs/Properties/Default.rd.xml delete mode 100644 Samples/XamlResponsiveTechniques/cs/Properties/Default.rd.xml delete mode 100644 Samples/XamlStateTriggers/cs/Properties/Default.rd.xml delete mode 100644 Samples/XamlTailoredMultipleViews/cs/TailoredMultipleViews/Properties/Default.rd.xml delete mode 100644 Samples/XamlTransform3DAnimations/cs/Properties/Default.rd.xml create mode 100644 SharedContent/vb/App.xaml.vb create mode 100644 SharedContent/vb/AssemblyInfo.vb rename {Samples/Notifications/cs/Notifications/Properties => SharedContent/vb}/Default.rd.xml (100%) create mode 100644 SharedContent/vb/Library.rd.xml rename {Samples/Projection/cs => SharedContent/vb}/MainPage.xaml (93%) create mode 100644 SharedContent/vb/MainPage.xaml.vb diff --git a/README.md b/README.md index 31c4e33013..fb4c213c48 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,9 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github. Simple inking Touch keyboard + + Touch keyboard text input + diff --git a/Samples/Accelerometer/vb/Accelerometer.sln b/Samples/Accelerometer/vb/Accelerometer.sln new file mode 100644 index 0000000000..4c7bf08385 --- /dev/null +++ b/Samples/Accelerometer/vb/Accelerometer.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22820.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Accelerometer", "Accelerometer.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Accelerometer/vb/Accelerometer.vbproj b/Samples/Accelerometer/vb/Accelerometer.vbproj new file mode 100644 index 0000000000..a6a30b0bd0 --- /dev/null +++ b/Samples/Accelerometer/vb/Accelerometer.vbproj @@ -0,0 +1,242 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + SDKTemplate + Accelerometer + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + + + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Scenario1_DataEvents.xaml + MSBuild:Compile + Designer + + + Scenario2_ShakeEvents.xaml + MSBuild:Compile + Designer + + + Scenario3_Polling.xaml + MSBuild:Compile + Designer + + + Scenario4_OrientationChanged.xaml + MSBuild:Compile + Designer + + + Scenario5_DataEventsBatching.xaml + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/Accelerometer/vb/Package.appxmanifest b/Samples/Accelerometer/vb/Package.appxmanifest new file mode 100644 index 0000000000..d85ee1cf83 --- /dev/null +++ b/Samples/Accelerometer/vb/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + + Accelerometer VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Accelerometer/vb/SampleConfiguration.vb b/Samples/Accelerometer/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..1b6ef17141 --- /dev/null +++ b/Samples/Accelerometer/vb/SampleConfiguration.vb @@ -0,0 +1,31 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "Accelerometer" + + Public ReadOnly Property scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Data events", .ClassType = GetType(Scenario1_DataEvents)}, New Scenario() With {.Title = "Shake events", .ClassType = GetType(Scenario2_ShakeEvents)}, New Scenario() With {.Title = "Polling", .ClassType = GetType(Scenario3_Polling)}, New Scenario() With {.Title = "OrientationChange", .ClassType = GetType(Scenario4_OrientationChanged)}, New Scenario() With {.Title = "Data events batching", .ClassType = GetType(Scenario5_DataEventsBatching)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/Accelerometer/vb/Scenario1_DataEvents.xaml.vb b/Samples/Accelerometer/vb/Scenario1_DataEvents.xaml.vb new file mode 100644 index 0000000000..18a8958052 --- /dev/null +++ b/Samples/Accelerometer/vb/Scenario1_DataEvents.xaml.vb @@ -0,0 +1,134 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports System +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports System.Threading.Tasks +Imports Windows.UI.Core + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario1_DataEvents + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Private _accelerometer As Accelerometer + + Private _desiredReportInterval As UInteger + + Public Sub New() + Me.InitializeComponent() + _accelerometer = Accelerometer.GetDefault() + If _accelerometer IsNot Nothing Then + ' Select a report interval that is both suitable for the purposes of the app and supported by the sensor. + ' This value will be used later to activate the sensor. + Dim minReportInterval As UInteger = _accelerometer.MinimumReportInterval + _desiredReportInterval = If(minReportInterval > 16, minReportInterval, 16) + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableButton.IsEnabled Then + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler _accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + _accelerometer.ReportInterval = 0 + End If + + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' This is the event handler for VisibilityChanged events. You would register for these notifications + ''' if handling sensor data when the app is not visible could cause unintended actions in the app. + ''' + ''' + ''' + ''' Event data that can be examined for the current visibility state. + ''' + Private Sub VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If ScenarioDisableButton.IsEnabled Then + If e.Visible Then + AddHandler _accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + Else + RemoveHandler _accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + End If + End If + End Sub + + ''' + ''' This is the event handler for ReadingChanged events. + ''' + ''' + ''' + Async Private Sub ReadingChanged(sender As Object, e As AccelerometerReadingChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Dim reading As AccelerometerReading = e.Reading + ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.AccelerationX) + ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.AccelerationY) + ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.AccelerationZ) + End Sub) + End Sub + + ''' + ''' This is the click handler for the 'Enable' button. + ''' + ''' + ''' + Private Sub ScenarioEnable(sender As Object, e As RoutedEventArgs) + If _accelerometer IsNot Nothing Then + _accelerometer.ReportInterval = _desiredReportInterval + AddHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + AddHandler _accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + ScenarioEnableButton.IsEnabled = False + ScenarioDisableButton.IsEnabled = True + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Disable' button. + ''' + ''' + ''' + Private Sub ScenarioDisable(sender As Object, e As RoutedEventArgs) + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler _accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + _accelerometer.ReportInterval = 0 + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + End Class +End Namespace diff --git a/Samples/Accelerometer/vb/Scenario2_ShakeEvents.xaml.vb b/Samples/Accelerometer/vb/Scenario2_ShakeEvents.xaml.vb new file mode 100644 index 0000000000..5c51a947ae --- /dev/null +++ b/Samples/Accelerometer/vb/Scenario2_ShakeEvents.xaml.vb @@ -0,0 +1,126 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +' Windows Store code +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports System +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.UI.Core + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario2_ShakeEvents + Inherits Page + + Private _accelerometer As Accelerometer + + Private _shakeCount As UShort + + Dim rootPage As MainPage = MainPage.Current + + Public Sub New() + Me.InitializeComponent() + _accelerometer = Accelerometer.GetDefault() + If _accelerometer Is Nothing Then + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + + _shakeCount = 0 + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableButton.IsEnabled Then + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler _accelerometer.Shaken, New TypedEventHandler(Of Accelerometer, AccelerometerShakenEventArgs)(AddressOf Shaken) + End If + + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' This is the event handler for VisibilityChanged events. You would register for these notifications + ''' if handling sensor data when the app is not visible could cause unintended actions in the app. + ''' + ''' + ''' + ''' Event data that can be examined for the current visibility state. + ''' + Private Sub VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If ScenarioDisableButton.IsEnabled Then + If e.Visible Then + AddHandler _accelerometer.Shaken, New TypedEventHandler(Of Accelerometer, AccelerometerShakenEventArgs)(AddressOf Shaken) + Else + RemoveHandler _accelerometer.Shaken, New TypedEventHandler(Of Accelerometer, AccelerometerShakenEventArgs)(AddressOf Shaken) + End If + End If + End Sub + + ''' + ''' This is the event handler for Shaken events. + ''' + ''' + ''' + Async Private Sub Shaken(sender As Object, e As AccelerometerShakenEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + _shakeCount = _shakeCount + 1 + ScenarioOutputText.Text = _shakeCount.ToString() + End Sub) + End Sub + + ''' + ''' This is the click handler for the 'Enable' button. + ''' + ''' + ''' + Private Sub ScenarioEnable(sender As Object, e As RoutedEventArgs) + If _accelerometer IsNot Nothing Then + AddHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + AddHandler _accelerometer.Shaken, New TypedEventHandler(Of Accelerometer, AccelerometerShakenEventArgs)(AddressOf Shaken) + ScenarioEnableButton.IsEnabled = False + ScenarioDisableButton.IsEnabled = True + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Disable' button. + ''' + ''' + ''' + Private Sub ScenarioDisable(sender As Object, e As RoutedEventArgs) + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler _accelerometer.Shaken, New TypedEventHandler(Of Accelerometer, AccelerometerShakenEventArgs)(AddressOf Shaken) + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + End Class +End Namespace diff --git a/Samples/Accelerometer/vb/Scenario3_Polling.xaml.vb b/Samples/Accelerometer/vb/Scenario3_Polling.xaml.vb new file mode 100644 index 0000000000..635c153e8e --- /dev/null +++ b/Samples/Accelerometer/vb/Scenario3_Polling.xaml.vb @@ -0,0 +1,139 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports System +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports System.Threading.Tasks +Imports Windows.UI.Core + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario3_Polling + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Private _accelerometer As Accelerometer + + Private _desiredReportInterval As UInteger + + Private _dispatcherTimer As DispatcherTimer + + Public Sub New() + Me.InitializeComponent() + _accelerometer = Accelerometer.GetDefault() + If _accelerometer IsNot Nothing Then + ' Select a report interval that is both suitable for the purposes of the app and supported by the sensor. + ' This value will be used later to activate the sensor. + Dim minReportInterval As UInteger = _accelerometer.MinimumReportInterval + _desiredReportInterval = If(minReportInterval > 16, minReportInterval, 16) + _dispatcherTimer = New DispatcherTimer() + AddHandler _dispatcherTimer.Tick, AddressOf DisplayCurrentReading + _dispatcherTimer.Interval = New TimeSpan(0, 0, 0, 0, CType(_desiredReportInterval, Integer)) + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableButton.IsEnabled Then + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + _dispatcherTimer.Stop() + _accelerometer.ReportInterval = 0 + End If + + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' This is the event handler for VisibilityChanged events. You would register for these notifications + ''' if handling sensor data when the app is not visible could cause unintended actions in the app. + ''' + ''' + ''' + ''' Event data that can be examined for the current visibility state. + ''' + Private Sub VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If ScenarioDisableButton.IsEnabled Then + If e.Visible Then + _dispatcherTimer.Start() + Else + _dispatcherTimer.Stop() + End If + End If + End Sub + + ''' + ''' This is the dispatcher callback. + ''' + ''' + ''' + Private Sub DisplayCurrentReading(sender As Object, args As Object) + Dim reading As AccelerometerReading = _accelerometer.GetCurrentReading() + If reading IsNot Nothing Then + ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.AccelerationX) + ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.AccelerationY) + ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.AccelerationZ) + End If + End Sub + + ''' + ''' This is the click handler for the 'Enable' button. + ''' + ''' + ''' + Private Sub ScenarioEnable(sender As Object, e As RoutedEventArgs) + If _accelerometer IsNot Nothing Then + _accelerometer.ReportInterval = _desiredReportInterval + AddHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + _dispatcherTimer.Start() + ScenarioEnableButton.IsEnabled = False + ScenarioDisableButton.IsEnabled = True + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Disable' button. + ''' + ''' + ''' + Private Sub ScenarioDisable(sender As Object, e As RoutedEventArgs) + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + _dispatcherTimer.Stop() + _accelerometer.ReportInterval = 0 + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + End Class +End Namespace diff --git a/Samples/Accelerometer/vb/Scenario4_OrientationChanged.xaml.vb b/Samples/Accelerometer/vb/Scenario4_OrientationChanged.xaml.vb new file mode 100644 index 0000000000..43a887c6f3 --- /dev/null +++ b/Samples/Accelerometer/vb/Scenario4_OrientationChanged.xaml.vb @@ -0,0 +1,183 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports System +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports System.Threading.Tasks +Imports Windows.UI.Core +Imports Windows.Graphics.Display + +Namespace Global.SDKTemplate + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario4_OrientationChanged + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim accelerometerOriginal As Accelerometer + + Dim accelerometerReadingTransform As Accelerometer + + Dim displayInformation As DisplayInformation + + Public Sub New() + Me.InitializeComponent() + accelerometerOriginal = Accelerometer.GetDefault() + accelerometerReadingTransform = Accelerometer.GetDefault() + If accelerometerOriginal Is Nothing OrElse accelerometerReadingTransform Is Nothing Then + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + + displayInformation = DisplayInformation.GetForCurrentView() + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + If accelerometerOriginal Is Nothing OrElse accelerometerReadingTransform Is Nothing Then + ScenarioEnableButton.IsEnabled = False + Else + ScenarioEnableButton.IsEnabled = True + End If + + ScenarioDisableButton.IsEnabled = False + AddHandler displayInformation.OrientationChanged, AddressOf displayInformation_OrientationChanged + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableButton.IsEnabled Then + RemoveHandler Window.Current.VisibilityChanged, AddressOf Current_VisibilityChanged + RemoveHandler accelerometerOriginal.ReadingChanged, AddressOf _accelerometerOriginal_ReadingChanged + RemoveHandler accelerometerReadingTransform.ReadingChanged, AddressOf _accelerometerReadingTransform_ReadingChanged + accelerometerOriginal.ReportInterval = 0 + accelerometerReadingTransform.ReportInterval = 0 + End If + + RemoveHandler displayInformation.OrientationChanged, AddressOf displayInformation_OrientationChanged + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' Invoked when there is a change in the display orientation. + ''' + ''' + ''' DisplayInformation object from which the new Orientation can be determined + ''' + ''' + Sub displayInformation_OrientationChanged(sender As DisplayInformation, args As Object) + If Nothing IsNot accelerometerReadingTransform Then + accelerometerReadingTransform.ReadingTransform = sender.CurrentOrientation + End If + End Sub + + ''' + ''' This is the click handler for the 'Enable' button. + ''' + ''' + ''' + Sub ScenarioEnable(sender As Object, e As RoutedEventArgs) + accelerometerOriginal.ReportInterval = accelerometerOriginal.MinimumReportInterval + accelerometerReadingTransform.ReportInterval = accelerometerReadingTransform.MinimumReportInterval + accelerometerReadingTransform.ReadingTransform = displayInformation.CurrentOrientation + AddHandler Window.Current.VisibilityChanged, AddressOf Current_VisibilityChanged + AddHandler accelerometerOriginal.ReadingChanged, AddressOf _accelerometerOriginal_ReadingChanged + AddHandler accelerometerReadingTransform.ReadingChanged, AddressOf _accelerometerReadingTransform_ReadingChanged + ScenarioEnableButton.IsEnabled = False + ScenarioDisableButton.IsEnabled = True + End Sub + + ''' + ''' This is the event handler for ReadingChanged event of the 'accelerometerOriginal' and should + ''' notify of the accelerometer reading changes. + ''' + ''' + ''' + ''' Event data represents the accelerometer reading in its original reference frame. + ''' + Async Sub _accelerometerOriginal_ReadingChanged(sender As Accelerometer, args As AccelerometerReadingChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Dim reading As AccelerometerReading = args.Reading + ScenarioOutput_X_Original.Text = String.Format("{0,5:0.00}", reading.AccelerationX) + ScenarioOutput_Y_Original.Text = String.Format("{0,5:0.00}", reading.AccelerationY) + ScenarioOutput_Z_Original.Text = String.Format("{0,5:0.00}", reading.AccelerationZ) + End Sub) + End Sub + + ''' + ''' This is the event handler for ReadingChanged event of the 'accelerometerReadingTransform' and should + ''' notify of the accelerometer reading changes. + ''' + ''' + ''' + ''' Event data represents the accelerometer reading in its original reference frame. + ''' + Async Sub _accelerometerReadingTransform_ReadingChanged(sender As Accelerometer, args As AccelerometerReadingChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Dim reading As AccelerometerReading = args.Reading + ScenarioOutput_X_ReadingTransform.Text = String.Format("{0,5:0.00}", reading.AccelerationX) + ScenarioOutput_Y_ReadingTransform.Text = String.Format("{0,5:0.00}", reading.AccelerationY) + ScenarioOutput_Z_ReadingTransform.Text = String.Format("{0,5:0.00}", reading.AccelerationZ) + End Sub) + End Sub + + ''' + ''' This is the event handler for VisibilityChanged events. You would register for these notifications + ''' if handling sensor data when the app is not visible could cause unintended actions in the app. + ''' + ''' + ''' + ''' Event data that can be examined for the current visibility state. + ''' + Sub Current_VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If ScenarioDisableButton.IsEnabled Then + If e.Visible Then + AddHandler accelerometerOriginal.ReadingChanged, AddressOf _accelerometerOriginal_ReadingChanged + AddHandler accelerometerReadingTransform.ReadingChanged, AddressOf _accelerometerReadingTransform_ReadingChanged + Else + RemoveHandler accelerometerOriginal.ReadingChanged, AddressOf _accelerometerOriginal_ReadingChanged + RemoveHandler accelerometerReadingTransform.ReadingChanged, AddressOf _accelerometerReadingTransform_ReadingChanged + End If + End If + End Sub + + ''' + ''' This is the click handler for the 'Disable' button. + ''' + ''' + ''' + Sub ScenarioDisable(sender As Object, e As RoutedEventArgs) + RemoveHandler Window.Current.VisibilityChanged, AddressOf Current_VisibilityChanged + RemoveHandler accelerometerOriginal.ReadingChanged, AddressOf _accelerometerOriginal_ReadingChanged + RemoveHandler accelerometerReadingTransform.ReadingChanged, AddressOf _accelerometerReadingTransform_ReadingChanged + accelerometerOriginal.ReportInterval = 0 + accelerometerReadingTransform.ReportInterval = 0 + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + End Class +End Namespace diff --git a/Samples/Accelerometer/vb/Scenario5_DataEventsBatching.xaml.vb b/Samples/Accelerometer/vb/Scenario5_DataEventsBatching.xaml.vb new file mode 100644 index 0000000000..7628f17bb0 --- /dev/null +++ b/Samples/Accelerometer/vb/Scenario5_DataEventsBatching.xaml.vb @@ -0,0 +1,140 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports System +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports System.Threading.Tasks +Imports Windows.UI.Core + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario5_DataEventsBatching + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Private accelerometer As Accelerometer + + Private desiredReportInterval As UInteger + + Private desiredReportLatency As UInteger + + Public Sub New() + Me.InitializeComponent() + accelerometer = Accelerometer.GetDefault() + If accelerometer IsNot Nothing Then + ' Select a report interval that is both suitable for the purposes of the app and supported by the sensor. + ' This value will be used later to activate the sensor. + Dim minReportInterval As UInteger = accelerometer.MinimumReportInterval + desiredReportInterval = If(minReportInterval > 16, minReportInterval, 16) + ' MaxBatchSize will be 0 if the accelerometer does not support batching. + Dim maxLatency As UInteger = accelerometer.MaxBatchSize * desiredReportInterval + desiredReportLatency = If(maxLatency < 10000, maxLatency, 10000) + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableButton.IsEnabled Then + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + accelerometer.ReportInterval = 0 + End If + + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' This is the event handler for VisibilityChanged events. You would register for these notifications + ''' if handling sensor data when the app is not visible could cause unintended actions in the app. + ''' + ''' + ''' + ''' Event data that can be examined for the current visibility state. + ''' + Private Sub VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If ScenarioDisableButton.IsEnabled Then + If e.Visible Then + AddHandler accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + Else + RemoveHandler accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + End If + End If + End Sub + + ''' + ''' This is the event handler for ReadingChanged events. + ''' + ''' + ''' + Async Private Sub ReadingChanged(sender As Object, e As AccelerometerReadingChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Dim reading As AccelerometerReading = e.Reading + ScenarioOutput_X.Text = String.Format("{0,5:0.00}", reading.AccelerationX) + ScenarioOutput_Y.Text = String.Format("{0,5:0.00}", reading.AccelerationY) + ScenarioOutput_Z.Text = String.Format("{0,5:0.00}", reading.AccelerationZ) + End Sub) + End Sub + + ''' + ''' This is the click handler for the 'Enable' button. + ''' + ''' + ''' + Private Sub ScenarioEnable(sender As Object, e As RoutedEventArgs) + If accelerometer IsNot Nothing Then + accelerometer.ReportInterval = desiredReportInterval + accelerometer.ReportLatency = desiredReportLatency + AddHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + AddHandler accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + ScenarioEnableButton.IsEnabled = False + ScenarioDisableButton.IsEnabled = True + Else + rootPage.NotifyUser("No accelerometer found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Disable' button. + ''' + ''' + ''' + Private Sub ScenarioDisable(sender As Object, e As RoutedEventArgs) + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler accelerometer.ReadingChanged, New TypedEventHandler(Of Accelerometer, AccelerometerReadingChangedEventArgs)(AddressOf ReadingChanged) + accelerometer.ReportInterval = 0 + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + End Class +End Namespace diff --git a/Samples/Accelerometer/vb/project.json b/Samples/Accelerometer/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/Accelerometer/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/ActivitySensor/vb/ActivitySensor.sln b/Samples/ActivitySensor/vb/ActivitySensor.sln new file mode 100644 index 0000000000..3900f738ae --- /dev/null +++ b/Samples/ActivitySensor/vb/ActivitySensor.sln @@ -0,0 +1,60 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22418.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ActivitySensor", "ActivitySensor.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ActivitySensorTasks", "Tasks\ActivitySensorTasks.vbproj", "{E1A94F43-803F-4F2C-B8D0-366A6F3E178D}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|ARM.ActiveCfg = Debug|ARM + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|ARM.Build.0 = Debug|ARM + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|ARM.Deploy.0 = Debug|ARM + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|x64.ActiveCfg = Debug|x64 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|x64.Build.0 = Debug|x64 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|x64.Deploy.0 = Debug|x64 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|x86.ActiveCfg = Debug|x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|x86.Build.0 = Debug|x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Debug|x86.Deploy.0 = Debug|x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|ARM.ActiveCfg = Release|ARM + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|ARM.Build.0 = Release|ARM + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|ARM.Deploy.0 = Release|ARM + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|x64.ActiveCfg = Release|x64 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|x64.Build.0 = Release|x64 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|x64.Deploy.0 = Release|x64 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|x86.ActiveCfg = Release|x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|x86.Build.0 = Release|x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/ActivitySensor/vb/ActivitySensor.vbproj b/Samples/ActivitySensor/vb/ActivitySensor.vbproj new file mode 100644 index 0000000000..b933aef062 --- /dev/null +++ b/Samples/ActivitySensor/vb/ActivitySensor.vbproj @@ -0,0 +1,242 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + SDKTemplate + ActivitySensor + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Scenario1_CurrentActivity.xaml + MSBuild:Compile + Designer + + + Scenario2_History.xaml + MSBuild:Compile + Designer + + + Scenario3_ChangeEvents.xaml + MSBuild:Compile + Designer + + + Scenario4_BackgroundActivity.xaml + 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 + + + + + {e9d6df34-56b9-4d21-9ac0-b39cdf79151a} + ActivitySensorTasks + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/ActivitySensor/vb/Package.appxmanifest b/Samples/ActivitySensor/vb/Package.appxmanifest new file mode 100644 index 0000000000..533a09cea1 --- /dev/null +++ b/Samples/ActivitySensor/vb/Package.appxmanifest @@ -0,0 +1,60 @@ + + + + + + + + + + Activity Sensor VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/ActivitySensor/vb/SampleConfiguration.vb b/Samples/ActivitySensor/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..fec72d3fad --- /dev/null +++ b/Samples/ActivitySensor/vb/SampleConfiguration.vb @@ -0,0 +1,31 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "Activity sensor" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Current activity", .ClassType = GetType(Scenario1_CurrentActivity)}, New Scenario() With {.Title = "Activity history", .ClassType = GetType(Scenario2_History)}, New Scenario() With {.Title = "Events", .ClassType = GetType(Scenario3_ChangeEvents)}, New Scenario() With {.Title = "Background activity", .ClassType = GetType(Scenario4_BackgroundActivity)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/ActivitySensor/vb/Scenario1_CurrentActivity.xaml.vb b/Samples/ActivitySensor/vb/Scenario1_CurrentActivity.xaml.vb new file mode 100644 index 0000000000..73d1cca459 --- /dev/null +++ b/Samples/ActivitySensor/vb/Scenario1_CurrentActivity.xaml.vb @@ -0,0 +1,61 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario1_CurrentActivity + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim ActivitySensorClassId As Guid = New Guid("9D9E0118-1807-4F2E-96E4-2CE57142E196") + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' This is the click handler for the 'Get Current Activity' button. + ''' + ''' + ''' + Async Private Sub ScenarioGetCurrentActivity(sender As Object, e As RoutedEventArgs) + ScenarioOutput_Activity.Text = "No data" + ScenarioOutput_Confidence.Text = "No data" + ScenarioOutput_Timestamp.Text = "No data" + rootPage.NotifyUser("", NotifyType.StatusMessage) + ' Determine if we can access activity sensors + Dim deviceAccessInfo = DeviceAccessInformation.CreateFromDeviceClassId(ActivitySensorClassId) + If deviceAccessInfo.CurrentStatus = DeviceAccessStatus.Allowed Then + ' Get the default sensor + Dim activitySensor As ActivitySensor = Await ActivitySensor.GetDefaultAsync() + If activitySensor IsNot Nothing Then + ' Get the current activity reading + Dim reading = Await activitySensor.GetCurrentReadingAsync() + If reading IsNot Nothing Then + ScenarioOutput_Activity.Text = reading.Activity.ToString() + ScenarioOutput_Confidence.Text = reading.Confidence.ToString() + ScenarioOutput_Timestamp.Text = reading.Timestamp.ToString("u") + End If + Else + rootPage.NotifyUser("No activity sensor found", NotifyType.ErrorMessage) + End If + Else + rootPage.NotifyUser("Access denied to activity sensors", NotifyType.ErrorMessage) + End If + End Sub + End Class +End Namespace diff --git a/Samples/ActivitySensor/vb/Scenario2_History.xaml.vb b/Samples/ActivitySensor/vb/Scenario2_History.xaml.vb new file mode 100644 index 0000000000..0bc2dcd2b0 --- /dev/null +++ b/Samples/ActivitySensor/vb/Scenario2_History.xaml.vb @@ -0,0 +1,77 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Globalization +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario2_History + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim ActivitySensorClassId As Guid = New Guid("9D9E0118-1807-4F2E-96E4-2CE57142E196") + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' This is the click handler for the 'Get Activity History' button. + ''' + ''' + ''' + Async Private Sub ScenarioGetActivityHistory(sender As Object, e As RoutedEventArgs) + ScenarioOutput_Count.Text = "No data" + ScenarioOutput_Activity1.Text = "No data" + ScenarioOutput_Confidence1.Text = "No data" + ScenarioOutput_Timestamp1.Text = "No data" + ScenarioOutput_ActivityN.Text = "No data" + ScenarioOutput_ConfidenceN.Text = "No data" + ScenarioOutput_TimestampN.Text = "No data" + rootPage.NotifyUser("", NotifyType.StatusMessage) + ' Determine if we can access activity sensors + Dim deviceAccessInfo = DeviceAccessInformation.CreateFromDeviceClassId(ActivitySensorClassId) + If deviceAccessInfo.CurrentStatus = DeviceAccessStatus.Allowed Then + ' Determine if an activity sensor is present + ' This can also be done using Windows::Devices::Enumeration::DeviceInformation::FindAllAsync + Dim activitySensor As ActivitySensor = Await ActivitySensor.GetDefaultAsync() + If activitySensor IsNot Nothing Then + Dim calendar = New Calendar() + calendar.SetToNow() + calendar.AddDays(-1) + Dim yesterday = calendar.GetDateTime() + ' Get history from yesterday onwards + Dim history = Await ActivitySensor.GetSystemHistoryAsync(yesterday) + ScenarioOutput_Count.Text = history.Count.ToString() + If history.Count > 0 Then + Dim reading1 = history(0) + ScenarioOutput_Activity1.Text = reading1.Activity.ToString() + ScenarioOutput_Confidence1.Text = reading1.Confidence.ToString() + ScenarioOutput_Timestamp1.Text = reading1.Timestamp.ToString("u") + Dim readingN = history(history.Count - 1) + ScenarioOutput_ActivityN.Text = readingN.Activity.ToString() + ScenarioOutput_ConfidenceN.Text = readingN.Confidence.ToString() + ScenarioOutput_TimestampN.Text = readingN.Timestamp.ToString("u") + End If + Else + rootPage.NotifyUser("No activity sensors found", NotifyType.ErrorMessage) + End If + Else + rootPage.NotifyUser("Access to activity sensors is denied", NotifyType.ErrorMessage) + End If + End Sub + End Class +End Namespace diff --git a/Samples/ActivitySensor/vb/Scenario3_ChangeEvents.xaml.vb b/Samples/ActivitySensor/vb/Scenario3_ChangeEvents.xaml.vb new file mode 100644 index 0000000000..7a4c45d56e --- /dev/null +++ b/Samples/ActivitySensor/vb/Scenario3_ChangeEvents.xaml.vb @@ -0,0 +1,141 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario3_ChangeEvents + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim ActivitySensorClassId As Guid = New Guid("9D9E0118-1807-4F2E-96E4-2CE57142E196") + + Private _deviceAccessInformation As DeviceAccessInformation + + Private _activitySensor As ActivitySensor + + Public Sub New() + Me.InitializeComponent() + _activitySensor = Nothing + _deviceAccessInformation = DeviceAccessInformation.CreateFromDeviceClassId(ActivitySensorClassId) + AddHandler _deviceAccessInformation.AccessChanged, New TypedEventHandler(Of DeviceAccessInformation, DeviceAccessChangedEventArgs)(AddressOf AccessChanged) + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioEnableReadingChangedButton.IsEnabled = True + ScenarioDisableReadingChangedButton.IsEnabled = False + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableReadingChangedButton.IsEnabled AndAlso _activitySensor IsNot Nothing Then + RemoveHandler _activitySensor.ReadingChanged, New TypedEventHandler(Of ActivitySensor, ActivitySensorReadingChangedEventArgs)(AddressOf ReadingChanged) + End If + + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' This is the event handler for ReadingChanged events. + ''' + ''' + ''' + Async Private Sub ReadingChanged(sender As Object, e As ActivitySensorReadingChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Dim reading As ActivitySensorReading = e.Reading + ScenarioOutput_Activity.Text = reading.Activity.ToString() + ScenarioOutput_Confidence.Text = reading.Confidence.ToString() + ScenarioOutput_ReadingTimestamp.Text = reading.Timestamp.ToString("u") + End Sub) + End Sub + + ''' + ''' This is the click handler for the 'Reading Changed On' button. + ''' + ''' + ''' + Private Async Sub ScenarioEnableReadingChanged(sender As Object, e As RoutedEventArgs) + If _deviceAccessInformation.CurrentStatus = DeviceAccessStatus.Allowed Then + If _activitySensor Is Nothing Then + _activitySensor = Await ActivitySensor.GetDefaultAsync() + End If + + If _activitySensor IsNot Nothing Then + _activitySensor.SubscribedActivities.Add(ActivityType.Walking) + _activitySensor.SubscribedActivities.Add(ActivityType.Running) + _activitySensor.SubscribedActivities.Add(ActivityType.InVehicle) + _activitySensor.SubscribedActivities.Add(ActivityType.Biking) + _activitySensor.SubscribedActivities.Add(ActivityType.Fidgeting) + AddHandler _activitySensor.ReadingChanged, New TypedEventHandler(Of ActivitySensor, ActivitySensorReadingChangedEventArgs)(AddressOf ReadingChanged) + ScenarioEnableReadingChangedButton.IsEnabled = False + ScenarioDisableReadingChangedButton.IsEnabled = True + rootPage.NotifyUser("Subscribed to reading changes", NotifyType.StatusMessage) + Else + rootPage.NotifyUser("No activity sensor found", NotifyType.ErrorMessage) + End If + Else + rootPage.NotifyUser("Access denied to activity sensors", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Reading Changed Off' button. + ''' + ''' + ''' + Private Sub ScenarioDisableReadingChanged(sender As Object, e As RoutedEventArgs) + If _activitySensor IsNot Nothing Then + RemoveHandler _activitySensor.ReadingChanged, New TypedEventHandler(Of ActivitySensor, ActivitySensorReadingChangedEventArgs)(AddressOf ReadingChanged) + rootPage.NotifyUser("Unsubscribed from reading changes", NotifyType.StatusMessage) + End If + + ScenarioEnableReadingChangedButton.IsEnabled = True + ScenarioDisableReadingChangedButton.IsEnabled = False + End Sub + + ''' + ''' This is the event handler for AccessChanged events. + ''' + ''' + ''' + Private Async Sub AccessChanged(sender As DeviceAccessInformation, e As DeviceAccessChangedEventArgs) + Dim status = e.Status + If status <> DeviceAccessStatus.Allowed Then + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Access denied to activity sensors", NotifyType.ErrorMessage) + _activitySensor = Nothing + ScenarioEnableReadingChangedButton.IsEnabled = True + ScenarioDisableReadingChangedButton.IsEnabled = False + End Sub) + End If + End Sub + End Class +End Namespace diff --git a/Samples/ActivitySensor/vb/Scenario4_BackgroundActivity.xaml.vb b/Samples/ActivitySensor/vb/Scenario4_BackgroundActivity.xaml.vb new file mode 100644 index 0000000000..57ea591f83 --- /dev/null +++ b/Samples/ActivitySensor/vb/Scenario4_BackgroundActivity.xaml.vb @@ -0,0 +1,169 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel.Background +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Storage +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.SDKTemplate + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario4_BackgroundActivity + Inherits Page + + Public Const SampleBackgroundTaskName As String = "ActivitySensorBackgroundTask" + + Public Const SampleBackgroundTaskEntryPoint As String = "Tasks.ActivitySensorBackgroundTask" + + Dim ActivitySensorClassId As Guid = New Guid("9D9E0118-1807-4F2E-96E4-2CE57142E196") + + Dim rootPage As MainPage = MainPage.Current + + Dim registered As Boolean = False + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + For Each task In BackgroundTaskRegistration.AllTasks + If task.Value.Name = Scenario4_BackgroundActivity.SampleBackgroundTaskName Then + registered = True + Exit For + End If + Next + + UpdateUIAsync(If(registered, "Registered", "Unregistered")) + End Sub + + ''' + ''' This is the click handler for the 'Register Task' button. + ''' + ''' + ''' + Async Private Sub ScenarioRegisterTask(sender As Object, e As RoutedEventArgs) + ' Determine if we can access activity sensors + Dim deviceAccessInfo = DeviceAccessInformation.CreateFromDeviceClassId(ActivitySensorClassId) + If deviceAccessInfo.CurrentStatus = DeviceAccessStatus.Allowed Then + ' Determine if an activity sensor is present + ' This can also be done using Windows::Devices::Enumeration::DeviceInformation::FindAllAsync + Dim activitySensor As ActivitySensor = Await ActivitySensor.GetDefaultAsync() + If activitySensor IsNot Nothing Then + Dim status = Await BackgroundExecutionManager.RequestAccessAsync() + If(BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity = status) OrElse (BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity = status) Then + RegisterBackgroundTask() + Else + rootPage.NotifyUser("Background tasks may be disabled for this app", NotifyType.ErrorMessage) + End If + Else + rootPage.NotifyUser("No activity sensors found", NotifyType.ErrorMessage) + End If + Else + rootPage.NotifyUser("Access denied to activity sensors", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Unregister Task' button. + ''' + ''' + ''' + Private Sub ScenarioUnregisterTask(sender As Object, e As RoutedEventArgs) + For Each cur In BackgroundTaskRegistration.AllTasks + If SampleBackgroundTaskName = cur.Value.Name Then + cur.Value.Unregister(True) + registered = False + End If + Next + + If Not registered Then + UpdateUIAsync("Unregistered") + End If + End Sub + + ''' + ''' This is the event handler for background task completion. + ''' + ''' The task that is reporting completion. + ''' The completion report arguments. + Private Sub OnCompleted(task As IBackgroundTaskRegistration, args As BackgroundTaskCompletedEventArgs) + Dim status As String = "Completed" + Try + args.CheckResult() + Catch e As Exception + status = e.Message + End Try + + UpdateUIAsync(status) + End Sub + + ''' + ''' Registers the background task. + ''' + Private Sub RegisterBackgroundTask() + Dim builder = New BackgroundTaskBuilder() With {.Name = SampleBackgroundTaskName, .TaskEntryPoint = SampleBackgroundTaskEntryPoint} + Const reportIntervalMs As UInt32 = 3000 + Dim trigger = New ActivitySensorTrigger(reportIntervalMs) + trigger.SubscribedActivities.Add(ActivityType.Walking) + trigger.SubscribedActivities.Add(ActivityType.Running) + trigger.SubscribedActivities.Add(ActivityType.Biking) + builder.SetTrigger(trigger) + Dim task As BackgroundTaskRegistration = builder.Register() + AddHandler task.Completed, New BackgroundTaskCompletedEventHandler(AddressOf OnCompleted) + registered = True + UpdateUIAsync("Registered") + End Sub + + ''' + ''' Updates the scenario UI. + ''' + ''' The status string to display. + Async Private Sub UpdateUIAsync(status As String) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + ScenarioRegisterTaskButton.IsEnabled = Not registered + ScenarioUnregisterTaskButton.IsEnabled = registered + ScenarioOutput_TaskRegistration.Text = status + Dim settings = ApplicationData.Current.LocalSettings + If settings.Values.ContainsKey("ReportCount") Then + ScenarioOutput_ReportCount.Text = settings.Values("ReportCount").ToString() + End If + + If settings.Values.ContainsKey("TaskStatus") Then + ScenarioOutput_TaskStatus.Text = settings.Values("TaskStatus").ToString() + End If + + If settings.Values.ContainsKey("LastActivity") Then + ScenarioOutput_LastActivity.Text = CType(settings.Values("LastActivity"), String) + End If + + If settings.Values.ContainsKey("LastConfidence") Then + ScenarioOutput_LastConfidence.Text = CType(settings.Values("LastConfidence"), String) + End If + + If settings.Values.ContainsKey("LastTimestamp") Then + ScenarioOutput_LastTimestamp.Text = settings.Values("LastTimestamp").ToString() + End If + End Sub) + End Sub + End Class +End Namespace diff --git a/Samples/ActivitySensor/vb/Tasks/ActivitySensorBackgroundTask.vb b/Samples/ActivitySensor/vb/Tasks/ActivitySensorBackgroundTask.vb new file mode 100644 index 0000000000..61aaf66f21 --- /dev/null +++ b/Samples/ActivitySensor/vb/Tasks/ActivitySensorBackgroundTask.vb @@ -0,0 +1,59 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Diagnostics +Imports Windows.ApplicationModel.Background +Imports Windows.Devices.Sensors +Imports Windows.Storage + +Namespace Global.Tasks + + Public NotInheritable Class ActivitySensorBackgroundTask + Implements IBackgroundTask + + ''' + ''' The entry point of a background task. + ''' + ''' The current background task instance. + Public Sub Run(taskInstance As IBackgroundTaskInstance) Implements IBackgroundTask.Run + Debug.WriteLine("Background " & taskInstance.Task.Name & " Starting...") + AddHandler taskInstance.Canceled, New BackgroundTaskCanceledEventHandler(AddressOf OnCanceled) + ' Read the activity reports + Dim triggerDetails As ActivitySensorTriggerDetails = TryCast(taskInstance.TriggerDetails, ActivitySensorTriggerDetails) + Dim reports = triggerDetails.ReadReports() + Dim settings = ApplicationData.Current.LocalSettings + settings.Values("ReportCount") = reports.Count + If reports.Count > 0 Then + Dim lastReading = reports(reports.Count - 1).Reading + settings.Values("LastActivity") = lastReading.Activity.ToString() + settings.Values("LastConfidence") = lastReading.Confidence.ToString() + settings.Values("LastTimestamp") = lastReading.Timestamp.ToString("u") + Else + settings.Values("LastActivity") = "No data" + settings.Values("LastConfidence") = "No data" + settings.Values("LastTimestamp") = "No data" + End If + + settings.Values("TaskStatus") = "Completed at " & DateTime.Now.ToString("u") + End Sub + + ''' + ''' Handles background task cancellation. + ''' + ''' The background task instance being cancelled. + ''' The cancellation reason. + Private Sub OnCanceled(sender As IBackgroundTaskInstance, reason As BackgroundTaskCancellationReason) + Dim settings = ApplicationData.Current.LocalSettings + Debug.WriteLine("Background " & sender.Task.Name & " Cancel Requested...") + settings.Values("TaskStatus") = reason.ToString() & " at " & DateTime.Now.ToString("u") + End Sub + End Class +End Namespace diff --git a/Samples/ActivitySensor/vb/Tasks/ActivitySensorTasks.vbproj b/Samples/ActivitySensor/vb/Tasks/ActivitySensorTasks.vbproj new file mode 100644 index 0000000000..22e6a17e73 --- /dev/null +++ b/Samples/ActivitySensor/vb/Tasks/ActivitySensorTasks.vbproj @@ -0,0 +1,156 @@ + + + + + Debug + x86 + {E1A94F43-803F-4F2C-B8D0-366A6F3E178D} + + winmdobj + Tasks + ActivitySensorTasksCS + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + + Properties\AssemblyInfo.vb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/ActivitySensor/vb/Tasks/project.json b/Samples/ActivitySensor/vb/Tasks/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/ActivitySensor/vb/Tasks/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/ActivitySensor/vb/project.json b/Samples/ActivitySensor/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/ActivitySensor/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AdaptiveStreaming/cs/AdaptiveStreaming.csproj b/Samples/AdaptiveStreaming/cs/AdaptiveStreaming.csproj index 02b8106d42..cca9a1799b 100644 --- a/Samples/AdaptiveStreaming/cs/AdaptiveStreaming.csproj +++ b/Samples/AdaptiveStreaming/cs/AdaptiveStreaming.csproj @@ -135,15 +135,18 @@ MSBuild:CompileDesigner - + + Scenario1.xaml MSBuild:Compile Designer - + + Scenario2.xaml MSBuild:Compile Designer - + + Scenario3.xaml MSBuild:Compile Designer @@ -152,7 +155,8 @@ MSBuild:Compile Designer - + + Scenario4.xaml Designer MSBuild:Compile diff --git a/Samples/AdaptiveStreaming/cs/Scenario1.xaml b/Samples/AdaptiveStreaming/shared/Scenario1.xaml similarity index 100% rename from Samples/AdaptiveStreaming/cs/Scenario1.xaml rename to Samples/AdaptiveStreaming/shared/Scenario1.xaml diff --git a/Samples/AdaptiveStreaming/cs/Scenario2.xaml b/Samples/AdaptiveStreaming/shared/Scenario2.xaml similarity index 100% rename from Samples/AdaptiveStreaming/cs/Scenario2.xaml rename to Samples/AdaptiveStreaming/shared/Scenario2.xaml diff --git a/Samples/AdaptiveStreaming/cs/Scenario3.xaml b/Samples/AdaptiveStreaming/shared/Scenario3.xaml similarity index 100% rename from Samples/AdaptiveStreaming/cs/Scenario3.xaml rename to Samples/AdaptiveStreaming/shared/Scenario3.xaml diff --git a/Samples/AdaptiveStreaming/cs/Scenario4.xaml b/Samples/AdaptiveStreaming/shared/Scenario4.xaml similarity index 100% rename from Samples/AdaptiveStreaming/cs/Scenario4.xaml rename to Samples/AdaptiveStreaming/shared/Scenario4.xaml diff --git a/Samples/AdaptiveStreaming/vb/AdaptiveStreaming.sln b/Samples/AdaptiveStreaming/vb/AdaptiveStreaming.sln new file mode 100644 index 0000000000..1e672f359d --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/AdaptiveStreaming.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22823.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AdaptiveStreaming", "AdaptiveStreaming.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/AdaptiveStreaming/vb/AdaptiveStreaming.vbproj b/Samples/AdaptiveStreaming/vb/AdaptiveStreaming.vbproj new file mode 100644 index 0000000000..52730c125a --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/AdaptiveStreaming.vbproj @@ -0,0 +1,245 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + AdaptiveStreaming + AdaptiveStreaming + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + + Properties\AssemblyInfo.vb + + + + Scenario1.xaml + + + Scenario2.xaml + + + Scenario3.xaml + + + Scenario4.xaml + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Scenario1.xaml + MSBuild:Compile + Designer + + + Scenario2.xaml + MSBuild:Compile + Designer + + + Scenario3.xaml + MSBuild:Compile + Designer + + + Styles\Styles.xaml + MSBuild:Compile + Designer + + + Scenario4.xaml + Designer + MSBuild:Compile + + + + + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/AdaptiveStreaming/vb/Package.appxmanifest b/Samples/AdaptiveStreaming/vb/Package.appxmanifest new file mode 100644 index 0000000000..dd1fec9e41 --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/Package.appxmanifest @@ -0,0 +1,31 @@ + + + + + + AdaptiveStreaming + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/AdaptiveStreaming/vb/PlayReady/CommonLicenseRequest.vb b/Samples/AdaptiveStreaming/vb/PlayReady/CommonLicenseRequest.vb new file mode 100644 index 0000000000..3492830cbd --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/PlayReady/CommonLicenseRequest.vb @@ -0,0 +1,56 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Net +Imports System.Net.Http +Imports System.Threading.Tasks + +Namespace Global.LicenseRequest + + Public Class CommonLicenseRequest + + Private _lastErrorMessage As String + + Public Function GetLastErrorMessage() As String + Return _lastErrorMessage + End Function + + Public Sub New() + _lastErrorMessage = String.Empty + End Sub + + ''' + ''' Invoked to acquire the PlayReady license. + ''' + ''' License Server URI to retrieve the PlayReady license. + ''' HttpContent including the Challenge transmitted to the PlayReady server. + Public Async Overridable Function AcquireLicense(licenseServerUri As Uri, httpRequestContent As HttpContent) As Task(Of HttpContent) + Try + Dim httpClient As HttpClient = New HttpClient() + httpClient.DefaultRequestHeaders.Add("msprdrm_server_redirect_compat", "false") + httpClient.DefaultRequestHeaders.Add("msprdrm_server_exception_compat", "false") + Dim response As HttpResponseMessage = Await httpClient.PostAsync(licenseServerUri, httpRequestContent) + response.EnsureSuccessStatusCode() + If response.StatusCode = HttpStatusCode.OK Then + _lastErrorMessage = String.Empty + Return response.Content + Else + _lastErrorMessage = "AcquireLicense - Http Response Status Code: " & response.StatusCode.ToString() + End If + Catch exception As Exception + _lastErrorMessage = exception.Message + Return Nothing + End Try + + Return Nothing + End Function + End Class +End Namespace diff --git a/Samples/AdaptiveStreaming/vb/SampleConfiguration.vb b/Samples/AdaptiveStreaming/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..cb67f64f43 --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/SampleConfiguration.vb @@ -0,0 +1,32 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls +Imports AdaptiveStreaming + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "AdaptiveStreaming" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Basic HLS/DASH Playback", .ClassType = GetType(Scenario1)}, New Scenario() With {.Title = "Configuring HLS/DASH Playback", .ClassType = GetType(Scenario2)}, New Scenario() With {.Title = "Customized Resource Acquisiton", .ClassType = GetType(Scenario3)}, New Scenario() With {.Title = "HLS/DASH Playback with PlayReady", .ClassType = GetType(Scenario4)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/AdaptiveStreaming/vb/Scenario1.xaml.vb b/Samples/AdaptiveStreaming/vb/Scenario1.xaml.vb new file mode 100644 index 0000000000..f77fe11e8f --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/Scenario1.xaml.vb @@ -0,0 +1,39 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate + +Namespace Global.AdaptiveStreaming + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario1 + Inherits Page + + Private rootPage As MainPage + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + Private Sub btnPlay_Click(sender As Object, e As RoutedEventArgs) + Dim manifest As System.Uri = New System.Uri(txtInputURL.Text) + mePlayer.Source = manifest + End Sub + End Class +End Namespace diff --git a/Samples/AdaptiveStreaming/vb/Scenario2.xaml.vb b/Samples/AdaptiveStreaming/vb/Scenario2.xaml.vb new file mode 100644 index 0000000000..197eb2a9dc --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/Scenario2.xaml.vb @@ -0,0 +1,179 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Media.Streaming.Adaptive +Imports Windows.UI.Core + +Namespace Global.AdaptiveStreaming + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario2 + Inherits Page + + Private rootPage As MainPage + + Dim ams As AdaptiveMediaSource = Nothing + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + Private Sub log(s As String) + Dim text As TextBlock = New TextBlock() + text.Text = s + text.TextWrapping = TextWrapping.WrapWholeWords + stkOutput.Children.Add(text) + End Sub + + Private Sub btnPlay_Click(sender As Object, e As Windows.UI.Xaml.RoutedEventArgs) + If String.IsNullOrEmpty(txtInputURL.Text) Then + rootPage.NotifyUser("Specify a URI to play", NotifyType.ErrorMessage) + Return + End If + + InitializeAdaptiveMediaSource(New System.Uri(txtInputURL.Text), mePlayer) + End Sub + + Async Private Sub InitializeAdaptiveMediaSource(uri As System.Uri, m As MediaElement) + Dim result As AdaptiveMediaSourceCreationResult = Await AdaptiveMediaSource.CreateFromUriAsync(uri) + If result.Status = AdaptiveMediaSourceCreationStatus.Success Then + ams = result.MediaSource + m.SetMediaStreamSource(ams) + outputBitrates() + txtDownloadBitrate.Text = ams.InitialBitrate.ToString() + txtPlaybackBitrate.Text = ams.InitialBitrate.ToString() + AddHandler ams.DownloadRequested, AddressOf DownloadRequested + AddHandler ams.DownloadBitrateChanged, AddressOf DownloadBitrateChanged + AddHandler ams.PlaybackBitrateChanged, AddressOf PlaybackBitrateChanged + Else + rootPage.NotifyUser("Error creating the AdaptiveMediaSource" & vbLf & vbTab & result.Status.ToString(), NotifyType.ErrorMessage) + End If + End Sub + + Private Sub DownloadRequested(sender As AdaptiveMediaSource, args As AdaptiveMediaSourceDownloadRequestedEventArgs) + UpdateBitrateUI(txtMeasuredBandwidth, CType(ams.InboundBitsPerSecond, UInteger)) + End Sub + + Private Sub DownloadBitrateChanged(sender As AdaptiveMediaSource, args As AdaptiveMediaSourceDownloadBitrateChangedEventArgs) + UpdateBitrateUI(txtDownloadBitrate, args.NewValue) + End Sub + + Private Sub PlaybackBitrateChanged(sender As AdaptiveMediaSource, args As AdaptiveMediaSourcePlaybackBitrateChangedEventArgs) + UpdateBitrateUI(txtPlaybackBitrate, args.NewValue) + End Sub + + Private Async Sub UpdateBitrateUI(t As TextBlock, newBitrate As UInteger) + Await Me.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, New DispatchedHandler(Sub() + t.Text = newBitrate.ToString() + End Sub)) + End Sub + + Private Sub outputBitrates() + If ams IsNot Nothing Then + Dim bitrates As String = "Available bitrates: " + For Each b In ams.AvailableBitrates + bitrates &= b & " " + Next + + log(bitrates) + Else + rootPage.NotifyUser("Error: Adaptive Media Source is not initialized.", NotifyType.ErrorMessage) + End If + End Sub + + Private Sub btnSetInitialBitrate_Click(sender As Object, e As RoutedEventArgs) + If ams IsNot Nothing Then + Dim bitrate As UInteger + If UInteger.TryParse(txtInitialBitrate.Text, bitrate) Then + Try + ams.InitialBitrate = bitrate + log("Initial bitrate set to " & bitrate) + Catch + log("Initial bitrate must match a value from the manifest") + End Try + Else + log("Initial bitrate must be set to a positive integer") + End If + Else + rootPage.NotifyUser("Error: Adaptive Media Source is not initialized.", NotifyType.ErrorMessage) + End If + End Sub + + Private Sub btnSetMinBitrate_Click(sender As Object, e As RoutedEventArgs) + If ams IsNot Nothing Then + Dim bitrate As UInteger + If UInteger.TryParse(txtMinBitrate.Text, bitrate) Then + Dim minbitrate As UInteger = ams.AvailableBitrates(0) + For Each b In ams.AvailableBitrates + If b >= bitrate Then + minbitrate = b + Exit For + End If + Next + + ams.DesiredMinBitrate = minbitrate + log("Min bitrate set to " & minbitrate) + Else + log("Min bitrate must be a positive integer") + End If + Else + rootPage.NotifyUser("Error: Adaptive Media Source is not initialized.", NotifyType.ErrorMessage) + End If + End Sub + + Private Sub btnSetMaxBitrate_Click(sender As Object, e As RoutedEventArgs) + If ams IsNot Nothing Then + Dim bitrate As UInteger + If UInteger.TryParse(txtMaxBitrate.Text, bitrate) Then + Dim maxbitrate As UInteger = ams.AvailableBitrates(ams.AvailableBitrates.Count - 1) + For Each b In ams.AvailableBitrates + If b <= bitrate Then + maxbitrate = b + Else + Exit For + End If + Next + + ams.DesiredMaxBitrate = maxbitrate + log("Max bitrate set to " & maxbitrate) + Else + log("Max bitrate must be a positive integer") + End If + Else + rootPage.NotifyUser("Error: Adaptive Media Source is not initialized.", NotifyType.ErrorMessage) + End If + End Sub + + Private Sub btnSetBandwidthMeasurementWindow_Click(sender As Object, e As RoutedEventArgs) + If ams IsNot Nothing Then + Dim windowSize As Integer + If Integer.TryParse(txtBandwidthMeasurementWindow.Text, windowSize) Then + ams.InboundBitsPerSecondWindow = New TimeSpan(0, 0, windowSize) + log("Bandwidth measurement window size set to " & windowSize) + Else + log("Bandwidth measurement window size must be set to an int") + End If + Else + rootPage.NotifyUser("Error: Adaptive Media Source is not initialized.", NotifyType.ErrorMessage) + End If + End Sub + End Class +End Namespace diff --git a/Samples/AdaptiveStreaming/vb/Scenario3.xaml.vb b/Samples/AdaptiveStreaming/vb/Scenario3.xaml.vb new file mode 100644 index 0000000000..210ce58da5 --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/Scenario3.xaml.vb @@ -0,0 +1,90 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Media.Streaming.Adaptive +Imports Windows.UI.Core + +Namespace Global.AdaptiveStreaming + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario3 + Inherits Page + + Private rootPage As MainPage + + Dim ams As AdaptiveMediaSource = Nothing + + Dim httpClient As Windows.Web.Http.HttpClient = Nothing + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + Async Private Sub log(s As String) + Await Me.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, New DispatchedHandler(Sub() + Dim text As TextBlock = New TextBlock() + text.Text = s + text.TextWrapping = TextWrapping.WrapWholeWords + stkOutput.Children.Add(text) + End Sub)) + End Sub + + Private Sub btnPlay_Click(sender As Object, e As Windows.UI.Xaml.RoutedEventArgs) + If String.IsNullOrEmpty(txtInputURL.Text) Then + rootPage.NotifyUser("Specify a URI to play", NotifyType.ErrorMessage) + Return + End If + + InitializeAdaptiveMediaSource(New System.Uri(txtInputURL.Text), mePlayer) + End Sub + + Async Private Sub InitializeAdaptiveMediaSource(uri As System.Uri, m As MediaElement) + httpClient = New Windows.Web.Http.HttpClient() + httpClient.DefaultRequestHeaders.TryAppendWithoutValidation("X-CustomHeader", "This is a custom header") + Dim result As AdaptiveMediaSourceCreationResult = Await AdaptiveMediaSource.CreateFromUriAsync(uri, httpClient) + If result.Status = AdaptiveMediaSourceCreationStatus.Success Then + ams = result.MediaSource + m.SetMediaStreamSource(ams) + AddHandler ams.DownloadRequested, AddressOf DownloadRequested + AddHandler ams.DownloadCompleted, AddressOf DownloadCompleted + AddHandler ams.DownloadFailed, AddressOf DownloadFailed + Else + rootPage.NotifyUser("Error creating the AdaptiveMediaSource" & vbLf & vbTab & result.Status.ToString(), NotifyType.ErrorMessage) + End If + End Sub + + Private Sub DownloadRequested(sender As AdaptiveMediaSource, args As AdaptiveMediaSourceDownloadRequestedEventArgs) + If args.ResourceType = AdaptiveMediaSourceResourceType.Key Then + Dim originalUri As String = args.ResourceUri.ToString() + Dim secureUri As String = originalUri.Replace("http:", "https:") + args.Result.ResourceUri = New Uri(secureUri) + End If + End Sub + + Private Sub DownloadCompleted(sender As AdaptiveMediaSource, args As AdaptiveMediaSourceDownloadCompletedEventArgs) + log("Download Completed. Resource Type: " & args.ResourceType.ToString() & " Resource URI: " & args.ResourceUri.ToString()) + End Sub + + Private Sub DownloadFailed(sender As AdaptiveMediaSource, args As AdaptiveMediaSourceDownloadFailedEventArgs) + log("Download Failured. Resource Type: " & args.ResourceType.ToString() & " Resource URI: " & args.ResourceUri.ToString() & vbLf & "HTTP Response:" & vbLf & args.HttpResponseMessage.ToString()) + End Sub + End Class +End Namespace diff --git a/Samples/AdaptiveStreaming/vb/Scenario4.xaml.vb b/Samples/AdaptiveStreaming/vb/Scenario4.xaml.vb new file mode 100644 index 0000000000..d19de21d78 --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/Scenario4.xaml.vb @@ -0,0 +1,235 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Media.Streaming.Adaptive +Imports Windows.UI.Core +'Simplifies call to the MediaProtectionManager +Imports Windows.Media.Protection +Imports Windows.Media.Protection.PlayReady +Imports System.Net.Http +Imports Windows.Foundation.Collections +Imports System.Net.Http.Headers +Imports LicenseRequest +Imports System.Runtime.InteropServices +Imports System.Threading.Tasks + +Namespace Global.AdaptiveStreaming + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario4 + Inherits Page + + Private rootPage As MainPage + + Dim ams As AdaptiveMediaSource = Nothing + + Private protectionManager As MediaProtectionManager = Nothing + + Dim serviceCompletionNotifier As MediaProtectionServiceCompletion = Nothing + + Private playReadyLicenseUrl As String = "" + + Private playReadyChallengeCustomData As String = "" + + Private Const MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED As Integer = -2147174251 + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + Async Private Sub log(s As String) + Await Me.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, New DispatchedHandler(Sub() + Dim text As TextBlock = New TextBlock() + text.Text = s + text.TextWrapping = TextWrapping.WrapWholeWords + stkOutput.Children.Add(text) + End Sub)) + End Sub + + Private Sub btnPlay_Click(sender As Object, e As Windows.UI.Xaml.RoutedEventArgs) + If String.IsNullOrEmpty(txtInputURL.Text) Then + rootPage.NotifyUser("Specify a URI to play", NotifyType.ErrorMessage) + Return + End If + + InitializeAdaptiveMediaSource(New System.Uri(txtInputURL.Text), mePlayer) + End Sub + + Async Private Sub InitializeAdaptiveMediaSource(uri As System.Uri, m As MediaElement) + Dim result As AdaptiveMediaSourceCreationResult = Await AdaptiveMediaSource.CreateFromUriAsync(uri) + If result.Status = AdaptiveMediaSourceCreationStatus.Success Then + ams = result.MediaSource + SetUpProtectionManager(m) + m.SetMediaStreamSource(ams) + Else + rootPage.NotifyUser("Error creating the AdaptiveMediaSource" & vbLf & vbTab & result.Status.ToString(), NotifyType.ErrorMessage) + End If + End Sub + + Private Sub SetUpProtectionManager(ByRef m As MediaElement) + log("Enter SetUpProtectionManager") + log("Creating protection system mappings...") + protectionManager = New MediaProtectionManager() + AddHandler protectionManager.ComponentLoadFailed, New ComponentLoadFailedEventHandler(AddressOf ProtectionManager_ComponentLoadFailed) + AddHandler protectionManager.ServiceRequested, New ServiceRequestedEventHandler(AddressOf ProtectionManager_ServiceRequested) + 'Setup PlayReady as the ProtectionSystem to use by MF. + 'The code here is mandatory and should be just copied directly over to the app + Dim cpSystems As Windows.Foundation.Collections.PropertySet = New Windows.Foundation.Collections.PropertySet() + cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput") + protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems) + protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}") + protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionContainerGuid", "{9A04F079-9840-4286-AB92-E65BE0885F95}") + m.ProtectionManager = protectionManager + log("Leave SetUpProtectionManager") + End Sub + + Private Async Sub ProtectionManager_ServiceRequested(sender As MediaProtectionManager, e As ServiceRequestedEventArgs) + log("Enter ProtectionManager_ServiceRequested") + If TypeOf e.Request Is PlayReadyIndividualizationServiceRequest Then + Dim IndivRequest As PlayReadyIndividualizationServiceRequest = TryCast(e.Request, PlayReadyIndividualizationServiceRequest) + Dim bResultIndiv As Boolean = Await ReactiveIndivRequest(IndivRequest, e.Completion) + ElseIf TypeOf e.Request Is PlayReadyLicenseAcquisitionServiceRequest Then + Dim licenseRequest As PlayReadyLicenseAcquisitionServiceRequest = TryCast(e.Request, PlayReadyLicenseAcquisitionServiceRequest) + LicenseAcquisitionRequest(licenseRequest, e.Completion, playReadyLicenseUrl, playReadyChallengeCustomData) + End If + + log("Leave ProtectionManager_ServiceRequested") + End Sub + + Private Sub ProtectionManager_ComponentLoadFailed(sender As MediaProtectionManager, e As ComponentLoadFailedEventArgs) + log("Enter ProtectionManager_ComponentLoadFailed") + log(e.Information.ToString()) + For i = 0 To e.Information.Items.Count - 1 + log(e.Information.Items(i).Name & vbLf & "Reasons=0x" & e.Information.Items(i).Reasons.ToString() & vbLf & "Renewal Id=" & e.Information.Items(i).RenewalId) + Next + + e.Completion.Complete(False) + log("Leave ProtectionManager_ComponentLoadFailed") + End Sub + + ''' + ''' Invoked to acquire the PlayReady License + ''' + Async Sub LicenseAcquisitionRequest(licenseRequest As PlayReadyLicenseAcquisitionServiceRequest, CompletionNotifier As MediaProtectionServiceCompletion, Url As String, ChallengeCustomData As String) + Dim bResult As Boolean = False + Dim ExceptionMessage As String = String.Empty + Try + If Not String.IsNullOrEmpty(Url) Then + log("ProtectionManager PlayReady Manual License Acquisition Service Request in progress - URL: " & Url) + If Not String.IsNullOrEmpty(ChallengeCustomData) Then + Dim encoding As System.Text.UTF8Encoding = New System.Text.UTF8Encoding() + Dim b As Byte() = encoding.GetBytes(ChallengeCustomData) + licenseRequest.ChallengeCustomData = Convert.ToBase64String(b, 0, b.Length) + End If + + Dim soapMessage As PlayReadySoapMessage = licenseRequest.GenerateManualEnablingChallenge() + Dim messageBytes As Byte() = soapMessage.GetMessageBody() + Dim httpContent As HttpContent = New ByteArrayContent(messageBytes) + Dim propertySetHeaders As IPropertySet = soapMessage.MessageHeaders + For Each strHeaderName In propertySetHeaders.Keys + Dim strHeaderValue As String = propertySetHeaders(strHeaderName).ToString() + If strHeaderName.Equals("Content-Type", StringComparison.OrdinalIgnoreCase) Then + httpContent.Headers.ContentType = MediaTypeHeaderValue.Parse(strHeaderValue) + Else + httpContent.Headers.Add(strHeaderName.ToString(), strHeaderValue) + End If + Next + + Dim licenseAcquision As CommonLicenseRequest = New CommonLicenseRequest() + Dim responseHttpContent As HttpContent = Await licenseAcquision.AcquireLicense(New Uri(Url), httpContent) + If responseHttpContent IsNot Nothing Then + Dim exResult As Exception = licenseRequest.ProcessManualEnablingResponse(Await responseHttpContent.ReadAsByteArrayAsync()) + If exResult IsNot Nothing Then + Throw exResult + End If + + bResult = True + Else + ExceptionMessage = licenseAcquision.GetLastErrorMessage() + End If + Else + log("ProtectionManager PlayReady License Acquisition Service Request in progress - URL: " & licenseRequest.Uri.ToString()) + Await licenseRequest.BeginServiceRequest() + bResult = True + End If + Catch e As Exception + ExceptionMessage = e.Message + End Try + + If bResult = True Then + log(If(Not String.IsNullOrEmpty(Url), "ProtectionManager Manual PlayReady License Acquisition Service Request successful", "ProtectionManager PlayReady License Acquisition Service Request successful")) + Else + log(If(Not String.IsNullOrEmpty(Url), "ProtectionManager Manual PlayReady License Acquisition Service Request failed: " & ExceptionMessage, "ProtectionManager PlayReady License Acquisition Service Request failed: " & ExceptionMessage)) + End If + + CompletionNotifier.Complete(bResult) + End Sub + + ''' + ''' Proactive Individualization Request + ''' + Async Sub ProActiveIndivRequest() + Dim indivRequest As PlayReadyIndividualizationServiceRequest = New PlayReadyIndividualizationServiceRequest() + log("ProtectionManager PlayReady ProActive Individualization Service Request in progress...") + Dim bResultIndiv As Boolean = Await ReactiveIndivRequest(indivRequest, Nothing) + If bResultIndiv = True Then + log("ProtectionManager PlayReady ProActive Individualization Service Request successful") + Else + log("ProtectionManager PlayReady ProActive Individualization Service Request failed") + End If + End Sub + + ''' + ''' Invoked to send the Individualization Request + ''' + Async Function ReactiveIndivRequest(IndivRequest As PlayReadyIndividualizationServiceRequest, CompletionNotifier As MediaProtectionServiceCompletion) As Task(Of Boolean) + Dim bResult As Boolean = False + Dim exception As Exception = Nothing + log("ProtectionManager PlayReady Individualization Service Request in progress...") + Try + Await IndivRequest.BeginServiceRequest() + Catch ex As Exception + exception = ex + Finally + If exception Is Nothing Then + bResult = True + Else + Dim comException As COMException = TryCast(exception, COMException) + If comException IsNot Nothing AndAlso comException.HResult = MSPR_E_CONTENT_ENABLING_ACTION_REQUIRED Then + IndivRequest.NextServiceRequest() + End If + End If + End Try + + If bResult = True Then + log("ProtectionManager PlayReady Individualization Service Request successful") + Else + log("ProtectionManager PlayReady Individualization Service Request failed") + End If + + If CompletionNotifier IsNot Nothing Then + CompletionNotifier.Complete(bResult) + End If + + Return bResult + End Function + End Class +End Namespace diff --git a/Samples/AdaptiveStreaming/vb/project.json b/Samples/AdaptiveStreaming/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/AdaptiveStreaming/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AdvancedCasting/cs/AdvancedCasting.csproj b/Samples/AdvancedCasting/cs/AdvancedCasting.csproj index 3e1a571ecd..d8cfad76b6 100644 --- a/Samples/AdvancedCasting/cs/AdvancedCasting.csproj +++ b/Samples/AdvancedCasting/cs/AdvancedCasting.csproj @@ -122,7 +122,9 @@ ProjectionViewPage.xaml - + + Properties\AssemblyInfo.cs + 01_MediaElement.xaml @@ -141,51 +143,63 @@ - + + App.xaml MSBuild:Compile Designer - + + 02_Casting_API_CastButton.xaml MSBuild:Compile Designer - + + 03_DIAL_Sender_API.xaml MSBuild:Compile Designer - + + 05_Multi_View_Media_Application.xaml MSBuild:Compile Designer - + + 06_Combine_Casting_Tech.xaml MSBuild:Compile Designer - + + UnhandledExceptionPage.xaml Designer MSBuild:Compile - + + MainPage.xaml MSBuild:Compile Designer - + + ProjectionViewPage.xaml MSBuild:Compile Designer - + + 01_MediaElement.xaml MSBuild:Compile Designer - + + 04_DIAL_Receiver_App.xaml MSBuild:Compile Designer - + + Styles\MediaTransportControlWithCustomCastButtonStyles.xaml MSBuild:Compile Designer - + + Styles\ProjectedMediaTransportControlsStyles.xaml MSBuild:Compile Designer diff --git a/Samples/AdvancedCasting/cs/ProjectionViewPage.xaml.cs b/Samples/AdvancedCasting/cs/ProjectionViewPage.xaml.cs index d5aaef8cd9..472e829470 100644 --- a/Samples/AdvancedCasting/cs/ProjectionViewPage.xaml.cs +++ b/Samples/AdvancedCasting/cs/ProjectionViewPage.xaml.cs @@ -26,17 +26,17 @@ public ProjectionViewPage() { this.InitializeComponent(); - ProjectedMediaTransportControls pmtcs = this.player.TransportControls as ProjectedMediaTransportControls; + ProjectedMediaTransportControls pmtcs = this._player.TransportControls as ProjectedMediaTransportControls; if (pmtcs != null) pmtcs.StopProjectingButtonClick += ProjectionViewPage_StopProjectingButtonClick; - this.player.MediaOpened += Player_MediaOpened; + this._player.MediaOpened += Player_MediaOpened; } private void Player_MediaOpened(object sender, RoutedEventArgs e) { - this.player.IsFullWindow = true; - this.player.AreTransportControlsEnabled = true; + this._player.IsFullWindow = true; + this._player.AreTransportControlsEnabled = true; } private void ProjectionViewPage_StopProjectingButtonClick(object sender, EventArgs e) @@ -48,18 +48,18 @@ private void ProjectionViewPage_StopProjectingButtonClick(object sender, EventAr public async Task SetMediaSource (Uri source, TimeSpan position) { - await this.player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => + await this._player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { - this.player.Source = source; - this.player.Position = position; - this.player.Play(); + this._player.Source = source; + this._player.Position = position; + this._player.Play(); }); return true; } public MediaElement Player { - get { return this.player; } + get { return this._player; } } ProjectionViewBroker broker = null; @@ -84,8 +84,8 @@ await broker.ProjectionViewPageControl.Dispatcher.RunAsync(CoreDispatcherPriorit MainPage.Current.ProjectionViewPageControl = null; }); - this.player.Stop(); - this.player.Source = null; + this._player.Stop(); + this._player.Source = null; Window.Current.Close(); } @@ -113,10 +113,10 @@ public async void StopProjecting() // There may be cases to end the projection from the projected view // (e.g. the presentation hosted in that view concludes) // broker.ProjectionViewPageControl.StartViewInUse(); - await this.player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => + await this._player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => { - this.player.Stop(); - this.player.Source = null; + this._player.Stop(); + this._player.Source = null; broker.ProjectionViewPageControl.StartViewInUse(); diff --git a/Samples/AdvancedCasting/cs/Properties/AssemblyInfo.cs b/Samples/AdvancedCasting/cs/Properties/AssemblyInfo.cs deleted file mode 100644 index 8deb85e22b..0000000000 --- a/Samples/AdvancedCasting/cs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ScreenCasting")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ScreenCasting")] -[assembly: AssemblyCopyright("Copyright 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] diff --git a/Samples/AdvancedCasting/cs/01_MediaElement.xaml b/Samples/AdvancedCasting/shared/01_MediaElement.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/01_MediaElement.xaml rename to Samples/AdvancedCasting/shared/01_MediaElement.xaml diff --git a/Samples/AdvancedCasting/cs/02_Casting_API_CastButton.xaml b/Samples/AdvancedCasting/shared/02_Casting_API_CastButton.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/02_Casting_API_CastButton.xaml rename to Samples/AdvancedCasting/shared/02_Casting_API_CastButton.xaml diff --git a/Samples/AdvancedCasting/cs/03_DIAL_Sender_API.xaml b/Samples/AdvancedCasting/shared/03_DIAL_Sender_API.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/03_DIAL_Sender_API.xaml rename to Samples/AdvancedCasting/shared/03_DIAL_Sender_API.xaml diff --git a/Samples/AdvancedCasting/cs/04_DIAL_Receiver_App.xaml b/Samples/AdvancedCasting/shared/04_DIAL_Receiver_App.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/04_DIAL_Receiver_App.xaml rename to Samples/AdvancedCasting/shared/04_DIAL_Receiver_App.xaml diff --git a/Samples/AdvancedCasting/cs/05_Multi_View_Media_Application.xaml b/Samples/AdvancedCasting/shared/05_Multi_View_Media_Application.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/05_Multi_View_Media_Application.xaml rename to Samples/AdvancedCasting/shared/05_Multi_View_Media_Application.xaml diff --git a/Samples/AdvancedCasting/cs/06_Combine_Casting_Tech.xaml b/Samples/AdvancedCasting/shared/06_Combine_Casting_Tech.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/06_Combine_Casting_Tech.xaml rename to Samples/AdvancedCasting/shared/06_Combine_Casting_Tech.xaml diff --git a/Samples/AdvancedCasting/cs/App.xaml b/Samples/AdvancedCasting/shared/App.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/App.xaml rename to Samples/AdvancedCasting/shared/App.xaml diff --git a/Samples/AdvancedCasting/cs/MainPage.xaml b/Samples/AdvancedCasting/shared/MainPage.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/MainPage.xaml rename to Samples/AdvancedCasting/shared/MainPage.xaml diff --git a/Samples/AdvancedCasting/cs/Styles/MediaTransportControlWithCustomCastButtonStyles.xaml b/Samples/AdvancedCasting/shared/MediaTransportControlWithCustomCastButtonStyles.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/Styles/MediaTransportControlWithCustomCastButtonStyles.xaml rename to Samples/AdvancedCasting/shared/MediaTransportControlWithCustomCastButtonStyles.xaml diff --git a/Samples/AdvancedCasting/cs/Styles/ProjectedMediaTransportControlsStyles.xaml b/Samples/AdvancedCasting/shared/ProjectedMediaTransportControlsStyles.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/Styles/ProjectedMediaTransportControlsStyles.xaml rename to Samples/AdvancedCasting/shared/ProjectedMediaTransportControlsStyles.xaml diff --git a/Samples/AdvancedCasting/cs/ProjectionViewPage.xaml b/Samples/AdvancedCasting/shared/ProjectionViewPage.xaml similarity index 94% rename from Samples/AdvancedCasting/cs/ProjectionViewPage.xaml rename to Samples/AdvancedCasting/shared/ProjectionViewPage.xaml index a8c8848000..97f9dc18bc 100644 --- a/Samples/AdvancedCasting/cs/ProjectionViewPage.xaml +++ b/Samples/AdvancedCasting/shared/ProjectionViewPage.xaml @@ -30,7 +30,7 @@ - + diff --git a/Samples/AdvancedCasting/cs/UnhandledExceptionPage.xaml b/Samples/AdvancedCasting/shared/UnhandledExceptionPage.xaml similarity index 100% rename from Samples/AdvancedCasting/cs/UnhandledExceptionPage.xaml rename to Samples/AdvancedCasting/shared/UnhandledExceptionPage.xaml diff --git a/Samples/AdvancedCasting/vb/01_MediaElement.xaml.vb b/Samples/AdvancedCasting/vb/01_MediaElement.xaml.vb new file mode 100644 index 0000000000..864243c56b --- /dev/null +++ b/Samples/AdvancedCasting/vb/01_MediaElement.xaml.vb @@ -0,0 +1,61 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Data.Azure +Imports ScreenCasting.Data.Common +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + Public NotInheritable Partial Class Scenario01 + Inherits Page + + Private rootPage As MainPage + + Private video As VideoMetaData + + Public Sub New() + Me.InitializeComponent() + rootPage = MainPage.Current + AddHandler player.MediaOpened, AddressOf Player_MediaOpened + AddHandler player.MediaFailed, AddressOf Player_MediaFailed + AddHandler player.CurrentStateChanged, AddressOf Player_CurrentStateChanged + ' Get a video + Dim dataProvider As AzureDataProvider = New AzureDataProvider() + video = dataProvider.GetRandomVideo() + Me.player.Source = video.VideoLink + Me.LicenseText.Text = "License: " & video.License + rootPage.NotifyUser(String.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage) + Me.player.TransportControls.IsCompact = True + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + +#Region " Media Element Methods " + Private Sub Player_CurrentStateChanged(sender As Object, e As RoutedEventArgs) + If Me.player.CurrentState <> Windows.UI.Xaml.Media.MediaElementState.Closed Then + rootPage.NotifyUser(String.Format("{0} '{1}'", Me.player.CurrentState, video.Title), NotifyType.StatusMessage) + End If + End Sub + + Private Sub Player_MediaFailed(sender As Object, e As ExceptionRoutedEventArgs) + rootPage.NotifyUser(String.Format("Failed to load '{0}', {1}", video.Title, e.ErrorMessage), NotifyType.ErrorMessage) + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("Openend '{0}'", video.Title), NotifyType.StatusMessage) + End Sub +#End Region + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/02_Casting_API_CastButton.xaml.vb b/Samples/AdvancedCasting/vb/02_Casting_API_CastButton.xaml.vb new file mode 100644 index 0000000000..85f0347542 --- /dev/null +++ b/Samples/AdvancedCasting/vb/02_Casting_API_CastButton.xaml.vb @@ -0,0 +1,139 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Controls +Imports ScreenCasting.Data.Azure +Imports ScreenCasting.Data.Common +Imports System +Imports Windows.Devices.Enumeration +Imports Windows.Foundation +Imports Windows.Media.Casting +Imports Windows.UI +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Media.Imaging +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + Public NotInheritable Partial Class Scenario02 + Inherits Page + + Private rootPage As MainPage + + Private picker As CastingDevicePicker = Nothing + + Private video As VideoMetaData = Nothing + + Private connection As CastingConnection + + Public Sub New() + Me.InitializeComponent() + rootPage = MainPage.Current + AddHandler player.MediaOpened, AddressOf Player_MediaOpened + AddHandler player.MediaFailed, AddressOf Player_MediaFailed + AddHandler player.CurrentStateChanged, AddressOf Player_CurrentStateChanged + ' Get an Azure hosted video + Dim dataProvider As AzureDataProvider = New AzureDataProvider() + video = dataProvider.GetRandomVideo() + rootPage.NotifyUser(String.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage) + player.Source = video.VideoLink + Me.LicenseText.Text = "License: " & video.License + AddHandler(CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton)).CastButtonClicked, AddressOf TransportControls_CastButtonClicked + picker = New CastingDevicePicker() + picker.Filter.SupportedCastingSources.Add(player.GetAsCastingSource()) + AddHandler picker.CastingDeviceSelected, AddressOf Picker_CastingDeviceSelected + AddHandler picker.CastingDevicePickerDismissed, AddressOf Picker_CastingDevicePickerDismissed + picker.Appearance.BackgroundColor = Colors.Black + picker.Appearance.ForegroundColor = Colors.White + picker.Appearance.AccentColor = Colors.Gray + picker.Appearance.SelectedAccentColor = Colors.Gray + picker.Appearance.SelectedForegroundColor = Colors.White + picker.Appearance.SelectedBackgroundColor = Colors.Black + End Sub + + Private Sub TransportControls_CastButtonClicked(sender As Object, e As EventArgs) + rootPage.NotifyUser("Custom Cast Button Clicked", NotifyType.StatusMessage) + player.Pause() + 'Get the custom transport controls + Dim mtc As MediaTransportControlsWithCustomCastButton = CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton) + 'Retrieve the location of the casting button + Dim transform As GeneralTransform = mtc.CastButton.TransformToVisual(TryCast(Window.Current.Content, UIElement)) + Dim pt As Point = transform.TransformPoint(New Point(0, 0)) + picker.Show(New Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above) + End Sub + + Private Async Sub Picker_CastingDevicePickerDismissed(sender As CastingDevicePicker, args As Object) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + player.Play() + End Sub) + End Sub + + Private Async Sub Picker_CastingDeviceSelected(sender As CastingDevicePicker, args As CastingDeviceSelectedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + Try + rootPage.NotifyUser(String.Format("Picker DeviceSelected event fired for device '{0}'", args.SelectedCastingDevice.FriendlyName), NotifyType.StatusMessage) + rootPage.NotifyUser(String.Format("Creating connection for '{0}'", args.SelectedCastingDevice.FriendlyName), NotifyType.StatusMessage) + connection = args.SelectedCastingDevice.CreateCastingConnection() + AddHandler connection.ErrorOccurred, AddressOf Connection_ErrorOccurred + AddHandler connection.StateChanged, AddressOf Connection_StateChanged + ' Get the casting source from the MediaElement + Dim source As CastingSource = Nothing + Try + source = player.GetAsCastingSource() + rootPage.NotifyUser(String.Format("Starting casting to '{0}'", args.SelectedCastingDevice.FriendlyName), NotifyType.StatusMessage) + Dim status As CastingConnectionErrorStatus = Await connection.RequestStartCastingAsync(source) + If status = CastingConnectionErrorStatus.Succeeded Then + player.Play() + rootPage.NotifyUser(String.Format("Starting casting to '{0}'", args.SelectedCastingDevice.FriendlyName), NotifyType.StatusMessage) + End If + Catch + rootPage.NotifyUser(String.Format("Failed to get casting source for video '{0}'", video.Title), NotifyType.ErrorMessage) + End Try + Catch ex As Exception + UnhandledExceptionPage.ShowUnhandledException(ex) + End Try + End Sub) + End Sub + +#Region " Casting Connection Status Methods " + Private Async Sub Connection_StateChanged(sender As CastingConnection, args As Object) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Casting Connection State Changed: " & sender.State.ToString(), NotifyType.StatusMessage) + End Sub) + End Sub + + Private Async Sub Connection_ErrorOccurred(sender As CastingConnection, args As CastingConnectionErrorOccurredEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Connection Error Occured: " & args.Message, NotifyType.ErrorMessage) + End Sub) + End Sub + +#End Region +#Region " Media Element Status Methods " + Private Sub Player_CurrentStateChanged(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("{0} '{1}'", Me.player.CurrentState, video.Title), NotifyType.StatusMessage) + End Sub + + Private Sub Player_MediaFailed(sender As Object, e As ExceptionRoutedEventArgs) + rootPage.NotifyUser(String.Format("Failed to load '{0}'", video.Title), NotifyType.ErrorMessage) + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("Openend '{0}'", video.Title), NotifyType.StatusMessage) + End Sub + +#End Region + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/03_DIAL_Sender_API.xaml.vb b/Samples/AdvancedCasting/vb/03_DIAL_Sender_API.xaml.vb new file mode 100644 index 0000000000..76c73cf193 --- /dev/null +++ b/Samples/AdvancedCasting/vb/03_DIAL_Sender_API.xaml.vb @@ -0,0 +1,176 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Controls +Imports ScreenCasting.Data.Azure +Imports ScreenCasting.Data.Common +Imports System +Imports Windows.Devices.Enumeration +Imports Windows.Foundation +Imports Windows.Media.DialProtocol +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + Public NotInheritable Partial Class Scenario03 + Inherits Page + + Private rootPage As MainPage + + Private picker As DialDevicePicker = Nothing + + Private video As VideoMetaData = Nothing + + Private activeDialDevice As DialDevice = Nothing + + Private activeDeviceInformation As DeviceInformation = Nothing + + Public Sub New() + Me.InitializeComponent() + rootPage = MainPage.Current + AddHandler player.MediaOpened, AddressOf Player_MediaOpened + AddHandler player.MediaFailed, AddressOf Player_MediaFailed + AddHandler player.CurrentStateChanged, AddressOf Player_CurrentStateChanged + ' Get an Azure hosted video + Dim dataProvider As AzureDataProvider = New AzureDataProvider() + video = dataProvider.GetRandomVideo() + rootPage.NotifyUser(String.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage) + Me.player.Source = video.VideoLink + AddHandler(CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton)).CastButtonClicked, AddressOf TransportControls_CastButtonClicked + Me.dial_launch_args_textbox.Text = String.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id) + AddHandler(CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton)).CastButtonClicked, AddressOf TransportControls_CastButtonClicked + picker = New DialDevicePicker() + picker.Filter.SupportedAppNames.Add(Me.dial_appname_textbox.Text) + AddHandler picker.DialDeviceSelected, AddressOf Picker_DeviceSelected + AddHandler picker.DisconnectButtonClicked, AddressOf Picker_DisconnectButtonClicked + AddHandler picker.DialDevicePickerDismissed, AddressOf Picker_DevicePickerDismissed + End Sub + + Private Sub TransportControls_CastButtonClicked(sender As Object, e As EventArgs) + rootPage.NotifyUser("Show Device Picker Button Clicked", NotifyType.StatusMessage) + player.Pause() + 'Get the custom transport controls + Dim mtc As MediaTransportControlsWithCustomCastButton = CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton) + 'Retrieve the location of the casting button + Dim transform As GeneralTransform = mtc.CastButton.TransformToVisual(TryCast(Window.Current.Content, UIElement)) + Dim pt As Point = transform.TransformPoint(New Point(0, 0)) + picker.Show(New Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above) + Try + If activeDialDevice IsNot Nothing Then + picker.SetDisplayStatus(activeDialDevice, DialDeviceDisplayStatus.Connected) + End If + Catch ex As Exception + UnhandledExceptionPage.ShowUnhandledException(ex) + End Try + End Sub + +#Region " Device Picker Methods " + Private Async Sub Picker_DevicePickerDismissed(sender As DialDevicePicker, args As Object) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + Try + rootPage.NotifyUser(String.Format("Picker DevicePickerDismissed event fired for device"), NotifyType.StatusMessage) + If activeDialDevice IsNot Nothing Then + Me.player.Play() + End If + Catch ex As Exception + UnhandledExceptionPage.ShowUnhandledException(ex) + End Try + End Sub) + End Sub + + Private Async Sub Picker_DisconnectButtonClicked(sender As DialDevicePicker, args As DialDisconnectButtonClickedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + Try + rootPage.NotifyUser(String.Format("Picker DisconnectButtonClicked event fired for device '{0}'", activeDeviceInformation.Name), NotifyType.StatusMessage) + ' Get the DialDevice instance for the selected device + Dim selectedDialDevice As DialDevice = Await DialDevice.FromIdAsync(args.Device.Id) + picker.SetDisplayStatus(selectedDialDevice, DialDeviceDisplayStatus.Connecting) + Dim app As DialApp = selectedDialDevice.GetDialApp(Me.dial_appname_textbox.Text) + 'Get the current application state + 'DialAppStateDetails stateDetails = await app.GetAppStateAsync(); + Dim result As DialAppStopResult = Await app.StopAsync() + If result = DialAppStopResult.Stopped Then + rootPage.NotifyUser("Application stopped successfully.", NotifyType.StatusMessage) + picker.SetDisplayStatus(args.Device, DialDeviceDisplayStatus.Disconnected) + activeDialDevice = Nothing + activeDeviceInformation = Nothing + picker.Hide() + Else + If result = DialAppStopResult.StopFailed OrElse result = DialAppStopResult.NetworkFailure Then + rootPage.NotifyUser(String.Format("Error occured trying to stop application. Status: '{0}'", result.ToString()), NotifyType.StatusMessage) + picker.SetDisplayStatus(args.Device, DialDeviceDisplayStatus.Error) + Else + rootPage.NotifyUser(String.Format("Stop is not supported by device: '{0}'", activeDeviceInformation.Name), NotifyType.ErrorMessage) + activeDialDevice = Nothing + activeDeviceInformation = Nothing + End If + End If + Catch ex As Exception + UnhandledExceptionPage.ShowUnhandledException(ex) + End Try + End Sub) + End Sub + + Private Async Sub Picker_DeviceSelected(sender As DialDevicePicker, args As DialDeviceSelectedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + Try + rootPage.NotifyUser(String.Format("Picker DeviceSelected event fired"), NotifyType.StatusMessage) + picker.SetDisplayStatus(args.SelectedDialDevice, DialDeviceDisplayStatus.Connecting) + rootPage.NotifyUser(String.Format("Resolving DialDevice'"), NotifyType.StatusMessage) + 'Get the DialApp object for the specific application on the selected device + Dim app As DialApp = args.SelectedDialDevice.GetDialApp(Me.dial_appname_textbox.Text) + If app Is Nothing Then + picker.SetDisplayStatus(args.SelectedDialDevice, DialDeviceDisplayStatus.Error) + Else + rootPage.NotifyUser(String.Format("Attempting to launch '{0}'", app.AppName), NotifyType.StatusMessage) + 'Launch the application on the 1st screen device + Dim result As DialAppLaunchResult = Await app.RequestLaunchAsync(Me.dial_launch_args_textbox.Text) + If result = DialAppLaunchResult.Launched Then + rootPage.NotifyUser(String.Format("Launched '{0}'", app.AppName), NotifyType.StatusMessage) + activeDialDevice = args.SelectedDialDevice + Dim selectedDeviceInformation As DeviceInformation = Await DeviceInformation.CreateFromIdAsync(args.SelectedDialDevice.Id) + activeDeviceInformation = selectedDeviceInformation + picker.SetDisplayStatus(activeDialDevice, DialDeviceDisplayStatus.Connected) + picker.Hide() + Else + rootPage.NotifyUser(String.Format("Attempting to launch '{0}'", app.AppName), NotifyType.StatusMessage) + picker.SetDisplayStatus(args.SelectedDialDevice, DialDeviceDisplayStatus.Error) + End If + End If + Catch ex As Exception + UnhandledExceptionPage.ShowUnhandledException(ex) + End Try + End Sub) + End Sub + +#End Region +#Region " Media Element Status Methods " + Private Sub Player_CurrentStateChanged(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("{0} '{1}'", Me.player.CurrentState, video.Title), NotifyType.StatusMessage) + End Sub + + Private Sub Player_MediaFailed(sender As Object, e As ExceptionRoutedEventArgs) + rootPage.NotifyUser(String.Format("Failed to load '{0}'", video.Title), NotifyType.ErrorMessage) + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("Openend '{0}'", video.Title), NotifyType.StatusMessage) + player.Play() + End Sub + +#End Region + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/04_DIAL_Receiver_App.xaml.vb b/Samples/AdvancedCasting/vb/04_DIAL_Receiver_App.xaml.vb new file mode 100644 index 0000000000..d905aed6e1 --- /dev/null +++ b/Samples/AdvancedCasting/vb/04_DIAL_Receiver_App.xaml.vb @@ -0,0 +1,102 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Data.Azure +Imports ScreenCasting.Data.Common +Imports ScreenCasting.Util +Imports System +Imports Windows.ApplicationModel.Activation +Imports Windows.Storage +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + Public NotInheritable Partial Class Scenario04 + Inherits Page + + Private rootPage As MainPage + + Private video As VideoMetaData = Nothing + + Private originalPosition As TimeSpan = New TimeSpan(0) + + Public Sub New() + Me.InitializeComponent() + rootPage = MainPage.Current + AddHandler rootPage.SizeChanged, AddressOf RootPage_SizeChanged + End Sub + + Protected Async Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + AddHandler player.MediaOpened, AddressOf Player_MediaOpened + AddHandler player.MediaFailed, AddressOf Player_MediaFailed + AddHandler player.CurrentStateChanged, AddressOf Player_CurrentStateChanged + AddHandler player.MediaEnded, AddressOf Player_MediaEnded + If TypeOf e.Parameter Is DialReceiverActivatedEventArgs Then + Dim activationArgs As DialReceiverActivatedEventArgs = CType(e.Parameter, DialReceiverActivatedEventArgs) + 'Parse the DIAL arguments from the activation arguments + Dim dialArgs As DialLaunchArguments = DialLaunchArguments.Parse(activationArgs.Arguments) + ' Get the list of available Azure videos. + Dim dataProvider As AzureDataProvider = New AzureDataProvider() + video = dataProvider.GetFromID(dialArgs.VideoId) + rootPage.NotifyUser(String.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage) + Me.player.Source = video.VideoLink + Me.LicenseText.Text = "License: " & video.License + player.Position = dialArgs.Position + Else + Dim localVideo As StorageFile = Await StorageFile.GetFileFromApplicationUriAsync(New Uri("ms-appx:///Assets/casting.mp4")) + Dim stream = Await localVideo.OpenAsync(FileAccessMode.Read) + Me.player.SetSource(stream, localVideo.FileType) + End If + End Sub + + Private Sub Player_MediaEnded(sender As Object, e As RoutedEventArgs) + If video Is Nothing Then + Me.player.Position = New TimeSpan(0) + Me.player.Play() + End If + End Sub + + Private Sub RootPage_SizeChanged(sender As Object, e As SizeChangedEventArgs) + Me.player.Height = Me.Height + Me.player.Width = Me.Width + End Sub + +#Region " Media Element Methods " + Private Sub Player_CurrentStateChanged(sender As Object, e As RoutedEventArgs) + If video Is Nothing Then + rootPage.NotifyUser(String.Format("{0}", Me.player.CurrentState), NotifyType.StatusMessage) + Else + rootPage.NotifyUser(String.Format("{0} '{1}'", Me.player.CurrentState, video.Title), NotifyType.StatusMessage) + End If + End Sub + + Private Sub Player_MediaFailed(sender As Object, e As ExceptionRoutedEventArgs) + If video Is Nothing Then + rootPage.NotifyUser(String.Format("Failed to load"), NotifyType.ErrorMessage) + Else + rootPage.NotifyUser(String.Format("Failed to load '{0}'", video.Title), NotifyType.ErrorMessage) + End If + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + If video Is Nothing Then + rootPage.NotifyUser(String.Format("Openend"), NotifyType.StatusMessage) + Else + rootPage.NotifyUser(String.Format("Openend '{0}'", "Title"), NotifyType.StatusMessage) + End If + + player.Play() + End Sub +#End Region + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/05_Multi_View_Media_Application.xaml.vb b/Samples/AdvancedCasting/vb/05_Multi_View_Media_Application.xaml.vb new file mode 100644 index 0000000000..988e3ff920 --- /dev/null +++ b/Samples/AdvancedCasting/vb/05_Multi_View_Media_Application.xaml.vb @@ -0,0 +1,189 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Controls +Imports ScreenCasting.Data.Azure +Imports ScreenCasting.Data.Common +Imports ScreenCasting.Util +Imports System +Imports Windows.ApplicationModel.Core +Imports Windows.Devices.Enumeration +Imports Windows.Foundation +Imports Windows.UI.Core +Imports Windows.UI.ViewManagement +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Media.Imaging +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + Partial Public NotInheritable Class Scenario05 + Inherits Page + + Private rootPage As MainPage + + Private picker As DevicePicker + + Private video As VideoMetaData = Nothing + + Dim pvb As ProjectionViewBroker = New ProjectionViewBroker() + + Dim activeDevice As DeviceInformation = Nothing + + Dim thisViewId As Integer + + Public Sub New() + Me.InitializeComponent() + rootPage = MainPage.Current + AddHandler player.MediaOpened, AddressOf Player_MediaOpened + AddHandler player.MediaFailed, AddressOf Player_MediaFailed + AddHandler player.CurrentStateChanged, AddressOf Player_CurrentStateChanged + ' Get an Azure hosted video + Dim dataProvider As AzureDataProvider = New AzureDataProvider() + video = dataProvider.GetRandomVideo() + rootPage.NotifyUser(String.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage) + Me.player.Source = video.VideoLink + Me.LicenseText.Text = "License: " & video.License + AddHandler(CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton)).CastButtonClicked, AddressOf TransportControls_CastButtonClicked + picker = New DevicePicker() + picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector()) + AddHandler picker.DeviceSelected, AddressOf Picker_DeviceSelected + AddHandler picker.DisconnectButtonClicked, AddressOf Picker_DisconnectButtonClicked + AddHandler picker.DevicePickerDismissed, AddressOf Picker_DevicePickerDismissed + AddHandler pvb.ProjectionStopping, AddressOf Pvb_ProjectionStopping + End Sub + + Private Sub TransportControls_CastButtonClicked(sender As Object, e As EventArgs) + rootPage.NotifyUser("Custom Cast Button Clicked", NotifyType.StatusMessage) + player.Pause() + 'Get the custom transport controls + Dim mtc As MediaTransportControlsWithCustomCastButton = CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton) + 'Retrieve the location of the casting button + Dim transform As GeneralTransform = mtc.CastButton.TransformToVisual(TryCast(Window.Current.Content, UIElement)) + Dim pt As Point = transform.TransformPoint(New Point(0, 0)) + picker.Show(New Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above) + End Sub + + Private Async Sub Picker_DeviceSelected(sender As DevicePicker, args As DeviceSelectedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + Try + picker.SetDisplayStatus(args.SelectedDevice, "Connecting", DevicePickerDisplayStatusOptions.ShowProgress) + ' Getting the selected device improves debugging + Dim selectedDevice As DeviceInformation = args.SelectedDevice + thisViewId = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Id + If rootPage.ProjectionViewPageControl Is Nothing Then + ' First, create a new, blank view + Dim thisDispatcher = Window.Current.Dispatcher + Await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + rootPage.ProjectionViewPageControl = ViewLifetimeControl.CreateForCurrentView() + pvb.MainPageDispatcher = thisDispatcher + pvb.ProjectionViewPageControl = rootPage.ProjectionViewPageControl + pvb.MainViewId = thisViewId + ' Display the page in the view. Note that the view will not become visible + ' until "StartProjectingAsync" is called + Dim rootFrame = New Frame() + rootFrame.Navigate(GetType(ProjectionViewPage), pvb) + Window.Current.Content = rootFrame + Window.Current.Activate() + End Sub) + End If + + Try + rootPage.ProjectionViewPageControl.StartViewInUse() + Try + Await ProjectionManager.StartProjectingAsync(rootPage.ProjectionViewPageControl.Id, thisViewId, selectedDevice) + Catch ex As Exception + If Not ProjectionManager.ProjectionDisplayAvailable OrElse pvb.ProjectedPage Is Nothing Then + Throw ex + End If + + End Try + + If ProjectionManager.ProjectionDisplayAvailable AndAlso pvb.ProjectedPage IsNot Nothing Then + Me.player.Pause() + Await pvb.ProjectedPage.SetMediaSource(Me.player.Source, Me.player.Position) + activeDevice = selectedDevice + picker.SetDisplayStatus(args.SelectedDevice, "Connected", DevicePickerDisplayStatusOptions.ShowDisconnectButton) + picker.Hide() + Else + rootPage.NotifyUser(String.Format("Projection has failed to '{0}'", selectedDevice.Name), NotifyType.ErrorMessage) + picker.SetDisplayStatus(args.SelectedDevice, "Connection Failed", DevicePickerDisplayStatusOptions.ShowRetryButton) + End If + Catch + rootPage.NotifyUser(String.Format("Projection has failed to '{0}'", selectedDevice.Name), NotifyType.ErrorMessage) + Try + picker.SetDisplayStatus(args.SelectedDevice, "Connection Failed", DevicePickerDisplayStatusOptions.ShowRetryButton) + Catch + End Try + + End Try + Catch ex As Exception + UnhandledExceptionPage.ShowUnhandledException(ex) + End Try + End Sub) + End Sub + + Private Async Sub Picker_DevicePickerDismissed(sender As DevicePicker, args As Object) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + If activeDevice Is Nothing Then + player.Play() + End If + End Sub) + End Sub + + Private Async Sub Picker_DisconnectButtonClicked(sender As DevicePicker, args As DeviceDisconnectButtonClickedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Disconnect Button clicked", NotifyType.StatusMessage) + sender.SetDisplayStatus(args.Device, "Disconnecting", DevicePickerDisplayStatusOptions.ShowProgress) + If Me.pvb.ProjectedPage IsNot Nothing Then + Me.pvb.ProjectedPage.StopProjecting() + End If + + sender.SetDisplayStatus(args.Device, "Disconnected", DevicePickerDisplayStatusOptions.None) + rootPage.NotifyUser("Disconnected", NotifyType.StatusMessage) + activeDevice = Nothing + End Sub) + End Sub + + Private Async Sub Pvb_ProjectionStopping(sender As Object, e As EventArgs) + Dim broker As ProjectionViewBroker = TryCast(sender, ProjectionViewBroker) + Dim position As TimeSpan = broker.ProjectedPage.Player.Position + Dim source As Uri = broker.ProjectedPage.Player.Source + Await rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Resuming playback on the first screen", NotifyType.StatusMessage) + Me.player.Source = source + Me.player.Position = position + Me.player.Play() + rootPage.ProjectionViewPageControl = Nothing + End Sub) + End Sub + +#Region " Media Element Status Methods " + Private Sub Player_CurrentStateChanged(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("{0} '{1}'", Me.player.CurrentState, video.Title), NotifyType.StatusMessage) + End Sub + + Private Sub Player_MediaFailed(sender As Object, e As ExceptionRoutedEventArgs) + rootPage.NotifyUser(String.Format("Failed to load '{0}'", video.Title), NotifyType.ErrorMessage) + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("Openend '{0}'", video.Title), NotifyType.StatusMessage) + player.Play() + End Sub + +#End Region + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/06_Combine_Casting_Tech.xaml.vb b/Samples/AdvancedCasting/vb/06_Combine_Casting_Tech.xaml.vb new file mode 100644 index 0000000000..468d79e56c --- /dev/null +++ b/Samples/AdvancedCasting/vb/06_Combine_Casting_Tech.xaml.vb @@ -0,0 +1,420 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.Foundation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports Windows.UI.Xaml.Media +Imports Windows.Media.DialProtocol +Imports ScreenCasting.Data.Azure +Imports ScreenCasting.Data.Common +Imports Windows.Devices.Enumeration +Imports System.Threading.Tasks +Imports Windows.Media.Casting +Imports ScreenCasting.Controls +Imports ScreenCasting.Util +Imports Windows.UI.ViewManagement +Imports Windows.ApplicationModel.Core +Imports Windows.UI.Core +Imports Windows.Storage + +Namespace Global.ScreenCasting + + Partial Public NotInheritable Class Scenario06 + Inherits Page + + Private Const MAX_RESULTS As Integer = 10 + + Private rootPage As MainPage + + Private picker As DevicePicker = Nothing + + Private activeDevice As DeviceInformation = Nothing + + Private activeCastConnectionHandler As Object = Nothing + + Private video As VideoMetaData = Nothing + + Dim thisViewId As Integer + + Public Sub New() + Me.InitializeComponent() + rootPage = MainPage.Current + AddHandler player.MediaOpened, AddressOf Player_MediaOpened + AddHandler player.MediaFailed, AddressOf Player_MediaFailed + AddHandler player.CurrentStateChanged, AddressOf Player_CurrentStateChanged + ' Get an Azure hosted video + Dim dataProvider As AzureDataProvider = New AzureDataProvider() + video = dataProvider.GetRandomVideo() + rootPage.NotifyUser(String.Format("Opening '{0}'", video.Title), NotifyType.StatusMessage) + Me.player.Source = video.VideoLink + Me.LicenseText.Text = "License: " & video.License + Me.dial_launch_args_textbox.Text = String.Format("v={0}&t=0&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id) + AddHandler(CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton)).CastButtonClicked, AddressOf TransportControls_CastButtonClicked + picker = New DevicePicker() + AddHandler picker.DeviceSelected, AddressOf Picker_DeviceSelected + AddHandler picker.DisconnectButtonClicked, AddressOf Picker_DisconnectButtonClicked + AddHandler picker.DevicePickerDismissed, AddressOf Picker_DevicePickerDismissed + picker.Filter.SupportedDeviceSelectors.Add("System.Devices.DevObjectType:=6 AND System.Devices.AepContainer.ProtocolIds:~~{0E261DE4-12F0-46E6-91BA-428607CCEF64} AND System.Devices.AepContainer.Categories:~~Multimedia.ApplicationLauncher.DIAL") + picker.Filter.SupportedDeviceSelectors.Add("System.Devices.InterfaceClassGuid:=""{D0875FB4-2196-4c7a-A63D-E416ADDD60A1}""" & " AND System.Devices.InterfaceEnabled:=System.StructuredQueryType.Boolean#True") + picker.Filter.SupportedDeviceSelectors.Add(ProjectionManager.GetDeviceSelector()) + AddHandler pvb.ProjectionStopping, AddressOf Pvb_ProjectionStopping + End Sub + + Dim pvb As ProjectionViewBroker = New ProjectionViewBroker() + + Private Sub TransportControls_CastButtonClicked(sender As Object, e As EventArgs) + player.Pause() + rootPage.NotifyUser("Show Device Picker Button Clicked", NotifyType.StatusMessage) + 'Get the custom transport controls + Dim mtc As MediaTransportControlsWithCustomCastButton = CType(Me.player.TransportControls, MediaTransportControlsWithCustomCastButton) + 'Retrieve the location of the casting button + Dim transform As GeneralTransform = mtc.CastButton.TransformToVisual(TryCast(Window.Current.Content, UIElement)) + Dim pt As Point = transform.TransformPoint(New Point(0, 0)) + picker.Show(New Rect(pt.X, pt.Y, mtc.CastButton.ActualWidth, mtc.CastButton.ActualHeight), Windows.UI.Popups.Placement.Above) + End Sub + +#Region " Device Picker Methods " + Private Async Sub Picker_DeviceSelected(sender As DevicePicker, args As DeviceSelectedEventArgs) + Dim deviceId As String = args.SelectedDevice.Id + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + Try + picker.SetDisplayStatus(args.SelectedDevice, "Connecting", DevicePickerDisplayStatusOptions.ShowProgress) + Catch + End Try + + 'The selectedDeviceInfo instance is needed to be able to update the picker. + Dim selectedDeviceInfo As DeviceInformation = args.SelectedDevice +#If DEBUG Then + selectedDeviceInfo = Await DeviceInformation.CreateFromIdAsync(args.SelectedDevice.Id) +#End If + Dim castSucceeded As Boolean = False + castSucceeded = Await TryLaunchDialAppAsync(selectedDeviceInfo) + If Not castSucceeded Then + castSucceeded = Await TryProjectionManagerCastAsync(selectedDeviceInfo) + End If + + If Not castSucceeded Then + castSucceeded = Await TryCastMediaElementAsync(selectedDeviceInfo) + End If + + If castSucceeded Then + Try + picker.SetDisplayStatus(selectedDeviceInfo, "Connected", DevicePickerDisplayStatusOptions.ShowDisconnectButton) + Catch + End Try + + Try + picker.Hide() + Catch + End Try + Else + Try + picker.SetDisplayStatus(selectedDeviceInfo, "Connecting failed", DevicePickerDisplayStatusOptions.ShowRetryButton) + Catch + End Try + End If + End Sub) + End Sub + + Private Async Sub Picker_DevicePickerDismissed(sender As DevicePicker, args As Object) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + If activeDevice Is Nothing Then + player.Play() + End If + End Sub) + End Sub + + Private Async Sub Picker_DisconnectButtonClicked(sender As DevicePicker, args As DeviceDisconnectButtonClickedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + rootPage.NotifyUser("Disconnect Button clicked", NotifyType.StatusMessage) + sender.SetDisplayStatus(args.Device, "Disconnecting", DevicePickerDisplayStatusOptions.ShowProgress) + Dim disconnected As Boolean = False + If TypeOf Me.activeCastConnectionHandler Is ProjectionViewBroker Then + disconnected = TryStopProjectionManagerAsync(CType(activeCastConnectionHandler, ProjectionViewBroker)) + End If + + If TypeOf Me.activeCastConnectionHandler Is DialApp Then + disconnected = Await TryStopDialAppAsync(CType(activeCastConnectionHandler, DialApp)) + End If + + If TypeOf Me.activeCastConnectionHandler Is CastingConnection Then + disconnected = Await TryDisconnectCastingSessionAsync(CType(activeCastConnectionHandler, CastingConnection)) + End If + + If disconnected Then + Try + sender.SetDisplayStatus(args.Device, "Disconnected", DevicePickerDisplayStatusOptions.None) + Catch + End Try + + activeDevice = Nothing + activeCastConnectionHandler = Nothing + sender.Hide() + Else + sender.SetDisplayStatus(args.Device, "Disconnect failed", DevicePickerDisplayStatusOptions.ShowDisconnectButton) + End If + End Sub) + End Sub + +#End Region +#Region " ProjectionManager APIs" + Private Async Function TryProjectionManagerCastAsync(device As DeviceInformation) As Task(Of Boolean) + Dim projectionManagerCastAsyncSucceeded As Boolean = False + If (activeDevice Is Nothing AndAlso ProjectionManager.ProjectionDisplayAvailable AndAlso device Is Nothing) OrElse device IsNot Nothing Then + thisViewId = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().Id + If rootPage.ProjectionViewPageControl Is Nothing Then + ' First, create a new, blank view + Dim thisDispatcher = Window.Current.Dispatcher + Await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + rootPage.ProjectionViewPageControl = ViewLifetimeControl.CreateForCurrentView() + pvb.MainPageDispatcher = thisDispatcher + pvb.ProjectionViewPageControl = rootPage.ProjectionViewPageControl + pvb.MainViewId = thisViewId + ' Display the page in the view. Note that the view will not become visible + ' until "StartProjectingAsync" is called + Dim rootFrame = New Frame() + rootFrame.Navigate(GetType(ProjectionViewPage), pvb) + Window.Current.Content = rootFrame + Window.Current.Activate() + End Sub) + End If + + Try + rootPage.ProjectionViewPageControl.StartViewInUse() + Try + rootPage.NotifyUser(String.Format("Starting projection of '{0}' on a second view '{1}' using ProjectionManager", video.Title, device.Name), NotifyType.StatusMessage) + Await ProjectionManager.StartProjectingAsync(rootPage.ProjectionViewPageControl.Id, thisViewId, device) + Catch ex As Exception + If Not ProjectionManager.ProjectionDisplayAvailable Then + Throw ex + End If + + End Try + + If pvb.ProjectedPage IsNot Nothing Then + Me.player.Pause() + Await pvb.ProjectedPage.SetMediaSource(Me.player.Source, Me.player.Position) + End If + + If device IsNot Nothing Then + activeDevice = device + activeCastConnectionHandler = pvb + End If + + projectionManagerCastAsyncSucceeded = True + rootPage.NotifyUser(String.Format("Displaying '{0}' on a second view '{1}' using ProjectionManager", video.Title, device.Name), NotifyType.StatusMessage) + Catch + rootPage.NotifyUser("The projection view is being disposed", NotifyType.ErrorMessage) + End Try + + ApplicationView.GetForCurrentView().ExitFullScreenMode() + End If + + Return projectionManagerCastAsyncSucceeded + End Function + + Private Function TryStopProjectionManagerAsync(broker As ProjectionViewBroker) As Boolean + broker.ProjectedPage.StopProjecting() + Return True + End Function + + Private Async Sub Pvb_ProjectionStopping(sender As Object, e As EventArgs) + Dim broker As ProjectionViewBroker = TryCast(sender, ProjectionViewBroker) + Dim position As TimeSpan = broker.ProjectedPage.Player.Position + Dim source As Uri = broker.ProjectedPage.Player.Source + Await rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Resuming playback on the first screen", NotifyType.StatusMessage) + Me.player.Source = source + Me.player.Position = position + Me.player.Play() + rootPage.ProjectionViewPageControl = Nothing + End Sub) + End Sub + +#End Region +#Region " Windows.Media.Casting APIs " + Private Async Function TryCastMediaElementAsync(device As DeviceInformation) As Task(Of Boolean) + Dim castMediaElementSucceeded As Boolean = False + rootPage.NotifyUser(String.Format("Checking to see if device {0} supports Miracast, Bluetooth, or DLNA", device.Name), NotifyType.StatusMessage) + Dim connection As CastingConnection = Nothing + If activeDevice IsNot Nothing AndAlso device.Id = activeDevice.Id Then + connection = TryCast(activeCastConnectionHandler, CastingConnection) + Else + activeDevice = Nothing + activeCastConnectionHandler = Nothing + End If + + If connection Is Nothing OrElse connection.State = CastingConnectionState.Disconnected OrElse connection.State = CastingConnectionState.Disconnecting Then + Dim castDevice As CastingDevice = Nothing + activeDevice = Nothing + rootPage.NotifyUser(String.Format("Attempting to resolve casting device for '{0}'", device.Name), NotifyType.StatusMessage) + Try + castDevice = Await CastingDevice.FromIdAsync(device.Id) + Catch + End Try + + If castDevice Is Nothing Then + rootPage.NotifyUser(String.Format("'{0}' does not support playback of this media", device.Name), NotifyType.StatusMessage) + Else + rootPage.NotifyUser(String.Format("Creating connection for '{0}'", device.Name), NotifyType.StatusMessage) + connection = castDevice.CreateCastingConnection() + AddHandler connection.ErrorOccurred, AddressOf Connection_ErrorOccurred + AddHandler connection.StateChanged, AddressOf Connection_StateChanged + End If + + rootPage.NotifyUser(String.Format("Casting to '{0}'", device.Name), NotifyType.StatusMessage) + Dim source As CastingSource = Nothing + Try + source = player.GetAsCastingSource() + Catch + End Try + + If source Is Nothing Then + rootPage.NotifyUser(String.Format("Failed to get casting source for video '{0}'", video.Title), NotifyType.ErrorMessage) + Else + Dim status As CastingConnectionErrorStatus = Await connection.RequestStartCastingAsync(source) + If status = CastingConnectionErrorStatus.Succeeded Then + activeDevice = device + activeCastConnectionHandler = connection + castMediaElementSucceeded = True + player.Play() + Else + rootPage.NotifyUser(String.Format("Failed to cast to '{0}'", device.Name), NotifyType.ErrorMessage) + End If + End If + End If + + Return castMediaElementSucceeded + End Function + + Private Async Sub Connection_StateChanged(sender As CastingConnection, args As Object) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Casting Connection State Changed: " & sender.State.ToString(), NotifyType.StatusMessage) + End Sub) + End Sub + + Private Async Sub Connection_ErrorOccurred(sender As CastingConnection, args As CastingConnectionErrorOccurredEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + rootPage.NotifyUser("Casting Error Occured: " & args.Message, NotifyType.ErrorMessage) + activeDevice = Nothing + activeCastConnectionHandler = Nothing + End Sub) + End Sub + + Private Async Function TryDisconnectCastingSessionAsync(connection As CastingConnection) As Task(Of Boolean) + Dim disconnected As Boolean = False + 'Disconnect the casting session + Dim status As CastingConnectionErrorStatus = Await connection.DisconnectAsync() + If status = CastingConnectionErrorStatus.Succeeded Then + rootPage.NotifyUser("Connection disconnected successfully.", NotifyType.StatusMessage) + disconnected = True + Else + rootPage.NotifyUser(String.Format("Failed to disconnect connection with reason {0}.", status.ToString()), NotifyType.ErrorMessage) + End If + + Return disconnected + End Function + +#End Region +#Region " Windows.Media.DialProtocal APIs " + Private Async Function TryLaunchDialAppAsync(device As DeviceInformation) As Task(Of Boolean) + Dim dialAppLaunchSucceeded As Boolean = False + Me.dial_launch_args_textbox.Text = String.Format("v={0}&t={1}&pairingCode=E4A8136D-BCD3-45F4-8E49-AE01E9A46B5F", video.Id, player.Position.Ticks) + rootPage.NotifyUser(String.Format("Checking to see if device {0} supports DIAL", device.Name), NotifyType.StatusMessage) + Dim dialDevice As DialDevice = Nothing + rootPage.NotifyUser(String.Format("Attempting to resolve DIAL device for '{0}'", device.Name), NotifyType.StatusMessage) + Dim newIds As String() = CType(device.Properties("{0BBA1EDE-7566-4F47-90EC-25FC567CED2A} 2"), String()) + If newIds.Length > 0 Then + Dim deviceId As String = newIds(0) + Try + dialDevice = Await DialDevice.FromIdAsync(deviceId) + Catch + End Try + End If + + If dialDevice Is Nothing Then + rootPage.NotifyUser(String.Format("'{0}' does not support DIAL", device.Name), NotifyType.StatusMessage) + Else + 'Get the DialApp object for the specific application on the selected device + Dim app As DialApp = dialDevice.GetDialApp(Me.dial_appname_textbox.Text) + If app Is Nothing Then + rootPage.NotifyUser(String.Format("'{0}' cannot find app with ID '{1}'", device.Name, Me.dial_appname_textbox.Text), NotifyType.StatusMessage) + Else + rootPage.NotifyUser(String.Format("Attempting to launch '{0}'", app.AppName), NotifyType.StatusMessage) + 'Launch the application on the 1st screen device + Dim result As DialAppLaunchResult = Await app.RequestLaunchAsync(Me.dial_launch_args_textbox.Text) + If result = DialAppLaunchResult.Launched Then + activeDevice = device + activeCastConnectionHandler = app + rootPage.NotifyUser(String.Format("Launched '{0}'", app.AppName), NotifyType.StatusMessage) + dialAppLaunchSucceeded = True + End If + End If + End If + + Return dialAppLaunchSucceeded + End Function + + Private Async Function TryStopDialAppAsync(app As DialApp) As Task(Of Boolean) + Dim stopped As Boolean = False + 'Get the current application state + Dim stateDetails As DialAppStateDetails = Await app.GetAppStateAsync() + Select Case stateDetails.State + Case DialAppState.NetworkFailure + rootPage.NotifyUser("Network Failure while getting application state", NotifyType.ErrorMessage) + Exit Select + Case DialAppState.Stopped + stopped = True + rootPage.NotifyUser("Application was already stopped.", NotifyType.StatusMessage) + Exit Select + Case Else + Dim result As DialAppStopResult = Await app.StopAsync() + If result = DialAppStopResult.Stopped Then + stopped = True + rootPage.NotifyUser("Application stopped successfully.", NotifyType.StatusMessage) + Else + If result = DialAppStopResult.StopFailed OrElse result = DialAppStopResult.NetworkFailure Then + rootPage.NotifyUser(String.Format("Error occured trying to stop application. Status: '{0}'", result.ToString()), NotifyType.StatusMessage) + Else + stopped = True + rootPage.NotifyUser(String.Format("Stop is not supported by device: '{0}'", activeDevice.Name), NotifyType.ErrorMessage) + End If + End If + + Exit Select + End Select + + Return stopped + End Function + +#End Region +#Region " Media Element Status Methods " + Private Sub Player_CurrentStateChanged(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("{0} '{1}'", Me.player.CurrentState, video.Title), NotifyType.StatusMessage) + End Sub + + Private Sub Player_MediaFailed(sender As Object, e As ExceptionRoutedEventArgs) + rootPage.NotifyUser(String.Format("Failed to load '{0}'", video.Title), NotifyType.ErrorMessage) + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + rootPage.NotifyUser(String.Format("Openend '{0}'", video.Title), NotifyType.StatusMessage) + player.Play() + End Sub + +#End Region + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/AdvancedCasting.sln b/Samples/AdvancedCasting/vb/AdvancedCasting.sln new file mode 100644 index 0000000000..2838f3b7f9 --- /dev/null +++ b/Samples/AdvancedCasting/vb/AdvancedCasting.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22823.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AdvancedCasting", "AdvancedCasting.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/AdvancedCasting/vb/AdvancedCasting.vbproj b/Samples/AdvancedCasting/vb/AdvancedCasting.vbproj new file mode 100644 index 0000000000..8669452adf --- /dev/null +++ b/Samples/AdvancedCasting/vb/AdvancedCasting.vbproj @@ -0,0 +1,292 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + ScreenCasting + ScreenCasting + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + 02_Casting_API_CastButton.xaml + + + 03_DIAL_Sender_API.xaml + + + 05_Multi_View_Media_Application.xaml + + + 06_Combine_Casting_Tech.xaml + + + + UnhandledExceptionPage.xaml + + + App.xaml + + + + + + + + + MainPage.xaml + + + ProjectionViewPage.xaml + + + Properties\AssemblyInfo.vb + + + + 01_MediaElement.xaml + + + 04_DIAL_Receiver_App.xaml + + + + + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + 02_Casting_API_CastButton.xaml + MSBuild:Compile + Designer + + + 03_DIAL_Sender_API.xaml + MSBuild:Compile + Designer + + + 05_Multi_View_Media_Application.xaml + MSBuild:Compile + Designer + + + 06_Combine_Casting_Tech.xaml + MSBuild:Compile + Designer + + + UnhandledExceptionPage.xaml + Designer + MSBuild:Compile + + + MainPage.xaml + MSBuild:Compile + Designer + + + ProjectionViewPage.xaml + MSBuild:Compile + Designer + + + 01_MediaElement.xaml + MSBuild:Compile + Designer + + + 04_DIAL_Receiver_App.xaml + MSBuild:Compile + Designer + + + Styles\MediaTransportControlWithCustomCastButtonStyles.xaml + MSBuild:Compile + Designer + + + Styles\ProjectedMediaTransportControlsStyles.xaml + MSBuild:Compile + Designer + + + Styles\Styles.xaml + MSBuild:Compile + Designer + + + + + Properties\Default.rd.xml + + + Assets\casting.mp4 + + + Assets\smallTile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squareTile-sdk.png + + + Assets\storeLogo-sdk.png + + + Assets\tile-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/AdvancedCasting/vb/App.xaml.vb b/Samples/AdvancedCasting/vb/App.xaml.vb new file mode 100644 index 0000000000..aad7c4a5a2 --- /dev/null +++ b/Samples/AdvancedCasting/vb/App.xaml.vb @@ -0,0 +1,122 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + ''' + ''' Provides application-specific behavior to supplement the default Application class. + ''' + NotInheritable Partial Class App + Inherits Application + + Public Sub New() + Me.InitializeComponent() + AddHandler Me.Suspending, AddressOf OnSuspending + End Sub + + ''' + ''' Invoked when the application is launched normally by the end user. Other entry points + ''' will be used such as when the application is launched to open a specific file. + ''' + ''' Details about the launch request and process. + Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs) + If System.Diagnostics.Debugger.IsAttached Then + Me.DebugSettings.EnableFrameRateCounter = False + End If + + AddHandler Application.Current.UnhandledException, AddressOf Current_UnhandledException + Window.Current.Activate() + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages(0) + AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed + If e.PreviousExecutionState = ApplicationExecutionState.Terminated Then + End If + + Window.Current.Content = rootFrame + Window.Current.Activate() + End If + + If rootFrame.Content Is Nothing Then + Try + rootFrame.Navigate(GetType(MainPage), e) + Catch ex As Exception + Window.Current.Content = New Frame() + Window.Current.Activate() + rootFrame.Navigate(GetType(UnhandledExceptionPage), e.Arguments) + Dim content = CType(rootFrame.Content, UnhandledExceptionPage) + content.StatusMessage = ex.Message & ex.StackTrace + End Try + End If + + Window.Current.Activate() + End Sub + + Private Sub Current_UnhandledException(sender As Object, e As UnhandledExceptionEventArgs) + Window.Current.Content = New Frame() + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + Window.Current.Activate() + rootFrame.Navigate(GetType(UnhandledExceptionPage)) + Dim content = CType(rootFrame.Content, UnhandledExceptionPage) + content.StatusMessage = e.Exception.Message & e.Exception.StackTrace + End Sub + + Protected Overrides Sub OnActivated(args As IActivatedEventArgs) + Try + Window.Current.Content = New Frame() + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + Window.Current.Activate() + If args.Kind = ActivationKind.DialReceiver Then + rootFrame.Navigate(GetType(MainPage), args) + Else + rootFrame.Navigate(GetType(MainPage)) + End If + + MyBase.OnActivated(args) + Catch ex As Exception + Window.Current.Content = New Frame() + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + Window.Current.Activate() + rootFrame.Navigate(GetType(UnhandledExceptionPage)) + Dim content = CType(rootFrame.Content, UnhandledExceptionPage) + content.StatusMessage = ex.Message & ex.StackTrace + End Try + End Sub + + ''' + ''' Invoked when Navigation to a certain page fails + ''' + ''' The Frame which failed navigation + ''' Details about the navigation failure + Sub OnNavigationFailed(sender As Object, e As NavigationFailedEventArgs) + Throw New Exception("Failed to load Page " & e.SourcePageType.FullName) + End Sub + + ''' + ''' Invoked when application execution is being suspended. Application state is saved + ''' without knowing whether the application will be terminated or resumed with the contents + ''' of memory still intact. + ''' + ''' The source of the suspend request. + ''' Details about the suspend request. + Private Sub OnSuspending(sender As Object, e As SuspendingEventArgs) + Dim deferral = e.SuspendingOperation.GetDeferral() + deferral.Complete() + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Controls/MediaTransportControlsWithCustomCastButton.vb b/Samples/AdvancedCasting/vb/Controls/MediaTransportControlsWithCustomCastButton.vb new file mode 100644 index 0000000000..1543814ccd --- /dev/null +++ b/Samples/AdvancedCasting/vb/Controls/MediaTransportControlsWithCustomCastButton.vb @@ -0,0 +1,51 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Controls.Primitives +Imports Windows.UI.Xaml.Data +Imports Windows.UI.Xaml.Documents +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media + +Namespace Global.ScreenCasting.Controls + + Public NotInheritable Class MediaTransportControlsWithCustomCastButton + Inherits MediaTransportControls + + Public Sub New() + Me.DefaultStyleKey = GetType(MediaTransportControlsWithCustomCastButton) + End Sub + + Public Event CastButtonClicked As EventHandler + + Private Sub CastButton_Click(sender As Object, e As RoutedEventArgs) + RaiseEvent CastButtonClicked(Me, EventArgs.Empty) + End Sub + + Public ReadOnly Property CastButton As Button + Get + Return TryCast(Me.GetTemplateChild("CustomCastButton"), Button) + End Get + End Property + + Protected Overrides Sub OnApplyTemplate() + MyBase.OnApplyTemplate() + Me.IsCompact = True + AddHandler CastButton.Click, AddressOf CastButton_Click + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Controls/ProjectedMediaTransportControls.vb b/Samples/AdvancedCasting/vb/Controls/ProjectedMediaTransportControls.vb new file mode 100644 index 0000000000..6bad11ea26 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Controls/ProjectedMediaTransportControls.vb @@ -0,0 +1,56 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Controls.Primitives +Imports Windows.UI.Xaml.Data +Imports Windows.UI.Xaml.Documents +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media + +Namespace Global.ScreenCasting.Controls + + Public NotInheritable Class ProjectedMediaTransportControls + Inherits MediaTransportControls + + Public Sub New() + Me.DefaultStyleKey = GetType(ProjectedMediaTransportControls) + End Sub + + Protected Overrides Sub OnApplyTemplate() + MyBase.OnApplyTemplate() + 'Find the Swap Views button and subscribe to the clicked event. + Dim swapViewsButton As Button = TryCast(GetTemplateChild("SwapViewsButton"), Button) + AddHandler swapViewsButton.Click, AddressOf SwapViewsButton_Click + 'Find the Stop Projecting button and subscribe to the clicked event. + Dim stopProjectingButton As Button = TryCast(GetTemplateChild("StopProjectingButton"), Button) + AddHandler stopProjectingButton.Click, AddressOf StopProjectingButton_Click + Me.IsCompact = True + End Sub + + Public Event StopProjectingButtonClick As EventHandler + + Public Event SwapViewsButtonClick As EventHandler + + Private Sub StopProjectingButton_Click(sender As Object, e As RoutedEventArgs) + RaiseEvent StopProjectingButtonClick(Me, EventArgs.Empty) + End Sub + + Private Sub SwapViewsButton_Click(sender As Object, e As RoutedEventArgs) + RaiseEvent SwapViewsButtonClick(Me, EventArgs.Empty) + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Controls/ProjectionViewBroker.vb b/Samples/AdvancedCasting/vb/Controls/ProjectionViewBroker.vb new file mode 100644 index 0000000000..fd4b079bf3 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Controls/ProjectionViewBroker.vb @@ -0,0 +1,43 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Controls +Imports ScreenCasting.Util +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.UI.Core +Imports Windows.UI.Xaml.Controls + +Namespace Global.ScreenCasting + + ' This is a simple container for a set of data used to comminicate between the main and the projection view + Friend Class ProjectionViewBroker + + Public MainPageDispatcher As CoreDispatcher + + Public ProjectionViewPageControl As ViewLifetimeControl + + Public MainViewId As Integer + + Public Event ProjectionStopping As EventHandler + + Public ProjectedPage As ProjectionViewPage + + Public Sub NotifyProjectionStopping() + Try + RaiseEvent ProjectionStopping(Me, EventArgs.Empty) + Catch + End Try + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Data/Azure/AzureDataProvider.vb b/Samples/AdvancedCasting/vb/Data/Azure/AzureDataProvider.vb new file mode 100644 index 0000000000..f439eed341 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Data/Azure/AzureDataProvider.vb @@ -0,0 +1,97 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.Web.Syndication +Imports ScreenCasting.Data.Common + +Namespace Global.ScreenCasting.Data.Azure + + Public Class AzureDataProvider + Inherits ItemsDataProvider + + Private Shared s_metaDataList As Dictionary(Of String, VideoMetaData) = Nothing + + Private Const MAX_RESULTS As Integer = 10 + + Public Overrides Function GetRandomVideo() As VideoMetaData + Dim videos As List(Of VideoMetaData) = GetAll(MAX_RESULTS) + Dim indexRandomizer As Random = New Random() + Return videos(indexRandomizer.Next(0, videos.Count - 1)) + End Function + + Public Overrides Function GetAll(max_results As Integer) As List(Of VideoMetaData) + If s_metaDataList Is Nothing Then + Dim l As Dictionary(Of String, VideoMetaData) = New Dictionary(Of String, VideoMetaData)() + Dim video1 As VideoMetaData = New VideoMetaData() + video1.Id = "AzureMediaServicesOverview" + video1.PubDate = DateTime.Now + video1.VideoLink = New Uri("http://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest(format=m3u8-aapl)") + video1.Title = "Azure Media Services Overview" + video1.WebPageLink = New Uri("http://amsplayer.azurewebsites.net/amssamples.html") + video1.License = "(C) Microsoft Coorporation | All Rights Reserved" + video1.Thumbnail = New Uri("http://t3.gstatic.com/images?q=tbn:ANd9GcRoTu81vs8GuQtJBGUZ0pLEiNHVVx3dFwHsu7JCkvGop8Z-98EsPg") + l.Add(video1.Id, video1) + Dim video2 As VideoMetaData = New VideoMetaData() + video2.Id = "BigBuckBunnyTrailer" + video2.PubDate = DateTime.Now + video2.VideoLink = New Uri("http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi") + video2.Title = "Big Buck Bunny" + video2.WebPageLink = New Uri("https://peach.blender.org/") + video2.License = "(CC) Blender Foundation | peach.blender.org" + video2.Thumbnail = New Uri("http://t0.gstatic.com/images?q=tbn:ANd9GcQT54UKh0zX5OUDNLRyXOOwt3pqj0lpaLCJebucva2LSV49aGjRfg") + l.Add(video2.Id, video2) + Dim video3 As VideoMetaData = New VideoMetaData() + video3.Id = "bc57e088-27ec-44e0-ac20-a85ccbcd50da" + video3.PubDate = DateTime.Now + video3.VideoLink = New Uri("http://amssamples.streaming.mediaservices.windows.net/bc57e088-27ec-44e0-ac20-a85ccbcd50da/TearsOfSteel.ism/manifest(format=mpd-time-csf)") + video3.Title = "Tears of Steel" + video3.WebPageLink = New Uri("https://mango.blender.org/") + video3.License = "(CC) Blender Foundation | durian.blender.org/" + video3.Thumbnail = New Uri("http://t3.gstatic.com/images?q=tbn:ANd9GcQO0MMO_vXf8Q1zjZWLHa1_566Mf_jty6vJKRi9R-C_0W-gXnNOog") + l.Add(video3.Id, video3) + 'VideoMetaData video4 = new VideoMetaData(); + 'video4.Id = "b6822ec8-5c2b-4ae0-a851-fd46a78294e9"; + 'video4.PubDate = DateTime.Now; + 'video4.VideoLink = new Uri("http://amssamples.streaming.mediaservices.windows.net/b6822ec8-5c2b-4ae0-a851-fd46a78294e9/ElephantsDream.ism/manifest(filtername=FirstFilter,format=mpd-time-csf)"); + 'video4.Title = "Elephants Dream"; + 'video4.WebPageLink = new Uri("https://orange.blender.org/"); + 'video4.License = "(c) copyright 2006, Blender Foundation / Netherlands Media Art Institute / www.elephantsdream.org"; + 'video4.Thumbnail = new Uri("https://orange.blender.org/wp-content/uploads/2006/05/edscore_cover_l.jpg"); + 'l.Add(video4.Id, video4); + Dim video5 As VideoMetaData = New VideoMetaData() + video5.Id = "49b57c87-f5f3-48b3-ba22-c55cfdffa9cb" + video5.PubDate = DateTime.Now + video5.VideoLink = New Uri("http://amssamples.streaming.mediaservices.windows.net/49b57c87-f5f3-48b3-ba22-c55cfdffa9cb/Sintel.ism/manifest(format=m3u8-aapl)") + video5.Title = "Sintel" + video5.WebPageLink = New Uri("https://durian.blender.org/") + video5.License = "© copyright Blender Foundation | www.sintel.org" + video5.Thumbnail = New Uri("https://durian.blender.org/wp-content/uploads/2010/05/sintel_trailer_1080.jpg") + l.Add(video5.Id, video5) + s_metaDataList = l + End If + + Return s_metaDataList.Values.ToList() + End Function + + Public Overrides Function GetFromID(id As String) As VideoMetaData + If s_metaDataList Is Nothing Then + GetAll(20) + End If + + Dim video As VideoMetaData = s_metaDataList(id) + Return video + End Function + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Data/Common/ItemsDataProvider.vb b/Samples/AdvancedCasting/vb/Data/Common/ItemsDataProvider.vb new file mode 100644 index 0000000000..e653f69096 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Data/Common/ItemsDataProvider.vb @@ -0,0 +1,27 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks + +Namespace Global.ScreenCasting.Data.Common + + Public MustInherit Class ItemsDataProvider + + Public MustOverride Function GetAll(max_results As Integer) As List(Of VideoMetaData) + + Public MustOverride Function GetRandomVideo() As VideoMetaData + + Public MustOverride Function GetFromID(ID As String) As VideoMetaData + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Data/Common/VideoMetaData.vb b/Samples/AdvancedCasting/vb/Data/Common/VideoMetaData.vb new file mode 100644 index 0000000000..cf00b1c6a8 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Data/Common/VideoMetaData.vb @@ -0,0 +1,35 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks + +Namespace Global.ScreenCasting.Data.Common + + Public Class VideoMetaData + + Public Property Id As String + + Public Property Title As String + + Public Property PubDate As DateTime + + Public Property License As String + + Public Property WebPageLink As Uri + + Public Property VideoLink As Uri + + Public Property Thumbnail As Uri + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/MainPage.xaml.vb b/Samples/AdvancedCasting/vb/MainPage.xaml.vb new file mode 100644 index 0000000000..53d3d77c25 --- /dev/null +++ b/Samples/AdvancedCasting/vb/MainPage.xaml.vb @@ -0,0 +1,153 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Util +Imports System +Imports System.Collections.Generic +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.ViewManagement +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Data +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class MainPage + Inherits Page + + Public Shared Current As MainPage + + Public ProjectionViewPageControl As ViewLifetimeControl + + Public Sub New() + LoadScenarios() + Me.DataContext = Me + Me.InitializeComponent() + Current = Me + SampleTitle.Text = FEATURE_NAME + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ApplicationView.GetForCurrentView().ExitFullScreenMode() + AddHandler Me.ScenarioControl.SelectionChanged, AddressOf ScenarioControl_SelectionChanged + Try + ScenarioControl.ItemsSource = Scenarios + If TypeOf e.Parameter Is DialReceiverActivatedEventArgs Then + NavigateToScenario(GetType(Scenario04), e.Parameter) + Else + ScenarioControl.SelectedIndex = 0 + End If + Catch ex As Exception + Window.Current.Content = New Frame() + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + rootFrame.Navigate(GetType(UnhandledExceptionPage), Nothing) + Dim content = CType(rootFrame.Content, UnhandledExceptionPage) + content.StatusMessage = ex.Message & ex.StackTrace + End Try + End Sub + + ''' + ''' Called whenever the user changes selection in the scenarios list. This method will navigate to the respective + ''' sample scenario page. + ''' + ''' + ''' + Private Sub ScenarioControl_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + NotifyUser(String.Empty, NotifyType.StatusMessage) + Dim scenarioListBox As ListBox = TryCast(sender, ListBox) + Dim s As Scenario = Scenarios(scenarioListBox.SelectedIndex) + If s IsNot Nothing Then + ScenarioFrame.Navigate(s.ClassType) + If Window.Current.Bounds.Width < 640 Then + Splitter.IsPaneOpen = False + StatusBorder.Visibility = Visibility.Collapsed + Else + Splitter.IsPaneOpen = True + StatusBorder.Visibility = Visibility.Visible + End If + End If + End Sub + + Friend Sub NavigateToScenario(scenarioType As Type, args As Object) + Try + NotifyUser(String.Empty, NotifyType.StatusMessage) + Dim scenarioListBox As ListBox = Me.ScenarioControl + Dim selectedIndex As Integer = -1 + RemoveHandler Me.ScenarioControl.SelectionChanged, AddressOf ScenarioControl_SelectionChanged + For idx = 0 To scenarioListBox.Items.Count - 1 + If(CType(scenarioListBox.Items(idx), Scenario)).ClassType Is scenarioType Then + selectedIndex = idx + Exit For + End If + Next + + If selectedIndex > -1 Then + scenarioListBox.SelectedIndex = selectedIndex + End If + + Dim s As Scenario = TryCast(scenarioListBox.SelectedItem, Scenario) + If s IsNot Nothing Then + ScenarioFrame.Navigate(s.ClassType, args) + If Window.Current.Bounds.Width < 640 Then + Splitter.IsPaneOpen = False + StatusBorder.Visibility = Visibility.Collapsed + Else + Splitter.IsPaneOpen = True + StatusBorder.Visibility = Visibility.Visible + End If + End If + + AddHandler Me.ScenarioControl.SelectionChanged, AddressOf ScenarioControl_SelectionChanged + Catch ex As Exception + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + Window.Current.Content = New Frame() + rootFrame.Navigate(GetType(UnhandledExceptionPage), ex.Message) + Dim content = CType(rootFrame.Content, UnhandledExceptionPage) + content.StatusMessage = ex.Message & ex.StackTrace + End Try + End Sub + + ''' + ''' Used to display messages to the user + ''' + ''' + ''' + Public Sub NotifyUser(strMessage As String, type As NotifyType) + Select type + Case NotifyType.StatusMessage + StatusBorder.Background = New SolidColorBrush(Windows.UI.Colors.Green) + Case NotifyType.ErrorMessage + StatusBorder.Background = New SolidColorBrush(Windows.UI.Colors.Red) + End Select + + StatusBlock.Text = strMessage + StatusBorder.Visibility = If((StatusBlock.Text <> String.Empty), Visibility.Visible, Visibility.Collapsed) + End Sub + + Async Sub Footer_Click(sender As Object, e As RoutedEventArgs) + Await Windows.System.Launcher.LaunchUriAsync(New Uri((CType(sender, HyperlinkButton)).Tag.ToString())) + End Sub + + Private Sub Button_Click(sender As Object, e As RoutedEventArgs) + Splitter.IsPaneOpen = If((Splitter.IsPaneOpen = True), False, True) + StatusBorder.Visibility = Visibility.Collapsed + End Sub + End Class + + Public Enum NotifyType + StatusMessage + ErrorMessage + End Enum +End Namespace diff --git a/Samples/AdvancedCasting/vb/Package.appxmanifest b/Samples/AdvancedCasting/vb/Package.appxmanifest new file mode 100644 index 0000000000..d05a74c1ca --- /dev/null +++ b/Samples/AdvancedCasting/vb/Package.appxmanifest @@ -0,0 +1,37 @@ + + + + + + ScreenCasting VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/AdvancedCasting/vb/ProjectionViewPage.xaml.vb b/Samples/AdvancedCasting/vb/ProjectionViewPage.xaml.vb new file mode 100644 index 0000000000..fc0a2198b6 --- /dev/null +++ b/Samples/AdvancedCasting/vb/ProjectionViewPage.xaml.vb @@ -0,0 +1,108 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports ScreenCasting.Controls +Imports System +Imports System.Threading.Tasks +Imports Windows.UI.Core +Imports Windows.UI.ViewManagement +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + Partial Public NotInheritable Class ProjectionViewPage + Inherits Page + + Public Sub New() + Me.InitializeComponent() + Dim pmtcs As ProjectedMediaTransportControls = TryCast(Me.Player.TransportControls, ProjectedMediaTransportControls) + If pmtcs IsNot Nothing Then + AddHandler pmtcs.StopProjectingButtonClick, AddressOf ProjectionViewPage_StopProjectingButtonClick + End If + + AddHandler Me.Player.MediaOpened, AddressOf Player_MediaOpened + End Sub + + Private Sub Player_MediaOpened(sender As Object, e As RoutedEventArgs) + Me.Player.IsFullWindow = True + Me.Player.AreTransportControlsEnabled = True + End Sub + + Private Sub ProjectionViewPage_StopProjectingButtonClick(sender As Object, e As EventArgs) + Me.StopProjecting() + End Sub + + Public Async Function SetMediaSource(source As Uri, position As TimeSpan) As Task(Of Boolean) + Await Me.Player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + Me.Player.Source = source + Me.Player.Position = position + Me.Player.Play() + End Sub) + Return True + End Function + + Public ReadOnly Property Player As MediaElement + Get + Return _player + End Get + End Property + + Dim broker As ProjectionViewBroker = Nothing + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + broker = CType(e.Parameter, ProjectionViewBroker) + broker.ProjectedPage = Me + AddHandler broker.ProjectionViewPageControl.Released, AddressOf thisViewControl_Released + End Sub + + Private Async Sub thisViewControl_Released(sender As Object, e As EventArgs) + RemoveHandler broker.ProjectionViewPageControl.Released, AddressOf thisViewControl_Released + Await broker.ProjectionViewPageControl.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Me.broker.NotifyProjectionStopping() + MainPage.Current.ProjectionViewPageControl = Nothing + End Sub) + Me.Player.Stop() + Me.Player.Source = Nothing + Window.Current.Close() + End Sub + + Public Async Sub SwapViews() + broker.ProjectionViewPageControl.StartViewInUse() + Await ProjectionManager.SwapDisplaysForViewsAsync(ApplicationView.GetForCurrentView().Id, broker.MainViewId) + broker.ProjectionViewPageControl.StopViewInUse() + End Sub + + Private Sub SwapViews_Click(sender As Object, e As RoutedEventArgs) + SwapViews() + End Sub + + Public Async Sub StopProjecting() + broker.NotifyProjectionStopping() + Await Me.Player.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Async Sub() + Me.Player.Stop() + Me.Player.Source = Nothing + broker.ProjectionViewPageControl.StartViewInUse() + Try + Await ProjectionManager.StopProjectingAsync(broker.ProjectionViewPageControl.Id, broker.MainViewId) + Catch + End Try + + Window.Current.Close() + End Sub) + broker.ProjectionViewPageControl.StopViewInUse() + End Sub + + Private Sub StopProjecting_Click(sender As Object, e As RoutedEventArgs) + StopProjecting() + End Sub + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/SampleConfiguration.vb b/Samples/AdvancedCasting/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..19d1e247ca --- /dev/null +++ b/Samples/AdvancedCasting/vb/SampleConfiguration.vb @@ -0,0 +1,42 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls +Imports ScreenCasting +Imports System.Reflection +Imports ScreenCasting.Util + +Namespace Global.ScreenCasting + + Partial Public Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "ScreenCasting" + + Public ReadOnly Property Scenarios As List(Of Scenario) + + Private Sub LoadScenarios() + If ApiInformation.IsTypePresent("Windows.Devices.Enumeration.DevicePicker") Then + _Scenarios = New List(Of Scenario) From {New Scenario() With {.Title = "1 - Media Element Casting 101", .ClassType = Type.GetType("ScreenCasting.Scenario01", False)}, New Scenario() With {.Title = "2 - Casting APIs and a Custom Cast Button", .ClassType = Type.GetType("ScreenCasting.Scenario02", False)}, New Scenario() With {.Title = "3 - DIAL Sender Universal Windows app", .ClassType = Type.GetType("ScreenCasting.Scenario03", False)}, New Scenario() With {.Title = "4 - DIAL Receiver Windows Universal app", .ClassType = Type.GetType("ScreenCasting.Scenario04")}, New Scenario() With {.Title = "5 - Multi-View Media Application", .ClassType = Type.GetType("ScreenCasting.Scenario05")}, New Scenario() With {.Title = "6 - Combine Casting Methods", .ClassType = Type.GetType("ScreenCasting.Scenario06")}} + Else + _Scenarios = New List(Of Scenario) From {New Scenario() With {.Title = "DIAL Receiver Windows Universal Application", .ClassType = GetType(Scenario04)}} + End If + End Sub + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/UnhandledExceptionPage.xaml.vb b/Samples/AdvancedCasting/vb/UnhandledExceptionPage.xaml.vb new file mode 100644 index 0000000000..9fc7812d7c --- /dev/null +++ b/Samples/AdvancedCasting/vb/UnhandledExceptionPage.xaml.vb @@ -0,0 +1,66 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.IO +Imports System.Linq +Imports System.Runtime.InteropServices.WindowsRuntime +Imports Windows.Foundation +Imports Windows.Foundation.Collections +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Controls.Primitives +Imports Windows.UI.Xaml.Data +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation + +Namespace Global.ScreenCasting + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class UnhandledExceptionPage + Inherits Page + + Public Shared Sub ShowUnhandledException(ex As Exception) + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + Window.Current.Content = rootFrame + Window.Current.Activate() + End If + + rootFrame.Navigate(GetType(UnhandledExceptionPage), ex.ToString()) + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + MyBase.OnNavigatedTo(e) + If TypeOf e.Parameter Is String Then + Me.StatusMessage = CType(e.Parameter, String) + End If + End Sub + + Public Sub New() + InitializeComponent() + End Sub + + Public Property StatusMessage As String + Get + Return Me.Status.Text + End Get + + Set + Me.Status.Text = value + End Set + End Property + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Util/ApiInformation.vb b/Samples/AdvancedCasting/vb/Util/ApiInformation.vb new file mode 100644 index 0000000000..722fb27cb0 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Util/ApiInformation.vb @@ -0,0 +1,30 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks + +Namespace Global.ScreenCasting.Util + + Class ApiInformation + + Public Shared Function IsTypePresent(typeName As String) As Boolean + Try + Dim picker As Windows.Media.Casting.CastingDevicePicker = New Windows.Media.Casting.CastingDevicePicker() + Return True + Catch + Return False + End Try + End Function + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Util/CustomDevicePickerFilter.vb b/Samples/AdvancedCasting/vb/Util/CustomDevicePickerFilter.vb new file mode 100644 index 0000000000..0ee8620f54 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Util/CustomDevicePickerFilter.vb @@ -0,0 +1,47 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.Devices.Enumeration + +Namespace Global.ScreenCasting.Util + + Public Class CustomDevicePickerFilter + + Private _supportedDeviceSelectors As IList(Of String) = New List(Of String)() + + Public ReadOnly Property SupportedDeviceSelectors As IList(Of String) + Get + Return _supportedDeviceSelectors + End Get + End Property + + Public Overrides Function ToString() As String + Dim retval As String = String.Empty + If supportedDeviceSelectors.Count > 0 Then + retval = supportedDeviceSelectors(0) + End If + + If supportedDeviceSelectors.Count > 1 Then + retval = "(" & retval & ")" + End If + + For idx = 1 To supportedDeviceSelectors.Count - 1 + retval = retval & " OR (" & supportedDeviceSelectors(idx) & ")" + Next + + Return retval + End Function + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Util/DialLaunchArguments.vb b/Samples/AdvancedCasting/vb/Util/DialLaunchArguments.vb new file mode 100644 index 0000000000..89a8b281d3 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Util/DialLaunchArguments.vb @@ -0,0 +1,56 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks + +Namespace Global.ScreenCasting.Util + + Class DialLaunchArguments + + Public Property VideoId As String + + Public Property PairingCode As String + + Public Property Position As TimeSpan + + Private Sub New() + End Sub + + Public Shared Function Parse(arguments As String) As DialLaunchArguments + Try + Dim dialLaunchArgs As DialLaunchArguments = New DialLaunchArguments() + Dim argswithkeys As String() = arguments.Split("&"c) + For Each currentArgWithKey In argswithkeys + Dim key As String = currentArgWithKey.Split("="c)(0) + Dim val As String = currentArgWithKey.Split("="c)(1) + Select key + Case "v" + dialLaunchArgs.VideoId = val + Exit Select + Case "t" + dialLaunchArgs.Position = TimeSpan.FromTicks(Long.Parse(val)) + Exit Select + Case "pairingCode" + dialLaunchArgs.PairingCode = val + Exit Select + End Select + Next + + Return dialLaunchArgs + Catch ex As Exception + Throw New ArgumentOutOfRangeException(String.Format("Failed to parse DIAL launch arguments: '{0}'", arguments), ex) + End Try + End Function + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Util/RequiredDeviceProperties.vb b/Samples/AdvancedCasting/vb/Util/RequiredDeviceProperties.vb new file mode 100644 index 0000000000..3eb1089a9e --- /dev/null +++ b/Samples/AdvancedCasting/vb/Util/RequiredDeviceProperties.vb @@ -0,0 +1,67 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks + +Namespace Global.ScreenCasting.Util + + Public Class RequiredDeviceProperties + + Public Shared ReadOnly DEVPKEY_AepContainer_FriendlyName As String = "{0bba1ede-7566-4f47-90ec-25fc567ced2a}, 5" + + Public Shared ReadOnly DEVPKEY_AepContainer_SupportsAudio As String = "{6af55d45-38db-4495-acb0-d4728a3b8314}, 2" + + Public Shared ReadOnly DEVPKEY_AepContainer_SupportsVideo As String = "{6af55d45-38db-4495-acb0-d4728a3b8314}, 3" + + Public Shared ReadOnly DEVPKEY_AepContainer_SupportsImages As String = "{6af55d45-38db-4495-acb0-d4728a3b8314}, 4" + + Public Shared ReadOnly DEVPKEY_AepContainer_SupportedUriSchemes As String = "{6af55d45-38db-4495-acb0-d4728a3b8314}, 5" + + Public Shared ReadOnly DEVPKEY_AepContainer_Categories As String = "System.Devices.AepContainer.Categories" + + Public Shared ReadOnly DEVPKEY_DeviceContainer_Manufacturer As String = "System.Devices.Manufacturer" + + Public Shared ReadOnly DEVPKEY_DeviceContainer_ModelName As String = "System.Devices.ModelName" + + Public Shared ReadOnly DEVPKEY_Device_ContainerId As String = "System.Devices.ContainerId" + + Public Shared ReadOnly DEVPKEY_Device_InstanceId As String = "System.Devices.DeviceInstanceId" + + Private Sub New() + End Sub + + Public Shared Sub AddProps(list As IList(Of String)) + For Each s In Props + list.Add(s) + Next + End Sub + + Public Shared ReadOnly Property Props As List(Of String) + Get + Dim properties As List(Of String) = New List(Of String)() + properties.Add(RequiredDeviceProperties.DEVPKEY_AepContainer_FriendlyName) + properties.Add(RequiredDeviceProperties.DEVPKEY_AepContainer_SupportsAudio) + properties.Add(RequiredDeviceProperties.DEVPKEY_AepContainer_SupportsVideo) + properties.Add(RequiredDeviceProperties.DEVPKEY_AepContainer_SupportsImages) + properties.Add(RequiredDeviceProperties.DEVPKEY_AepContainer_SupportedUriSchemes) + properties.Add(RequiredDeviceProperties.DEVPKEY_AepContainer_Categories) + properties.Add(RequiredDeviceProperties.DEVPKEY_DeviceContainer_Manufacturer) + properties.Add(RequiredDeviceProperties.DEVPKEY_DeviceContainer_ModelName) + properties.Add(RequiredDeviceProperties.DEVPKEY_Device_ContainerId) + properties.Add(RequiredDeviceProperties.DEVPKEY_Device_InstanceId) + Return properties + End Get + End Property + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/Util/ViewLifetimeControl.vb b/Samples/AdvancedCasting/vb/Util/ViewLifetimeControl.vb new file mode 100644 index 0000000000..7f1aada692 --- /dev/null +++ b/Samples/AdvancedCasting/vb/Util/ViewLifetimeControl.vb @@ -0,0 +1,236 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +' The objects defined here demonstrate how to make sure each of the views created remains alive as long as +' the app needs them, but only when they're being used by the app or the user. Many of the scenarios contained in this +' sample use these functions to keep track of the views available and ensure that the view is not closed while +' the scenario is attempting to show it. +' +' As you can see in scenario 1, the ApplicationViewSwitcher.TryShowAsStandaloneAsync and +' ProjectionManager.StartProjectingAsync methods let you show one view next to another. The Consolidated event +' is fired when a view stops being visible separately from other views. Common cases where this will occur +' is when the view falls out of the list of recently used apps, or when the user performs the close gesture on the view. +' This is a good time to close the view, provided the app isn't trying to show the view at the same time. This event +' is fired on the thread of the view that becomes consolidated. +' +' Each view lives on its own thread, so concurrency control is necessary. Also, as you'll see in the sample, +' certain objects may be bound to UI on given threads. Properties of those objects should only be updated +' on that UI thread. +Imports System +Imports System.ComponentModel +Imports Windows.UI.Core +Imports Windows.UI.ViewManagement + +Namespace Global.ScreenCasting.Util + + ' A custom event that fires whenever the secondary view is ready to be closed. You should + ' clean up any state (including deregistering for events) then close the window in this handler + Public Delegate Sub ViewReleasedHandler(sender As [Object], e As EventArgs) + + ' A ViewLifetimeControl is instantiated for every secondary view. ViewLifetimeControl's reference count + ' keeps track of when the secondary view thinks it's in usem and when the main view is interacting with the secondary view (about to show + ' it to the user, etc.) When the reference count drops to zero, the secondary view is closed. + Public NotInheritable Class ViewLifetimeControl + Implements INotifyPropertyChanged + + Dim window As CoreWindow + + Dim _title As String + + Dim refCount As Integer = 0 + + Dim viewId As Integer + + Dim _released As Boolean = False + + Dim _consolidated As Boolean = True + + Event InternalReleased As ViewReleasedHandler + + ' Instantiate views using "CreateForCurrentView" + Private Sub New(newWindow As CoreWindow) + _Dispatcher = newWindow.Dispatcher + window = newWindow + viewId = ApplicationView.GetApplicationViewIdForWindow(window) + RegisterForEvents() + End Sub + + ' Register for events on the current view + Private Sub RegisterForEvents() + AddHandler ApplicationView.GetForCurrentView().Consolidated, AddressOf ViewConsolidated + AddHandler window.VisibilityChanged, AddressOf VisibilityChanged + End Sub + + ' Unregister for events. Call this method before closing the view to prevent leaks. + Private Sub UnregisterForEvents() + RemoveHandler ApplicationView.GetForCurrentView().Consolidated, AddressOf ViewConsolidated + RemoveHandler window.VisibilityChanged, AddressOf VisibilityChanged + End Sub + + Private Sub VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If e.Visible Then + Consolidated = False + End If + End Sub + + ' A view is consolidated with other views hen there's no way for the user to get to it (it's not in the list of recently used apps, cannot be + ' launched from Start, etc.) A view stops being consolidated when it's visible--at that point the user can interact with it, move it on or off screen, etc. + ' It's generally a good idea to close a view after it has been consolidated, but keep it open while it's visible. + Private Sub ViewConsolidated(sender As ApplicationView, e As ApplicationViewConsolidatedEventArgs) + Consolidated = True + End Sub + + ' Called when a view has been "consolidated" (no longer accessible to the user) + ' and no other view is trying to interact with it. This should only be closed after the reference + ' count goes to 0 (including being consolidated). At the end of this, the view is closed. + Private Sub FinalizeRelease() + Dim justReleased As Boolean = False + SyncLock Me + If refCount = 0 Then + justReleased = True + _released = True + End If + + End SyncLock + + If justReleased Then + UnregisterForEvents() + RaiseEvent InternalReleased(Me, Nothing) + End If + End Sub + + ' Creates ViewLifetimeControl for the particular view. + ' Only do this once per view. + Public Shared Function CreateForCurrentView() As ViewLifetimeControl + Return New ViewLifetimeControl(CoreWindow.GetForCurrentThread()) + End Function + + ' For purposes of this sample, the collection of views + ' is bound to a UI collection. This property is available for binding + Public Property Title As String + Get + Return _title + End Get + + Set + If _title <> Value Then + _title = Value + RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Title")) + End If + End Set + End Property + + ' Necessary to communicate with the window + Public ReadOnly Property Dispatcher As CoreDispatcher + + ' Each view has a unique Id, found using the ApplicationView.Id property or + ' ApplicationView.GetApplicationViewIdForCoreWindow method. This id is used in all of the ApplicationViewSwitcher + ' and ProjectionManager APIs. + Public ReadOnly Property Id As Integer + Get + Return viewId + End Get + End Property + + ' Keeps track of if the consolidated event has fired yet. A view is consolidated with other views + ' when there's no way for the user to get to it (it's not in the list of recently used apps, cannot be + ' launched from Start, etc.) A view stops being consolidated when it's visible--at that point + ' the user can interact with it, move it on or off screen, etc. + Public Property Consolidated As Boolean + Get + Return _consolidated + End Get + Set(value As Boolean) + If _consolidated <> value Then + _consolidated = value + If _consolidated Then + StopViewInUse() + Else + StartViewInUse() + End If + End If + End Set + End Property + + ' Signals that the view is being interacted with by another view, + ' so it shouldn't be closed even if it becomes "consolidated" + Public Function StartViewInUse() As Integer + Dim releasedCopy As Boolean = False + Dim refCountCopy As Integer = 0 + SyncLock Me + releasedCopy = Me._released + If Not _released Then + refCountCopy = "'refCount=refCount+1' could not be converted to a ExpressionSyntax" + End If + + End SyncLock + + If releasedCopy Then + Throw New InvalidOperationException("This view is being disposed") + End If + + Return refCountCopy + End Function + + ' Should come after any call to StartViewInUse + ' Signals that the another view has finished interacting with the view tracked + ' by this object + Public Function StopViewInUse() As Integer + Dim refCountCopy As Integer = 0 + Dim releasedCopy As Boolean = False + SyncLock Me + releasedCopy = Me._released + If Not _released Then + refCountCopy = "'refCount=refCount-1' could not be converted to a ExpressionSyntax" + If refCountCopy = 0 Then + Dispatcher.RunAsync(CoreDispatcherPriority.Low, AddressOf FinalizeRelease) + End If + End If + + End SyncLock + + If releasedCopy Then + Throw New InvalidOperationException("This view is being disposed") + End If + + Return refCountCopy + End Function + + ' Signals to consumers that its time to close the view so that + ' they can clean up (including calling Window.Close() when finished) + Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged + + Public Custom Event Released As ViewReleasedHandler + AddHandler(value As ViewReleasedHandler) + Dim releasedCopy As Boolean = False + SyncLock Me + releasedCopy = _released + If Not _released Then + AddHandler InternalReleased, value + End If + + End SyncLock + + If releasedCopy Then + Throw New InvalidOperationException("This view is being disposed") + End If + End AddHandler + + RemoveHandler(value As ViewReleasedHandler) + SyncLock Me + RemoveHandler InternalReleased, value + End SyncLock + End RemoveHandler + RaiseEvent(sender As Object, e As EventArgs) + RaiseEvent InternalReleased(sender, e) + End RaiseEvent + End Event + End Class +End Namespace diff --git a/Samples/AdvancedCasting/vb/project.json b/Samples/AdvancedCasting/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/AdvancedCasting/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.csproj b/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.csproj index ba135b39a4..e4d82cddac 100644 --- a/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.csproj +++ b/Samples/AllJoyn/ConsumerExperiences/cs/AllJoynConsumerExperiences.csproj @@ -99,7 +99,9 @@ MainPage.xaml - + + Properties\AssemblyInfo.cs + diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Properties/AssemblyInfo.cs b/Samples/AllJoyn/ConsumerExperiences/cs/Properties/AssemblyInfo.cs deleted file mode 100644 index 2aa975602b..0000000000 --- a/Samples/AllJoyn/ConsumerExperiences/cs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("AllJoyn Consumer Experiences")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SDK Sample")] -[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] diff --git a/Samples/AllJoyn/ProducerExperiences/cs/AllJoynProducerExperiences.csproj b/Samples/AllJoyn/ProducerExperiences/cs/AllJoynProducerExperiences.csproj index a0fe398d59..2b5a19176e 100644 --- a/Samples/AllJoyn/ProducerExperiences/cs/AllJoynProducerExperiences.csproj +++ b/Samples/AllJoyn/ProducerExperiences/cs/AllJoynProducerExperiences.csproj @@ -102,7 +102,9 @@ - + + Properties\AssemblyInfo.cs + diff --git a/Samples/AllJoyn/ProducerExperiences/cs/Properties/AssemblyInfo.cs b/Samples/AllJoyn/ProducerExperiences/cs/Properties/AssemblyInfo.cs deleted file mode 100644 index 14af420017..0000000000 --- a/Samples/AllJoyn/ProducerExperiences/cs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,25 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using System.Reflection; -using System.Runtime.InteropServices; - -[assembly: AssemblyTitle("AllJoyn Producer Experiences")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SDK Sample")] -[assembly: AssemblyCopyright("Copyright (c) Microsoft. All rights reserved.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] diff --git a/Samples/Altimeter/vb/Altimeter.sln b/Samples/Altimeter/vb/Altimeter.sln new file mode 100644 index 0000000000..133cd7d751 --- /dev/null +++ b/Samples/Altimeter/vb/Altimeter.sln @@ -0,0 +1,40 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.22418.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Altimeter", "Altimeter.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/Altimeter/vb/Altimeter.vbproj b/Samples/Altimeter/vb/Altimeter.vbproj new file mode 100644 index 0000000000..c40fa6a177 --- /dev/null +++ b/Samples/Altimeter/vb/Altimeter.vbproj @@ -0,0 +1,224 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + SDKTemplate + Altimeter + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Scenario1_DataEvents.xaml + MSBuild:Compile + Designer + + + Scenario2_Polling.xaml + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/Altimeter/vb/Package.appxmanifest b/Samples/Altimeter/vb/Package.appxmanifest new file mode 100644 index 0000000000..f26fd5b589 --- /dev/null +++ b/Samples/Altimeter/vb/Package.appxmanifest @@ -0,0 +1,54 @@ + + + + + + + + + + + Altimeter VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/Altimeter/vb/SampleConfiguration.vb b/Samples/Altimeter/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..2e83403c3c --- /dev/null +++ b/Samples/Altimeter/vb/SampleConfiguration.vb @@ -0,0 +1,31 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "Altimeter" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Data Events", .ClassType = GetType(Scenario1_DataEvents)}, New Scenario() With {.Title = "Polling", .ClassType = GetType(Scenario2_Polling)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/Altimeter/vb/Scenario1_DataEvents.xaml.vb b/Samples/Altimeter/vb/Scenario1_DataEvents.xaml.vb new file mode 100644 index 0000000000..c2da77ade9 --- /dev/null +++ b/Samples/Altimeter/vb/Scenario1_DataEvents.xaml.vb @@ -0,0 +1,132 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Threading.Tasks +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario1_DataEvents + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Private sensor As Altimeter + + Private desiredReportIntervalMs As UInteger + + Public Sub New() + Me.InitializeComponent() + sensor = Altimeter.GetDefault() + If Nothing IsNot sensor Then + ' Select a report interval that is both suitable for the purposes of the app and supported by the sensor. + ' This value will be used later to activate the sensor. + Dim minReportIntervalMs As UInteger = sensor.MinimumReportInterval + desiredReportIntervalMs = If(minReportIntervalMs > 1000, minReportIntervalMs, 1000) + Else + rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + If ScenarioDisableButton.IsEnabled Then + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler sensor.ReadingChanged, New TypedEventHandler(Of Altimeter, AltimeterReadingChangedEventArgs)(AddressOf ReadingChanged) + sensor.ReportInterval = 0 + End If + + MyBase.OnNavigatingFrom(e) + End Sub + + ''' + ''' This is the event handler for VisibilityChanged events. You would register for these notifications + ''' if handling sensor data when the app is not visible could cause unintended actions in the app. + ''' + ''' + ''' + ''' Event data that can be examined for the current visibility state. + ''' + Private Sub VisibilityChanged(sender As Object, e As VisibilityChangedEventArgs) + If ScenarioDisableButton.IsEnabled Then + If e.Visible Then + AddHandler sensor.ReadingChanged, New TypedEventHandler(Of Altimeter, AltimeterReadingChangedEventArgs)(AddressOf ReadingChanged) + Else + RemoveHandler sensor.ReadingChanged, New TypedEventHandler(Of Altimeter, AltimeterReadingChangedEventArgs)(AddressOf ReadingChanged) + End If + End If + End Sub + + ''' + ''' This is the event handler for ReadingChanged events. + ''' + ''' + ''' + Async Private Sub ReadingChanged(sender As Object, e As AltimeterReadingChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Dim reading As AltimeterReading = e.Reading + ScenarioOutput_M.Text = String.Format("{0,5:0.00}", reading.AltitudeChangeInMeters) + End Sub) + End Sub + + ''' + ''' This is the click handler for the 'Enable' button. + ''' + ''' + ''' + Private Sub ScenarioEnable(sender As Object, e As RoutedEventArgs) + If Nothing IsNot sensor Then + sensor.ReportInterval = desiredReportIntervalMs + AddHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + AddHandler sensor.ReadingChanged, New TypedEventHandler(Of Altimeter, AltimeterReadingChangedEventArgs)(AddressOf ReadingChanged) + ScenarioEnableButton.IsEnabled = False + ScenarioDisableButton.IsEnabled = True + Else + rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'Disable' button. + ''' + ''' + ''' + Private Sub ScenarioDisable(sender As Object, e As RoutedEventArgs) + RemoveHandler Window.Current.VisibilityChanged, New WindowVisibilityChangedEventHandler(AddressOf VisibilityChanged) + RemoveHandler sensor.ReadingChanged, New TypedEventHandler(Of Altimeter, AltimeterReadingChangedEventArgs)(AddressOf ReadingChanged) + sensor.ReportInterval = 0 + ScenarioEnableButton.IsEnabled = True + ScenarioDisableButton.IsEnabled = False + End Sub + End Class +End Namespace diff --git a/Samples/Altimeter/vb/Scenario2_Polling.xaml.vb b/Samples/Altimeter/vb/Scenario2_Polling.xaml.vb new file mode 100644 index 0000000000..f4788895cf --- /dev/null +++ b/Samples/Altimeter/vb/Scenario2_Polling.xaml.vb @@ -0,0 +1,53 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Threading.Tasks +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario2_Polling + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Private sensor As Altimeter + + Public Sub New() + Me.InitializeComponent() + sensor = Altimeter.GetDefault() + If Nothing Is sensor Then + rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage) + End If + End Sub + + ''' + ''' This is the click handler for the 'GetData' button. + ''' + ''' + ''' + Private Sub ScenarioGetData(sender As Object, e As RoutedEventArgs) + If Nothing IsNot sensor Then + Dim reading As AltimeterReading = sensor.GetCurrentReading() + If Nothing IsNot reading Then + ScenarioOutput_M.Text = String.Format("{0,5:0.00}", reading.AltitudeChangeInMeters) + End If + Else + rootPage.NotifyUser("No altimeter found", NotifyType.ErrorMessage) + End If + End Sub + End Class +End Namespace diff --git a/Samples/Altimeter/vb/project.json b/Samples/Altimeter/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/Altimeter/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AnimationMetrics/vb/AnimationMetrics.sln b/Samples/AnimationMetrics/vb/AnimationMetrics.sln new file mode 100644 index 0000000000..59bf551883 --- /dev/null +++ b/Samples/AnimationMetrics/vb/AnimationMetrics.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AnimationMetrics", "AnimationMetrics.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/AnimationMetrics/vb/AnimationMetrics.vbproj b/Samples/AnimationMetrics/vb/AnimationMetrics.vbproj new file mode 100644 index 0000000000..757a51c16b --- /dev/null +++ b/Samples/AnimationMetrics/vb/AnimationMetrics.vbproj @@ -0,0 +1,225 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + SDKTemplate + AnimationMetrics + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + Scenario1_Metrics.xaml + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Scenario1_Metrics.xaml + 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 + + + + + Microsoft Desktop Extension SDK for Universal App Platform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/AnimationMetrics/vb/Package.appxmanifest b/Samples/AnimationMetrics/vb/Package.appxmanifest new file mode 100644 index 0000000000..bf4429b4bf --- /dev/null +++ b/Samples/AnimationMetrics/vb/Package.appxmanifest @@ -0,0 +1,50 @@ + + + + + + + + + + + Animation Metrics VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/AnimationMetrics/vb/SampleConfiguration.vb b/Samples/AnimationMetrics/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..696c1e271f --- /dev/null +++ b/Samples/AnimationMetrics/vb/SampleConfiguration.vb @@ -0,0 +1,31 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "Animation metrics VB sample" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Retrieving Animation Metrics", .ClassType = GetType(Scenario1_Metrics)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/AnimationMetrics/vb/Scenario1_Metrics.xaml.vb b/Samples/AnimationMetrics/vb/Scenario1_Metrics.xaml.vb new file mode 100644 index 0000000000..ee43f2c5bd --- /dev/null +++ b/Samples/AnimationMetrics/vb/Scenario1_Metrics.xaml.vb @@ -0,0 +1,122 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports Windows.UI.Core.AnimationMetrics + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class Scenario1_Metrics + Inherits Page + + Private rootPage As MainPage + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + ''' + ''' Retrieves the specified metrics and displays them in textual form. + ''' + ''' The AnimationEffect whose metrics are to be displayed. + ''' The AnimationEffecTarget whose metrics are to be displayed. + Private Sub DisplayMetrics(effect As AnimationEffect, target As AnimationEffectTarget) + Dim s = New System.Text.StringBuilder() + Dim animationDescription As AnimationDescription = New AnimationDescription(effect, target) + s.AppendFormat("Stagger delay = {0}ms", animationDescription.StaggerDelay.TotalMilliseconds) + s.AppendLine() + s.AppendFormat("Stagger delay factor = {0}", animationDescription.StaggerDelayFactor) + s.AppendLine() + s.AppendFormat("Delay limit = {0}ms", animationDescription.DelayLimit.TotalMilliseconds) + s.AppendLine() + s.AppendFormat("ZOrder = {0}", animationDescription.ZOrder) + s.AppendLine() + s.AppendLine() + Dim animationIndex As Integer = 0 + For Each animation As IPropertyAnimation In animationDescription.Animations + animationIndex += 1 + s.AppendFormat("Animation #{0}:", animationIndex) + s.AppendLine() + Select Case animation.Type + Case PropertyAnimationType.Scale + Dim scale As ScaleAnimation = TryCast(animation, ScaleAnimation) + s.AppendLine("Type = Scale") + If scale.InitialScaleX.HasValue Then + s.AppendFormat("InitialScaleX = {0}", scale.InitialScaleX.Value) + s.AppendLine() + End If + + If scale.InitialScaleY.HasValue Then + s.AppendFormat("InitialScaleY = {0}", scale.InitialScaleY.Value) + s.AppendLine() + End If + + s.AppendFormat("FinalScaleX = {0}", scale.FinalScaleX) + s.AppendLine() + s.AppendFormat("FinalScaleY = {0}", scale.FinalScaleY) + s.AppendLine() + s.AppendFormat("Origin = {0}, {1}", scale.NormalizedOrigin.X, scale.NormalizedOrigin.Y) + s.AppendLine() + Case PropertyAnimationType.Translation + s.AppendLine("Type = Translation") + Case PropertyAnimationType.Opacity + Dim opacity As OpacityAnimation = TryCast(animation, OpacityAnimation) + s.AppendLine("Type = Opacity") + If opacity.InitialOpacity.HasValue Then + s.AppendFormat("InitialOpacity = {0}", opacity.InitialOpacity.Value) + s.AppendLine() + End If + + s.AppendFormat("FinalOpacity = {0}", opacity.FinalOpacity) + s.AppendLine() + End Select + + s.AppendFormat("Delay = {0}ms", animation.Delay.TotalMilliseconds) + s.AppendLine() + s.AppendFormat("Duration = {0}ms", animation.Duration.TotalMilliseconds) + s.AppendLine() + s.AppendFormat("Cubic Bezier control points") + s.AppendLine() + s.AppendFormat(" X1 = {0}, Y1 = {1}", animation.Control1.X, animation.Control1.Y) + s.AppendLine() + s.AppendFormat(" X2 = {0}, Y2 = {1}", animation.Control2.X, animation.Control2.Y) + s.AppendLine() + s.AppendLine() + Next + + Metrics.Text = s.ToString() + End Sub + + ''' + ''' When the selection changes, update the output window. + ''' + ''' + ''' + Private Sub Animations_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + Dim lb As ListBox = TryCast(sender, ListBox) + If lb IsNot Nothing Then + Dim selectedListBoxItem As Object = lb.SelectedItem + If selectedListBoxItem Is AddToListAdded Then + DisplayMetrics(AnimationEffect.AddToList, AnimationEffectTarget.Added) + ElseIf selectedListBoxItem Is AddToListAffected Then + DisplayMetrics(AnimationEffect.AddToList, AnimationEffectTarget.Affected) + ElseIf selectedListBoxItem Is EnterPage Then + DisplayMetrics(AnimationEffect.EnterPage, AnimationEffectTarget.Primary) + End If + End If + End Sub + End Class +End Namespace diff --git a/Samples/AnimationMetrics/vb/project.json b/Samples/AnimationMetrics/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/AnimationMetrics/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AppServices/cs/AppServicesClient/AppServicesClient.csproj b/Samples/AppServices/cs/AppServicesClient/AppServicesClient.csproj index 87c5b6e0a1..f43b45248d 100644 --- a/Samples/AppServices/cs/AppServicesClient/AppServicesClient.csproj +++ b/Samples/AppServices/cs/AppServicesClient/AppServicesClient.csproj @@ -120,7 +120,8 @@ MSBuild:Compile Designer - + + KeepConnectionOpenScenario.xaml Designer MSBuild:Compile @@ -129,7 +130,8 @@ MSBuild:Compile Designer - + + OpenCloseConnectionScenario.xaml Designer MSBuild:Compile diff --git a/Samples/AppServices/cs/AppServicesProvider/AppServicesProvider.csproj b/Samples/AppServices/cs/AppServicesProvider/AppServicesProvider.csproj index a99f9b6ad2..d30517c78b 100644 --- a/Samples/AppServices/cs/AppServicesProvider/AppServicesProvider.csproj +++ b/Samples/AppServices/cs/AppServicesProvider/AppServicesProvider.csproj @@ -122,7 +122,8 @@ MSBuild:Compile Designer - + + ShowPackageFamilyName.xaml Designer MSBuild:Compile @@ -175,4 +176,4 @@ --> - + \ No newline at end of file diff --git a/Samples/AppServices/cs/AppServicesClient/KeepConnectionOpenScenario.xaml b/Samples/AppServices/shared/KeepConnectionOpenScenario.xaml similarity index 100% rename from Samples/AppServices/cs/AppServicesClient/KeepConnectionOpenScenario.xaml rename to Samples/AppServices/shared/KeepConnectionOpenScenario.xaml diff --git a/Samples/AppServices/cs/AppServicesClient/OpenCloseConnectionScenario.xaml b/Samples/AppServices/shared/OpenCloseConnectionScenario.xaml similarity index 100% rename from Samples/AppServices/cs/AppServicesClient/OpenCloseConnectionScenario.xaml rename to Samples/AppServices/shared/OpenCloseConnectionScenario.xaml diff --git a/Samples/AppServices/cs/AppServicesProvider/ShowPackageFamilyName.xaml b/Samples/AppServices/shared/ShowPackageFamilyName.xaml similarity index 100% rename from Samples/AppServices/cs/AppServicesProvider/ShowPackageFamilyName.xaml rename to Samples/AppServices/shared/ShowPackageFamilyName.xaml diff --git a/Samples/AppServices/vb/AppServices.sln b/Samples/AppServices/vb/AppServices.sln new file mode 100644 index 0000000000..b234c3fdd3 --- /dev/null +++ b/Samples/AppServices/vb/AppServices.sln @@ -0,0 +1,81 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AppServicesClient", "AppServicesClient\AppServicesClient.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AppServicesProvider", "AppServicesProvider\AppServicesProvider.vbproj", "{88C81CF2-AAEC-4F89-A50D-9C851EBB0860}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RandomNumberService", "RandomNumberService\RandomNumberService.vbproj", "{44BD24C4-7750-4F32-B768-27732D7D2ACD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|Any CPU.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|Any CPU.ActiveCfg = Debug|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|ARM.ActiveCfg = Debug|ARM + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|ARM.Build.0 = Debug|ARM + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|ARM.Deploy.0 = Debug|ARM + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|x64.ActiveCfg = Debug|x64 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|x64.Build.0 = Debug|x64 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|x64.Deploy.0 = Debug|x64 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|x86.ActiveCfg = Debug|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|x86.Build.0 = Debug|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Debug|x86.Deploy.0 = Debug|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|Any CPU.ActiveCfg = Release|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|ARM.ActiveCfg = Release|ARM + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|ARM.Build.0 = Release|ARM + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|ARM.Deploy.0 = Release|ARM + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|x64.ActiveCfg = Release|x64 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|x64.Build.0 = Release|x64 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|x64.Deploy.0 = Release|x64 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|x86.ActiveCfg = Release|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|x86.Build.0 = Release|x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860}.Release|x86.Deploy.0 = Release|x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|Any CPU.ActiveCfg = Debug|x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|ARM.ActiveCfg = Debug|ARM + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|ARM.Build.0 = Debug|ARM + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|x64.ActiveCfg = Debug|x64 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|x64.Build.0 = Debug|x64 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|x86.ActiveCfg = Debug|x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Debug|x86.Build.0 = Debug|x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|Any CPU.ActiveCfg = Release|x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|ARM.ActiveCfg = Release|ARM + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|ARM.Build.0 = Release|ARM + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|x64.ActiveCfg = Release|x64 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|x64.Build.0 = Release|x64 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|x86.ActiveCfg = Release|x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/AppServices/vb/AppServicesClient/AppServicesClient.vbproj b/Samples/AppServices/vb/AppServicesClient/AppServicesClient.vbproj new file mode 100644 index 0000000000..5c4c9b5179 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesClient/AppServicesClient.vbproj @@ -0,0 +1,228 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + AppServicesClient + AppServicesClient + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + KeepConnectionOpenScenario.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + OpenCloseConnectionScenario.xaml + + + Properties\AssemblyInfo.vb + + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + KeepConnectionOpenScenario.xaml + Designer + MSBuild:Compile + + + MainPage.xaml + MSBuild:Compile + Designer + + + OpenCloseConnectionScenario.xaml + Designer + MSBuild:Compile + + + 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 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/AppServices/vb/AppServicesClient/KeepConnectionOpenScenario.xaml.vb b/Samples/AppServices/vb/AppServicesClient/KeepConnectionOpenScenario.xaml.vb new file mode 100644 index 0000000000..c970f72c99 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesClient/KeepConnectionOpenScenario.xaml.vb @@ -0,0 +1,145 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports Windows.ApplicationModel.AppService +Imports Windows.Foundation.Collections + +Namespace Global.AppServicesClient + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Partial Public NotInheritable Class KeepConnectionOpenScenario + Inherits Page + + Private rootPage As MainPage + + Private connection As AppServiceConnection + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + Private Async Sub OpenConnection_Click(sender As Object, e As Windows.UI.Xaml.RoutedEventArgs) + If connection IsNot Nothing Then + rootPage.NotifyUser("A connection already exists", NotifyType.ErrorMessage) + Return + End If + + connection = New AppServiceConnection() + connection.AppServiceName = "com.microsoft.randomnumbergenerator" + connection.PackageFamilyName = "Microsoft.SDKSamples.AppServicesProvider.CS_8wekyb3d8bbwe" + AddHandler connection.ServiceClosed, AddressOf Connection_ServiceClosed + Dim status As AppServiceConnectionStatus = Await connection.OpenAsync() + If status = AppServiceConnectionStatus.Success Then + rootPage.NotifyUser("Connection is open", NotifyType.StatusMessage) + Else + Select Case status + Case AppServiceConnectionStatus.AppNotInstalled + rootPage.NotifyUser("The app AppServicesProvider is not installed. Deploy AppServicesProvider to this device and try again.", NotifyType.ErrorMessage) + Case AppServiceConnectionStatus.AppUnavailable + rootPage.NotifyUser("The app AppServicesProvider is not available. This could be because it is currently being updated or was installed to a removable device that is no longer available.", NotifyType.ErrorMessage) + Case AppServiceConnectionStatus.AppServiceUnavailable + rootPage.NotifyUser(String.Format("The app AppServicesProvider is installed but it does not provide the app service {0}.", connection.AppServiceName), NotifyType.ErrorMessage) + Case AppServiceConnectionStatus.Unknown + rootPage.NotifyUser("An unkown error occurred while we were trying to open an AppServiceConnection.", NotifyType.ErrorMessage) + End Select + + connection.Dispose() + connection = Nothing + End If + End Sub + + Private Async Sub Connection_ServiceClosed(sender As AppServiceConnection, args As AppServiceClosedEventArgs) + Await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, Sub() + If connection IsNot Nothing Then + connection.Dispose() + connection = Nothing + End If + End Sub) + End Sub + + Private Sub CloseConnection_Click(sender As Object, e As Windows.UI.Xaml.RoutedEventArgs) + If connection Is Nothing Then + rootPage.NotifyUser("There's no open connection to close", NotifyType.ErrorMessage) + Return + End If + + connection.Dispose() + connection = Nothing + rootPage.NotifyUser("Connection is closed", NotifyType.StatusMessage) + End Sub + + Private Async Sub GenerateRandomNumber_Click(sender As Object, e As Windows.UI.Xaml.RoutedEventArgs) + If connection Is Nothing Then + rootPage.NotifyUser("You need to open a connection before trying to generate a random number.", NotifyType.ErrorMessage) + Return + End If + + 'Parse user input + Dim minValueInput As Integer = 0 + Dim valueParsed As Boolean = Integer.TryParse(MinValue.Text, minValueInput) + If Not valueParsed Then + rootPage.NotifyUser("The Minimum Value should be a valid integer", NotifyType.ErrorMessage) + Return + End If + + Dim maxValueInput As Integer = 0 + valueParsed = Integer.TryParse(MaxValue.Text, maxValueInput) + If Not valueParsed Then + rootPage.NotifyUser("The Maximum Value should be a valid integer", NotifyType.ErrorMessage) + Return + End If + + If maxValueInput <= minValueInput Then + rootPage.NotifyUser("Maximum Value must be larger than Minimum Value", NotifyType.ErrorMessage) + Return + End If + + 'Send a message to the app service + Dim inputs = New ValueSet() + inputs.Add("minvalue", minValueInput) + inputs.Add("maxvalue", maxValueInput) + Dim response As AppServiceResponse = Await connection.SendMessageAsync(inputs) + If response.Status = AppServiceResponseStatus.Success Then + If Not response.Message.ContainsKey("result") Then + rootPage.NotifyUser("The app service response message does not contain a key called ""result""", NotifyType.StatusMessage) + Return + End If + + Dim resultText = response.Message("result").ToString() + If Not String.IsNullOrEmpty(resultText) Then + Result.Text = resultText + rootPage.NotifyUser("App service responded with a result", NotifyType.StatusMessage) + Else + rootPage.NotifyUser("App service did not respond with a result", NotifyType.ErrorMessage) + End If + Else + Select Case response.Status + Case AppServiceResponseStatus.Failure + rootPage.NotifyUser("The service failed to acknowledge the message we sent it. It may have been terminated because the client was suspended.", NotifyType.ErrorMessage) + Case AppServiceResponseStatus.ResourceLimitsExceeded + rootPage.NotifyUser("The service exceeded the resources allocated to it and had to be terminated.", NotifyType.ErrorMessage) + Case Else + rootPage.NotifyUser("An unkown error occurred while we were trying to send a message to the service.", NotifyType.ErrorMessage) + End Select + End If + End Sub + End Class +End Namespace diff --git a/Samples/AppServices/vb/AppServicesClient/OpenCloseConnectionScenario.xaml.vb b/Samples/AppServices/vb/AppServicesClient/OpenCloseConnectionScenario.xaml.vb new file mode 100644 index 0000000000..c8c1e54d38 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesClient/OpenCloseConnectionScenario.xaml.vb @@ -0,0 +1,112 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports SDKTemplate +Imports System +Imports Windows.ApplicationModel.AppService +Imports Windows.Foundation.Collections +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.AppServicesClient + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class OpenCloseConnectionScenario + Inherits Page + + Private rootPage As MainPage + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + End Sub + + Private Async Sub GenerateRandomNumber_Click(sender As Object, e As RoutedEventArgs) + 'Parse user input + Dim minValueInput As Integer = 0 + Dim valueParsed As Boolean = Integer.TryParse(MinValue.Text, minValueInput) + If Not valueParsed Then + rootPage.NotifyUser("The Minimum Value should be a valid integer", NotifyType.ErrorMessage) + Return + End If + + Dim maxValueInput As Integer = 0 + valueParsed = Integer.TryParse(MaxValue.Text, maxValueInput) + If Not valueParsed Then + rootPage.NotifyUser("The Maximum Value should be a valid integer", NotifyType.ErrorMessage) + Return + End If + + If maxValueInput <= minValueInput Then + rootPage.NotifyUser("Maximum Value must be larger than Minimum Value", NotifyType.ErrorMessage) + Return + End If + + Using connection = New AppServiceConnection() + connection.AppServiceName = "com.microsoft.randomnumbergenerator" + connection.PackageFamilyName = "Microsoft.SDKSamples.AppServicesProvider.CS_8wekyb3d8bbwe" + Dim status As AppServiceConnectionStatus = Await connection.OpenAsync() + If status = AppServiceConnectionStatus.Success Then + rootPage.NotifyUser("Connection established", NotifyType.StatusMessage) + End If + + Select status + Case AppServiceConnectionStatus.AppNotInstalled + rootPage.NotifyUser("The app AppServicesProvider is not installed. Deploy AppServicesProvider to this device and try again.", NotifyType.ErrorMessage) + Return + Case AppServiceConnectionStatus.AppUnavailable + rootPage.NotifyUser("The app AppServicesProvider is not available. This could be because it is currently being updated or was installed to a removable device that is no longer available.", NotifyType.ErrorMessage) + Return + Case AppServiceConnectionStatus.AppServiceUnavailable + rootPage.NotifyUser(String.Format("The app AppServicesProvider is installed but it does not provide the app service {0}.", connection.AppServiceName), NotifyType.ErrorMessage) + Return + Case AppServiceConnectionStatus.Unknown + rootPage.NotifyUser("An unkown error occurred while we were trying to open an AppServiceConnection.", NotifyType.ErrorMessage) + Return + End Select + + 'Set up the inputs and send a message to the service + Dim inputs = New ValueSet() + inputs.Add("minvalue", minValueInput) + inputs.Add("maxvalue", maxValueInput) + Dim response As AppServiceResponse = Await connection.SendMessageAsync(inputs) + If response.Status = AppServiceResponseStatus.Success AndAlso response.Message.ContainsKey("result") Then + Dim resultText = response.Message("result").ToString() + If Not String.IsNullOrEmpty(resultText) Then + Result.Text = resultText + rootPage.NotifyUser("App service responded with a result", NotifyType.StatusMessage) + Else + rootPage.NotifyUser("App service did not respond with a result", NotifyType.ErrorMessage) + End If + + Return + End If + + Select response.Status + Case AppServiceResponseStatus.Failure + rootPage.NotifyUser("The service failed to acknowledge the message we sent it. It may have been terminated or it's RequestReceived handler might not be handling incoming messages correctly.", NotifyType.ErrorMessage) + Return + Case AppServiceResponseStatus.ResourceLimitsExceeded + rootPage.NotifyUser("The service exceeded the resources allocated to it and had to be terminated.", NotifyType.ErrorMessage) + Return + Case AppServiceResponseStatus.Unknown + rootPage.NotifyUser("An unkown error occurred while we were trying to send a message to the service.", NotifyType.ErrorMessage) + Return + End Select + End Using + End Sub + End Class +End Namespace diff --git a/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest b/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest new file mode 100644 index 0000000000..4dae51c6ef --- /dev/null +++ b/Samples/AppServices/vb/AppServicesClient/Package.appxmanifest @@ -0,0 +1,54 @@ + + + + + + + + + + + AppServicesClient VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/AppServices/vb/AppServicesClient/SampleConfiguration.vb b/Samples/AppServices/vb/AppServicesClient/SampleConfiguration.vb new file mode 100644 index 0000000000..ebcb4711de --- /dev/null +++ b/Samples/AppServices/vb/AppServicesClient/SampleConfiguration.vb @@ -0,0 +1,32 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls +Imports AppServicesClient + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "App service client sample" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Open/Close Connection", .ClassType = GetType(OpenCloseConnectionScenario)}, New Scenario() With {.Title = "Keep Connection Open", .ClassType = GetType(KeepConnectionOpenScenario)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/AppServices/vb/AppServicesClient/project.json b/Samples/AppServices/vb/AppServicesClient/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesClient/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AppServices/vb/AppServicesProvider/AppServicesProvider.vbproj b/Samples/AppServices/vb/AppServicesProvider/AppServicesProvider.vbproj new file mode 100644 index 0000000000..3e6fd66b75 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesProvider/AppServicesProvider.vbproj @@ -0,0 +1,226 @@ + + + + + Debug + x86 + {88C81CF2-AAEC-4F89-A50D-9C851EBB0860} + + AppContainerExe + AppServicesProvider + AppServicesProvider + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + ShowPackageFamilyName.xaml + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + ShowPackageFamilyName.xaml + Designer + MSBuild:Compile + + + 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 + + + + + {44bd24c4-7750-4f32-b768-27732d7d2acd} + RandomNumberService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest b/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest new file mode 100644 index 0000000000..a39b911418 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesProvider/Package.appxmanifest @@ -0,0 +1,59 @@ + + + + + + + + + + + AppServicesProvider VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/AppServices/vb/AppServicesProvider/SampleConfiguration.vb b/Samples/AppServices/vb/AppServicesProvider/SampleConfiguration.vb new file mode 100644 index 0000000000..c1c413a92d --- /dev/null +++ b/Samples/AppServices/vb/AppServicesProvider/SampleConfiguration.vb @@ -0,0 +1,32 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls +Imports AppServicesProvider + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "App service provider sample" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Show Package Family Name", .ClassType = GetType(ShowPackageFamilyName)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + End Class +End Namespace diff --git a/Samples/AppServices/vb/AppServicesProvider/ShowPackageFamilyName.xaml.vb b/Samples/AppServices/vb/AppServicesProvider/ShowPackageFamilyName.xaml.vb new file mode 100644 index 0000000000..815a5f1c80 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesProvider/ShowPackageFamilyName.xaml.vb @@ -0,0 +1,36 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports SDKTemplate +Imports Windows.ApplicationModel +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.AppServicesProvider + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class ShowPackageFamilyName + Inherits Page + + Private rootPage As MainPage + + Public Sub New() + Me.InitializeComponent() + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + rootPage = MainPage.Current + PackageFamilyName.Text = Package.Current.Id.FamilyName + End Sub + End Class +End Namespace diff --git a/Samples/AppServices/vb/AppServicesProvider/project.json b/Samples/AppServices/vb/AppServicesProvider/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/AppServices/vb/AppServicesProvider/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/AppServices/vb/RandomNumberService/RandomNumberGeneratorTask.vb b/Samples/AppServices/vb/RandomNumberService/RandomNumberGeneratorTask.vb new file mode 100644 index 0000000000..62f34362a5 --- /dev/null +++ b/Samples/AppServices/vb/RandomNumberService/RandomNumberGeneratorTask.vb @@ -0,0 +1,49 @@ +Imports System +Imports Windows.ApplicationModel.AppService +Imports Windows.ApplicationModel.Background +Imports Windows.Foundation.Collections + +Namespace Global.RandomNumberService + + Public NotInheritable Class RandomNumberGeneratorTask + Implements IBackgroundTask + + Dim serviceDeferral As BackgroundTaskDeferral + + Dim connection As AppServiceConnection + + Dim randomNumberGenerator As Random + + Public Sub Run(taskInstance As IBackgroundTaskInstance) Implements IBackgroundTask.Run + serviceDeferral = taskInstance.GetDeferral() + AddHandler taskInstance.Canceled, AddressOf OnTaskCanceled + randomNumberGenerator = New Random(CType(DateTime.Now.Ticks, Integer)) + Dim details = TryCast(taskInstance.TriggerDetails, AppServiceTriggerDetails) + connection = details.AppServiceConnection + AddHandler connection.RequestReceived, AddressOf OnRequestReceived + End Sub + + Private Sub OnTaskCanceled(sender As IBackgroundTaskInstance, reason As BackgroundTaskCancellationReason) + If serviceDeferral IsNot Nothing Then + serviceDeferral.Complete() + serviceDeferral = Nothing + End If + End Sub + + Async Sub OnRequestReceived(sender As AppServiceConnection, args As AppServiceRequestReceivedEventArgs) + 'Get a deferral so we can use an awaitable API to respond to the message + Dim messageDeferral = args.GetDeferral() + Try + Dim input = args.Request.Message + Dim minValue As Integer = CType(input("minvalue"), Integer) + Dim maxValue As Integer = CType(input("maxvalue"), Integer) + 'Create the response + Dim result = New ValueSet() + result.Add("result", randomNumberGenerator.Next(minValue, maxValue)) + Await args.Request.SendResponseAsync(result) + Finally + messageDeferral.Complete() + End Try + End Sub + End Class +End Namespace diff --git a/Samples/AppServices/vb/RandomNumberService/RandomNumberService.vbproj b/Samples/AppServices/vb/RandomNumberService/RandomNumberService.vbproj new file mode 100644 index 0000000000..c3151079b9 --- /dev/null +++ b/Samples/AppServices/vb/RandomNumberService/RandomNumberService.vbproj @@ -0,0 +1,158 @@ + + + + + Debug + x86 + {44BD24C4-7750-4F32-B768-27732D7D2ACD} + + winmdobj + RandomNumberService + RandomNumberService + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + + Properties\AssemblyInfo.vb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/AppServices/vb/RandomNumberService/project.json b/Samples/AppServices/vb/RandomNumberService/project.json new file mode 100644 index 0000000000..ecc018e3bf --- /dev/null +++ b/Samples/AppServices/vb/RandomNumberService/project.json @@ -0,0 +1,17 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0", + "System.Numerics.Vectors": "4.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/ApplicationData/cs/ApplicationData.csproj b/Samples/ApplicationData/cs/ApplicationData.csproj index cd90f9e1b2..abd9c2f85e 100644 --- a/Samples/ApplicationData/cs/ApplicationData.csproj +++ b/Samples/ApplicationData/cs/ApplicationData.csproj @@ -155,51 +155,63 @@ - + + App.xaml MSBuild:Compile Designer - + + MainPage.xaml MSBuild:Compile Designer - + + Scenario1_Files.xaml MSBuild:Compile Designer - + + Scenario2_Settings.xaml MSBuild:Compile Designer - + + Scenario3_SettingContainer.xaml MSBuild:Compile Designer - + + Scenario4_CompositeSettings.xaml MSBuild:Compile Designer - + + Scenario5_DataChangedEvent.xaml MSBuild:Compile Designer - + + Scenario6_HighPriority.xaml MSBuild:Compile Designer - + + Scenario7_Msappdata.xaml MSBuild:Compile Designer - + + Scenario8_ClearScenario.xaml MSBuild:Compile Designer - + + Scenario9_SetVersion.xaml MSBuild:Compile Designer - + + Styles\Styles.xaml MSBuild:Compile Designer diff --git a/Samples/ApplicationData/cs/App.xaml b/Samples/ApplicationData/shared/App.xaml similarity index 100% rename from Samples/ApplicationData/cs/App.xaml rename to Samples/ApplicationData/shared/App.xaml diff --git a/Samples/ApplicationData/cs/MainPage.xaml b/Samples/ApplicationData/shared/MainPage.xaml similarity index 100% rename from Samples/ApplicationData/cs/MainPage.xaml rename to Samples/ApplicationData/shared/MainPage.xaml diff --git a/Samples/ApplicationData/cs/Scenario1_Files.xaml b/Samples/ApplicationData/shared/Scenario1_Files.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario1_Files.xaml rename to Samples/ApplicationData/shared/Scenario1_Files.xaml diff --git a/Samples/ApplicationData/cs/Scenario2_Settings.xaml b/Samples/ApplicationData/shared/Scenario2_Settings.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario2_Settings.xaml rename to Samples/ApplicationData/shared/Scenario2_Settings.xaml diff --git a/Samples/ApplicationData/cs/Scenario3_SettingContainer.xaml b/Samples/ApplicationData/shared/Scenario3_SettingContainer.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario3_SettingContainer.xaml rename to Samples/ApplicationData/shared/Scenario3_SettingContainer.xaml diff --git a/Samples/ApplicationData/cs/Scenario4_CompositeSettings.xaml b/Samples/ApplicationData/shared/Scenario4_CompositeSettings.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario4_CompositeSettings.xaml rename to Samples/ApplicationData/shared/Scenario4_CompositeSettings.xaml diff --git a/Samples/ApplicationData/cs/Scenario5_DataChangedEvent.xaml b/Samples/ApplicationData/shared/Scenario5_DataChangedEvent.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario5_DataChangedEvent.xaml rename to Samples/ApplicationData/shared/Scenario5_DataChangedEvent.xaml diff --git a/Samples/ApplicationData/cs/Scenario6_HighPriority.xaml b/Samples/ApplicationData/shared/Scenario6_HighPriority.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario6_HighPriority.xaml rename to Samples/ApplicationData/shared/Scenario6_HighPriority.xaml diff --git a/Samples/ApplicationData/cs/Scenario7_Msappdata.xaml b/Samples/ApplicationData/shared/Scenario7_Msappdata.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario7_Msappdata.xaml rename to Samples/ApplicationData/shared/Scenario7_Msappdata.xaml diff --git a/Samples/ApplicationData/cs/Scenario8_ClearScenario.xaml b/Samples/ApplicationData/shared/Scenario8_ClearScenario.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario8_ClearScenario.xaml rename to Samples/ApplicationData/shared/Scenario8_ClearScenario.xaml diff --git a/Samples/ApplicationData/cs/Scenario9_SetVersion.xaml b/Samples/ApplicationData/shared/Scenario9_SetVersion.xaml similarity index 100% rename from Samples/ApplicationData/cs/Scenario9_SetVersion.xaml rename to Samples/ApplicationData/shared/Scenario9_SetVersion.xaml diff --git a/Samples/ApplicationData/cs/Styles/Styles.xaml b/Samples/ApplicationData/shared/Styles.xaml similarity index 100% rename from Samples/ApplicationData/cs/Styles/Styles.xaml rename to Samples/ApplicationData/shared/Styles.xaml diff --git a/Samples/ApplicationData/vb/App.xaml.vb b/Samples/ApplicationData/vb/App.xaml.vb new file mode 100644 index 0000000000..451ee42862 --- /dev/null +++ b/Samples/ApplicationData/vb/App.xaml.vb @@ -0,0 +1,82 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the Microsoft Public License. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.SDKTemplate + + ''' + ''' Provides application-specific behavior to supplement the default Application class. + ''' + NotInheritable Partial Class App + Inherits Application + + Public Sub New() + Me.InitializeComponent() + AddHandler Me.Suspending, AddressOf OnSuspending + End Sub + + ''' + ''' Invoked when the application is launched normally by the end user. Other entry points + ''' will be used such as when the application is launched to open a specific file. + ''' + ''' Details about the launch request and process. + Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs) +#If DEBUG Then + If System.Diagnostics.Debugger.IsAttached Then + Me.DebugSettings.EnableFrameRateCounter = False + End If +#End If + + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages(0) + AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed + If e.PreviousExecutionState = ApplicationExecutionState.Terminated Then + End If + + Window.Current.Content = rootFrame + End If + + If rootFrame.Content Is Nothing Then + rootFrame.Navigate(GetType(MainPage), e.Arguments) + End If + + Window.Current.Activate() + End Sub + + ''' + ''' Invoked when Navigation to a certain page fails + ''' + ''' The Frame which failed navigation + ''' Details about the navigation failure + Sub OnNavigationFailed(sender As Object, e As NavigationFailedEventArgs) + Throw New Exception("Failed to load Page " & e.SourcePageType.FullName) + End Sub + + ''' + ''' Invoked when application execution is being suspended. Application state is saved + ''' without knowing whether the application will be terminated or resumed with the contents + ''' of memory still intact. + ''' + ''' The source of the suspend request. + ''' Details about the suspend request. + Private Sub OnSuspending(sender As Object, e As SuspendingEventArgs) + Dim deferral = e.SuspendingOperation.GetDeferral() + deferral.Complete() + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/ApplicationData.sln b/Samples/ApplicationData/vb/ApplicationData.sln new file mode 100644 index 0000000000..746419e13c --- /dev/null +++ b/Samples/ApplicationData/vb/ApplicationData.sln @@ -0,0 +1,43 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ApplicationData", "ApplicationData.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|Any CPU.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/ApplicationData/vb/ApplicationData.vbproj b/Samples/ApplicationData/vb/ApplicationData.vbproj new file mode 100644 index 0000000000..b9f2ced92a --- /dev/null +++ b/Samples/ApplicationData/vb/ApplicationData.vbproj @@ -0,0 +1,292 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + ApplicationDataSample + ApplicationDataSample + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml + + + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + Scenario1_Files.xaml + + + Scenario2_Settings.xaml + + + Scenario3_SettingContainer.xaml + + + Scenario4_CompositeSettings.xaml + + + Scenario5_DataChangedEvent.xaml + + + Scenario6_HighPriority.xaml + + + Scenario7_Msappdata.xaml + + + Scenario8_ClearScenario.xaml + + + Scenario9_SetVersion.xaml + + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + Scenario1_Files.xaml + MSBuild:Compile + Designer + + + Scenario2_Settings.xaml + MSBuild:Compile + Designer + + + Scenario3_SettingContainer.xaml + MSBuild:Compile + Designer + + + Scenario4_CompositeSettings.xaml + MSBuild:Compile + Designer + + + Scenario5_DataChangedEvent.xaml + MSBuild:Compile + Designer + + + Scenario6_HighPriority.xaml + MSBuild:Compile + Designer + + + Scenario7_Msappdata.xaml + MSBuild:Compile + Designer + + + Scenario8_ClearScenario.xaml + MSBuild:Compile + Designer + + + Scenario9_SetVersion.xaml + MSBuild:Compile + Designer + + + Styles\Styles.xaml + MSBuild:Compile + Designer + + + + + Properties\Default.rd.xml + + + + + + Assets\microsoft-sdk.png + + + Assets\smallTile-sdk.png + + + Assets\smalltile-Windows-sdk.png + + + Assets\splash-sdk.png + + + Assets\splash-Windows-sdk.png + + + Assets\squareTile-sdk.png + + + Assets\storeLogo-sdk.png + + + Assets\tile-sdk.png + + + Assets\windows-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/ApplicationData/vb/Assets/appDataLocal.png b/Samples/ApplicationData/vb/Assets/appDataLocal.png new file mode 100644 index 0000000000000000000000000000000000000000..ffb7a714d5ab6e4fe963b59249a9f7059334e7bc GIT binary patch literal 934 zcmeAS@N?(olHy`uVBq!ia0vp^#URYV1SC}yS8W7RjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r$I`|HQFyrz36)6l1%+{VRjv*CsZ*MyKJvNXyT6pegqXmEZ0}dSv z2KN`+w99fPY;t(DsJrj2$;apQlNY4KEtdSUXujK?8@VqJms-C(eE9V8yR4g68qDUR zDUtvE>z!D=yWf@1=YOoQh`;r?;>V#m^|GJS*55z=u4d1i`SJN}*G`|UD|zViecEeV z+pEUL_xxAwe|JCW-m90&`m4X>-#+1HepcBq-&|L;n>JWFe}>DoJGsb71qhnH8} z;&u)`JMG#r>+}33GKYCT-!HZKHQV3!Hs@!v(xp$Pe*G5L{wv-3&7`xtq9tbKnO!fr zn=8k^Jn?qs^`hNr>C4|XR8Fq@`qh5%l$iJ$yM=RG7rsn89?o{|xS4oabL+zDgnJ4m zMbgPHU31eDUmQ1`{lxOI;r%yXw#XW+zy9adVZ*RxIoq~POFOsarirzEF8i6)Pyepg zUGc@phJD|Y%a^6^wTiVZn|0PSw*14Mir2qWYIZE!*P3aa5XT+uXj_@9c-`DA=vL?H z%Dj%V)2!E|KWhHwyz%C<&xg-|ESPe8=8w|X(uK1MY)UM@xxdIx)G)s-Q~I*dsp`wK z)HpdS*{AoOEx#+jIcnwlo7!&N&iffR&zikg+&nw$%(6o{S}y}DqnAu z9C!Y#AC$;nck|gQFKb1dOHXFp{6Hm6|c`Lo;39y@(L-1)k&bNJbJ57UHQH&-fNe|t51oB73@KeLw1(`>!R zcl4r?ew_JiACuej*QA=>cQSMSYaOx1`v04|3p9LNlQmS|&CXE2^CT)`?wq`LcMnXX gbt*(kzopr0KGcLJOBUy literal 0 HcmV?d00001 diff --git a/Samples/ApplicationData/vb/Assets/appDataRoaming.png b/Samples/ApplicationData/vb/Assets/appDataRoaming.png new file mode 100644 index 0000000000000000000000000000000000000000..6149388f75b45cdb6272175b3ff17e5a875bb86a GIT binary patch literal 1111 zcmeAS@N?(olHy`uVBq!ia0vp^#URYV1|(NI+dczQjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r$I`|HQFyrz36)6l1%x^qh978JN-p=wZT5KTT_PnZin#|GTGjjHn z`909t|O=S~ih279W0IzOq`=ncKyFYeK@mKfiz966Dbk<~YUDWYoC8 zM}c0!DlXG-Qn?ZxXo z;upHLs@%M3v{EQi*jV@S!>1>T+c$Qo^@*y@&3QS)xc1wjTBFU9a@tRdP9z6?I#wMW z>1k@X*{HdraHhSie$q*Et?Mh!9JRB4pf_{nqD%SO4;`oYb$QkKo>}9w(<$Qj);+UQ zx2dHiubIAblI>Ps?*1ny*LVK(ORaL+lOt-B{`*bCRikchao?`Wjx#=e@1NhAv&SjT zb-wI|ptL>9r!f6m(ycPXdxifL@A#^Om7O!ENxJfUe-*IwXY&lXV8vC-&htg6Uye%J zT$^0ftTFSA-OpWB)02E={@uChZB>q@+vzEvvVOg32sLv4q^@sLFZ5;O_Q%zCrp=lZ zBrKdFrn_Fv_*(zw2&3PIzpl+s-+BI9JzMvB<+R9> zQ=VIDH7+aZY`%8*_O^vS?mJRba_g0Br*N`>gEc@+fR@ZdA8!3+pM5IA_FnA{abRJ< N;OXk;vd$@?2>`-X@mK%= literal 0 HcmV?d00001 diff --git a/Samples/ApplicationData/vb/Assets/appDataTemp.png b/Samples/ApplicationData/vb/Assets/appDataTemp.png new file mode 100644 index 0000000000000000000000000000000000000000..f039c312893ed3f7f9871abc96ad627c977619f9 GIT binary patch literal 994 zcmeAS@N?(olHy`uVBq!ia0vp^#URYV1|(NI+dczQjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCij$3p^r$I{1!&FymBhK4}I9=5kLL$B>G+x3kU`zA_MT3-*3>GQg`$vzhIZ zQ`q_jpKUsq7^Kb41TgSwcx-a4-zM6md+*_H<8-4NLT2B8oa%eB{CT~;o52Jhfk~WB zMvfk894A>6XDX-&x1=;tSx{`s&#Zg>$7Vckj}-lWzwK&Sy_JXD?zh<+Z9AW))YZw_h;YK-xs}U#+mKS>-m10`+s|@ae7OM z^5OhG-I=O6sU@PB+FJq?_rA%P;Ug4zIW6KDr?$GyHtXpMP4A1uVbV*Y={>}R6j6FVSuJhZ@=v=-ZT*MfAsaZv&Jz(~V2aQXYo!#K0|EOktS*VnK z$I|ChI#<2CJfSjmTHB3``>H$rLT0?t`#31H+`bH{^!@`Pd;^KUY+_cla#QT zdOw@(P3nZUP zm6@MUfFrih-00~2iO5lHxZ3CU`XdP{#^#US>x9kpTf=g$E2U`%_sow^D)yXulwSMj zWa;*-OY0+cbf{mdo&T}CwZmlkOCdQmtH`pVzn6}tOFy^!S#7b;-{Na|{QFmDT$5*( z*&4;Z|I*oi&2n+wNu|xIk!@OX+Ogd%m%^5 + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class MainPage + Inherits Page + + Public Shared Current As MainPage + + Public Sub New() + Me.InitializeComponent() + Current = Me + SampleTitle.Text = FEATURE_NAME + End Sub + + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + ScenarioControl.ItemsSource = scenarios + If Window.Current.Bounds.Width < 640 Then + ScenarioControl.SelectedIndex = -1 + Else + ScenarioControl.SelectedIndex = 0 + End If + End Sub + + ''' + ''' Called whenever the user changes selection in the scenarios list. This method will navigate to the respective + ''' sample scenario page. + ''' + ''' + ''' + Private Sub ScenarioControl_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + NotifyUser(String.Empty, NotifyType.StatusMessage) + Dim scenarioListBox As ListBox = TryCast(sender, ListBox) + Dim s As Scenario = TryCast(scenarioListBox.SelectedItem, Scenario) + If s IsNot Nothing Then + ScenarioFrame.Navigate(s.ClassType) + If Window.Current.Bounds.Width < 640 Then + Splitter.IsPaneOpen = False + StatusBorder.Visibility = Visibility.Collapsed + End If + End If + End Sub + + ''' + ''' Used to display messages to the user + ''' + ''' + ''' + Public Sub NotifyUser(strMessage As String, type As NotifyType) + Select type + Case NotifyType.StatusMessage + StatusBorder.Background = New SolidColorBrush(Windows.UI.Colors.Green) + Case NotifyType.ErrorMessage + StatusBorder.Background = New SolidColorBrush(Windows.UI.Colors.Red) + End Select + + StatusBlock.Text = strMessage + StatusBorder.Visibility = If((StatusBlock.Text <> String.Empty), Visibility.Visible, Visibility.Collapsed) + End Sub + + Async Sub Footer_Click(sender As Object, e As RoutedEventArgs) + Await Windows.System.Launcher.LaunchUriAsync(New Uri((CType(sender, HyperlinkButton)).Tag.ToString())) + End Sub + + Private Sub Button_Click(sender As Object, e As RoutedEventArgs) + Splitter.IsPaneOpen = If((Splitter.IsPaneOpen = True), False, True) + StatusBorder.Visibility = Visibility.Collapsed + End Sub + End Class + + Public Enum NotifyType + StatusMessage + ErrorMessage + End Enum + + Public Class ScenarioBindingConverter + Implements IValueConverter + + Public Function Convert(value As Object, targetType As Type, parameter As Object, language As String) As Object Implements IValueConverter.Convert + Dim s As Scenario = TryCast(value, Scenario) + Return(MainPage.Current.Scenarios.IndexOf(s) + 1) & ") " & s.Title + End Function + + Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, language As String) As Object Implements IValueConverter.ConvertBack + Return True + End Function + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Package.appxmanifest b/Samples/ApplicationData/vb/Package.appxmanifest new file mode 100644 index 0000000000..3425dc7de6 --- /dev/null +++ b/Samples/ApplicationData/vb/Package.appxmanifest @@ -0,0 +1,31 @@ + + + + + + ApplicationData VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/ApplicationData/vb/SampleConfiguration.vb b/Samples/ApplicationData/vb/SampleConfiguration.vb new file mode 100644 index 0000000000..a68ffb8513 --- /dev/null +++ b/Samples/ApplicationData/vb/SampleConfiguration.vb @@ -0,0 +1,35 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the Microsoft Public License. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Collections.Generic +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + Inherits Page + + Public Const FEATURE_NAME As String = "ApplicationData" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "Files", .ClassType = GetType(ApplicationDataSample.Files)}, New Scenario() With {.Title = "Settings", .ClassType = GetType(ApplicationDataSample.Settings)}, New Scenario() With {.Title = "Setting Containers", .ClassType = GetType(ApplicationDataSample.SettingContainer)}, New Scenario() With {.Title = "Composite Settings", .ClassType = GetType(ApplicationDataSample.CompositeSettings)}, New Scenario() With {.Title = "DataChanged Event", .ClassType = GetType(ApplicationDataSample.DataChangedEvent)}, New Scenario() With {.Title = "Roaming: HighPriority", .ClassType = GetType(ApplicationDataSample.HighPriority)}, New Scenario() With {.Title = "ms-appdata:// Protocol", .ClassType = GetType(ApplicationDataSample.Msappdata)}, New Scenario() With {.Title = "Clear", .ClassType = GetType(ApplicationDataSample.ClearScenario)}, New Scenario() With {.Title = "SetVersion", .ClassType = GetType(ApplicationDataSample.SetVersion)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + + Public Overrides Function ToString() As String + Return Title + End Function + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario1_Files.xaml.vb b/Samples/ApplicationData/vb/Scenario1_Files.xaml.vb new file mode 100644 index 0000000000..0e054860d2 --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario1_Files.xaml.vb @@ -0,0 +1,167 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Files + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim localFolder As StorageFolder = Nothing + + Dim localCounter As Integer = 0 + + Dim localCacheFolder As StorageFolder = Nothing + + Dim localCacheCounter As Integer = 0 + + Dim roamingFolder As StorageFolder = Nothing + + Dim roamingCounter As Integer = 0 + + Dim temporaryFolder As StorageFolder = Nothing + + Dim temporaryCounter As Integer = 0 + + Const filename As String = "sampleFile.txt" + + Public Sub New() + Me.InitializeComponent() + localFolder = ApplicationData.Current.LocalFolder + localCacheFolder = ApplicationData.Current.LocalCacheFolder + roamingFolder = ApplicationData.Current.RoamingFolder + temporaryFolder = ApplicationData.Current.TemporaryFolder + DisplayOutput() + End Sub + + ' Guidance for Local, LocalCache, Roaming, and Temporary files. + ' + ' Files are ideal for storing large data-sets, databases, or data that is + ' in a common file-format. + ' + ' Files can exist in either the Local, LocalCache, Roaming, or Temporary folders. + ' + ' Roaming files will be synchronized across machines on which the user has + ' singed in with a connected account. Roaming of files is not instant; the + ' system weighs several factors when determining when to send the data. Usage + ' of roaming data should be kept below the quota (available via the + ' RoamingStorageQuota property), or else roaming of data will be suspended. + ' Files cannot be roamed while an application is writing to them, so be sure + ' to close your application's file objects when they are no longer needed. + ' + ' Local files are not synchronized, but are backed up, and can then be restored to a + ' machine different than where they were originally written. These should be for + ' important files that allow the feel that the user did not loose anything + ' when they restored to a new device. + ' + ' Temporary files are subject to deletion when not in use. The system + ' considers factors such as available disk capacity and the age of a file when + ' determining when or whether to delete a temporary file. + ' + ' LocalCache files are for larger files that can be recreated by the app, and for + ' machine specific or private files that should not be restored to a new device. + Async Sub Increment_Local_Click(sender As [Object], e As RoutedEventArgs) + localCounter = localCounter + 1 + Dim file As StorageFile = Await localFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting) + Await FileIO.WriteTextAsync(file, localCounter.ToString()) + Read_Local_Counter() + End Sub + + Async Sub Read_Local_Counter() + Try + Dim file As StorageFile = Await localFolder.GetFileAsync(filename) + Dim text As String = Await FileIO.ReadTextAsync(file) + LocalOutputTextBlock.Text = "Local Counter: " & text + localCounter = Integer.Parse(text) + Catch + LocalOutputTextBlock.Text = "Local Counter: " + End Try + End Sub + + Async Sub Increment_LocalCache_Click(sender As [Object], e As RoutedEventArgs) + localCacheCounter = localCacheCounter + 1 + Dim file As StorageFile = Await localCacheFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting) + Await FileIO.WriteTextAsync(file, localCacheCounter.ToString()) + Read_LocalCache_Counter() + End Sub + + Async Sub Read_LocalCache_Counter() + Try + Dim file As StorageFile = Await localCacheFolder.GetFileAsync(filename) + Dim text As String = Await FileIO.ReadTextAsync(file) + LocalCacheOutputTextBlock.Text = "LocalCache Counter: " & text + localCacheCounter = Integer.Parse(text) + Catch + LocalCacheOutputTextBlock.Text = "LocalCache Counter: " + End Try + End Sub + + Async Sub Increment_Roaming_Click(sender As [Object], e As RoutedEventArgs) + roamingCounter = roamingCounter + 1 + Dim file As StorageFile = Await roamingFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting) + Await FileIO.WriteTextAsync(file, roamingCounter.ToString()) + Read_Roaming_Counter() + End Sub + + Async Sub Read_Roaming_Counter() + Try + Dim file As StorageFile = Await roamingFolder.GetFileAsync(filename) + Dim text As String = Await FileIO.ReadTextAsync(file) + RoamingOutputTextBlock.Text = "Roaming Counter: " & text + roamingCounter = Integer.Parse(text) + Catch + RoamingOutputTextBlock.Text = "Roaming Counter: " + End Try + End Sub + + Async Sub Increment_Temporary_Click(sender As [Object], e As RoutedEventArgs) + temporaryCounter = temporaryCounter + 1 + Dim file As StorageFile = Await temporaryFolder.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting) + Await FileIO.WriteTextAsync(file, temporaryCounter.ToString()) + Read_Temporary_Counter() + End Sub + + Async Sub Read_Temporary_Counter() + Try + Dim file As StorageFile = Await temporaryFolder.GetFileAsync(filename) + Dim text As String = Await FileIO.ReadTextAsync(file) + TemporaryOutputTextBlock.Text = "Temporary Counter: " & text + temporaryCounter = Integer.Parse(text) + Catch + TemporaryOutputTextBlock.Text = "Temporary Counter: " + End Try + End Sub + + Sub DisplayOutput() + Read_Local_Counter() + Read_LocalCache_Counter() + Read_Roaming_Counter() + Read_Temporary_Counter() + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario2_Settings.xaml.vb b/Samples/ApplicationData/vb/Scenario2_Settings.xaml.vb new file mode 100644 index 0000000000..5980d77846 --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario2_Settings.xaml.vb @@ -0,0 +1,60 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Settings + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim roamingSettings As ApplicationDataContainer = Nothing + + Const SettingName As String = "exampleSetting" + + Public Sub New() + Me.InitializeComponent() + roamingSettings = ApplicationData.Current.RoamingSettings + DisplayOutput() + End Sub + + Sub WriteSetting_Click(sender As [Object], e As RoutedEventArgs) + roamingSettings.Values(SettingName) = "Hello World" + DisplayOutput() + End Sub + + Sub DeleteSetting_Click(sender As [Object], e As RoutedEventArgs) + roamingSettings.Values.Remove(SettingName) + DisplayOutput() + End Sub + + Sub DisplayOutput() + Dim value As [Object] = roamingSettings.Values(SettingName) + OutputTextBlock.Text = String.Format("Setting: {0}", (If(value Is Nothing, "", ("""" & value & """")))) + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario3_SettingContainer.xaml.vb b/Samples/ApplicationData/vb/Scenario3_SettingContainer.xaml.vb new file mode 100644 index 0000000000..56bdb26d76 --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario3_SettingContainer.xaml.vb @@ -0,0 +1,80 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class SettingContainer + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim localSettings As ApplicationDataContainer = Nothing + + Const containerName As String = "exampleContainer" + + Const settingName As String = "exampleSetting" + + Public Sub New() + Me.InitializeComponent() + localSettings = ApplicationData.Current.LocalSettings + DisplayOutput() + End Sub + + Sub CreateContainer_Click(sender As [Object], e As RoutedEventArgs) + Dim container As ApplicationDataContainer = localSettings.CreateContainer(containerName, ApplicationDataCreateDisposition.Always) + DisplayOutput() + End Sub + + Sub DeleteContainer_Click(sender As [Object], e As RoutedEventArgs) + localSettings.DeleteContainer(containerName) + DisplayOutput() + End Sub + + Sub WriteSetting_Click(sender As [Object], e As RoutedEventArgs) + If localSettings.Containers.ContainsKey(containerName) Then + localSettings.Containers(containerName).Values(settingName) = "Hello World" + End If + + DisplayOutput() + End Sub + + Sub DeleteSetting_Click(sender As [Object], e As RoutedEventArgs) + If localSettings.Containers.ContainsKey(containerName) Then + localSettings.Containers(containerName).Values.Remove(settingName) + End If + + DisplayOutput() + End Sub + + Sub DisplayOutput() + Dim hasContainer As Boolean = localSettings.Containers.ContainsKey(containerName) + Dim hasSetting As Boolean = If(hasContainer, localSettings.Containers(containerName).Values.ContainsKey(settingName), False) + Dim output As String = String.Format("Container Exists: {0}" & vbLf & "Setting Exists: {1}", If(hasContainer, "true", "false"), If(hasSetting, "true", "false")) + OutputTextBlock.Text = output + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario4_CompositeSettings.xaml.vb b/Samples/ApplicationData/vb/Scenario4_CompositeSettings.xaml.vb new file mode 100644 index 0000000000..3d1dabe9c0 --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario4_CompositeSettings.xaml.vb @@ -0,0 +1,74 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class CompositeSettings + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim roamingSettings As ApplicationDataContainer = Nothing + + Const settingName As String = "exampleCompositeSetting" + + Const settingName1 As String = "one" + + Const settingName2 As String = "hello" + + Public Sub New() + Me.InitializeComponent() + roamingSettings = ApplicationData.Current.RoamingSettings + DisplayOutput() + End Sub + + Sub WriteCompositeSetting_Click(sender As [Object], e As RoutedEventArgs) + Dim composite As ApplicationDataCompositeValue = New ApplicationDataCompositeValue() + composite(settingName1) = 1 + composite(settingName2) = "world" + roamingSettings.Values(settingName) = composite + DisplayOutput() + End Sub + + Sub DeleteCompositeSetting_Click(sender As [Object], e As RoutedEventArgs) + roamingSettings.Values.Remove(settingName) + DisplayOutput() + End Sub + + Sub DisplayOutput() + Dim composite As ApplicationDataCompositeValue = CType(roamingSettings.Values(settingName), ApplicationDataCompositeValue) + Dim output As String + If composite Is Nothing Then + output = "Composite Setting: " + Else + output = String.Format("Composite Setting: {{{0} = {1}, {2} = ""{3}""}}", settingName1, composite(settingName1), settingName2, composite(settingName2)) + End If + + OutputTextBlock.Text = output + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario5_DataChangedEvent.xaml.vb b/Samples/ApplicationData/vb/Scenario5_DataChangedEvent.xaml.vb new file mode 100644 index 0000000000..5491333c7c --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario5_DataChangedEvent.xaml.vb @@ -0,0 +1,84 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Foundation +Imports Windows.UI.Core +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class DataChangedEvent + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim applicationData As ApplicationData = Nothing + + Dim roamingSettings As ApplicationDataContainer = Nothing + + Dim _dataChangedHandler As TypedEventHandler(Of ApplicationData, Object) = Nothing + + Const settingName As String = "userName" + + Public Sub New() + Me.InitializeComponent() + applicationData = ApplicationData.Current + roamingSettings = applicationData.RoamingSettings + DisplayOutput() + End Sub + + Sub SimulateRoaming_Click(sender As [Object], e As RoutedEventArgs) + roamingSettings.Values(settingName) = UserName.Text + applicationData.SignalDataChanged() + End Sub + + Async Sub DataChangedHandler(appData As Windows.Storage.ApplicationData, o As Object) + Await Me.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + DisplayOutput() + End Sub) + End Sub + + Sub DisplayOutput() + Dim value As [Object] = roamingSettings.Values(settingName) + OutputTextBlock.Text = "Name: " & (If(value Is Nothing, "", ("""" & value & """"))) + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + _dataChangedHandler = New TypedEventHandler(Of ApplicationData, Object)(AddressOf DataChangedHandler) + AddHandler applicationData.DataChanged, AddressOf dataChangedHandler + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + MyBase.OnNavigatingFrom(e) + RemoveHandler applicationData.DataChanged, AddressOf DataChangedHandler + _dataChangedHandler = Nothing + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario6_HighPriority.xaml.vb b/Samples/ApplicationData/vb/Scenario6_HighPriority.xaml.vb new file mode 100644 index 0000000000..33860f9388 --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario6_HighPriority.xaml.vb @@ -0,0 +1,83 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Foundation +Imports Windows.UI.Core +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class HighPriority + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim roamingSettings As ApplicationDataContainer = Nothing + + Dim applicationData As ApplicationData = Nothing + + Dim _dataChangedHandler As TypedEventHandler(Of ApplicationData, Object) = Nothing + + Public Sub New() + Me.InitializeComponent() + applicationData = ApplicationData.Current + roamingSettings = applicationData.RoamingSettings + DisplayOutput(False) + End Sub + + Sub IncrementHighPriority_Click(sender As [Object], e As RoutedEventArgs) + Dim counter As Integer = Convert.ToInt32(roamingSettings.Values("HighPriority")) + roamingSettings.Values("HighPriority") = counter + 1 + DisplayOutput(False) + End Sub + + Async Sub DataChangedHandler(appData As Windows.Storage.ApplicationData, o As Object) + Await Me.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + DisplayOutput(True) + End Sub) + End Sub + + Sub DisplayOutput(remoteUpdate As Boolean) + Dim counter As Integer = Convert.ToInt32(roamingSettings.Values("HighPriority")) + OutputTextBlock.Text = "Counter: " & counter & (If(remoteUpdate, " (updated remotely)", "")) + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + _dataChangedHandler = New TypedEventHandler(Of ApplicationData, Object)(AddressOf dataChangedHandler) + AddHandler applicationData.DataChanged, AddressOf dataChangedHandler + End Sub + + ''' + ''' Invoked immediately before the Page is unloaded and is no longer the current source of a parent Frame. + ''' + ''' + ''' Event data that can be examined by overriding code. The event data is representative + ''' of the navigation that will unload the current Page unless canceled. The + ''' navigation can potentially be canceled by setting Cancel. + ''' + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + MyBase.OnNavigatingFrom(e) + RemoveHandler applicationData.DataChanged, AddressOf dataChangedHandler + _dataChangedHandler = Nothing + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario7_Msappdata.xaml.vb b/Samples/ApplicationData/vb/Scenario7_Msappdata.xaml.vb new file mode 100644 index 0000000000..293b11eeda --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario7_Msappdata.xaml.vb @@ -0,0 +1,67 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Msappdata + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + Dim appData As ApplicationData = ApplicationData.Current + Try + Dim sourceFile As StorageFile = Await StorageFile.GetFileFromApplicationUriAsync(New Uri("ms-appx:///assets/appDataLocal.png")) + Await sourceFile.CopyAsync(appData.LocalFolder) + Catch + End Try + + Try + Dim sourceFile As StorageFile = Await StorageFile.GetFileFromApplicationUriAsync(New Uri("ms-appx:///assets/appDataRoaming.png")) + Await sourceFile.CopyAsync(appData.RoamingFolder) + Catch + End Try + + Try + Dim sourceFile As StorageFile = Await StorageFile.GetFileFromApplicationUriAsync(New Uri("ms-appx:///assets/appDataTemp.png")) + Await sourceFile.CopyAsync(appData.TemporaryFolder) + Catch + End Try + + LocalImage.Source = New Windows.UI.Xaml.Media.Imaging.BitmapImage(New Uri("ms-appdata:///local/appDataLocal.png")) + RoamingImage.Source = New Windows.UI.Xaml.Media.Imaging.BitmapImage(New Uri("ms-appdata:///roaming/appDataRoaming.png")) + TempImage.Source = New Windows.UI.Xaml.Media.Imaging.BitmapImage(New Uri("ms-appdata:///temp/appDataTemp.png")) + End Sub + + Protected Overrides Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + LocalImage.Source = Nothing + RoamingImage.Source = Nothing + TempImage.Source = Nothing + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario8_ClearScenario.xaml.vb b/Samples/ApplicationData/vb/Scenario8_ClearScenario.xaml.vb new file mode 100644 index 0000000000..b00d4c6ecf --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario8_ClearScenario.xaml.vb @@ -0,0 +1,48 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class ClearScenario + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Public Sub New() + Me.InitializeComponent() + End Sub + + Async Sub Clear_Click(sender As [Object], e As RoutedEventArgs) + Try + Await Windows.Storage.ApplicationData.Current.ClearAsync() + OutputTextBlock.Text = "ApplicationData has been cleared. Visit the other scenarios to see that their data has been cleared." + Catch + OutputTextBlock.Text = "Unable to clear settings. This can happen when files are in use." + End Try + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/Scenario9_SetVersion.xaml.vb b/Samples/ApplicationData/vb/Scenario9_SetVersion.xaml.vb new file mode 100644 index 0000000000..a68d751cac --- /dev/null +++ b/Samples/ApplicationData/vb/Scenario9_SetVersion.xaml.vb @@ -0,0 +1,91 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System +Imports Windows.Storage + +Namespace Global.ApplicationDataSample + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class SetVersion + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Dim appData As ApplicationData = Nothing + + Const settingName As String = "SetVersionSetting" + + Const settingValue0 As String = "Data.v0" + + Const settingValue1 As String = "Data.v1" + + Public Sub New() + Me.InitializeComponent() + appData = ApplicationData.Current + DisplayOutput() + End Sub + + Sub SetVersionHandler0(request As SetVersionRequest) + Dim deferral As SetVersionDeferral = request.GetDeferral() + Dim version As UInteger = appData.Version + Select version + Case 0 + Case 1 + appData.LocalSettings.Values(settingName) = settingValue0 + Case Else + Throw New Exception("Unexpected ApplicationData Version: " & version) + End Select + + deferral.Complete() + End Sub + + Sub SetVersionHandler1(request As SetVersionRequest) + Dim deferral As SetVersionDeferral = request.GetDeferral() + Dim version As UInteger = appData.Version + Select version + Case 0 + appData.LocalSettings.Values(settingName) = settingValue1 + Case 1 + Case Else + Throw New Exception("Unexpected ApplicationData Version: " & version) + End Select + + deferral.Complete() + End Sub + + Async Sub SetVersion0_Click(sender As [Object], e As RoutedEventArgs) + Await appData.SetVersionAsync(0, New ApplicationDataSetVersionHandler(AddressOf SetVersionHandler0)) + DisplayOutput() + End Sub + + Async Sub SetVersion1_Click(sender As [Object], e As RoutedEventArgs) + Await appData.SetVersionAsync(1, New ApplicationDataSetVersionHandler(AddressOf SetVersionHandler1)) + DisplayOutput() + End Sub + + Sub DisplayOutput() + OutputTextBlock.Text = "Version: " & appData.Version + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/SuspensionManager.vb b/Samples/ApplicationData/vb/SuspensionManager.vb new file mode 100644 index 0000000000..2066db1750 --- /dev/null +++ b/Samples/ApplicationData/vb/SuspensionManager.vb @@ -0,0 +1,221 @@ +Imports System +Imports System.Collections.Generic +Imports System.IO +Imports System.Linq +Imports System.Runtime.Serialization +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.ApplicationModel +Imports Windows.Storage +Imports Windows.Storage.Streams +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls + +Namespace Global.SDKTemplate.Common + + ''' + ''' SuspensionManager captures global session state to simplify process lifetime management + ''' for an application. Note that session state will be automatically cleared under a variety + ''' of conditions and should only be used to store information that would be convenient to + ''' carry across sessions, but that should be discarded when an application crashes or is + ''' upgraded. + ''' + Friend NotInheritable Class SuspensionManager + + Private Shared _sessionState As Dictionary(Of String, Object) = New Dictionary(Of String, Object)() + + Private Shared _knownTypes As List(Of Type) = New List(Of Type)() + + Private Const sessionStateFilename As String = "_sessionState.xml" + + Public Shared ReadOnly Property SessionState As Dictionary(Of String, Object) + Get + Return _sessionState + End Get + End Property + + Public Shared ReadOnly Property KnownTypes As List(Of Type) + Get + Return _knownTypes + End Get + End Property + + ''' + ''' Save the current . Any instances + ''' registered with will also preserve their current + ''' navigation stack, which in turn gives their active an opportunity + ''' to save its state. + ''' + ''' An asynchronous task that reflects when session state has been saved. + Public Shared Async Function SaveAsync() As Task + Try + For Each weakFrameReference In _registeredFrames + Dim frame As Frame = Nothing + If weakFrameReference.TryGetTarget(frame) Then + SaveFrameNavigationState(frame) + End If + Next + + ' Serialize the session state synchronously to avoid asynchronous access to shared + ' state + Dim sessionData As MemoryStream = New MemoryStream() + Dim serializer As DataContractSerializer = New DataContractSerializer(GetType(Dictionary(Of String, Object)), _knownTypes) + serializer.WriteObject(sessionData, _sessionState) + ' Get an output stream for the SessionState file and write the state asynchronously + Dim file As StorageFile = Await ApplicationData.Current.LocalFolder.CreateFileAsync(sessionStateFilename, CreationCollisionOption.ReplaceExisting) + Using fileStream As Stream = Await file.OpenStreamForWriteAsync() + sessionData.Seek(0, SeekOrigin.Begin) + Await sessionData.CopyToAsync(fileStream) + End Using + Catch e As Exception + Throw New SuspensionManagerException(e) + End Try + End Function + + ''' + ''' Restores previously saved . Any instances + ''' registered with will also restore their prior navigation + ''' state, which in turn gives their active an opportunity restore its + ''' state. + ''' + ''' An optional key that identifies the type of session. + ''' This can be used to distinguish between multiple application launch scenarios. + ''' An asynchronous task that reflects when session state has been read. The + ''' content of should not be relied upon until this task + ''' completes. + Public Shared Async Function RestoreAsync(Optional sessionBaseKey As String = Nothing) As Task + _sessionState = New Dictionary(Of String, [Object])() + Try + ' Get the input stream for the SessionState file + Dim file As StorageFile = Await ApplicationData.Current.LocalFolder.GetFileAsync(sessionStateFilename) + Using inStream As IInputStream = Await file.OpenSequentialReadAsync() + ' Deserialize the Session State + Dim serializer As DataContractSerializer = New DataContractSerializer(GetType(Dictionary(Of String, Object)), _knownTypes) + _sessionState = CType(serializer.ReadObject(inStream.AsStreamForRead()), Dictionary(Of String, Object)) + End Using + + For Each weakFrameReference In _registeredFrames + Dim frame As Frame = Nothing + If weakFrameReference.TryGetTarget(frame) AndAlso CType(frame.GetValue(FrameSessionBaseKeyProperty), String) = sessionBaseKey Then + frame.ClearValue(FrameSessionStateProperty) + RestoreFrameNavigationState(frame) + End If + Next + Catch e As Exception + Throw New SuspensionManagerException(e) + End Try + End Function + + Private Shared FrameSessionStateKeyProperty As DependencyProperty = DependencyProperty.RegisterAttached("_FrameSessionStateKey", GetType(String), GetType(SuspensionManager), Nothing) + + Private Shared FrameSessionBaseKeyProperty As DependencyProperty = DependencyProperty.RegisterAttached("_FrameSessionBaseKeyParams", GetType(String), GetType(SuspensionManager), Nothing) + + Private Shared FrameSessionStateProperty As DependencyProperty = DependencyProperty.RegisterAttached("_FrameSessionState", GetType(Dictionary(Of String, [Object])), GetType(SuspensionManager), Nothing) + + Private Shared _registeredFrames As List(Of WeakReference(Of Frame)) = New List(Of WeakReference(Of Frame))() + + ''' + ''' Registers a instance to allow its navigation history to be saved to + ''' and restored from . Frames should be registered once + ''' immediately after creation if they will participate in session state management. Upon + ''' registration if state has already been restored for the specified key + ''' the navigation history will immediately be restored. Subsequent invocations of + ''' will also restore navigation history. + ''' + ''' An instance whose navigation history should be managed by + ''' + ''' A unique key into used to + ''' store navigation-related information. + ''' An optional key that identifies the type of session. + ''' This can be used to distinguish between multiple application launch scenarios. + Public Shared Sub RegisterFrame(frame As Frame, sessionStateKey As String, Optional sessionBaseKey As String = Nothing) + If frame.GetValue(FrameSessionStateKeyProperty) IsNot Nothing Then + Throw New InvalidOperationException("Frames can only be registered to one session state key") + End If + + If frame.GetValue(FrameSessionStateProperty) IsNot Nothing Then + Throw New InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all") + End If + + If Not String.IsNullOrEmpty(sessionBaseKey) Then + frame.SetValue(FrameSessionBaseKeyProperty, sessionBaseKey) + sessionStateKey = sessionBaseKey & "_" & sessionStateKey + End If + + frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey) + _registeredFrames.Add(New WeakReference(Of Frame)(frame)) + RestoreFrameNavigationState(frame) + End Sub + + ''' + ''' Disassociates a previously registered by + ''' from . Any navigation state previously captured will be + ''' removed. + ''' + ''' An instance whose navigation history should no longer be + ''' managed. + Public Shared Sub UnregisterFrame(frame As Frame) + SessionState.Remove(CType(frame.GetValue(FrameSessionStateKeyProperty), String)) + _registeredFrames.RemoveAll(Function(weakFrameReference) + Dim testFrame As Frame = Nothing + Return Not weakFrameReference.TryGetTarget(testFrame) OrElse testFrame Is frame + End Function) + End Sub + + ''' + ''' Provides storage for session state associated with the specified . + ''' Frames that have been previously registered with have + ''' their session state saved and restored automatically as a part of the global + ''' . Frames that are not registered have transient state + ''' that can still be useful when restoring pages that have been discarded from the + ''' navigation cache. + ''' + ''' Apps may choose to rely on to manage + ''' page-specific state instead of working with frame session state directly. + ''' The instance for which session state is desired. + ''' A collection of state subject to the same serialization mechanism as + ''' . + Public Shared Function SessionStateForFrame(frame As Frame) As Dictionary(Of String, [Object]) + Dim frameState = CType(frame.GetValue(FrameSessionStateProperty), Dictionary(Of String, [Object])) + If frameState Is Nothing Then + Dim frameSessionKey = CType(frame.GetValue(FrameSessionStateKeyProperty), String) + If frameSessionKey IsNot Nothing Then + If Not _sessionState.ContainsKey(frameSessionKey) Then + _sessionState(frameSessionKey) = New Dictionary(Of String, [Object])() + End If + + frameState = CType(_sessionState(frameSessionKey), Dictionary(Of String, [Object])) + Else + frameState = New Dictionary(Of String, [Object])() + End If + + frame.SetValue(FrameSessionStateProperty, frameState) + End If + + Return frameState + End Function + + Private Shared Sub RestoreFrameNavigationState(frame As Frame) + Dim frameState = SessionStateForFrame(frame) + If frameState.ContainsKey("Navigation") Then + frame.SetNavigationState(CType(frameState("Navigation"), String)) + End If + End Sub + + Private Shared Sub SaveFrameNavigationState(frame As Frame) + Dim frameState = SessionStateForFrame(frame) + frameState("Navigation") = frame.GetNavigationState() + End Sub + End Class + + Public Class SuspensionManagerException + Inherits Exception + + Public Sub New() + End Sub + + Public Sub New(e As Exception) + MyBase.New("SuspensionManager failed", e) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationData/vb/project.json b/Samples/ApplicationData/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/ApplicationData/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/ApplicationResources/vb/AppResourceClassLibrary/AppResourceClassLibrary.vbproj b/Samples/ApplicationResources/vb/AppResourceClassLibrary/AppResourceClassLibrary.vbproj new file mode 100644 index 0000000000..8962e360d7 --- /dev/null +++ b/Samples/ApplicationResources/vb/AppResourceClassLibrary/AppResourceClassLibrary.vbproj @@ -0,0 +1,171 @@ + + + + + Debug + x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD} + + Library + AppResourceClassLibrary + AppResourceClassLibrary + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + + Properties\AssemblyInfo.vb + + + + + strings\ja\resources.resw + + + strings\fr\resources.resw + + + strings\en\resources.resw + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/ApplicationResources/vb/AppResourceClassLibrary/class1.vb b/Samples/ApplicationResources/vb/AppResourceClassLibrary/class1.vb new file mode 100644 index 0000000000..9e24143c46 --- /dev/null +++ b/Samples/ApplicationResources/vb/AppResourceClassLibrary/class1.vb @@ -0,0 +1,30 @@ +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Text +Imports System.Threading.Tasks +Imports Windows.ApplicationModel.Resources + +Namespace Global.AppResourceClassLibrary + + Public Module LocalizedNamesLibrary + + Dim resourceLoader As ResourceLoader = Nothing + + Public ReadOnly Property LibraryName As String + Get + Dim name As String = Nothing + GetLibraryName("string1", name) + Return name + End Get + End Property + + Private Sub GetLibraryName(resourceName As String, ByRef resourceValue As String) + If resourceLoader Is Nothing Then + resourceLoader = ResourceLoader.GetForCurrentView("AppResourceClassLibrary/Resources") + End If + + resourceValue = resourceLoader.GetString(resourceName) + End Sub + End Module +End Namespace diff --git a/Samples/ApplicationResources/vb/AppResourceClassLibrary/project.json b/Samples/ApplicationResources/vb/AppResourceClassLibrary/project.json new file mode 100644 index 0000000000..ecc018e3bf --- /dev/null +++ b/Samples/ApplicationResources/vb/AppResourceClassLibrary/project.json @@ -0,0 +1,17 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0", + "System.Numerics.Vectors": "4.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/ApplicationResources/vb/ApplicationResources.sln b/Samples/ApplicationResources/vb/ApplicationResources.sln new file mode 100644 index 0000000000..a8a2ba04f9 --- /dev/null +++ b/Samples/ApplicationResources/vb/ApplicationResources.sln @@ -0,0 +1,59 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ApplicationResources", "ApplicationResources.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AppResourceClassLibrary", "AppResourceClassLibrary\AppResourceClassLibrary.vbproj", "{B0D33B00-9009-40B6-8519-A97BD91DC1BD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|ARM = Debug|ARM + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|ARM = Release|ARM + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|Any CPU.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|Any CPU.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|Any CPU.ActiveCfg = Debug|x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|ARM.ActiveCfg = Debug|ARM + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|ARM.Build.0 = Debug|ARM + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|x64.ActiveCfg = Debug|x64 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|x64.Build.0 = Debug|x64 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|x86.ActiveCfg = Debug|x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Debug|x86.Build.0 = Debug|x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|Any CPU.ActiveCfg = Release|x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|ARM.ActiveCfg = Release|ARM + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|ARM.Build.0 = Release|ARM + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|x64.ActiveCfg = Release|x64 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|x64.Build.0 = Release|x64 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|x86.ActiveCfg = Release|x86 + {B0D33B00-9009-40B6-8519-A97BD91DC1BD}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/ApplicationResources/vb/ApplicationResources.vbproj b/Samples/ApplicationResources/vb/ApplicationResources.vbproj new file mode 100644 index 0000000000..ae372d94a7 --- /dev/null +++ b/Samples/ApplicationResources/vb/ApplicationResources.vbproj @@ -0,0 +1,584 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + ApplicationResources + ApplicationResources + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + App.xaml.vb + App.xaml + + + + languageoverride.xaml + + + MainPage.xaml.vb + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + scenario1.xaml + + + scenario10.xaml + + + scenario11.xaml + + + scenario12.xaml + + + scenario13.xaml + + + scenario2.xaml + + + scenario3.xaml + + + scenario4.xaml + + + scenario5.xaml + + + scenario6.xaml + + + scenario7.xaml + + + scenario8.xaml + + + scenario9.xaml + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Styles\Styles.xaml + MSBuild:Compile + Designer + + + + + Properties\Default.rd.xml + + + Assets\microsoft-sdk.png + + + Assets\windows-sdk.png + + + Images\en\projector.scale-100_contrast-black.png + + + Images\en\projector.scale-100_contrast-standard.png + + + Images\en\projector.scale-100_contrast-white.png + + + Images\en\projector.scale-140_contrast-black.png + + + Images\en\projector.scale-140_contrast-standard.png + + + Images\en\projector.scale-140_contrast-white.png + + + Images\en\projector.scale-180_contrast-black.png + + + Images\en\projector.scale-180_contrast-standard.png + + + Images\en\projector.scale-180_contrast-white.png + + + Images\ja\projector.scale-100_contrast-black.png + + + Images\ja\projector.scale-100_contrast-standard.png + + + Images\ja\projector.scale-100_contrast-white.png + + + Images\ja\projector.scale-140_contrast-black.png + + + Images\ja\projector.scale-140_contrast-standard.png + + + Images\ja\projector.scale-140_contrast-white.png + + + Images\ja\projector.scale-180_contrast-black.png + + + Images\ja\projector.scale-180_contrast-standard.png + + + Images\ja\projector.scale-180_contrast-white.png + + + Images\logo.contrast-black_scale-100.png + + + Images\logo.contrast-white_scale-100.png + + + Images\logo.scale-100.png + + + Images\logo.scale-140.png + + + Images\logo.scale-180.png + + + Images\logo.scale-80.png + + + Images\packagelogo.contrast-black_scale-100.png + + + Images\packagelogo.contrast-white_scale-100.png + + + Images\packagelogo.scale-100.png + + + Images\packagelogo.scale-140.png + + + Images\packagelogo.scale-180.png + + + Images\placeholder-sdk.png + + + Images\projectorwithscalecaption.scale-100.png + + + Images\projectorwithscalecaption.scale-140.png + + + Images\projectorwithscalecaption.scale-180.png + + + Images\smalllogo.contrast-black_scale-100.png + + + Images\smalllogo.contrast-white_scale-100.png + + + Images\smalllogo.scale-100.png + + + Images\smalllogo.scale-140.png + + + Images\smalllogo.scale-180.png + + + Images\smalllogo.scale-80.png + + + Images\splashscreen.contrast-black_scale-100.png + + + Images\splashscreen.contrast-white_scale-100.png + + + Images\splashscreen.scale-100.png + + + Images\splashscreen.scale-140.png + + + Images\splashscreen.scale-180.png + + + Images\tile-sdk.png + + + + + {b0d33b00-9009-40b6-8519-a97bd91dc1bd} + AppResourceClassLibrary + + + + + appdata\appdata.dxfl-dx10.dat + + + appdata\appdata.dxfl-dx11.dat + + + appdata\appdata.dxfl-dx9.dat + + + + + strings\dimensions\dimensions.contrast-black.resw + + + + + strings\dimensions\dimensions.contrast-black_scale-100.resw + + + + + strings\dimensions\dimensions.contrast-black_scale-140.resw + + + + + strings\dimensions\dimensions.contrast-black_scale-180.resw + + + + + strings\dimensions\dimensions.contrast-high.resw + + + + + strings\dimensions\dimensions.contrast-standard.resw + + + + + strings\dimensions\dimensions.contrast-white.resw + + + + + strings\dimensions\dimensions.contrast-white_scale-100.resw + + + + + strings\dimensions\dimensions.contrast-white_scale-140.resw + + + + + strings\dimensions\dimensions.contrast-white_scale-180.resw + + + + + strings\dimensions\dimensions.homeregion-001.resw + + + + + strings\dimensions\dimensions.homeregion-021.resw + + + + + strings\dimensions\dimensions.homeregion-us.resw + + + + + strings\dimensions\dimensions.lang-en.resw + + + + + strings\dimensions\dimensions.lang-en-gb.resw + + + + + strings\dimensions\dimensions.lang-fr.resw + + + + + strings\dimensions\dimensions.lang-fr-fr.resw + + + + + strings\dimensions\dimensions.resw + + + + + strings\dimensions\dimensions.scale-100.resw + + + + + strings\dimensions\dimensions.scale-140.resw + + + + + strings\dimensions\dimensions.scale-180.resw + + + + + strings\en\errors.resw + + + + + strings\en\resources.resw + + + + + strings\fr\errors.resw + + + + + strings\fr\resources.resw + Designer + + + + + strings\ja\errors.resw + + + + + strings\ja\resources.resw + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/ApplicationResources/vb/Package.appxmanifest b/Samples/ApplicationResources/vb/Package.appxmanifest new file mode 100644 index 0000000000..e1a4d5beb3 --- /dev/null +++ b/Samples/ApplicationResources/vb/Package.appxmanifest @@ -0,0 +1,31 @@ + + + + + + ms-resource:displayNameVB + Microsoft Corporation + images\packagelogo.png + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/ApplicationResources/vb/constants.vb b/Samples/ApplicationResources/vb/constants.vb new file mode 100644 index 0000000000..376514f366 --- /dev/null +++ b/Samples/ApplicationResources/vb/constants.vb @@ -0,0 +1,35 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System.Collections.Generic +Imports System +Imports SDKTemplate + +Namespace Global.SDKTemplate + + Public Partial Class MainPage + + ' Change the string below to reflect the name of your sample. + ' This is used on the main page as the title of the sample. + Public Const FEATURE_NAME As String = "Application Resources VB sample" + + Public ReadOnly Property Scenarios As New List(Of Scenario) From {New Scenario() With {.Title = "String Resources In XAML", .ClassType = GetType(Scenario1)}, New Scenario() With {.Title = "File Resources In XAML", .ClassType = GetType(Scenario2)}, New Scenario() With {.Title = "String Resources In Code", .ClassType = GetType(Scenario3)}, New Scenario() With {.Title = "Resources in the AppX manifest", .ClassType = GetType(Scenario4)}, New Scenario() With {.Title = "Additional Resource Files", .ClassType = GetType(Scenario5)}, New Scenario() With {.Title = "Class Library Resources", .ClassType = GetType(Scenario6)}, New Scenario() With {.Title = "Runtime Changes/Events", .ClassType = GetType(Scenario7)}, New Scenario() With {.Title = "Application Languages", .ClassType = GetType(Scenario8)}, New Scenario() With {.Title = "Override Languages", .ClassType = GetType(Scenario9)}, New Scenario() With {.Title = "Multi-dimensional fallback", .ClassType = GetType(Scenario10)}, New Scenario() With {.Title = "Working with webservices", .ClassType = GetType(Scenario11)}, New Scenario() With {.Title = "Retrieving resources in non-UI threads", .ClassType = GetType(Scenario12)}, New Scenario() With {.Title = "File resources in code", .ClassType = GetType(Scenario13)}} + End Class + + Public Class Scenario + + Public Property Title As String + + Public Property ClassType As Type + + Public Overrides Function ToString() As String + Return Title + End Function + End Class +End Namespace diff --git a/Samples/ApplicationResources/vb/languageoverride.xaml b/Samples/ApplicationResources/vb/languageoverride.xaml new file mode 100644 index 0000000000..0552467b4f --- /dev/null +++ b/Samples/ApplicationResources/vb/languageoverride.xaml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/Samples/ApplicationResources/vb/languageoverride.xaml.vb b/Samples/ApplicationResources/vb/languageoverride.xaml.vb new file mode 100644 index 0000000000..a08d340bdc --- /dev/null +++ b/Samples/ApplicationResources/vb/languageoverride.xaml.vb @@ -0,0 +1,89 @@ +Imports System +Imports System.Collections.Generic +Imports System.IO +Imports System.Linq +Imports Windows.Foundation +Imports Windows.Foundation.Collections +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Controls.Primitives +Imports Windows.UI.Xaml.Data +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation +Imports Windows.Globalization + +Namespace Global.SDKTemplate + + Public NotInheritable Partial Class LanguageOverride + Inherits UserControl + + Dim comboBoxValues As List(Of ComboBoxValue) + + Dim lastSelectionIndex As Integer + + Public Delegate Sub LanguageOverrideChangedEventHandler(sender As Object, e As EventArgs) + + Public Event LanguageOverrideChanged As LanguageOverrideChangedEventHandler + + Public Sub New() + Me.InitializeComponent() + AddHandler Loaded, AddressOf Control_Loaded + End Sub + + Sub Control_Loaded(sender As Object, e As RoutedEventArgs) + comboBoxValues = New List(Of ComboBoxValue)() + comboBoxValues.Add(New ComboBoxValue() With {.DisplayName = "Use language preferences (recommended)", .LanguageTag = ""}) + For i = 0 To ApplicationLanguages.Languages.Count - 1 + Me.LanguageOverrideComboBox_AddLanguage(New Windows.Globalization.Language(ApplicationLanguages.Languages(i))) + Next + + comboBoxValues.Add(New ComboBoxValue() With {.DisplayName = "——————", .LanguageTag = "-"}) + ' Create a List and sort it before adding items + Dim manifestLanguageObjects As List(Of Windows.Globalization.Language) = New List(Of Windows.Globalization.Language)() + For Each lang In ApplicationLanguages.ManifestLanguages + manifestLanguageObjects.Add(New Windows.Globalization.Language(lang)) + Next + + Dim orderedManifestLanguageObjects As IEnumerable(Of Windows.Globalization.Language) = manifestLanguageObjects.OrderBy(Function(lang) lang.DisplayName) + For Each lang In orderedManifestLanguageObjects + Me.LanguageOverrideComboBox_AddLanguage(lang) + Next + + LanguageOverrideComboBox.ItemsSource = comboBoxValues + LanguageOverrideComboBox.SelectedIndex = comboBoxValues.FindIndex(AddressOf FindCurrent) + AddHandler LanguageOverrideComboBox.SelectionChanged, AddressOf LanguageOverrideComboBox_SelectionChanged + lastSelectionIndex = LanguageOverrideComboBox.SelectedIndex + End Sub + + Private Sub LanguageOverrideComboBox_AddLanguage(lang As Windows.Globalization.Language) + comboBoxValues.Add(New ComboBoxValue() With {.DisplayName = lang.NativeName, .LanguageTag = lang.LanguageTag}) + End Sub + + Private Shared Function FindCurrent(value As ComboBoxValue) As Boolean + If value.LanguageTag = Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride Then + Return True + End If + + Return False + End Function + + Private Sub LanguageOverrideComboBox_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) + Dim combo As ComboBox = TryCast(sender, ComboBox) + If combo.SelectedValue.ToString() = "-" Then + combo.SelectedIndex = lastSelectionIndex + Else + lastSelectionIndex = combo.SelectedIndex + Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = combo.SelectedValue.ToString() + RaiseEvent LanguageOverrideChanged(Me, New EventArgs()) + End If + End Sub + End Class + + Public Class ComboBoxValue + + Public Property DisplayName As String + + Public Property LanguageTag As String + End Class +End Namespace diff --git a/Samples/ApplicationResources/vb/project.json b/Samples/ApplicationResources/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/ApplicationResources/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/ApplicationResources/vb/scenario1.xaml b/Samples/ApplicationResources/vb/scenario1.xaml new file mode 100644 index 0000000000..e8df0ce34c --- /dev/null +++ b/Samples/ApplicationResources/vb/scenario1.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + The text in the output section below uses an x:Uid attribute to refer to a string resource. The existence of + the x:Uid attribute instructs the XAML parser to retrieve that element's string resources using the Windows + resource management system using the Uid attribute value. Strings are authored in a Resources file (.resw). + Strings can be localized for various langauge by placing copies of the Resources file with appropriate + strings in folders that are named using appropriate BCP-47 language tags (e.g., "en", "de-CH", etc.). + + + Entries in the .resw file are of the form [Uid].[attribute]. Open the Scenario1.xaml file and note the use + of the x:Uid="WelcomeHeader" attribute for the TextBlock in the Output section and the corresponding + WelcomeHeader.Text resource in the strings\...\resources.resw file. + + + + + + + + + + + + + + + + diff --git a/Samples/ApplicationResources/vb/scenario1.xaml.vb b/Samples/ApplicationResources/vb/scenario1.xaml.vb new file mode 100644 index 0000000000..91f67a429d --- /dev/null +++ b/Samples/ApplicationResources/vb/scenario1.xaml.vb @@ -0,0 +1,38 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation +Imports SDKTemplate +Imports System + +Namespace Global.SDKTemplate + + ''' + ''' An empty page that can be used on its own or navigated to within a Frame. + ''' + Public NotInheritable Partial Class Scenario1 + Inherits Page + + Dim rootPage As MainPage = MainPage.Current + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when this page is about to be displayed in a Frame. + ''' + ''' Event data that describes how this page was reached. The Parameter + ''' property is typically used to configure the page. + Protected Overrides Sub OnNavigatedTo(e As NavigationEventArgs) + End Sub + End Class +End Namespace diff --git a/Samples/ApplicationResources/vb/scenario10.xaml b/Samples/ApplicationResources/vb/scenario10.xaml new file mode 100644 index 0000000000..cb6599542d --- /dev/null +++ b/Samples/ApplicationResources/vb/scenario10.xaml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + Resources can depend on many different dimensions, including scale, language and + contrast. The resource management system does appropriate fallback behavior to retrieve + the most appropriate resource for the current context. The resource qualifiers are + evaluated in a priority based system (e.g., language is more important than scale). + Application developers are encouraged to mark resources as appropriately as possible. + Only resources that are appropriate for all contexts should be left without any + qualifiers. Default resources are qualified resources that are chosen if no resource + matches the context. The default language can be set by manually editing the .csproj + file in a text editor. + + + This sample shows a list of string resources and the ordered set of resource candidates + for different languages, scales, etc. Various contexts can be simulated with the + drop-down below to see which resources are matched in various situations. Each candidate + has additional metadata that can used to determine why it was chosen. + + + Text="To view a resource that has been loaded inline in a different combination of qualifiers, choose the qualifier value below and click Show Message. + + + + + + English (United Kingdom) + English (United States) + French (France) + French (Canada) + German (Germany) + + + + + + + + + + + + + + + + + + + + + + World + Americas + Asia + Northern America + Latin America and the Caribbean + United States of America + + + + + - - - - - - - - diff --git a/Samples/CameraFaceDetection/cs/MainPage.xaml.cs b/Samples/CameraFaceDetection/cs/MainPage.xaml.cs index 05d0a4ea31..02eff92a2b 100644 --- a/Samples/CameraFaceDetection/cs/MainPage.xaml.cs +++ b/Samples/CameraFaceDetection/cs/MainPage.xaml.cs @@ -40,7 +40,7 @@ using Windows.UI; using System.Collections.Generic; -namespace CameraFaceDetection +namespace FaceDetection { public sealed partial class MainPage : Page diff --git a/Samples/CameraFaceDetection/cs/Package.appxmanifest b/Samples/CameraFaceDetection/cs/Package.appxmanifest index 2931df259b..10b073cca2 100644 --- a/Samples/CameraFaceDetection/cs/Package.appxmanifest +++ b/Samples/CameraFaceDetection/cs/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraFaceDetection + Face Detection C# Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraFaceDetection.App"> diff --git a/Samples/CameraFaceDetection/cpp/App.xaml b/Samples/CameraFaceDetection/shared/App.xaml similarity index 100% rename from Samples/CameraFaceDetection/cpp/App.xaml rename to Samples/CameraFaceDetection/shared/App.xaml diff --git a/Samples/CameraFaceDetection/cpp/MainPage.xaml b/Samples/CameraFaceDetection/shared/MainPage.xaml similarity index 100% rename from Samples/CameraFaceDetection/cpp/MainPage.xaml rename to Samples/CameraFaceDetection/shared/MainPage.xaml diff --git a/Samples/CameraFaceDetection/vb/App.xaml.vb b/Samples/CameraFaceDetection/vb/App.xaml.vb new file mode 100644 index 0000000000..d03b5f623b --- /dev/null +++ b/Samples/CameraFaceDetection/vb/App.xaml.vb @@ -0,0 +1,65 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.FaceDetection + + ''' + ''' Provides application-specific behavior to supplement the default Application class. + ''' + NotInheritable Partial Class App + Inherits Application + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when the application is launched normally by the end user. Other entry points + ''' will be used such as when the application is launched to open a specific file. + ''' + ''' Details about the launch request and process. + Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs) +#If DEBUG Then + If System.Diagnostics.Debugger.IsAttached Then + Me.DebugSettings.EnableFrameRateCounter = True + End If +#End If + + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages(0) + AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed + Window.Current.Content = rootFrame + End If + + If rootFrame.Content Is Nothing Then + rootFrame.Navigate(GetType(MainPage), e.Arguments) + End If + + Window.Current.Activate() + End Sub + + ''' + ''' Invoked when Navigation to a certain page fails + ''' + ''' The Frame which failed navigation + ''' Details about the navigation failure + Sub OnNavigationFailed(sender As Object, e As NavigationFailedEventArgs) + Throw New Exception("Failed to load Page " & e.SourcePageType.FullName) + End Sub + End Class +End Namespace diff --git a/Samples/CameraFaceDetection/vb/CameraFaceDetection.sln b/Samples/CameraFaceDetection/vb/CameraFaceDetection.sln new file mode 100644 index 0000000000..26ec666994 --- /dev/null +++ b/Samples/CameraFaceDetection/vb/CameraFaceDetection.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CameraFaceDetection", "CameraFaceDetection.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/CameraFaceDetection/vb/CameraFaceDetection.vbproj b/Samples/CameraFaceDetection/vb/CameraFaceDetection.vbproj new file mode 100644 index 0000000000..dd1d05f1db --- /dev/null +++ b/Samples/CameraFaceDetection/vb/CameraFaceDetection.vbproj @@ -0,0 +1,203 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + CameraFaceDetection + CameraFaceDetection + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + Microsoft Mobile Extension SDK for Universal App Platform + + + + + App.xaml + + + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + Designer + + + + + Properties\Default.rd.xml + + + Assets\smalltile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squaretile-sdk.png + + + Assets\storelogo-sdk.png + + + Assets\tile-sdk.png + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/CameraFaceDetection/vb/MainPage.xaml.vb b/Samples/CameraFaceDetection/vb/MainPage.xaml.vb new file mode 100644 index 0000000000..3391533109 --- /dev/null +++ b/Samples/CameraFaceDetection/vb/MainPage.xaml.vb @@ -0,0 +1,767 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Diagnostics +Imports System.Linq +Imports System.Threading.Tasks +Imports Windows.ApplicationModel +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.Foundation.Metadata +Imports Windows.Graphics.Display +Imports Windows.Graphics.Imaging +Imports Windows.Media +Imports Windows.Media.Core +Imports Windows.Media.Capture +Imports Windows.Media.MediaProperties +Imports Windows.Phone.UI.Input +Imports Windows.Storage +Imports Windows.Storage.FileProperties +Imports Windows.Storage.Streams +Imports Windows.System.Display +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation +Imports Windows.UI.Xaml.Shapes +Imports Windows.Media.FaceAnalysis +Imports Windows.UI +Imports System.Collections.Generic + +Namespace Global.FaceDetection + + Public NotInheritable Partial Class MainPage + Inherits Page + + ' Receive notifications about rotation of the device and UI and apply any necessary rotation to the preview stream and UI controls + Private ReadOnly _displayInformation As DisplayInformation = DisplayInformation.GetForCurrentView() + + Private ReadOnly _orientationSensor As SimpleOrientationSensor = SimpleOrientationSensor.GetDefault() + + Private _deviceOrientation As SimpleOrientation = SimpleOrientation.NotRotated + + Private _displayOrientation As DisplayOrientations = DisplayOrientations.Portrait + + ' Rotation metadata to apply to the preview stream and recorded videos (MF_MT_VIDEO_ROTATION) + ' Reference: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868174.aspx + Private Shared ReadOnly RotationKey As Guid = New Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1") + + ' Prevent the screen from sleeping while the camera is running + Private ReadOnly _displayRequest As DisplayRequest = New DisplayRequest() + + ' For listening to media property changes + Private ReadOnly _systemMediaControls As SystemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView() + + ' MediaCapture and its state variables + Private _mediaCapture As MediaCapture + + Private _previewProperties As IMediaEncodingProperties + + Private _isInitialized As Boolean + + Private _isRecording As Boolean + + ' Information about the camera device + Private _mirroringPreview As Boolean + + Private _externalCamera As Boolean + + Private _faceDetectionEffect As FaceDetectionEffect + +#Region " Constructor, lifecycle and navigation " + Public Sub New() + Me.InitializeComponent() + NavigationCacheMode = NavigationCacheMode.Disabled + AddHandler Application.Current.Suspending, AddressOf Application_Suspending + AddHandler Application.Current.Resuming, AddressOf Application_Resuming + End Sub + + Private Async Sub Application_Suspending(sender As Object, e As SuspendingEventArgs) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Dim deferral = e.SuspendingOperation.GetDeferral() + Await CleanupCameraAsync() + Await CleanupUiAsync() + deferral.Complete() + End If + End Sub + + Private Async Sub Application_Resuming(sender As Object, o As Object) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Await SetupUiAsync() + Await InitializeCameraAsync() + End If + End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + Await SetupUiAsync() + Await InitializeCameraAsync() + End Sub + + Protected Overrides Async Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + Await CleanupCameraAsync() + Await CleanupUiAsync() + End Sub + +#End Region + +#Region " Event handlers " + + ''' + ''' In the event of the app being minimized this method handles media property change events. If the app receives a mute + ''' notification, it is no longer in the foregroud. + ''' + ''' + ''' + Private Async Sub SystemMediaControls_PropertyChanged(sender As SystemMediaTransportControls, args As SystemMediaTransportControlsPropertyChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Async Sub() + If args.Property = SystemMediaTransportControlsProperty.SoundLevel AndAlso Frame.CurrentSourcePageType Is GetType(MainPage) Then + If sender.SoundLevel = SoundLevel.Muted Then + Await CleanupCameraAsync() + ElseIf Not _isInitialized Then + Await InitializeCameraAsync() + End If + End If + End Sub) + End Sub + + ''' + ''' Occurs each time the simple orientation sensor reports a new sensor reading. + ''' + ''' The event source. + ''' The event data. + Private Async Sub OrientationSensor_OrientationChanged(sender As SimpleOrientationSensor, args As SimpleOrientationSensorOrientationChangedEventArgs) + If args.Orientation <> SimpleOrientation.Faceup AndAlso args.Orientation <> SimpleOrientation.Facedown Then + _deviceOrientation = args.Orientation + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateButtonOrientation()) + End If + End Sub + + ''' + ''' This event will fire when the page is rotated, when the DisplayInformation.AutoRotationPreferences value set in the SetupUiAsync() method cannot be not honored. + ''' + ''' The event source. + ''' The event data. + Private Async Sub DisplayInformation_OrientationChanged(sender As DisplayInformation, args As Object) + _displayOrientation = sender.CurrentOrientation + If _previewProperties IsNot Nothing Then + Await SetPreviewRotationAsync() + End If + + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateButtonOrientation()) + End Sub + + Private Async Sub PhotoButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + Await TakePhotoAsync() + End Sub + + Private Async Sub VideoButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + If Not _isRecording Then + Await StartRecordingAsync() + Else + Await StopRecordingAsync() + End If + + UpdateCaptureControls() + End Sub + + Private Async Sub FaceDetectionButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + If _faceDetectionEffect Is Nothing OrElse Not _faceDetectionEffect.Enabled Then + FacesCanvas.Children.Clear() + Await CreateFaceDetectionEffectAsync() + Else + Await CleanUpFaceDetectionEffectAsync() + End If + + UpdateCaptureControls() + End Sub + + Private Async Sub HardwareButtons_CameraPressed(sender As Object, e As CameraEventArgs) + Await TakePhotoAsync() + End Sub + + Private Async Sub MediaCapture_RecordLimitationExceeded(sender As MediaCapture) + Await StopRecordingAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateCaptureControls()) + End Sub + + Private Async Sub MediaCapture_Failed(sender As MediaCapture, errorEventArgs As MediaCaptureFailedEventArgs) + Debug.WriteLine("MediaCapture_Failed: (0x{0:X}) {1}", errorEventArgs.Code, errorEventArgs.Message) + Await CleanupCameraAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateCaptureControls()) + End Sub + + Private Async Sub FaceDetectionEffect_FaceDetected(sender As FaceDetectionEffect, args As FaceDetectedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() HighlightDetectedFaces(args.ResultFrame.DetectedFaces)) + End Sub + +#End Region + +#Region " MediaCapture methods " + + ''' + ''' Initializes the MediaCapture, registers events, gets camera device information for mirroring and rotating, starts preview and unlocks the UI + ''' + ''' + Private Async Function InitializeCameraAsync() As Task + Debug.WriteLine("InitializeCameraAsync") + If _mediaCapture Is Nothing Then + ' Attempt to get the front camera if one is available, but use any camera device if not + Dim cameraDevice = Await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Front) + If cameraDevice Is Nothing Then + Debug.WriteLine("No camera device found!") + Return + End If + + _mediaCapture = New MediaCapture() + AddHandler _mediaCapture.RecordLimitationExceeded, AddressOf MediaCapture_RecordLimitationExceeded + AddHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + Dim settings = New MediaCaptureInitializationSettings With {.VideoDeviceId = cameraDevice.Id} + Try + Await _mediaCapture.InitializeAsync(settings) + _isInitialized = True + Catch ex As UnauthorizedAccessException + Debug.WriteLine("The app was denied access to the camera") + End Try + + If _isInitialized Then + If cameraDevice.EnclosureLocation Is Nothing OrElse cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Unknown Then + _externalCamera = True + Else + _externalCamera = False + _mirroringPreview =(cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Front) + End If + + Await StartPreviewAsync() + UpdateCaptureControls() + End If + End If + End Function + + ''' + ''' Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on + ''' + ''' + Private Async Function StartPreviewAsync() As Task + _displayRequest.RequestActive() + PreviewControl.Source = _mediaCapture + PreviewControl.FlowDirection = If(_mirroringPreview, FlowDirection.RightToLeft, FlowDirection.LeftToRight) + Await _mediaCapture.StartPreviewAsync() + _previewProperties = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) + If _previewProperties IsNot Nothing Then + _displayOrientation = _displayInformation.CurrentOrientation + Await SetPreviewRotationAsync() + End If + End Function + + ''' + ''' Gets the current orientation of the UI in relation to the device (when AutoRotationPreferences cannot be honored) and applies a corrective rotation to the preview + ''' + Private Async Function SetPreviewRotationAsync() As Task + If _externalCamera Then + Return + End If + + ' Calculate which way and how far to rotate the preview + Dim rotationDegrees As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _mirroringPreview Then + rotationDegrees =(360 - rotationDegrees) Mod 360 + End If + + ' Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames + Dim props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) + props.Properties.Add(RotationKey, rotationDegrees) + Await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, Nothing) + End Function + + ''' + ''' Stops the preview and deactivates a display request, to allow the screen to go into power saving modes + ''' + ''' + Private Async Function StopPreviewAsync() As Task + _previewProperties = Nothing + Await _mediaCapture.StopPreviewAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + PreviewControl.Source = Nothing + _displayRequest.RequestRelease() + End Sub) + End Function + + ''' + ''' Adds face detection to the preview stream, registers for its events, enables it, and gets the FaceDetectionEffect instance + ''' + ''' + Private Async Function CreateFaceDetectionEffectAsync() As Task + ' Create the definition, which will contain some initialization settings + Dim definition = New FaceDetectionEffectDefinition() + definition.SynchronousDetectionEnabled = False + definition.DetectionMode = FaceDetectionMode.HighPerformance + _faceDetectionEffect = CType(Await _mediaCapture.AddVideoEffectAsync(definition, MediaStreamType.VideoPreview), FaceDetectionEffect) + AddHandler _faceDetectionEffect.FaceDetected, AddressOf FaceDetectionEffect_FaceDetected + _faceDetectionEffect.DesiredDetectionInterval = TimeSpan.FromMilliseconds(33) + _faceDetectionEffect.Enabled = True + End Function + + ''' + ''' Disables and removes the face detection effect, and unregisters the event handler for face detection + ''' + ''' + Private Async Function CleanUpFaceDetectionEffectAsync() As Task + _faceDetectionEffect.Enabled = False + RemoveHandler _faceDetectionEffect.FaceDetected, AddressOf FaceDetectionEffect_FaceDetected + Await _mediaCapture.ClearEffectsAsync(MediaStreamType.VideoPreview) + _faceDetectionEffect = Nothing + End Function + + ''' + ''' Takes a photo to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function TakePhotoAsync() As Task + VideoButton.IsEnabled = _mediaCapture.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported + VideoButton.Opacity = If(VideoButton.IsEnabled, 1, 0) + Dim stream = New InMemoryRandomAccessStream() + Try + Debug.WriteLine("Taking photo...") + Await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream) + Debug.WriteLine("Photo taken!") + Dim photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()) + Await ReencodeAndSavePhotoAsync(stream, photoOrientation) + Catch ex As Exception + Debug.WriteLine("Exception when taking a photo: {0}", ex.ToString()) + End Try + + VideoButton.IsEnabled = True + VideoButton.Opacity = 1 + End Function + + ''' + ''' Records an MP4 video to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function StartRecordingAsync() As Task + Try + ' Create storage file in Pictures Library + Dim videoFile = Await KnownFolders.PicturesLibrary.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName) + Dim encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto) + ' Calculate rotation angle, taking mirroring into account if necessary + Dim rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation()) + encodingProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle)) + Debug.WriteLine("Starting recording...") + Await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile) + _isRecording = True + Debug.WriteLine("Started recording!") + Catch ex As Exception + Debug.WriteLine("Exception when starting video recording: {0}", ex.ToString()) + End Try + End Function + + ''' + ''' Stops recording a video + ''' + ''' + Private Async Function StopRecordingAsync() As Task + Debug.WriteLine("Stopping recording...") + _isRecording = False + Await _mediaCapture.StopRecordAsync() + Debug.WriteLine("Stopped recording!") + End Function + + ''' + ''' Cleans up the camera resources (after stopping any video recording and/or preview if necessary) and unregisters from MediaCapture events + ''' + ''' + Private Async Function CleanupCameraAsync() As Task + Debug.WriteLine("CleanupCameraAsync") + If _isInitialized Then + If _isRecording Then + Await StopRecordingAsync() + End If + + If _faceDetectionEffect IsNot Nothing Then + Await CleanUpFaceDetectionEffectAsync() + End If + + If _previewProperties IsNot Nothing Then + Await StopPreviewAsync() + End If + + _isInitialized = False + End If + + If _mediaCapture IsNot Nothing Then + RemoveHandler _mediaCapture.RecordLimitationExceeded, AddressOf MediaCapture_RecordLimitationExceeded + RemoveHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + _mediaCapture.Dispose() + _mediaCapture = Nothing + End If + End Function + +#End Region + +#Region " Helper functions " + + ''' + ''' Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors + ''' + ''' + Private Async Function SetupUiAsync() As Task + DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync() + End If + + _displayOrientation = _displayInformation.CurrentOrientation + If _orientationSensor IsNot Nothing Then + _deviceOrientation = _orientationSensor.GetCurrentOrientation() + End If + + RegisterEventHandlers() + End Function + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors, allows the StatusBar (on Phone) to show, and removes the page orientation lock + ''' + ''' + Private Async Function CleanupUiAsync() As Task + UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ShowAsync() + End If + + DisplayInformation.AutoRotationPreferences = DisplayOrientations.None + End Function + + ''' + ''' This method will update the icons, enable/disable and show/hide the photo/video buttons depending on the current state of the app and the capabilities of the device + ''' + Private Sub UpdateCaptureControls() + PhotoButton.IsEnabled = _previewProperties IsNot Nothing + VideoButton.IsEnabled = _previewProperties IsNot Nothing + FaceDetectionButton.IsEnabled = _previewProperties IsNot Nothing + FaceDetectionDisabledIcon.Visibility = If((_faceDetectionEffect Is Nothing OrElse Not _faceDetectionEffect.Enabled), Visibility.Visible, Visibility.Collapsed) + FaceDetectionEnabledIcon.Visibility = If((_faceDetectionEffect IsNot Nothing AndAlso _faceDetectionEffect.Enabled), Visibility.Visible, Visibility.Collapsed) + FacesCanvas.Visibility = If((_faceDetectionEffect IsNot Nothing AndAlso _faceDetectionEffect.Enabled), Visibility.Visible, Visibility.Collapsed) + StartRecordingIcon.Visibility = If(_isRecording, Visibility.Collapsed, Visibility.Visible) + StopRecordingIcon.Visibility = If(_isRecording, Visibility.Visible, Visibility.Collapsed) + If _isInitialized AndAlso Not _mediaCapture.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported Then + PhotoButton.IsEnabled = Not _isRecording + PhotoButton.Opacity = If(PhotoButton.IsEnabled, 1, 0) + End If + End Sub + + ''' + ''' Registers event handlers for hardware buttons and orientation sensors, and performs an initial update of the UI rotation + ''' + Private Sub RegisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then + AddHandler HardwareButtons.CameraPressed, AddressOf HardwareButtons_CameraPressed + End If + + If _orientationSensor IsNot Nothing Then + AddHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + UpdateButtonOrientation() + End If + + AddHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + AddHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors + ''' + Private Sub UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then + RemoveHandler HardwareButtons.CameraPressed, AddressOf HardwareButtons_CameraPressed + End If + + If _orientationSensor IsNot Nothing Then + RemoveHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + End If + + RemoveHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + RemoveHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Attempts to find and return a device mounted on the panel specified, and on failure to find one it will return the first device listed + ''' + ''' The desired panel on which the returned device should be mounted, if available + ''' + Private Shared Async Function FindCameraDeviceByPanelAsync(desiredPanel As Windows.Devices.Enumeration.Panel) As Task(Of DeviceInformation) + ' Get available devices for capturing pictures + Dim allVideoDevices = Await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture) + ' Get the desired camera by panel + Dim desiredDevice As DeviceInformation = allVideoDevices.FirstOrDefault(Function(x) x.EnclosureLocation IsNot Nothing AndAlso x.EnclosureLocation.Panel = desiredPanel) + Return If(desiredDevice, allVideoDevices.FirstOrDefault()) + End Function + + ''' + ''' Applies the given orientation to a photo stream and saves it as a StorageFile + ''' + ''' The photo stream + ''' The orientation metadata to apply to the photo + ''' + Private Shared Async Function ReencodeAndSavePhotoAsync(stream As IRandomAccessStream, photoOrientation As PhotoOrientation) As Task + Using inputStream = stream + Dim decoder = Await BitmapDecoder.CreateAsync(inputStream) + Dim file = Await KnownFolders.PicturesLibrary.CreateFileAsync("SimplePhoto.jpeg", CreationCollisionOption.GenerateUniqueName) + Using outputStream = Await file.OpenAsync(FileAccessMode.ReadWrite) + Dim encoder = Await BitmapEncoder.CreateForTranscodingAsync(outputStream, decoder) + Dim properties = New BitmapPropertySet From {{"System.Photo.Orientation", New BitmapTypedValue(photoOrientation, PropertyType.UInt16)}} + Await encoder.BitmapProperties.SetPropertiesAsync(properties) + Await encoder.FlushAsync() + End Using + End Using + End Function + +#End Region + +#Region " Rotation helpers " + + ''' + ''' Calculates the current camera orientation from the device orientation by taking into account whether the camera is external or facing the user + ''' + ''' The camera orientation in space, with an inverted rotation in the case the camera is mounted on the device and is facing the user + Private Function GetCameraOrientation() As SimpleOrientation + If _externalCamera Then + Return SimpleOrientation.NotRotated + End If + + Dim result = _deviceOrientation + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + result = SimpleOrientation.NotRotated + Case SimpleOrientation.Rotated180DegreesCounterclockwise + result = SimpleOrientation.Rotated90DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + result = SimpleOrientation.Rotated180DegreesCounterclockwise + Case SimpleOrientation.NotRotated + result = SimpleOrientation.Rotated270DegreesCounterclockwise + End Select + End If + + If _mirroringPreview Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return SimpleOrientation.Rotated270DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return SimpleOrientation.Rotated90DegreesCounterclockwise + End Select + End If + + Return result + End Function + + ''' + ''' Converts the given orientation of the device in space to the corresponding rotation in degrees + ''' + ''' The orientation of the device in space + ''' An orientation in degrees + Private Shared Function ConvertDeviceOrientationToDegrees(orientation As SimpleOrientation) As Integer + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return 90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return 180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the app on the screen to the corresponding rotation in degrees + ''' + ''' The orientation of the app on the screen + ''' An orientation in degrees + Private Shared Function ConvertDisplayOrientationToDegrees(orientation As DisplayOrientations) As Integer + Select orientation + Case DisplayOrientations.Portrait + Return 90 + Case DisplayOrientations.LandscapeFlipped + Return 180 + Case DisplayOrientations.PortraitFlipped + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the device in space to the metadata that can be added to captured photos + ''' + ''' The orientation of the device in space + ''' + Private Shared Function ConvertOrientationToPhotoOrientation(orientation As SimpleOrientation) As PhotoOrientation + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return PhotoOrientation.Rotate90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return PhotoOrientation.Rotate180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return PhotoOrientation.Rotate270 + Case Else + Return PhotoOrientation.Normal + End Select + End Function + + ''' + ''' Uses the current device orientation in space and page orientation on the screen to calculate the rotation + ''' transformation to apply to the controls + ''' + ''' An angle in degrees to rotate the controls so they remain upright to the user regardless of device and page + ''' orientation + Private Sub UpdateButtonOrientation() + Dim device As Integer = ConvertDeviceOrientationToDegrees(_deviceOrientation) + Dim display As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + device -= 90 + End If + + ' Combine both rotations and make sure that 0 <= result < 360 + Dim angle =(360 + display + device) Mod 360 + ' Rotate the buttons in the UI to match the rotation of the device + Dim transform = New RotateTransform With {.Angle = angle} + PhotoButton.RenderTransform = transform + VideoButton.RenderTransform = transform + FaceDetectionButton.RenderTransform = transform + End Sub + + ''' + ''' Uses the current display orientation to calculate the rotation transformation to apply to the face detection bounding box canvas + ''' and mirrors it if the preview is being mirrored + ''' + Private Sub SetFacesCanvasRotation() + ' Calculate how much to rotate the canvas + Dim rotationDegrees As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _mirroringPreview Then + rotationDegrees =(360 - rotationDegrees) Mod 360 + End If + + ' Apply the rotation + Dim transform = New RotateTransform With {.Angle = rotationDegrees} + FacesCanvas.RenderTransform = transform + Dim previewArea = GetPreviewStreamRectInControl(TryCast(_previewProperties, VideoEncodingProperties), PreviewControl) + If _displayOrientation = DisplayOrientations.Portrait OrElse _displayOrientation = DisplayOrientations.PortraitFlipped Then + FacesCanvas.Width = previewArea.Height + FacesCanvas.Height = previewArea.Width + Canvas.SetLeft(FacesCanvas, previewArea.X - (previewArea.Height - previewArea.Width) / 2) + Canvas.SetTop(FacesCanvas, previewArea.Y - (previewArea.Width - previewArea.Height) / 2) + Else + FacesCanvas.Width = previewArea.Width + FacesCanvas.Height = previewArea.Height + Canvas.SetLeft(FacesCanvas, previewArea.X) + Canvas.SetTop(FacesCanvas, previewArea.Y) + End If + + FacesCanvas.FlowDirection = If(_mirroringPreview, FlowDirection.RightToLeft, FlowDirection.LeftToRight) + End Sub + +#End Region + +#Region " Face detection helpers " + + ''' + ''' Iterates over all detected faces, creating and adding Rectangles to the FacesCanvas as face bounding boxes + ''' + ''' The list of detected faces from the FaceDetected event of the effect + Private Sub HighlightDetectedFaces(faces As IReadOnlyList(Of DetectedFace)) + FacesCanvas.Children.Clear() + For i = 0 To faces.Count - 1 + ' Face coordinate units are preview resolution pixels, which can be a different scale from our display resolution, so a conversion may be necessary + Dim faceBoundingBox As Rectangle = ConvertPreviewToUiRectangle(faces(i).FaceBox) + faceBoundingBox.StrokeThickness = 2 + faceBoundingBox.Stroke =(If(i = 0, New SolidColorBrush(Colors.Blue), New SolidColorBrush(Colors.DeepSkyBlue))) + FacesCanvas.Children.Add(faceBoundingBox) + Next + + SetFacesCanvasRotation() + End Sub + + ''' + ''' Takes face information defined in preview coordinates and returns one in UI coordinates, taking + ''' into account the position and size of the preview control. + ''' + ''' Face coordinates as retried from the FaceBox property of a DetectedFace, in preview coordinates. + ''' Rectangle in UI (CaptureElement) coordinates, to be used in a Canvas control. + Private Function ConvertPreviewToUiRectangle(faceBoxInPreviewCoordinates As BitmapBounds) As Rectangle + Dim result = New Rectangle() + Dim previewStream = TryCast(_previewProperties, VideoEncodingProperties) + If previewStream Is Nothing Then + Return result + End If + + If previewStream.Width = 0 OrElse previewStream.Height = 0 Then + Return result + End If + + Dim streamWidth As Double = previewStream.Width + Dim streamHeight As Double = previewStream.Height + If _displayOrientation = DisplayOrientations.Portrait OrElse _displayOrientation = DisplayOrientations.PortraitFlipped Then + streamHeight = previewStream.Width + streamWidth = previewStream.Height + End If + + ' Get the rectangle that is occupied by the actual video feed + Dim previewInUI = GetPreviewStreamRectInControl(previewStream, PreviewControl) + result.Width =(faceBoxInPreviewCoordinates.Width / streamWidth) * previewInUI.Width + result.Height =(faceBoxInPreviewCoordinates.Height / streamHeight) * previewInUI.Height + ' Scale the X and Y coordinates from preview stream coordinates to window coordinates + Dim x =(faceBoxInPreviewCoordinates.X / streamWidth) * previewInUI.Width + Dim y =(faceBoxInPreviewCoordinates.Y / streamHeight) * previewInUI.Height + Canvas.SetLeft(result, x) + Canvas.SetTop(result, y) + Return result + End Function + + ''' + ''' Calculates the size and location of the rectangle that contains the preview stream within the preview control, when the scaling mode is Uniform + ''' + ''' The resolution at which the preview is running + ''' The control that is displaying the preview using Uniform as the scaling mode + ''' + Public Function GetPreviewStreamRectInControl(previewResolution As VideoEncodingProperties, previewControl As CaptureElement) As Rect + Dim result = New Rect() + If previewControl Is Nothing OrElse previewControl.ActualHeight < 1 OrElse previewControl.ActualWidth < 1 OrElse previewResolution Is Nothing OrElse previewResolution.Height = 0 OrElse previewResolution.Width = 0 Then + Return result + End If + + Dim streamWidth = previewResolution.Width + Dim streamHeight = previewResolution.Height + If _displayOrientation = DisplayOrientations.Portrait OrElse _displayOrientation = DisplayOrientations.PortraitFlipped Then + streamWidth = previewResolution.Height + streamHeight = previewResolution.Width + End If + + result.Width = previewControl.ActualWidth + result.Height = previewControl.ActualHeight + If (previewControl.ActualWidth / previewControl.ActualHeight > streamWidth / CType(streamHeight, Double)) Then + Dim scale = previewControl.ActualHeight / streamHeight + Dim scaledWidth = streamWidth * scale + result.X = (previewControl.ActualWidth - scaledWidth) / 2.0 + result.Width = scaledWidth + Else + Dim scale = previewControl.ActualWidth / streamWidth + Dim scaledHeight = streamHeight * scale + result.Y = (previewControl.ActualHeight - scaledHeight) / 2.0 + result.Height = scaledHeight + End If + + Return result + End Function +#End Region + End Class +End Namespace diff --git a/Samples/CameraFaceDetection/vb/Package.appxmanifest b/Samples/CameraFaceDetection/vb/Package.appxmanifest new file mode 100644 index 0000000000..4cd37d27f4 --- /dev/null +++ b/Samples/CameraFaceDetection/vb/Package.appxmanifest @@ -0,0 +1,55 @@ + + + + + + + + + + Face Detection C# Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/CameraFaceDetection/vb/project.json b/Samples/CameraFaceDetection/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/CameraFaceDetection/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/CameraHdr/cpp/CameraHdr.vcxproj b/Samples/CameraHdr/cpp/CameraHdr.vcxproj index 64530352fc..f952648a4d 100644 --- a/Samples/CameraHdr/cpp/CameraHdr.vcxproj +++ b/Samples/CameraHdr/cpp/CameraHdr.vcxproj @@ -103,6 +103,9 @@ + + $(VC_IncludePath);$(UniversalCRT_IncludePath);$(WindowsSDK_IncludePath);..\..\..\SharedContent\cpp + /bigobj %(AdditionalOptions) @@ -142,17 +145,17 @@ - App.xaml + ..\shared\App.xaml - MainPage.xaml + ..\shared\MainPage.xaml - + Designer - + Designer @@ -163,10 +166,10 @@ - App.xaml + ..\shared\App.xaml - MainPage.xaml + ..\shared\MainPage.xaml Create diff --git a/Samples/CameraHdr/cpp/CameraHdr.vcxproj.filters b/Samples/CameraHdr/cpp/CameraHdr.vcxproj.filters index fb00a52cd6..1c4724dab0 100644 --- a/Samples/CameraHdr/cpp/CameraHdr.vcxproj.filters +++ b/Samples/CameraHdr/cpp/CameraHdr.vcxproj.filters @@ -1,7 +1,7 @@  - + @@ -34,7 +34,7 @@ - + diff --git a/Samples/CameraHdr/cpp/Package.appxmanifest b/Samples/CameraHdr/cpp/Package.appxmanifest index 8f9195c515..24aa8cf873 100644 --- a/Samples/CameraHdr/cpp/Package.appxmanifest +++ b/Samples/CameraHdr/cpp/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraHdr + CameraHdr C++ Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraHdr.App"> diff --git a/Samples/CameraHdr/cs/App.xaml b/Samples/CameraHdr/cs/App.xaml deleted file mode 100644 index 2d8e97ddc6..0000000000 --- a/Samples/CameraHdr/cs/App.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/Samples/CameraHdr/cs/CameraHdr.csproj b/Samples/CameraHdr/cs/CameraHdr.csproj index 8ffff84c94..54a09e2fca 100644 --- a/Samples/CameraHdr/cs/CameraHdr.csproj +++ b/Samples/CameraHdr/cs/CameraHdr.csproj @@ -118,7 +118,7 @@ MainPage.xaml - + Properties\AssemblyInfo.cs @@ -128,11 +128,13 @@ - + + App.xaml MSBuild:Compile Designer - + + MainPage.xaml MSBuild:Compile Designer diff --git a/Samples/CameraHdr/cs/MainPage.xaml b/Samples/CameraHdr/cs/MainPage.xaml deleted file mode 100644 index f13babef86..0000000000 --- a/Samples/CameraHdr/cs/MainPage.xaml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Samples/CameraHdr/cs/Package.appxmanifest b/Samples/CameraHdr/cs/Package.appxmanifest index 2b73d0fe61..cd4d1ea5af 100644 --- a/Samples/CameraHdr/cs/Package.appxmanifest +++ b/Samples/CameraHdr/cs/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraHdr + CameraHdr C# Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraHdr.App"> diff --git a/Samples/CameraHdr/cpp/App.xaml b/Samples/CameraHdr/shared/App.xaml similarity index 100% rename from Samples/CameraHdr/cpp/App.xaml rename to Samples/CameraHdr/shared/App.xaml diff --git a/Samples/CameraHdr/cpp/MainPage.xaml b/Samples/CameraHdr/shared/MainPage.xaml similarity index 100% rename from Samples/CameraHdr/cpp/MainPage.xaml rename to Samples/CameraHdr/shared/MainPage.xaml diff --git a/Samples/CameraHdr/vb/App.xaml.vb b/Samples/CameraHdr/vb/App.xaml.vb new file mode 100644 index 0000000000..48bfe77983 --- /dev/null +++ b/Samples/CameraHdr/vb/App.xaml.vb @@ -0,0 +1,65 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.CameraHdr + + ''' + ''' Provides application-specific behavior to supplement the default Application class. + ''' + NotInheritable Partial Class App + Inherits Application + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when the application is launched normally by the end user. Other entry points + ''' will be used such as when the application is launched to open a specific file. + ''' + ''' Details about the launch request and process. + Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs) +#If DEBUG Then + If System.Diagnostics.Debugger.IsAttached Then + Me.DebugSettings.EnableFrameRateCounter = True + End If +#End If + + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages(0) + AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed + Window.Current.Content = rootFrame + End If + + If rootFrame.Content Is Nothing Then + rootFrame.Navigate(GetType(MainPage), e.Arguments) + End If + + Window.Current.Activate() + End Sub + + ''' + ''' Invoked when Navigation to a certain page fails + ''' + ''' The Frame which failed navigation + ''' Details about the navigation failure + Sub OnNavigationFailed(sender As Object, e As NavigationFailedEventArgs) + Throw New Exception("Failed to load Page " & e.SourcePageType.FullName) + End Sub + End Class +End Namespace diff --git a/Samples/CameraHdr/vb/CameraHdr.sln b/Samples/CameraHdr/vb/CameraHdr.sln new file mode 100644 index 0000000000..6af5db7b6a --- /dev/null +++ b/Samples/CameraHdr/vb/CameraHdr.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CameraHdr", "CameraHdr.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/CameraHdr/vb/CameraHdr.vbproj b/Samples/CameraHdr/vb/CameraHdr.vbproj new file mode 100644 index 0000000000..72a70eb9b2 --- /dev/null +++ b/Samples/CameraHdr/vb/CameraHdr.vbproj @@ -0,0 +1,204 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + CameraHdr + CameraHdr + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + + Properties\Default.rd.xml + + + Assets\smalltile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squaretile-sdk.png + + + Assets\storelogo-sdk.png + + + Assets\tile-sdk.png + + + + + App.xaml + + + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + + + Microsoft Mobile Extension SDK for Universal App Platform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/CameraHdr/vb/MainPage.xaml.vb b/Samples/CameraHdr/vb/MainPage.xaml.vb new file mode 100644 index 0000000000..adadcd19db --- /dev/null +++ b/Samples/CameraHdr/vb/MainPage.xaml.vb @@ -0,0 +1,708 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Diagnostics +Imports System.Linq +Imports System.Threading.Tasks +Imports Windows.ApplicationModel +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.Foundation.Metadata +Imports Windows.Graphics.Display +Imports Windows.Graphics.Imaging +Imports Windows.Media +Imports Windows.Media.Capture +Imports Windows.Media.Core +Imports Windows.Media.Devices +Imports Windows.Media.MediaProperties +Imports Windows.Phone.UI.Input +Imports Windows.Storage +Imports Windows.Storage.FileProperties +Imports Windows.Storage.Streams +Imports Windows.System.Display +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation + +Namespace Global.CameraHdr + + Public NotInheritable Partial Class MainPage + Inherits Page + + ' Receive notifications about rotation of the device and UI and apply any necessary rotation to the preview stream and UI controls + Private ReadOnly _displayInformation As DisplayInformation = DisplayInformation.GetForCurrentView() + + Private ReadOnly _orientationSensor As SimpleOrientationSensor = SimpleOrientationSensor.GetDefault() + + Private _deviceOrientation As SimpleOrientation = SimpleOrientation.NotRotated + + Private _displayOrientation As DisplayOrientations = DisplayOrientations.Portrait + + ' Rotation metadata to apply to the preview stream and recorded videos (MF_MT_VIDEO_ROTATION) + ' Reference: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868174.aspx + Private Shared ReadOnly RotationKey As Guid = New Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1") + + ' Prevent the screen from sleeping while the camera is running + Private ReadOnly _displayRequest As DisplayRequest = New DisplayRequest() + + ' For listening to media property changes + Private ReadOnly _systemMediaControls As SystemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView() + + ' MediaCapture and its state variables + Private _mediaCapture As MediaCapture + + Private _isInitialized As Boolean + + Private _isPreviewing As Boolean + + ' Information about the camera device + Private _mirroringPreview As Boolean + + Private _externalCamera As Boolean + + Private _hdrSupported As Boolean + + ' The value at which the HDR certainty maxes out in the graphical representation + Private Const CERTAINTY_CAP As Double = 0.7 + + ' Advanced Capture and Scene Analysis instances + Private _advancedCapture As AdvancedPhotoCapture + + Private _sceneAnalysisEffect As SceneAnalysisEffect + + ''' + ''' Helper class to contain the information that describes an HDR capture + ''' + Public Class AdvancedCaptureContext + + Public CaptureFileName As String + + Public CaptureOrientation As PhotoOrientation + End Class + +#Region " Constructor, lifecycle and navigation " + Public Sub New() + Me.InitializeComponent() + NavigationCacheMode = NavigationCacheMode.Disabled + AddHandler Application.Current.Suspending, AddressOf Application_Suspending + AddHandler Application.Current.Resuming, AddressOf Application_Resuming + HdrImpactBar.Maximum = CERTAINTY_CAP + End Sub + + Private Async Sub Application_Suspending(sender As Object, e As SuspendingEventArgs) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Dim deferral = e.SuspendingOperation.GetDeferral() + Await CleanupCameraAsync() + Await CleanupUiAsync() + deferral.Complete() + End If + End Sub + + Private Async Sub Application_Resuming(sender As Object, o As Object) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Await SetupUiAsync() + Await InitializeCameraAsync() + End If + End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + Await SetupUiAsync() + Await InitializeCameraAsync() + End Sub + + Protected Overrides Async Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + Await CleanupCameraAsync() + Await CleanupUiAsync() + End Sub + +#End Region + +#Region " Event handlers " + + ''' + ''' In the event of the app being minimized this method handles media property change events. If the app receives a mute + ''' notification, it is no longer in the foregroud. + ''' + ''' + ''' + Private Async Sub SystemMediaControls_PropertyChanged(sender As SystemMediaTransportControls, args As SystemMediaTransportControlsPropertyChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Async Sub() + If args.Property = SystemMediaTransportControlsProperty.SoundLevel AndAlso Frame.CurrentSourcePageType Is GetType(MainPage) Then + If sender.SoundLevel = SoundLevel.Muted Then + Await CleanupCameraAsync() + ElseIf Not _isInitialized Then + Await InitializeCameraAsync() + End If + End If + End Sub) + End Sub + + ''' + ''' Occurs each time the simple orientation sensor reports a new sensor reading. + ''' + ''' The event source. + ''' The event data. + Private Async Sub OrientationSensor_OrientationChanged(sender As SimpleOrientationSensor, args As SimpleOrientationSensorOrientationChangedEventArgs) + If args.Orientation <> SimpleOrientation.Faceup AndAlso args.Orientation <> SimpleOrientation.Facedown Then + _deviceOrientation = args.Orientation + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateControlOrientation()) + End If + End Sub + + ''' + ''' This event will be raised when the page is rotated, when the DisplayInformation.AutoRotationPreferences value set in the SetupUiAsync() method + ''' cannot be not honored. + ''' + ''' The event source. + ''' The event data. + Private Async Sub DisplayInformation_OrientationChanged(sender As DisplayInformation, args As Object) + _displayOrientation = sender.CurrentOrientation + If _isPreviewing Then + Await SetPreviewRotationAsync() + End If + + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateControlOrientation()) + End Sub + + ''' + ''' This event will be raised every time the effect processes a preview frame, to deliver information about the current scene in the camera preview. + ''' + ''' The effect raising the event. + ''' The event data. + Private Async Sub SceneAnalysisEffect_SceneAnalyzed(sender As SceneAnalysisEffect, args As SceneAnalyzedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + HdrImpactBar.Value = Math.Min(CERTAINTY_CAP, args.ResultFrame.HighDynamicRange.Certainty) + End Sub) + End Sub + + Private Async Sub HdrToggleButton_Checked(sender As Object, e As RoutedEventArgs) + If Not _hdrSupported Then + Return + End If + + If HdrToggleButton.IsChecked = True Then + Await EnableHdrAsync() + Else + Await DisableHdrAsync() + End If + End Sub + + ''' + ''' This event will be raised only on devices that support returning a reference photo, which is a normal exposure of the scene + ''' without HDR, also referred to as "EV0". + ''' + ''' The object raising this event. + ''' The event data. + Private Async Sub AdvancedCapture_OptionalReferencePhotoCaptured(sender As AdvancedPhotoCapture, args As OptionalReferencePhotoCapturedEventArgs) + ' Retrieve the context (i.e. what capture does this belong to?) + Dim context = TryCast(args.Context, AdvancedCaptureContext) + Debug.WriteLine("AdvancedCapture_OptionalReferencePhotoCaptured for {0}", context.CaptureFileName) + ' Remove "_HDR" from the name of the capture to create the name of the reference + Dim referenceName = context.CaptureFileName.Replace("_HDR", "") + Using frame = args.Frame + Await ReencodeAndSavePhotoAsync(frame, referenceName, context.CaptureOrientation) + End Using + End Sub + + ''' + ''' This event will be raised when the capturing part of the HDR process is completed, and at this point the camera is technically ready + ''' to capture again while HDR fusion occurs. + ''' + ''' The object raising this event. + ''' The event data. + Private Sub AdvancedCapture_AllPhotosCaptured(sender As AdvancedPhotoCapture, args As Object) + Debug.WriteLine("AdvancedCapture_AllPhotosCaptured") + End Sub + + Private Async Sub PhotoButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + Await TakePhotoInCurrentModeAsync() + End Sub + + Private Async Sub HardwareButtons_CameraPressed(sender As Object, e As CameraEventArgs) + Await TakePhotoInCurrentModeAsync() + End Sub + + Private Async Sub MediaCapture_Failed(sender As MediaCapture, errorEventArgs As MediaCaptureFailedEventArgs) + Debug.WriteLine("MediaCapture_Failed: (0x{0:X}) {1}", errorEventArgs.Code, errorEventArgs.Message) + Await CleanupCameraAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateUi()) + End Sub + +#End Region + +#Region " MediaCapture methods " + + ''' + ''' Initializes the MediaCapture, registers events, gets camera device information for mirroring and rotating, starts preview and unlocks the UI + ''' + ''' + Private Async Function InitializeCameraAsync() As Task + Debug.WriteLine("InitializeCameraAsync") + If _mediaCapture Is Nothing Then + ' Attempt to get the back camera if one is available, but use any camera device if not + Dim cameraDevice = Await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Back) + If cameraDevice Is Nothing Then + Debug.WriteLine("No camera device found!") + Return + End If + + _mediaCapture = New MediaCapture() + AddHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + Dim settings = New MediaCaptureInitializationSettings With {.VideoDeviceId = cameraDevice.Id} + Try + Await _mediaCapture.InitializeAsync(settings) + _isInitialized = True + Catch ex As UnauthorizedAccessException + Debug.WriteLine("The app was denied access to the camera") + End Try + + If _isInitialized Then + _hdrSupported = _mediaCapture.VideoDeviceController.AdvancedPhotoControl.SupportedModes.Contains(Windows.Media.Devices.AdvancedPhotoMode.Hdr) + If cameraDevice.EnclosureLocation Is Nothing OrElse cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Unknown Then + _externalCamera = True + Else + _externalCamera = False + _mirroringPreview =(cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Front) + End If + + Await StartPreviewAsync() + If _isPreviewing Then + Await CreateSceneAnalysisEffectAsync() + End If + + UpdateUi() + End If + End If + End Function + + ''' + ''' Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on + ''' + ''' + Private Async Function StartPreviewAsync() As Task + _displayRequest.RequestActive() + PreviewControl.Source = _mediaCapture + PreviewControl.FlowDirection = If(_mirroringPreview, FlowDirection.RightToLeft, FlowDirection.LeftToRight) + Await _mediaCapture.StartPreviewAsync() + _isPreviewing = True + If _isPreviewing Then + Await SetPreviewRotationAsync() + End If + End Function + + ''' + ''' Gets the current orientation of the UI in relation to the device (when AutoRotationPreferences cannot be honored) and applies a corrective rotation to the preview + ''' + Private Async Function SetPreviewRotationAsync() As Task + If _externalCamera Then + Return + End If + + ' Calculate which way and how far to rotate the preview + Dim rotationDegrees As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _mirroringPreview Then + rotationDegrees =(360 - rotationDegrees) Mod 360 + End If + + ' Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames + Dim props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) + props.Properties.Add(RotationKey, rotationDegrees) + Await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, Nothing) + End Function + + ''' + ''' Stops the preview and deactivates a display request, to allow the screen to go into power saving modes + ''' + ''' + Private Async Function StopPreviewAsync() As Task + _isPreviewing = False + Await _mediaCapture.StopPreviewAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + PreviewControl.Source = Nothing + _displayRequest.RequestRelease() + End Sub) + End Function + + ''' + ''' Adds scene analysis to the video preview stream, registers for its event, enables it, and gets the effect instance + ''' + ''' + Private Async Function CreateSceneAnalysisEffectAsync() As Task + ' Create the definition, which will contain some initialization settings + Dim definition = New SceneAnalysisEffectDefinition() + _sceneAnalysisEffect = CType(Await _mediaCapture.AddVideoEffectAsync(definition, MediaStreamType.VideoPreview), SceneAnalysisEffect) + Debug.WriteLine("SA effect added to pipeline") + AddHandler _sceneAnalysisEffect.SceneAnalyzed, AddressOf SceneAnalysisEffect_SceneAnalyzed + _sceneAnalysisEffect.HighDynamicRangeAnalyzer.Enabled = True + End Function + + ''' + ''' Disables and removes the scene analysis effect, and unregisters the event handler for the SceneAnalyzed event of the effect + ''' + ''' + Private Async Function CleanSceneAnalysisEffectAsync() As Task + _sceneAnalysisEffect.HighDynamicRangeAnalyzer.Enabled = False + RemoveHandler _sceneAnalysisEffect.SceneAnalyzed, AddressOf SceneAnalysisEffect_SceneAnalyzed + Await _mediaCapture.ClearEffectsAsync(MediaStreamType.VideoPreview) + Debug.WriteLine("SA effect removed from pipeline") + _sceneAnalysisEffect = Nothing + End Function + + ''' + ''' Creates an instance of the AdvancedPhotoCapture, configures it to capture HDR images, and registers for its events + ''' + ''' + Private Async Function EnableHdrAsync() As Task + If _advancedCapture IsNot Nothing Then + Return + End If + + ' Explicitly choose HDR mode + Dim settings = New AdvancedPhotoCaptureSettings With {.Mode = AdvancedPhotoMode.Hdr} + _mediaCapture.VideoDeviceController.AdvancedPhotoControl.Configure(settings) + _advancedCapture = Await _mediaCapture.PrepareAdvancedPhotoCaptureAsync(ImageEncodingProperties.CreateJpeg()) + Debug.WriteLine("Enabled HDR mode") + AddHandler _advancedCapture.AllPhotosCaptured, AddressOf AdvancedCapture_AllPhotosCaptured + AddHandler _advancedCapture.OptionalReferencePhotoCaptured, AddressOf AdvancedCapture_OptionalReferencePhotoCaptured + End Function + + ''' + ''' Cleans up the instance of the AdvancedCapture + ''' + ''' + Private Async Function DisableHdrAsync() As Task + If _advancedCapture Is Nothing Then + Return + End If + + Await _advancedCapture.FinishAsync() + _advancedCapture = Nothing + Debug.WriteLine("Disabled HDR mode") + End Function + + ''' + ''' Takes a photo in the current mode (normal vs. HDR) and disables the UI during capture + ''' + ''' + Private Async Function TakePhotoInCurrentModeAsync() As Task + PhotoButton.IsEnabled = False + HdrToggleButton.IsEnabled = False + If _advancedCapture Is Nothing Then + Await TakeNormalPhotoAsync() + Else + Await TakeHdrPhotoAsync() + End If + + UpdateUi() + End Function + + ''' + ''' Takes a photo to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function TakeNormalPhotoAsync() As Task + Dim stream = New InMemoryRandomAccessStream() + Try + Debug.WriteLine("Taking photo...") + ' Generate a filename based on the current time + Dim fileName = String.Format("SimplePhoto_{0}.jpg", DateTime.Now.ToString("HHmmss")) + ' Get the orientation of the camera at the time of capture + Dim photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()) + Await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream) + Debug.WriteLine("Photo taken!") + Await ReencodeAndSavePhotoAsync(stream, fileName, photoOrientation) + Catch ex As Exception + Debug.WriteLine("Exception when taking a photo: {0}", ex.ToString()) + End Try + End Function + + ''' + ''' Takes an HDR photo to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function TakeHdrPhotoAsync() As Task + Try + Debug.WriteLine("Taking HDR photo...") + ' Read the current orientation of the camera and the capture time + Dim photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()) + Dim fileName = String.Format("SimplePhoto_{0}_HDR.jpg", DateTime.Now.ToString("HHmmss")) + ' Create a context object, to identify the capture in the OptionalReferencePhotoCaptured event + Dim context = New AdvancedCaptureContext() With {.CaptureFileName = fileName, .CaptureOrientation = photoOrientation} + ' Start capture, and pass the context object + Dim capture = Await _advancedCapture.CaptureAsync(context) + Debug.WriteLine("HDR photo taken! {0}", fileName) + Using frame = capture.Frame + Await ReencodeAndSavePhotoAsync(frame, fileName, photoOrientation) + End Using + Catch ex As Exception + Debug.WriteLine("Exception when taking an HDR photo: {0}", ex.ToString()) + End Try + End Function + + ''' + ''' Cleans up the camera resources (after stopping any video recording and/or preview if necessary) and unregisters from MediaCapture events + ''' + ''' + Private Async Function CleanupCameraAsync() As Task + Debug.WriteLine("CleanupCameraAsync") + If _isInitialized Then + If _isPreviewing Then + Await StopPreviewAsync() + End If + + If _advancedCapture IsNot Nothing Then + Await DisableHdrAsync() + End If + + If _sceneAnalysisEffect IsNot Nothing Then + Await CleanSceneAnalysisEffectAsync() + End If + + _isInitialized = False + End If + + If _mediaCapture IsNot Nothing Then + RemoveHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + _mediaCapture.Dispose() + _mediaCapture = Nothing + End If + End Function + +#End Region + +#Region " Helper functions " + + ''' + ''' Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors + ''' + ''' + Private Async Function SetupUiAsync() As Task + DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync() + End If + + _displayOrientation = _displayInformation.CurrentOrientation + If _orientationSensor IsNot Nothing Then + _deviceOrientation = _orientationSensor.GetCurrentOrientation() + End If + + RegisterEventHandlers() + End Function + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors, allows the StatusBar (on Phone) to show, and removes the page orientation lock + ''' + ''' + Private Async Function CleanupUiAsync() As Task + UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ShowAsync() + End If + + DisplayInformation.AutoRotationPreferences = DisplayOrientations.None + End Function + + ''' + ''' This method will update the icons, enable/disable and show/hide the photo/video buttons depending on the current state of the app and the capabilities of the device + ''' + Private Sub UpdateUi() + PhotoButton.IsEnabled = _isPreviewing + HdrToggleButton.IsEnabled = _isPreviewing AndAlso _hdrSupported + HdrToggleButton.IsChecked =(_advancedCapture IsNot Nothing) + HdrToggleButton.Opacity =(If(_hdrSupported, 1, 0)) + End Sub + + ''' + ''' Registers event handlers for hardware buttons and orientation sensors, and performs an initial update of the UI rotation + ''' + Private Sub RegisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then + AddHandler HardwareButtons.CameraPressed, AddressOf HardwareButtons_CameraPressed + End If + + If _orientationSensor IsNot Nothing Then + AddHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + UpdateControlOrientation() + End If + + AddHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + AddHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors + ''' + Private Sub UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then + RemoveHandler HardwareButtons.CameraPressed, AddressOf HardwareButtons_CameraPressed + End If + + If _orientationSensor IsNot Nothing Then + RemoveHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + End If + + RemoveHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + RemoveHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Attempts to find and return a device mounted on the panel specified, and on failure to find one it will return the first device listed + ''' + ''' The desired panel on which the returned device should be mounted, if available + ''' + Private Shared Async Function FindCameraDeviceByPanelAsync(desiredPanel As Windows.Devices.Enumeration.Panel) As Task(Of DeviceInformation) + ' Get available devices for capturing pictures + Dim allVideoDevices = Await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture) + ' Get the desired camera by panel + Dim desiredDevice As DeviceInformation = allVideoDevices.FirstOrDefault(Function(x) x.EnclosureLocation IsNot Nothing AndAlso x.EnclosureLocation.Panel = desiredPanel) + Return If(desiredDevice, allVideoDevices.FirstOrDefault()) + End Function + + ''' + ''' Applies the given orientation to a photo stream and saves it as a StorageFile + ''' + ''' The photo stream + ''' The orientation metadata to apply to the photo + ''' + Private Shared Async Function ReencodeAndSavePhotoAsync(stream As IRandomAccessStream, fileName As String, Optional photoOrientation As PhotoOrientation = PhotoOrientation.Normal) As Task + Using inputStream = stream + Dim decoder = Await BitmapDecoder.CreateAsync(inputStream) + Dim file = Await KnownFolders.PicturesLibrary.CreateFileAsync(fileName, CreationCollisionOption.GenerateUniqueName) + Using outputStream = Await file.OpenAsync(FileAccessMode.ReadWrite) + Dim encoder = Await BitmapEncoder.CreateForTranscodingAsync(outputStream, decoder) + ' Set the orientation of the capture + Dim properties = New BitmapPropertySet From {{"System.Photo.Orientation", New BitmapTypedValue(photoOrientation, PropertyType.UInt16)}} + Await encoder.BitmapProperties.SetPropertiesAsync(properties) + Await encoder.FlushAsync() + End Using + End Using + End Function + +#End Region + +#Region " Rotation helpers " + + ''' + ''' Calculates the current camera orientation from the device orientation by taking into account whether the camera is external or facing the user + ''' + ''' The camera orientation in space, with an inverted rotation in the case the camera is mounted on the device and is facing the user + Private Function GetCameraOrientation() As SimpleOrientation + If _externalCamera Then + Return SimpleOrientation.NotRotated + End If + + Dim result = _deviceOrientation + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + result = SimpleOrientation.NotRotated + Case SimpleOrientation.Rotated180DegreesCounterclockwise + result = SimpleOrientation.Rotated90DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + result = SimpleOrientation.Rotated180DegreesCounterclockwise + Case SimpleOrientation.NotRotated + result = SimpleOrientation.Rotated270DegreesCounterclockwise + End Select + End If + + If _mirroringPreview Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return SimpleOrientation.Rotated270DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return SimpleOrientation.Rotated90DegreesCounterclockwise + End Select + End If + + Return result + End Function + + ''' + ''' Converts the given orientation of the device in space to the corresponding rotation in degrees + ''' + ''' The orientation of the device in space + ''' An orientation in degrees + Private Shared Function ConvertDeviceOrientationToDegrees(orientation As SimpleOrientation) As Integer + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return 90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return 180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the app on the screen to the corresponding rotation in degrees + ''' + ''' The orientation of the app on the screen + ''' An orientation in degrees + Private Shared Function ConvertDisplayOrientationToDegrees(orientation As DisplayOrientations) As Integer + Select orientation + Case DisplayOrientations.Portrait + Return 90 + Case DisplayOrientations.LandscapeFlipped + Return 180 + Case DisplayOrientations.PortraitFlipped + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the device in space to the metadata that can be added to captured photos + ''' + ''' The orientation of the device in space + ''' + Private Shared Function ConvertOrientationToPhotoOrientation(orientation As SimpleOrientation) As PhotoOrientation + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return PhotoOrientation.Rotate90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return PhotoOrientation.Rotate180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return PhotoOrientation.Rotate270 + Case Else + Return PhotoOrientation.Normal + End Select + End Function + + ''' + ''' Uses the current device orientation in space and page orientation on the screen to calculate the rotation + ''' transformation to apply to the controls + ''' + Private Sub UpdateControlOrientation() + Dim device As Integer = ConvertDeviceOrientationToDegrees(_deviceOrientation) + Dim display As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + device -= 90 + End If + + ' Combine both rotations and make sure that 0 <= result < 360 + Dim angle = (360 + display + device) Mod 360 + ' Rotate the buttons in the UI to match the rotation of the device + Dim transform = New RotateTransform With {.Angle = angle} + PhotoButton.RenderTransform = transform + HdrToggleButton.RenderTransform = transform + HdrImpactBar.FlowDirection = If((angle = 180 OrElse angle = 270), FlowDirection.RightToLeft, FlowDirection.LeftToRight) + End Sub +#End Region + End Class +End Namespace diff --git a/Samples/CameraHdr/vb/Package.appxmanifest b/Samples/CameraHdr/vb/Package.appxmanifest new file mode 100644 index 0000000000..385685f53e --- /dev/null +++ b/Samples/CameraHdr/vb/Package.appxmanifest @@ -0,0 +1,55 @@ + + + + + + + + + + CameraHdr + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/CameraHdr/vb/project.json b/Samples/CameraHdr/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/CameraHdr/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/CameraResolution/README.md b/Samples/CameraResolution/README.md index b93f8329ed..f56c4c172d 100644 --- a/Samples/CameraResolution/README.md +++ b/Samples/CameraResolution/README.md @@ -1,4 +1,4 @@ - @@ -69,7 +69,7 @@ the changes will be reflected in any videos taken with the video button. * [**Windows.Graphics.Imaging.BitmapEncoder** class](https://msdn.microsoft.com/library/windows/apps/windows.graphics.imaging.bitmapencoder.aspx) -* [How to preview video from a webcam](https://msdn.microsoft.com/library/windows/apps/xaml/hh868171.aspx) +* [Capture photos and video with MediaCapture](https://msdn.microsoft.com/library/windows/apps/mt243896) * [Media capture using capture device](https://code.msdn.microsoft.com/windowsapps/Media-Capture-Sample-adf87622) diff --git a/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj b/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj index b2d9545e18..98498f2c3d 100644 --- a/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj +++ b/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj @@ -145,17 +145,17 @@ - App.xaml + ..\shared\App.xaml - MainPage.xaml + ..\shared\MainPage.xaml - + Designer - + Designer @@ -166,10 +166,10 @@ - App.xaml + ..\shared\App.xaml - MainPage.xaml + ..\shared\MainPage.xaml Create diff --git a/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj.filters b/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj.filters index 94811d4078..bb2f516eef 100644 --- a/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj.filters +++ b/Samples/CameraStarterKit/cpp/CameraStarterKit.vcxproj.filters @@ -1,7 +1,7 @@  - + @@ -34,7 +34,7 @@ - + diff --git a/Samples/CameraStarterKit/cpp/Package.appxmanifest b/Samples/CameraStarterKit/cpp/Package.appxmanifest index 2153e699c8..c3da80a5b0 100644 --- a/Samples/CameraStarterKit/cpp/Package.appxmanifest +++ b/Samples/CameraStarterKit/cpp/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraStarterKit + Camera Starter Kit C++ Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraStarterKit.App"> diff --git a/Samples/CameraStarterKit/cs/CameraStarterKit.csproj b/Samples/CameraStarterKit/cs/CameraStarterKit.csproj index f994761fbd..6485f12915 100644 --- a/Samples/CameraStarterKit/cs/CameraStarterKit.csproj +++ b/Samples/CameraStarterKit/cs/CameraStarterKit.csproj @@ -128,11 +128,13 @@ - + + App.xaml MSBuild:Compile Designer - + + MainPage.xaml MSBuild:Compile Designer diff --git a/Samples/CameraStarterKit/cs/MainPage.xaml b/Samples/CameraStarterKit/cs/MainPage.xaml deleted file mode 100644 index 07e9c3649f..0000000000 --- a/Samples/CameraStarterKit/cs/MainPage.xaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Samples/CameraStarterKit/cs/Package.appxmanifest b/Samples/CameraStarterKit/cs/Package.appxmanifest index 6e33fc956e..a86aaaf89d 100644 --- a/Samples/CameraStarterKit/cs/Package.appxmanifest +++ b/Samples/CameraStarterKit/cs/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraStarterKit + Camera Starter Kit C# Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraStarterKit.App"> diff --git a/Samples/CameraStarterKit/cpp/App.xaml b/Samples/CameraStarterKit/shared/App.xaml similarity index 100% rename from Samples/CameraStarterKit/cpp/App.xaml rename to Samples/CameraStarterKit/shared/App.xaml diff --git a/Samples/CameraStarterKit/cpp/MainPage.xaml b/Samples/CameraStarterKit/shared/MainPage.xaml similarity index 100% rename from Samples/CameraStarterKit/cpp/MainPage.xaml rename to Samples/CameraStarterKit/shared/MainPage.xaml diff --git a/Samples/CameraStarterKit/vb/App.xaml.vb b/Samples/CameraStarterKit/vb/App.xaml.vb new file mode 100644 index 0000000000..0951cfadb0 --- /dev/null +++ b/Samples/CameraStarterKit/vb/App.xaml.vb @@ -0,0 +1,65 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.CameraStarterKit + + ''' + ''' Provides application-specific behavior to supplement the default Application class. + ''' + NotInheritable Partial Class App + Inherits Application + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when the application is launched normally by the end user. Other entry points + ''' will be used such as when the application is launched to open a specific file. + ''' + ''' Details about the launch request and process. + Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs) +#If DEBUG Then + If System.Diagnostics.Debugger.IsAttached Then + Me.DebugSettings.EnableFrameRateCounter = True + End If +#End If + + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages(0) + AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed + Window.Current.Content = rootFrame + End If + + If rootFrame.Content Is Nothing Then + rootFrame.Navigate(GetType(MainPage), e.Arguments) + End If + + Window.Current.Activate() + End Sub + + ''' + ''' Invoked when Navigation to a certain page fails + ''' + ''' The Frame which failed navigation + ''' Details about the navigation failure + Sub OnNavigationFailed(sender As Object, e As NavigationFailedEventArgs) + Throw New Exception("Failed to load Page " & e.SourcePageType.FullName) + End Sub + End Class +End Namespace diff --git a/Samples/CameraStarterKit/vb/CameraStarterKit.sln b/Samples/CameraStarterKit/vb/CameraStarterKit.sln new file mode 100644 index 0000000000..8c00e63436 --- /dev/null +++ b/Samples/CameraStarterKit/vb/CameraStarterKit.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CameraStarterKit", "CameraStarterKit.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/CameraStarterKit/vb/CameraStarterKit.vbproj b/Samples/CameraStarterKit/vb/CameraStarterKit.vbproj new file mode 100644 index 0000000000..6352477f11 --- /dev/null +++ b/Samples/CameraStarterKit/vb/CameraStarterKit.vbproj @@ -0,0 +1,204 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + CameraStarterKit + CameraStarterKit + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + + Properties\Default.rd.xml + + + Assets\smalltile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squaretile-sdk.png + + + Assets\storelogo-sdk.png + + + Assets\tile-sdk.png + + + + + App.xaml + + + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + + + Microsoft Mobile Extension SDK for Universal App Platform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/CameraStarterKit/vb/MainPage.xaml.vb b/Samples/CameraStarterKit/vb/MainPage.xaml.vb new file mode 100644 index 0000000000..820bd51c0c --- /dev/null +++ b/Samples/CameraStarterKit/vb/MainPage.xaml.vb @@ -0,0 +1,584 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports System.Diagnostics +Imports System.Linq +Imports System.Threading.Tasks +Imports Windows.ApplicationModel +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.Foundation.Metadata +Imports Windows.Graphics.Display +Imports Windows.Graphics.Imaging +Imports Windows.Media +Imports Windows.Media.Capture +Imports Windows.Media.MediaProperties +Imports Windows.Phone.UI.Input +Imports Windows.Storage +Imports Windows.Storage.FileProperties +Imports Windows.Storage.Streams +Imports Windows.System.Display +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation + +Namespace Global.CameraStarterKit + + Public NotInheritable Partial Class MainPage + Inherits Page + + ' Receive notifications about rotation of the device and UI and apply any necessary rotation to the preview stream and UI controls + Private ReadOnly _displayInformation As DisplayInformation = DisplayInformation.GetForCurrentView() + + Private ReadOnly _orientationSensor As SimpleOrientationSensor = SimpleOrientationSensor.GetDefault() + + Private _deviceOrientation As SimpleOrientation = SimpleOrientation.NotRotated + + Private _displayOrientation As DisplayOrientations = DisplayOrientations.Portrait + + ' Rotation metadata to apply to the preview stream and recorded videos (MF_MT_VIDEO_ROTATION) + ' Reference: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868174.aspx + Private Shared ReadOnly RotationKey As Guid = New Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1") + + ' Prevent the screen from sleeping while the camera is running + Private ReadOnly _displayRequest As DisplayRequest = New DisplayRequest() + + ' For listening to media property changes + Private ReadOnly _systemMediaControls As SystemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView() + + ' MediaCapture and its state variables + Private _mediaCapture As MediaCapture + + Private _isInitialized As Boolean + + Private _isPreviewing As Boolean + + Private _isRecording As Boolean + + ' Information about the camera device + Private _mirroringPreview As Boolean + + Private _externalCamera As Boolean + +#Region " Constructor, lifecycle and navigation " + Public Sub New() + Me.InitializeComponent() + NavigationCacheMode = NavigationCacheMode.Disabled + AddHandler Application.Current.Suspending, AddressOf Application_Suspending + AddHandler Application.Current.Resuming, AddressOf Application_Resuming + End Sub + + Private Async Sub Application_Suspending(sender As Object, e As SuspendingEventArgs) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Dim deferral = e.SuspendingOperation.GetDeferral() + Await CleanupCameraAsync() + Await CleanupUiAsync() + deferral.Complete() + End If + End Sub + + Private Async Sub Application_Resuming(sender As Object, o As Object) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Await SetupUiAsync() + Await InitializeCameraAsync() + End If + End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + Await SetupUiAsync() + Await InitializeCameraAsync() + End Sub + + Protected Overrides Async Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + Await CleanupCameraAsync() + Await CleanupUiAsync() + End Sub + +#End Region + +#Region " Event handlers " + + ''' + ''' In the event of the app being minimized this method handles media property change events. If the app receives a mute + ''' notification, it is no longer in the foregroud. + ''' + ''' + ''' + Private Async Sub SystemMediaControls_PropertyChanged(sender As SystemMediaTransportControls, args As SystemMediaTransportControlsPropertyChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Async Sub() + If args.Property = SystemMediaTransportControlsProperty.SoundLevel AndAlso Frame.CurrentSourcePageType Is GetType(MainPage) Then + If sender.SoundLevel = SoundLevel.Muted Then + Await CleanupCameraAsync() + ElseIf Not _isInitialized Then + Await InitializeCameraAsync() + End If + End If + End Sub) + End Sub + + ''' + ''' Occurs each time the simple orientation sensor reports a new sensor reading. + ''' + ''' The event source. + ''' The event data. + Private Async Sub OrientationSensor_OrientationChanged(sender As SimpleOrientationSensor, args As SimpleOrientationSensorOrientationChangedEventArgs) + If args.Orientation <> SimpleOrientation.Faceup AndAlso args.Orientation <> SimpleOrientation.Facedown Then + _deviceOrientation = args.Orientation + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateButtonOrientation()) + End If + End Sub + + ''' + ''' This event will fire when the page is rotated, when the DisplayInformation.AutoRotationPreferences value set in the SetupUiAsync() method cannot be not honored. + ''' + ''' The event source. + ''' The event data. + Private Async Sub DisplayInformation_OrientationChanged(sender As DisplayInformation, args As Object) + _displayOrientation = sender.CurrentOrientation + If _isPreviewing Then + Await SetPreviewRotationAsync() + End If + + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateButtonOrientation()) + End Sub + + Private Async Sub PhotoButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + Await TakePhotoAsync() + End Sub + + Private Async Sub VideoButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + If Not _isRecording Then + Await StartRecordingAsync() + Else + Await StopRecordingAsync() + End If + + UpdateCaptureControls() + End Sub + + Private Async Sub HardwareButtons_CameraPressed(sender As Object, e As CameraEventArgs) + Await TakePhotoAsync() + End Sub + + Private Async Sub MediaCapture_RecordLimitationExceeded(sender As MediaCapture) + Await StopRecordingAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateCaptureControls()) + End Sub + + Private Async Sub MediaCapture_Failed(sender As MediaCapture, errorEventArgs As MediaCaptureFailedEventArgs) + Debug.WriteLine("MediaCapture_Failed: (0x{0:X}) {1}", errorEventArgs.Code, errorEventArgs.Message) + Await CleanupCameraAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateCaptureControls()) + End Sub + +#End Region + +#Region " MediaCapture methods " + + ''' + ''' Initializes the MediaCapture, registers events, gets camera device information for mirroring and rotating, starts preview and unlocks the UI + ''' + ''' + Private Async Function InitializeCameraAsync() As Task + Debug.WriteLine("InitializeCameraAsync") + If _mediaCapture Is Nothing Then + ' Attempt to get the back camera if one is available, but use any camera device if not + Dim cameraDevice = Await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Back) + If cameraDevice Is Nothing Then + Debug.WriteLine("No camera device found!") + Return + End If + + _mediaCapture = New MediaCapture() + AddHandler _mediaCapture.RecordLimitationExceeded, AddressOf MediaCapture_RecordLimitationExceeded + AddHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + Dim settings = New MediaCaptureInitializationSettings With {.VideoDeviceId = cameraDevice.Id} + Try + Await _mediaCapture.InitializeAsync(settings) + _isInitialized = True + Catch ex As UnauthorizedAccessException + Debug.WriteLine("The app was denied access to the camera") + End Try + + If _isInitialized Then + If cameraDevice.EnclosureLocation Is Nothing OrElse cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Unknown Then + _externalCamera = True + Else + _externalCamera = False + _mirroringPreview =(cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Front) + End If + + Await StartPreviewAsync() + UpdateCaptureControls() + End If + End If + End Function + + ''' + ''' Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on + ''' + ''' + Private Async Function StartPreviewAsync() As Task + _displayRequest.RequestActive() + PreviewControl.Source = _mediaCapture + PreviewControl.FlowDirection = If(_mirroringPreview, FlowDirection.RightToLeft, FlowDirection.LeftToRight) + Await _mediaCapture.StartPreviewAsync() + _isPreviewing = True + If _isPreviewing Then + Await SetPreviewRotationAsync() + End If + End Function + + ''' + ''' Gets the current orientation of the UI in relation to the device (when AutoRotationPreferences cannot be honored) and applies a corrective rotation to the preview + ''' + Private Async Function SetPreviewRotationAsync() As Task + If _externalCamera Then + Return + End If + + ' Calculate which way and how far to rotate the preview + Dim rotationDegrees As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _mirroringPreview Then + rotationDegrees =(360 - rotationDegrees) Mod 360 + End If + + ' Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames + Dim props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) + props.Properties.Add(RotationKey, rotationDegrees) + Await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, Nothing) + End Function + + ''' + ''' Stops the preview and deactivates a display request, to allow the screen to go into power saving modes + ''' + ''' + Private Async Function StopPreviewAsync() As Task + _isPreviewing = False + Await _mediaCapture.StopPreviewAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + PreviewControl.Source = Nothing + _displayRequest.RequestRelease() + End Sub) + End Function + + ''' + ''' Takes a photo to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function TakePhotoAsync() As Task + VideoButton.IsEnabled = _mediaCapture.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported + VideoButton.Opacity = If(VideoButton.IsEnabled, 1, 0) + Dim stream = New InMemoryRandomAccessStream() + Try + Debug.WriteLine("Taking photo...") + Await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream) + Debug.WriteLine("Photo taken!") + Dim photoOrientation = ConvertOrientationToPhotoOrientation(GetCameraOrientation()) + Await ReencodeAndSavePhotoAsync(stream, photoOrientation) + Catch ex As Exception + Debug.WriteLine("Exception when taking a photo: {0}", ex.ToString()) + End Try + + VideoButton.IsEnabled = True + VideoButton.Opacity = 1 + End Function + + ''' + ''' Records an MP4 video to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function StartRecordingAsync() As Task + Try + ' Create storage file in Pictures Library + Dim videoFile = Await KnownFolders.PicturesLibrary.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName) + Dim encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto) + ' Calculate rotation angle, taking mirroring into account if necessary + Dim rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation()) + encodingProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle)) + Debug.WriteLine("Starting recording...") + Await _mediaCapture.StartRecordToStorageFileAsync(encodingProfile, videoFile) + _isRecording = True + Debug.WriteLine("Started recording!") + Catch ex As Exception + Debug.WriteLine("Exception when starting video recording: {0}", ex.ToString()) + End Try + End Function + + ''' + ''' Stops recording a video + ''' + ''' + Private Async Function StopRecordingAsync() As Task + Debug.WriteLine("Stopping recording...") + _isRecording = False + Await _mediaCapture.StopRecordAsync() + Debug.WriteLine("Stopped recording!") + End Function + + ''' + ''' Cleans up the camera resources (after stopping any video recording and/or preview if necessary) and unregisters from MediaCapture events + ''' + ''' + Private Async Function CleanupCameraAsync() As Task + Debug.WriteLine("CleanupCameraAsync") + If _isInitialized Then + If _isRecording Then + Await StopRecordingAsync() + End If + + If _isPreviewing Then + Await StopPreviewAsync() + End If + + _isInitialized = False + End If + + If _mediaCapture IsNot Nothing Then + RemoveHandler _mediaCapture.RecordLimitationExceeded, AddressOf MediaCapture_RecordLimitationExceeded + RemoveHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + _mediaCapture.Dispose() + _mediaCapture = Nothing + End If + End Function + +#End Region + +#Region " Helper functions " + + ''' + ''' Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors + ''' + ''' + Private Async Function SetupUiAsync() As Task + DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync() + End If + + _displayOrientation = _displayInformation.CurrentOrientation + If _orientationSensor IsNot Nothing Then + _deviceOrientation = _orientationSensor.GetCurrentOrientation() + End If + + RegisterEventHandlers() + End Function + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors, allows the StatusBar (on Phone) to show, and removes the page orientation lock + ''' + ''' + Private Async Function CleanupUiAsync() As Task + UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ShowAsync() + End If + + DisplayInformation.AutoRotationPreferences = DisplayOrientations.None + End Function + + ''' + ''' This method will update the icons, enable/disable and show/hide the photo/video buttons depending on the current state of the app and the capabilities of the device + ''' + Private Sub UpdateCaptureControls() + PhotoButton.IsEnabled = _isPreviewing + VideoButton.IsEnabled = _isPreviewing + StartRecordingIcon.Visibility = If(_isRecording, Visibility.Collapsed, Visibility.Visible) + StopRecordingIcon.Visibility = If(_isRecording, Visibility.Visible, Visibility.Collapsed) + If _isInitialized AndAlso Not _mediaCapture.MediaCaptureSettings.ConcurrentRecordAndPhotoSupported Then + PhotoButton.IsEnabled = Not _isRecording + PhotoButton.Opacity = If(PhotoButton.IsEnabled, 1, 0) + End If + End Sub + + ''' + ''' Registers event handlers for hardware buttons and orientation sensors, and performs an initial update of the UI rotation + ''' + Private Sub RegisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then + AddHandler HardwareButtons.CameraPressed, AddressOf HardwareButtons_CameraPressed + End If + + If _orientationSensor IsNot Nothing Then + AddHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + UpdateButtonOrientation() + End If + + AddHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + AddHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors + ''' + Private Sub UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons") Then + RemoveHandler HardwareButtons.CameraPressed, AddressOf HardwareButtons_CameraPressed + End If + + If _orientationSensor IsNot Nothing Then + RemoveHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + End If + + RemoveHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + RemoveHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Attempts to find and return a device mounted on the panel specified, and on failure to find one it will return the first device listed + ''' + ''' The desired panel on which the returned device should be mounted, if available + ''' + Private Shared Async Function FindCameraDeviceByPanelAsync(desiredPanel As Windows.Devices.Enumeration.Panel) As Task(Of DeviceInformation) + ' Get available devices for capturing pictures + Dim allVideoDevices = Await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture) + ' Get the desired camera by panel + Dim desiredDevice As DeviceInformation = allVideoDevices.FirstOrDefault(Function(x) x.EnclosureLocation IsNot Nothing AndAlso x.EnclosureLocation.Panel = desiredPanel) + Return If(desiredDevice, allVideoDevices.FirstOrDefault()) + End Function + + ''' + ''' Applies the given orientation to a photo stream and saves it as a StorageFile + ''' + ''' The photo stream + ''' The orientation metadata to apply to the photo + ''' + Private Shared Async Function ReencodeAndSavePhotoAsync(stream As IRandomAccessStream, photoOrientation As PhotoOrientation) As Task + Using inputStream = stream + Dim decoder = Await BitmapDecoder.CreateAsync(inputStream) + Dim file = Await KnownFolders.PicturesLibrary.CreateFileAsync("SimplePhoto.jpeg", CreationCollisionOption.GenerateUniqueName) + Using outputStream = Await file.OpenAsync(FileAccessMode.ReadWrite) + Dim encoder = Await BitmapEncoder.CreateForTranscodingAsync(outputStream, decoder) + Dim properties = New BitmapPropertySet From {{"System.Photo.Orientation", New BitmapTypedValue(photoOrientation, PropertyType.UInt16)}} + Await encoder.BitmapProperties.SetPropertiesAsync(properties) + Await encoder.FlushAsync() + End Using + End Using + End Function + +#End Region + +#Region " Rotation helpers " + + ''' + ''' Calculates the current camera orientation from the device orientation by taking into account whether the camera is external or facing the user + ''' + ''' The camera orientation in space, with an inverted rotation in the case the camera is mounted on the device and is facing the user + Private Function GetCameraOrientation() As SimpleOrientation + If _externalCamera Then + Return SimpleOrientation.NotRotated + End If + + Dim result = _deviceOrientation + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + result = SimpleOrientation.NotRotated + Case SimpleOrientation.Rotated180DegreesCounterclockwise + result = SimpleOrientation.Rotated90DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + result = SimpleOrientation.Rotated180DegreesCounterclockwise + Case SimpleOrientation.NotRotated + result = SimpleOrientation.Rotated270DegreesCounterclockwise + End Select + End If + + If _mirroringPreview Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return SimpleOrientation.Rotated270DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return SimpleOrientation.Rotated90DegreesCounterclockwise + End Select + End If + + Return result + End Function + + ''' + ''' Converts the given orientation of the device in space to the corresponding rotation in degrees + ''' + ''' The orientation of the device in space + ''' An orientation in degrees + Private Shared Function ConvertDeviceOrientationToDegrees(orientation As SimpleOrientation) As Integer + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return 90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return 180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the app on the screen to the corresponding rotation in degrees + ''' + ''' The orientation of the app on the screen + ''' An orientation in degrees + Private Shared Function ConvertDisplayOrientationToDegrees(orientation As DisplayOrientations) As Integer + Select orientation + Case DisplayOrientations.Portrait + Return 90 + Case DisplayOrientations.LandscapeFlipped + Return 180 + Case DisplayOrientations.PortraitFlipped + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the device in space to the metadata that can be added to captured photos + ''' + ''' The orientation of the device in space + ''' + Private Shared Function ConvertOrientationToPhotoOrientation(orientation As SimpleOrientation) As PhotoOrientation + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return PhotoOrientation.Rotate90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return PhotoOrientation.Rotate180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return PhotoOrientation.Rotate270 + Case Else + Return PhotoOrientation.Normal + End Select + End Function + + ''' + ''' Uses the current device orientation in space and page orientation on the screen to calculate the rotation + ''' transformation to apply to the controls + ''' + Private Sub UpdateButtonOrientation() + Dim device As Integer = ConvertDeviceOrientationToDegrees(_deviceOrientation) + Dim display As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + device -= 90 + End If + + ' Combine both rotations and make sure that 0 <= result < 360 + Dim angle = (360 + display + device) Mod 360 + ' Rotate the buttons in the UI to match the rotation of the device + Dim transform = New RotateTransform With {.Angle = angle} + PhotoButton.RenderTransform = transform + VideoButton.RenderTransform = transform + End Sub +#End Region + End Class +End Namespace diff --git a/Samples/CameraStarterKit/vb/Package.appxmanifest b/Samples/CameraStarterKit/vb/Package.appxmanifest new file mode 100644 index 0000000000..a9fba451a8 --- /dev/null +++ b/Samples/CameraStarterKit/vb/Package.appxmanifest @@ -0,0 +1,55 @@ + + + + + + + + + + Camera Starter Kit VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/CameraStarterKit/vb/project.json b/Samples/CameraStarterKit/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/CameraStarterKit/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj b/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj index 9a15412197..fed1fe17bd 100644 --- a/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj +++ b/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj @@ -145,17 +145,17 @@ - App.xaml + ..\shared\App.xaml - MainPage.xaml + ..\shared\MainPage.xaml - + Designer - + Designer @@ -166,10 +166,10 @@ - App.xaml + ..\shared\App.xaml - MainPage.xaml + ..\shared\MainPage.xaml Create diff --git a/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj.filters b/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj.filters index 9b9f2ad4c4..0fb476d229 100644 --- a/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj.filters +++ b/Samples/CameraVideoStabilization/cpp/CameraVideoStabilization.vcxproj.filters @@ -1,7 +1,7 @@  - + @@ -34,7 +34,7 @@ - + diff --git a/Samples/CameraVideoStabilization/cpp/Package.appxmanifest b/Samples/CameraVideoStabilization/cpp/Package.appxmanifest index b2b421400a..563a57af62 100644 --- a/Samples/CameraVideoStabilization/cpp/Package.appxmanifest +++ b/Samples/CameraVideoStabilization/cpp/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraVideoStabilization + Camera Video Stabilization C++ Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraVideoStabilization.App"> diff --git a/Samples/CameraVideoStabilization/cs/CameraVideoStabilization.csproj b/Samples/CameraVideoStabilization/cs/CameraVideoStabilization.csproj index 2d4745c3af..6958a71792 100644 --- a/Samples/CameraVideoStabilization/cs/CameraVideoStabilization.csproj +++ b/Samples/CameraVideoStabilization/cs/CameraVideoStabilization.csproj @@ -128,11 +128,13 @@ - + + App.xaml MSBuild:Compile Designer - + + MainPage.xaml MSBuild:Compile Designer diff --git a/Samples/CameraVideoStabilization/cs/MainPage.xaml b/Samples/CameraVideoStabilization/cs/MainPage.xaml deleted file mode 100644 index 32fa04fa65..0000000000 --- a/Samples/CameraVideoStabilization/cs/MainPage.xaml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Samples/CameraVideoStabilization/cs/Package.appxmanifest b/Samples/CameraVideoStabilization/cs/Package.appxmanifest index 483c0d5ee7..a862922246 100644 --- a/Samples/CameraVideoStabilization/cs/Package.appxmanifest +++ b/Samples/CameraVideoStabilization/cs/Package.appxmanifest @@ -14,7 +14,7 @@ - CameraVideoStabilization + Camera Video Stabilization C# Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CameraVideoStabilization.App"> diff --git a/Samples/CameraVideoStabilization/cpp/App.xaml b/Samples/CameraVideoStabilization/shared/App.xaml similarity index 100% rename from Samples/CameraVideoStabilization/cpp/App.xaml rename to Samples/CameraVideoStabilization/shared/App.xaml diff --git a/Samples/CameraVideoStabilization/cpp/MainPage.xaml b/Samples/CameraVideoStabilization/shared/MainPage.xaml similarity index 100% rename from Samples/CameraVideoStabilization/cpp/MainPage.xaml rename to Samples/CameraVideoStabilization/shared/MainPage.xaml diff --git a/Samples/CameraVideoStabilization/vb/App.xaml.vb b/Samples/CameraVideoStabilization/vb/App.xaml.vb new file mode 100644 index 0000000000..fab9c76015 --- /dev/null +++ b/Samples/CameraVideoStabilization/vb/App.xaml.vb @@ -0,0 +1,65 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +Imports System +Imports Windows.ApplicationModel.Activation +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Navigation + +Namespace Global.CameraVideoStabilization + + ''' + ''' Provides application-specific behavior to supplement the default Application class. + ''' + NotInheritable Partial Class App + Inherits Application + + Public Sub New() + Me.InitializeComponent() + End Sub + + ''' + ''' Invoked when the application is launched normally by the end user. Other entry points + ''' will be used such as when the application is launched to open a specific file. + ''' + ''' Details about the launch request and process. + Protected Overrides Sub OnLaunched(e As LaunchActivatedEventArgs) +#If DEBUG Then + If System.Diagnostics.Debugger.IsAttached Then + Me.DebugSettings.EnableFrameRateCounter = True + End If +#End If + + Dim rootFrame As Frame = TryCast(Window.Current.Content, Frame) + If rootFrame Is Nothing Then + rootFrame = New Frame() + rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages(0) + AddHandler rootFrame.NavigationFailed, AddressOf OnNavigationFailed + Window.Current.Content = rootFrame + End If + + If rootFrame.Content Is Nothing Then + rootFrame.Navigate(GetType(MainPage), e.Arguments) + End If + + Window.Current.Activate() + End Sub + + ''' + ''' Invoked when Navigation to a certain page fails + ''' + ''' The Frame which failed navigation + ''' Details about the navigation failure + Sub OnNavigationFailed(sender As Object, e As NavigationFailedEventArgs) + Throw New Exception("Failed to load Page " & e.SourcePageType.FullName) + End Sub + End Class +End Namespace diff --git a/Samples/CameraVideoStabilization/vb/CameraVideoStabilization.sln b/Samples/CameraVideoStabilization/vb/CameraVideoStabilization.sln new file mode 100644 index 0000000000..58cede6dc2 --- /dev/null +++ b/Samples/CameraVideoStabilization/vb/CameraVideoStabilization.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CameraVideoStabilization", "CameraVideoStabilization.vbproj", "{1399F59A-6590-4E35-ACCF-5200C175D88B}" +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 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.ActiveCfg = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Build.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|ARM.Deploy.0 = Debug|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.ActiveCfg = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Build.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x64.Deploy.0 = Debug|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.ActiveCfg = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Build.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Debug|x86.Deploy.0 = Debug|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.ActiveCfg = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Build.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|ARM.Deploy.0 = Release|ARM + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.ActiveCfg = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Build.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x64.Deploy.0 = Release|x64 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.ActiveCfg = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Build.0 = Release|x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B}.Release|x86.Deploy.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Samples/CameraVideoStabilization/vb/CameraVideoStabilization.vbproj b/Samples/CameraVideoStabilization/vb/CameraVideoStabilization.vbproj new file mode 100644 index 0000000000..135807f05c --- /dev/null +++ b/Samples/CameraVideoStabilization/vb/CameraVideoStabilization.vbproj @@ -0,0 +1,204 @@ + + + + + Debug + x86 + {1399F59A-6590-4E35-ACCF-5200C175D88B} + + AppContainerExe + CameraVideoStabilization + CameraVideoStabilization + en-US + UAP + 10.0.10240.0 + 10.0.10240.0 + 14 + true + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + + + + true + true + true + bin\ARM\Debug\ + NETFX_CORE,WINDOWS_UWP + full + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\ARM\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + ARM + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x64\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x64\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x64 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + true + true + true + bin\x86\Debug\ + NETFX_CORE,WINDOWS_UWP + full + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + true + bin\x86\Release\ + NETFX_CORE,WINDOWS_UWP + true + pdbonly + x86 + false + true + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + true + + + + + + + + Properties\Default.rd.xml + + + Assets\smalltile-sdk.png + + + Assets\splash-sdk.png + + + Assets\squaretile-sdk.png + + + Assets\storelogo-sdk.png + + + Assets\tile-sdk.png + + + + + App.xaml + + + MainPage.xaml + + + Properties\AssemblyInfo.vb + + + + + Designer + + + + + App.xaml + MSBuild:Compile + Designer + + + MainPage.xaml + MSBuild:Compile + Designer + + + + + Microsoft Mobile Extension SDK for Universal App Platform + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 14.0 + + + On + + + Binary + + + Off + + + On + + + + \ No newline at end of file diff --git a/Samples/CameraVideoStabilization/vb/MainPage.xaml.vb b/Samples/CameraVideoStabilization/vb/MainPage.xaml.vb new file mode 100644 index 0000000000..7266045a0e --- /dev/null +++ b/Samples/CameraVideoStabilization/vb/MainPage.xaml.vb @@ -0,0 +1,640 @@ +'********************************************************* +' +' Copyright (c) Microsoft. All rights reserved. +' This code is licensed under the MIT License (MIT). +' THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +' ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +' IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +' PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +' +'********************************************************* +' '#define USE_VS_RECOMMENDATION' could not be converted to a StatementSyntax +Imports System +Imports System.Diagnostics +Imports System.Linq +Imports System.Threading.Tasks +Imports Windows.ApplicationModel +Imports Windows.Devices.Enumeration +Imports Windows.Devices.Sensors +Imports Windows.Foundation +Imports Windows.Foundation.Metadata +Imports Windows.Graphics.Display +Imports Windows.Media +Imports Windows.Media.Capture +Imports Windows.Media.Core +Imports Windows.Media.MediaProperties +Imports Windows.Storage +Imports Windows.Storage.FileProperties +Imports Windows.System.Display +Imports Windows.UI.Core +Imports Windows.UI.Xaml +Imports Windows.UI.Xaml.Controls +Imports Windows.UI.Xaml.Input +Imports Windows.UI.Xaml.Media +Imports Windows.UI.Xaml.Navigation + +Namespace Global.CameraVideoStabilization + + Public NotInheritable Partial Class MainPage + Inherits Page + + ' Receive notifications about rotation of the device and UI and apply any necessary rotation to the preview stream and UI controls + Private ReadOnly _displayInformation As DisplayInformation = DisplayInformation.GetForCurrentView() + + Private ReadOnly _orientationSensor As SimpleOrientationSensor = SimpleOrientationSensor.GetDefault() + + Private _deviceOrientation As SimpleOrientation = SimpleOrientation.NotRotated + + Private _displayOrientation As DisplayOrientations = DisplayOrientations.Portrait + + ' Rotation metadata to apply to the preview stream and recorded videos (MF_MT_VIDEO_ROTATION) + ' Reference: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868174.aspx + Private Shared ReadOnly RotationKey As Guid = New Guid("C380465D-2271-428C-9B83-ECEA3B4A85C1") + + ' Prevent the screen from sleeping while the camera is running + Private ReadOnly _displayRequest As DisplayRequest = New DisplayRequest() + + ' For listening to media property changes + Private ReadOnly _systemMediaControls As SystemMediaTransportControls = SystemMediaTransportControls.GetForCurrentView() + + ' MediaCapture and its state variables + Private _mediaCapture As MediaCapture + + Private _isInitialized As Boolean + + Private _isPreviewing As Boolean + + Private _isRecording As Boolean + + Private _encodingProfile As MediaEncodingProfile + + ' Information about the camera device + Private _mirroringPreview As Boolean + + Private _externalCamera As Boolean + + Private _videoStabilizationEffect As VideoStabilizationEffect + + Private _inputPropertiesBackup As VideoEncodingProperties + + Private _outputPropertiesBackup As VideoEncodingProperties + +#Region " Constructor, lifecycle and navigation " + Public Sub New() + Me.InitializeComponent() + NavigationCacheMode = NavigationCacheMode.Disabled + AddHandler Application.Current.Suspending, AddressOf Application_Suspending + AddHandler Application.Current.Resuming, AddressOf Application_Resuming + End Sub + + Private Async Sub Application_Suspending(sender As Object, e As SuspendingEventArgs) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Dim deferral = e.SuspendingOperation.GetDeferral() + Await CleanupCameraAsync() + Await CleanupUiAsync() + deferral.Complete() + End If + End Sub + + Private Async Sub Application_Resuming(sender As Object, o As Object) + If Frame.CurrentSourcePageType Is GetType(MainPage) Then + Await SetupUiAsync() + Await InitializeCameraAsync() + End If + End Sub + + Protected Overrides Async Sub OnNavigatedTo(e As NavigationEventArgs) + Await SetupUiAsync() + Await InitializeCameraAsync() + End Sub + + Protected Overrides Async Sub OnNavigatingFrom(e As NavigatingCancelEventArgs) + Await CleanupCameraAsync() + Await CleanupUiAsync() + End Sub + +#End Region + +#Region " Event handlers " + + ''' + ''' In the event of the app being minimized this method handles media property change events. If the app receives a mute + ''' notification, it is no longer in the foregroud. + ''' + ''' + ''' + Private Async Sub SystemMediaControls_PropertyChanged(sender As SystemMediaTransportControls, args As SystemMediaTransportControlsPropertyChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Async Sub() + If args.Property = SystemMediaTransportControlsProperty.SoundLevel AndAlso Frame.CurrentSourcePageType Is GetType(MainPage) Then + If sender.SoundLevel = SoundLevel.Muted Then + Await CleanupCameraAsync() + ElseIf Not _isInitialized Then + Await InitializeCameraAsync() + End If + End If + End Sub) + End Sub + + ''' + ''' Occurs each time the simple orientation sensor reports a new sensor reading. + ''' + ''' The event source. + ''' The event data. + Private Async Sub OrientationSensor_OrientationChanged(sender As SimpleOrientationSensor, args As SimpleOrientationSensorOrientationChangedEventArgs) + If args.Orientation <> SimpleOrientation.Faceup AndAlso args.Orientation <> SimpleOrientation.Facedown Then + _deviceOrientation = args.Orientation + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateButtonOrientation()) + End If + End Sub + + ''' + ''' This event will fire when the page is rotated, when the DisplayInformation.AutoRotationPreferences value set in the SetupUiAsync() method cannot be not honored. + ''' + ''' The event source. + ''' The event data. + Private Async Sub DisplayInformation_OrientationChanged(sender As DisplayInformation, args As Object) + _displayOrientation = sender.CurrentOrientation + If _isPreviewing Then + Await SetPreviewRotationAsync() + End If + + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateButtonOrientation()) + End Sub + + Private Async Sub VsToggleButton_Tapped(sender As Object, e As RoutedEventArgs) + If Not _isRecording Then + If _videoStabilizationEffect Is Nothing Then + Await CreateVideoStabilizationEffectAsync() + ElseIf _videoStabilizationEffect.Enabled Then + Await CleanUpVideoStabilizationEffectAsync() + End If + ElseIf Not _videoStabilizationEffect.Enabled Then + _videoStabilizationEffect.Enabled = True + End If + + UpdateCaptureControls() + End Sub + + Private Async Sub VideoButton_Tapped(sender As Object, e As TappedRoutedEventArgs) + If Not _isRecording Then + Await StartRecordingAsync() + Else + Await StopRecordingAsync() + End If + + UpdateCaptureControls() + End Sub + + ''' + ''' Triggers when the Enabled property of the VideoStabilizationEffect changes. + ''' + ''' The instance of the effect firing the event. + ''' Information about the event. + Private Async Sub VideoStabilizationEffect_EnabledChanged(sender As VideoStabilizationEffect, args As VideoStabilizationEffectEnabledChangedEventArgs) + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + Debug.WriteLine("VS Enabled: " & sender.Enabled & ". Reason: " & args.Reason.ToString()) + UpdateCaptureControls() + End Sub) + End Sub + + Private Async Sub MediaCapture_RecordLimitationExceeded(sender As MediaCapture) + Await StopRecordingAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateCaptureControls()) + End Sub + + Private Async Sub MediaCapture_Failed(sender As MediaCapture, errorEventArgs As MediaCaptureFailedEventArgs) + Debug.WriteLine("MediaCapture_Failed: (0x{0:X}) {1}", errorEventArgs.Code, errorEventArgs.Message) + Await CleanupCameraAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() UpdateCaptureControls()) + End Sub + +#End Region + +#Region " MediaCapture methods " + + ''' + ''' Initializes the MediaCapture, registers events, gets camera device information for mirroring and rotating, starts preview and unlocks the UI + ''' + ''' + Private Async Function InitializeCameraAsync() As Task + Debug.WriteLine("InitializeCameraAsync") + If _mediaCapture Is Nothing Then + ' Attempt to get the back camera if one is available, but use any camera device if not + Dim cameraDevice = Await FindCameraDeviceByPanelAsync(Windows.Devices.Enumeration.Panel.Back) + If cameraDevice Is Nothing Then + Debug.WriteLine("No camera device found!") + Return + End If + + _mediaCapture = New MediaCapture() + AddHandler _mediaCapture.RecordLimitationExceeded, AddressOf MediaCapture_RecordLimitationExceeded + AddHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + Dim settings = New MediaCaptureInitializationSettings With {.VideoDeviceId = cameraDevice.Id} + Try + Await _mediaCapture.InitializeAsync(settings) + _isInitialized = True + Catch ex As UnauthorizedAccessException + Debug.WriteLine("The app was denied access to the camera") + End Try + + _encodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto) + If _isInitialized Then + If cameraDevice.EnclosureLocation Is Nothing OrElse cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Unknown Then + _externalCamera = True + Else + _externalCamera = False + _mirroringPreview =(cameraDevice.EnclosureLocation.Panel = Windows.Devices.Enumeration.Panel.Front) + End If + + Await StartPreviewAsync() + UpdateCaptureControls() + End If + End If + End Function + + ''' + ''' Starts the preview and adjusts it for for rotation and mirroring after making a request to keep the screen on + ''' + ''' + Private Async Function StartPreviewAsync() As Task + _displayRequest.RequestActive() + PreviewControl.Source = _mediaCapture + PreviewControl.FlowDirection = If(_mirroringPreview, FlowDirection.RightToLeft, FlowDirection.LeftToRight) + Await _mediaCapture.StartPreviewAsync() + _isPreviewing = True + If _isPreviewing Then + Await SetPreviewRotationAsync() + End If + End Function + + ''' + ''' Gets the current orientation of the UI in relation to the device (when AutoRotationPreferences cannot be honored) and applies a corrective rotation to the preview + ''' + Private Async Function SetPreviewRotationAsync() As Task + If _externalCamera Then + Return + End If + + ' Calculate which way and how far to rotate the preview + Dim rotationDegrees As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _mirroringPreview Then + rotationDegrees =(360 - rotationDegrees) Mod 360 + End If + + ' Add rotation metadata to the preview stream to make sure the aspect ratio / dimensions match when rendering and getting preview frames + Dim props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) + props.Properties.Add(RotationKey, rotationDegrees) + Await _mediaCapture.SetEncodingPropertiesAsync(MediaStreamType.VideoPreview, props, Nothing) + End Function + + ''' + ''' Stops the preview and deactivates a display request, to allow the screen to go into power saving modes + ''' + ''' + Private Async Function StopPreviewAsync() As Task + _isPreviewing = False + Await _mediaCapture.StopPreviewAsync() + Await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, Sub() + PreviewControl.Source = Nothing + _displayRequest.RequestRelease() + End Sub) + End Function + + ''' + ''' Adds video stabilization to the video record stream, registers for its event, enables it, and gets the effect instance + ''' + ''' + Private Async Function CreateVideoStabilizationEffectAsync() As Task + If _videoStabilizationEffect IsNot Nothing Then + Return + End If + + ' Create the definition, which will contain some initialization settings + Dim definition = New VideoStabilizationEffectDefinition() + _videoStabilizationEffect = CType(Await _mediaCapture.AddVideoEffectAsync(definition, MediaStreamType.VideoRecord), VideoStabilizationEffect) + Debug.WriteLine("VS effect added to pipeline") + AddHandler _videoStabilizationEffect.EnabledChanged, AddressOf VideoStabilizationEffect_EnabledChanged + _videoStabilizationEffect.Enabled = True + Await SetUpVideoStabilizationRecommendationAsync() + End Function + + ''' + ''' Configures the pipeline to use the optimal resolutions for VS based on the settings currently in use + ''' + ''' + Private Async Function SetUpVideoStabilizationRecommendationAsync() As Task + Debug.WriteLine("Setting up VS recommendation...") + ' Get the recommendation from the effect based on our current input and output configuration + Dim recommendation = _videoStabilizationEffect.GetRecommendedStreamConfiguration(_mediaCapture.VideoDeviceController, _encodingProfile.Video) + If recommendation.InputProperties IsNot Nothing Then + _inputPropertiesBackup = TryCast(_mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord), VideoEncodingProperties) + Await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, recommendation.InputProperties) + Debug.WriteLine("VS recommendation for the MediaStreamProperties (input) has been applied") + End If + + If recommendation.OutputProperties IsNot Nothing Then + _outputPropertiesBackup = _encodingProfile.Video + _encodingProfile.Video = recommendation.OutputProperties + Debug.WriteLine("VS recommendation for the MediaEncodingProfile (output) has been applied") + End If + End Function + + ''' + ''' Disables and removes the video stabilization effect, and unregisters the event handler for the EnabledChanged event of the effect + ''' + ''' + Private Async Function CleanUpVideoStabilizationEffectAsync() As Task + If _videoStabilizationEffect Is Nothing Then + Return + End If + + _videoStabilizationEffect.Enabled = False + RemoveHandler _videoStabilizationEffect.EnabledChanged, AddressOf VideoStabilizationEffect_EnabledChanged + Await _mediaCapture.ClearEffectsAsync(MediaStreamType.VideoRecord) + Debug.WriteLine("VS effect removed from pipeline") + If _inputPropertiesBackup IsNot Nothing Then + Await _mediaCapture.VideoDeviceController.SetMediaStreamPropertiesAsync(MediaStreamType.VideoRecord, _inputPropertiesBackup) + _inputPropertiesBackup = Nothing + End If + + If _outputPropertiesBackup IsNot Nothing Then + _encodingProfile.Video = _outputPropertiesBackup + _outputPropertiesBackup = Nothing + End If + + _videoStabilizationEffect = Nothing + End Function + + ''' + ''' Records an MP4 video to a StorageFile and adds rotation metadata to it + ''' + ''' + Private Async Function StartRecordingAsync() As Task + Try + ' Create storage file in Pictures Library + Dim videoFile = Await KnownFolders.PicturesLibrary.CreateFileAsync("SimpleVideo.mp4", CreationCollisionOption.GenerateUniqueName) + ' Calculate rotation angle, taking mirroring into account if necessary + Dim rotationAngle = 360 - ConvertDeviceOrientationToDegrees(GetCameraOrientation()) + _encodingProfile.Video.Properties(RotationKey) = PropertyValue.CreateInt32(rotationAngle) + Debug.WriteLine("Starting recording...") + Await _mediaCapture.StartRecordToStorageFileAsync(_encodingProfile, videoFile) + _isRecording = True + Debug.WriteLine("Started recording to: " & videoFile.Path) + Catch ex As Exception + Debug.WriteLine("Exception when starting video recording: {0}", ex.ToString()) + End Try + End Function + + ''' + ''' Stops recording a video + ''' + ''' + Private Async Function StopRecordingAsync() As Task + Try + Debug.WriteLine("Stopping recording...") + _isRecording = False + Await _mediaCapture.StopRecordAsync() + If _videoStabilizationEffect IsNot Nothing AndAlso Not _videoStabilizationEffect.Enabled Then + Await CleanUpVideoStabilizationEffectAsync() + End If + + Debug.WriteLine("Stopped recording!") + Catch ex As Exception + Debug.WriteLine("Exception when stopping video recording: {0}", ex.ToString()) + End Try + End Function + + ''' + ''' Cleans up the camera resources (after stopping any video recording and/or preview if necessary) and unregisters from MediaCapture events + ''' + ''' + Private Async Function CleanupCameraAsync() As Task + Debug.WriteLine("CleanupCameraAsync") + If _isInitialized Then + If _isRecording Then + Await StopRecordingAsync() + End If + + If _videoStabilizationEffect IsNot Nothing Then + Await CleanUpVideoStabilizationEffectAsync() + End If + + If _isPreviewing Then + Await StopPreviewAsync() + End If + + _isInitialized = False + End If + + If _mediaCapture IsNot Nothing Then + RemoveHandler _mediaCapture.RecordLimitationExceeded, AddressOf MediaCapture_RecordLimitationExceeded + RemoveHandler _mediaCapture.Failed, AddressOf MediaCapture_Failed + _mediaCapture.Dispose() + _mediaCapture = Nothing + End If + End Function + +#End Region + +#Region " Helper functions " + + ''' + ''' Attempts to lock the page orientation, hide the StatusBar (on Phone) and registers event handlers for hardware buttons and orientation sensors + ''' + ''' + Private Async Function SetupUiAsync() As Task + DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync() + End If + + _displayOrientation = _displayInformation.CurrentOrientation + If _orientationSensor IsNot Nothing Then + _deviceOrientation = _orientationSensor.GetCurrentOrientation() + End If + + RegisterEventHandlers() + End Function + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors, allows the StatusBar (on Phone) to show, and removes the page orientation lock + ''' + ''' + Private Async Function CleanupUiAsync() As Task + UnregisterEventHandlers() + If ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar") Then + Await Windows.UI.ViewManagement.StatusBar.GetForCurrentView().ShowAsync() + End If + + DisplayInformation.AutoRotationPreferences = DisplayOrientations.None + End Function + + ''' + ''' This method will update the icons, enable/disable and show/hide the photo/video buttons depending on the current state of the app and the capabilities of the device + ''' + Private Sub UpdateCaptureControls() + VideoButton.IsEnabled = _isPreviewing + VsToggleButton.IsEnabled =(_isPreviewing AndAlso Not _isRecording) OrElse (_videoStabilizationEffect IsNot Nothing AndAlso Not _videoStabilizationEffect.Enabled) + StartRecordingIcon.Visibility = If(_isRecording, Visibility.Collapsed, Visibility.Visible) + StopRecordingIcon.Visibility = If(_isRecording, Visibility.Visible, Visibility.Collapsed) + If _videoStabilizationEffect IsNot Nothing AndAlso _videoStabilizationEffect.Enabled Then + VsOnIcon.Visibility = Visibility.Visible + VsOffIcon.Visibility = Visibility.Collapsed + Else + VsOnIcon.Visibility = Visibility.Collapsed + VsOffIcon.Visibility = Visibility.Visible + End If + End Sub + + ''' + ''' Registers event handlers for hardware buttons and orientation sensors, and performs an initial update of the UI rotation + ''' + Private Sub RegisterEventHandlers() + If _orientationSensor IsNot Nothing Then + AddHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + UpdateButtonOrientation() + End If + + AddHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + AddHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Unregisters event handlers for hardware buttons and orientation sensors + ''' + Private Sub UnregisterEventHandlers() + If _orientationSensor IsNot Nothing Then + RemoveHandler _orientationSensor.OrientationChanged, AddressOf OrientationSensor_OrientationChanged + End If + + RemoveHandler _displayInformation.OrientationChanged, AddressOf DisplayInformation_OrientationChanged + RemoveHandler _systemMediaControls.PropertyChanged, AddressOf SystemMediaControls_PropertyChanged + End Sub + + ''' + ''' Attempts to find and return a device mounted on the panel specified, and on failure to find one it will return the first device listed + ''' + ''' The desired panel on which the returned device should be mounted, if available + ''' + Private Shared Async Function FindCameraDeviceByPanelAsync(desiredPanel As Windows.Devices.Enumeration.Panel) As Task(Of DeviceInformation) + ' Get available devices for capturing pictures + Dim allVideoDevices = Await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture) + ' Get the desired camera by panel + Dim desiredDevice As DeviceInformation = allVideoDevices.FirstOrDefault(Function(x) x.EnclosureLocation IsNot Nothing AndAlso x.EnclosureLocation.Panel = desiredPanel) + Return If(desiredDevice, allVideoDevices.FirstOrDefault()) + End Function + +#End Region + +#Region " Rotation helpers " + + ''' + ''' Calculates the current camera orientation from the device orientation by taking into account whether the camera is external or facing the user + ''' + ''' The camera orientation in space, with an inverted rotation in the case the camera is mounted on the device and is facing the user + Private Function GetCameraOrientation() As SimpleOrientation + If _externalCamera Then + Return SimpleOrientation.NotRotated + End If + + Dim result = _deviceOrientation + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + result = SimpleOrientation.NotRotated + Case SimpleOrientation.Rotated180DegreesCounterclockwise + result = SimpleOrientation.Rotated90DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + result = SimpleOrientation.Rotated180DegreesCounterclockwise + Case SimpleOrientation.NotRotated + result = SimpleOrientation.Rotated270DegreesCounterclockwise + End Select + End If + + If _mirroringPreview Then + Select result + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return SimpleOrientation.Rotated270DegreesCounterclockwise + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return SimpleOrientation.Rotated90DegreesCounterclockwise + End Select + End If + + Return result + End Function + + ''' + ''' Converts the given orientation of the device in space to the corresponding rotation in degrees + ''' + ''' The orientation of the device in space + ''' An orientation in degrees + Private Shared Function ConvertDeviceOrientationToDegrees(orientation As SimpleOrientation) As Integer + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return 90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return 180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the app on the screen to the corresponding rotation in degrees + ''' + ''' The orientation of the app on the screen + ''' An orientation in degrees + Private Shared Function ConvertDisplayOrientationToDegrees(orientation As DisplayOrientations) As Integer + Select orientation + Case DisplayOrientations.Portrait + Return 90 + Case DisplayOrientations.LandscapeFlipped + Return 180 + Case DisplayOrientations.PortraitFlipped + Return 270 + Case Else + Return 0 + End Select + End Function + + ''' + ''' Converts the given orientation of the device in space to the metadata that can be added to captured photos + ''' + ''' The orientation of the device in space + ''' + Private Shared Function ConvertOrientationToPhotoOrientation(orientation As SimpleOrientation) As PhotoOrientation + Select orientation + Case SimpleOrientation.Rotated90DegreesCounterclockwise + Return PhotoOrientation.Rotate90 + Case SimpleOrientation.Rotated180DegreesCounterclockwise + Return PhotoOrientation.Rotate180 + Case SimpleOrientation.Rotated270DegreesCounterclockwise + Return PhotoOrientation.Rotate270 + Case Else + Return PhotoOrientation.Normal + End Select + End Function + + ''' + ''' Uses the current device orientation in space and page orientation on the screen to calculate the rotation + ''' transformation to apply to the controls + ''' + Private Sub UpdateButtonOrientation() + Dim device As Integer = ConvertDeviceOrientationToDegrees(_deviceOrientation) + Dim display As Integer = ConvertDisplayOrientationToDegrees(_displayOrientation) + If _displayInformation.NativeOrientation = DisplayOrientations.Portrait Then + device -= 90 + End If + + ' Combine both rotations and make sure that 0 <= result < 360 + Dim angle = (360 + display + device) Mod 360 + ' Rotate the buttons in the UI to match the rotation of the device + Dim transform = New RotateTransform With {.Angle = angle} + VsToggleButton.RenderTransform = transform + VideoButton.RenderTransform = transform + End Sub +#End Region + End Class +End Namespace diff --git a/Samples/CameraVideoStabilization/vb/Package.appxmanifest b/Samples/CameraVideoStabilization/vb/Package.appxmanifest new file mode 100644 index 0000000000..eff510dc71 --- /dev/null +++ b/Samples/CameraVideoStabilization/vb/Package.appxmanifest @@ -0,0 +1,55 @@ + + + + + + + + + + Camera Video Stabilization VB Sample + Microsoft Corporation + Assets\StoreLogo-sdk.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Samples/CameraVideoStabilization/vb/project.json b/Samples/CameraVideoStabilization/vb/project.json new file mode 100644 index 0000000000..c594939270 --- /dev/null +++ b/Samples/CameraVideoStabilization/vb/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file diff --git a/Samples/CashDrawer/cpp/CashDrawer.vcxproj b/Samples/CashDrawer/cpp/CashDrawer.vcxproj index e7f8337ed1..755e641f9a 100644 --- a/Samples/CashDrawer/cpp/CashDrawer.vcxproj +++ b/Samples/CashDrawer/cpp/CashDrawer.vcxproj @@ -146,13 +146,13 @@ - Scenario1_OpenDrawer.xaml + ..\shared\Scenario1_OpenDrawer.xaml - Scenario2_CloseDrawer.xaml + ..\shared\Scenario2_CloseDrawer.xaml - Scenario3_MultipleDrawers.xaml + ..\shared\Scenario3_MultipleDrawers.xaml @@ -162,9 +162,9 @@ Designer - - - + + + Styles\Styles.xaml @@ -191,13 +191,13 @@ - Scenario1_OpenDrawer.xaml + ..\shared\Scenario1_OpenDrawer.xaml - Scenario2_CloseDrawer.xaml + ..\shared\Scenario2_CloseDrawer.xaml - Scenario3_MultipleDrawers.xaml + ..\shared\Scenario3_MultipleDrawers.xaml diff --git a/Samples/CashDrawer/cpp/CashDrawer.vcxproj.filters b/Samples/CashDrawer/cpp/CashDrawer.vcxproj.filters index fb9ac5e01d..26fbe85bdc 100644 --- a/Samples/CashDrawer/cpp/CashDrawer.vcxproj.filters +++ b/Samples/CashDrawer/cpp/CashDrawer.vcxproj.filters @@ -38,9 +38,9 @@ Styles - - - + + + diff --git a/Samples/CashDrawer/cpp/Package.appxmanifest b/Samples/CashDrawer/cpp/Package.appxmanifest index 611cbbb32c..9119d0292d 100644 --- a/Samples/CashDrawer/cpp/Package.appxmanifest +++ b/Samples/CashDrawer/cpp/Package.appxmanifest @@ -14,7 +14,7 @@ - CashDrawer + Cash Drawer C++ Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -32,10 +32,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CashDrawer.App"> diff --git a/Samples/CashDrawer/cs/CashDrawer.csproj b/Samples/CashDrawer/cs/CashDrawer.csproj index 44bc359026..a06bde33fc 100644 --- a/Samples/CashDrawer/cs/CashDrawer.csproj +++ b/Samples/CashDrawer/cs/CashDrawer.csproj @@ -7,7 +7,7 @@ {DC30CE66-DAEE-4CCF-BD02-8837FE918B6F} AppContainerExe Properties - CashDrawerSample + SDKTemplate CashDrawer en-US UAP @@ -93,7 +93,9 @@ MainPage.xaml.cs MainPage.xaml - + + Properties\AssemblyInfo.cs + Scenario1_OpenDrawer.xaml @@ -121,17 +123,20 @@ MSBuild:Compile Designer - + + Scenario1_OpenDrawer.xaml MSBuild:Compile - + + Scenario2_CloseDrawer.xaml MSBuild:Compile - + + Scenario3_MultipleDrawers.xaml MSBuild:Compile diff --git a/Samples/CashDrawer/cs/Package.appxmanifest b/Samples/CashDrawer/cs/Package.appxmanifest index f7a09ea830..032c93f147 100644 --- a/Samples/CashDrawer/cs/Package.appxmanifest +++ b/Samples/CashDrawer/cs/Package.appxmanifest @@ -15,7 +15,7 @@ - CashDrawer + Cash Drawer C# Sample Microsoft Corporation Assets\StoreLogo-sdk.png @@ -33,10 +33,10 @@ Executable="$targetnametoken$.exe" EntryPoint="CashDrawer.App"> diff --git a/Samples/CashDrawer/cs/Properties/AssemblyInfo.cs b/Samples/CashDrawer/cs/Properties/AssemblyInfo.cs deleted file mode 100644 index 06cc102d08..0000000000 --- a/Samples/CashDrawer/cs/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("CashDrawer C# Sample")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Microsoft Corporation")] -[assembly: AssemblyProduct("SDKTemplate")] -[assembly: AssemblyCopyright("Copyright 2014")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] diff --git a/Samples/CashDrawer/cs/SampleConfiguration.cs b/Samples/CashDrawer/cs/SampleConfiguration.cs index f281744661..79f6453b1a 100644 --- a/Samples/CashDrawer/cs/SampleConfiguration.cs +++ b/Samples/CashDrawer/cs/SampleConfiguration.cs @@ -9,7 +9,6 @@ // //********************************************************* -using CashDrawerSample; using System; using System.Collections.Generic; using Windows.UI.Xaml.Controls; diff --git a/Samples/CashDrawer/cs/Scenario1_OpenDrawer.xaml b/Samples/CashDrawer/cs/Scenario1_OpenDrawer.xaml deleted file mode 100644 index 84ad403570..0000000000 --- a/Samples/CashDrawer/cs/Scenario1_OpenDrawer.xaml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - Discovers the default locally-connected cash drawer, claims and enables the drawer, and then opens the drawer. - - - - - - - - - - - - - -