From 4968d97b7ecc92a8772796ae79e703c78012ac68 Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Thu, 6 Aug 2015 10:55:02 -0700 Subject: [PATCH] Windows 10 RTM Release - August 2015 Update --- .gitattributes | 2 + README.md | 45 ++-- Samples/Accelerometer/README.md | 9 +- Samples/AccountPictureName/README.md | 53 ---- .../cpp/GetAccountPicture.xaml.cpp | 155 ------------ .../cpp/GetAccountPicture.xaml.h | 31 --- .../cpp/GetUserDisplayName.xaml.cpp | 55 ---- .../cpp/GetUserFirstAndLastName.xaml.cpp | 77 ------ .../cpp/GetUserFirstAndLastName.xaml.h | 29 --- .../cpp/SampleConfiguration.cpp | 50 ---- .../cpp/SetAccountPicture.xaml.cpp | 160 ------------ .../cs/AccountPictureName.sln | 43 ---- .../cs/GetAccountPicture.xaml.cs | 151 ----------- .../cs/GetUserDisplayName.xaml.cs | 54 ---- .../cs/GetUserFirstAndLastName.xaml.cs | 74 ------ .../cs/SampleConfiguration.cs | 82 ------ .../cs/SetAccountPicture.xaml.cs | 158 ------------ .../js/html/getAccountPicture.html | 40 --- .../js/html/setAccountPicture.html | 38 --- .../js/html/userFirstAndLastName.html | 30 --- .../js/js/getAccountPicture.js | 71 ------ .../js/js/sample-configuration.js | 32 --- .../js/js/setAccountPicture.js | 102 -------- .../js/js/userDisplayName.js | 24 -- .../js/js/userFirstAndLastName.js | 39 --- .../shared/GetAccountPicture.xaml | 59 ----- .../shared/SetAccountPicture.xaml | 61 ----- Samples/ActivitySensor/README.md | 9 +- Samples/AdaptiveStreaming/README.md | 9 +- Samples/AdvancedCasting/README.md | 11 +- Samples/AllJoyn/ConsumerExperiences/README.md | 2 +- Samples/AllJoyn/ProducerExperiences/README.md | 2 +- Samples/Altimeter/README.md | 7 +- Samples/AnimationLibrary/README.md | 8 +- Samples/AnimationMetrics/README.md | 8 +- Samples/AppServices/README.md | 13 +- Samples/ApplicationData/README.md | 7 +- Samples/ApplicationResources/README.md | 7 +- Samples/Appointments/README.md | 9 +- Samples/AssociationLaunching/README.md | 9 +- Samples/AudioCategory/README.md | 9 +- Samples/AudioCreation/README.md | 10 +- Samples/BackButton/README.md | 49 ++++ Samples/BackButton/cs/App.xaml.cs | 127 ++++++++++ Samples/BackButton/cs/MainPage.xaml.cs | 153 +++++++++++ Samples/BackButton/cs/Package.appxmanifest | 54 ++++ Samples/BackButton/cs/SampleConfiguration.cs | 33 +++ .../cs/Scenario1.xaml} | 16 +- Samples/BackButton/cs/Scenario1.xaml.cs | 56 +++++ Samples/BackButton/cs/SecondaryPage.xaml | 36 +++ Samples/BackButton/cs/SecondaryPage.xaml.cs | 55 ++++ Samples/BackButton/cs/SystemBack.csproj | 171 +++++++++++++ Samples/BackButton/cs/SystemBack.sln | 40 +++ Samples/BackgroundAudio/README.md | 9 +- Samples/BackgroundSensors/README.md | 9 +- Samples/BackgroundTask/README.md | 31 +-- Samples/BackgroundTransfer/README.md | 18 +- Samples/BarcodeScanner/README.md | 10 +- Samples/Barometer/README.md | 7 +- Samples/BasicFaceDetection/README.md | 10 +- Samples/BasicFaceTracking/README.md | 10 +- Samples/BasicInput/README.md | 9 +- Samples/BasicMediaCasting/README.md | 11 +- Samples/BluetoothAdvertisement/README.md | 11 +- Samples/CameraFaceDetection/README.md | 10 +- Samples/CameraGetPreviewFrame/README.md | 12 +- Samples/CameraHdr/README.md | 10 +- Samples/CameraProfile/README.md | 12 +- Samples/CameraStarterKit/README.md | 12 +- Samples/CameraVideoStabilization/README.md | 10 +- Samples/CashDrawer/README.md | 10 +- Samples/Clipboard/README.md | 9 +- Samples/Compass/README.md | 7 +- Samples/ComplexInk/README.md | 11 +- Samples/Compression/README.md | 27 +- Samples/ContentIndexer/README.md | 13 +- Samples/ContextMenu/README.md | 7 +- Samples/CortanaVoiceCommand/README.md | 35 ++- .../AdventureWorks/js/voiceCommandService.js | 2 +- Samples/CredentialPicker/README.md | 15 +- Samples/CustomHidDeviceAccess/README.md | 29 +-- Samples/CustomSensors/README.md | 9 +- Samples/CustomSerialDeviceAccess/README.md | 17 +- Samples/CustomUsbDeviceAccess/README.md | 39 ++- Samples/D2DCustomEffects/README.md | 7 +- Samples/D2DGradientMesh/README.md | 36 ++- Samples/D2DPhotoAdjustment/README.md | 38 ++- Samples/DWriteLineSpacingModes/README.md | 9 +- Samples/DWriteTextLayoutCloudFont/README.md | 9 +- Samples/DataReaderWriter/README.md | 12 +- Samples/DatagramSocket/README.md | 13 +- Samples/DeviceEnumeration/README.md | 47 ++-- Samples/DpiScaling/README.md | 8 +- .../shared/assets/projector-stretch.png | Bin 0 -> 1096 bytes .../shared/assets/projector.scale-100.png | Bin 0 -> 2110 bytes .../shared/assets/projector.scale-140.png | Bin 0 -> 3206 bytes .../shared/assets/projector.scale-180.png | Bin 0 -> 3369 bytes .../DpiScaling/shared/assets/projector.svg | 15 ++ Samples/DpiScaling/shared/xaml/Scenario1.xaml | 160 ++++++++++++ Samples/DpiScaling/shared/xaml/Scenario2.xaml | 162 ++++++++++++ Samples/EasProtocol/README.md | 32 +-- Samples/EfficientAnimations/README.md | 14 +- Samples/EnterpriseDataProtection/README.md | 29 ++- Samples/FeedReader/README.md | 31 +-- Samples/FileAccess/README.md | 8 +- Samples/FilePicker/README.md | 9 +- Samples/FilePickerContracts/README.md | 9 +- Samples/FileSearch/README.md | 9 +- Samples/FileThumbnails/README.md | 10 +- Samples/FolderEnumeration/README.md | 7 +- Samples/FullScreenMode/README.md | 8 +- Samples/Geolocation/README.md | 12 +- Samples/Geotag/README.md | 11 +- Samples/Gyrometer/README.md | 7 +- Samples/HomeGroup/README.md | 10 +- Samples/HtmlFormValidation/README.md | 23 +- Samples/HttpClient/README.md | 9 +- Samples/Inclinometer/README.md | 7 +- Samples/IndexedDB/README.md | 26 +- Samples/Ink/README.md | 23 +- Samples/JapanesePhoneticAnalysis/README.md | 9 +- Samples/Json/README.md | 11 +- Samples/KeyCredentialManager/README.md | 15 +- Samples/LampDevice/README.md | 10 +- Samples/LanguageFont/README.md | 7 +- Samples/LibraryManagement/README.md | 7 +- Samples/LightSensor/README.md | 9 +- Samples/LinguisticServices/README.md | 13 +- Samples/LiveDash/README.md | 9 +- Samples/LockScreenApps/README.md | 9 +- Samples/Logging/README.md | 11 +- Samples/LowLatencyInput/README.md | 9 +- Samples/MIDI/README.md | 30 +-- Samples/MagneticStripeReader/README.md | 10 +- Samples/MapControl/README.md | 26 +- Samples/MediaEditing/README.md | 10 +- Samples/MediaImport/README.md | 13 +- Samples/MediaTranscoding/README.md | 24 +- Samples/MessageDialog/README.md | 7 +- Samples/MobileBroadband/README.md | 12 +- Samples/MsBlobBuilder/README.md | 14 +- Samples/MultipleViews/README.md | 10 +- Samples/Nfc/README.md | 12 +- Samples/NfcProvisioner/README.md | 9 +- Samples/Notifications/README.md | 11 +- Samples/NumberFormatting/README.md | 7 +- Samples/OCR/README.md | 14 +- Samples/OrientationSensor/README.md | 11 +- Samples/Package/README.md | 7 +- Samples/PackagedContent/README.md | 14 +- Samples/PasswordVault/README.md | 15 +- Samples/Pedometer/README.md | 7 +- Samples/Personalization/README.md | 7 +- Samples/PhoneCall/README.md | 8 +- Samples/PosPrinter/README.md | 10 +- Samples/Printing/README.md | 14 +- Samples/Projection/README.md | 7 +- Samples/ProximitySensor/README.md | 9 +- .../ProxyStubsForWinRTComponents/README.md | 9 +- Samples/RadioManager/README.md | 12 +- Samples/RelativeInclinometer/README.md | 9 +- Samples/RelativeOrientationSensor/README.md | 9 +- Samples/ResizeAppView/README.md | 10 +- Samples/SecondaryTiles/README.md | 9 +- Samples/SemanticTextQuery/README.md | 10 +- Samples/SerialArduino/README.md | 23 +- Samples/ShareSource/README.md | 7 +- Samples/ShareTarget/README.md | 7 +- Samples/Simple3DGameDX/README.md | 9 +- Samples/Simple3DGameXaml/README.md | 9 +- Samples/SimpleCommunication/README.md | 53 ++-- Samples/SimpleImaging/README.md | 7 +- Samples/SimpleInk/README.md | 31 ++- Samples/SimpleOrientationSensor/README.md | 9 +- Samples/SmartCard/README.md | 15 +- Samples/SmsSendAndReceive/README.md | 12 +- Samples/SocketActivityStreamSocket/README.md | 11 +- Samples/SpatialSound/README.md | 19 +- .../SpeechRecognitionAndSynthesis/README.md | 25 +- ...nario8_ContinuousRecognitionListGrammar.js | 27 +- .../shared/SRGS/es-ES/SRGSColors.xml | 6 +- .../es-ES/LocalizationSpeechResources.resw | 6 +- Samples/SplashScreen/README.md | 9 +- Samples/StreamSocket/README.md | 9 +- Samples/Syndication/README.md | 11 +- .../SystemMediaTransportControls/README.md | 9 +- Samples/TextSegmentation/README.md | 13 +- Samples/TextSuggestion/README.md | 23 +- Samples/TitleBar/README.md | 8 +- Samples/Unicode/README.md | 9 +- Samples/UserConsentVerifier/README.md | 15 +- Samples/UserDataAccountManager/README.md | 42 +++- Samples/UserInfo/README.md | 55 ++++ .../cpp/Package.appxmanifest | 16 +- Samples/UserInfo/cpp/SampleConfiguration.cpp | 26 ++ Samples/UserInfo/cpp/SampleConfiguration.h | 78 ++++++ .../UserInfo/cpp/Scenario1_FindUsers.xaml.cpp | 150 +++++++++++ .../cpp/Scenario1_FindUsers.xaml.h} | 18 +- .../cpp/Scenario2_WatchUsers.xaml.cpp | 180 +++++++++++++ .../UserInfo/cpp/Scenario2_WatchUsers.xaml.h | 49 ++++ .../cpp/UserInfo.sln} | 2 +- .../cpp/UserInfo.vcxproj} | 37 +-- .../cpp/UserInfo.vcxproj.filters} | 18 +- .../cpp/pch.cpp | 0 .../cpp/pch.h | 1 - .../cs/Package.appxmanifest | 16 +- Samples/UserInfo/cs/SampleConfiguration.cs | 71 ++++++ .../UserInfo/cs/Scenario1_FindUsers.xaml.cs | 117 +++++++++ .../UserInfo/cs/Scenario2_WatchUsers.xaml.cs | 174 +++++++++++++ .../cs/UserInfo.csproj} | 39 +-- Samples/UserInfo/cs/UserInfo.sln | 40 +++ .../cs/project.json | 0 .../Microsoft.WinJS.4.0/css/placeholder.txt | 0 .../js/Microsoft.WinJS.4.0/fonts/placeholder | 0 .../js/en-US/placeholder.txt | 0 .../js/Package.appxmanifest | 13 +- .../js/UserInfo.jsproj} | 12 +- .../js/UserInfo.sln} | 2 +- .../js/css/placeholder.txt | 0 .../UserInfo/js/html/scenario1-findUsers.html | 41 +++ .../js/html/scenario2-watchUsers.html} | 12 +- .../js/images/placeholder.txt | 0 .../UserInfo/js/js/sample-configuration.js | 17 ++ Samples/UserInfo/js/js/scenario1-findUsers.js | 131 ++++++++++ .../UserInfo/js/js/scenario2-watchUsers.js | 136 ++++++++++ .../js/sample-utils/placeholder.txt | 0 .../shared/Scenario1_FindUsers.xaml} | 21 +- .../UserInfo/shared/Scenario2_WatchUsers.xaml | 40 +++ Samples/UserInteractionMode/README.md | 8 +- Samples/UserSelection/README.md | 14 +- Samples/UssdProtcol/README.md | 12 +- Samples/VideoPlayback/README.md | 9 +- Samples/VoIP/README.md | 12 +- Samples/WRLInProcessWinRTComponent/README.md | 11 +- .../WRLOutOfProcessWinRTComponent/README.md | 9 +- Samples/WebAccountManagement/README.md | 10 +- Samples/WebAuthenticationBroker/README.md | 36 +-- Samples/WebSocket/README.md | 11 +- Samples/WebView/README.md | 26 +- .../StreamUriResolverCS.csproj | 10 - Samples/WebWorkers/README.md | 26 +- Samples/WiFiDirect/README.md | 9 +- Samples/WiFiDirectServices/README.md | 11 +- Samples/WiFiScan/README.md | 12 +- Samples/WindowsAudioSession/README.md | 22 +- Samples/XamlAutoSuggestBox/README.md | 11 +- Samples/XamlBind/README.md | 13 +- Samples/XamlCloudFontIntegration/README.md | 9 +- Samples/XamlCommanding/README.md | 13 +- Samples/XamlContextMenu/README.md | 21 +- .../README.md | 13 +- Samples/XamlDeferLoadStrategy/README.md | 11 +- Samples/XamlDragAndDrop/README.md | 70 ++++++ .../XamlDragAndDrop/cpp/Assets/dropcursor.png | Bin 0 -> 2127 bytes .../XamlDragAndDrop/cpp/Assets/symbols.txt | 9 + .../cpp/DesignTimeResources.xaml | 6 + .../cpp/DragAndDropSampleNative.sln | 40 +++ .../cpp/DragAndDropSampleNative.vcxproj | 237 ++++++++++++++++++ .../DragAndDropSampleNative.vcxproj.filters | 72 ++++++ .../XamlDragAndDrop/cpp/Package.appxmanifest | 53 ++++ .../cpp/SampleConfiguration.cpp} | 24 +- .../cpp/SampleConfiguration.h | 29 +-- .../cpp/Scenario1_ListView.xaml | 70 ++++++ .../cpp/Scenario1_ListView.xaml.cpp | 203 +++++++++++++++ .../cpp/Scenario1_ListView.xaml.h | 43 ++++ .../cpp/Scenario2_DragUICustomization.xaml | 86 +++++++ .../Scenario2_DragUICustomization.xaml.cpp | 147 +++++++++++ .../cpp/Scenario2_DragUICustomization.xaml.h | 40 +++ .../cpp/Scenario3_StartDragAsync.xaml | 93 +++++++ .../cpp/Scenario3_StartDragAsync.xaml.cpp | 199 +++++++++++++++ .../cpp/Scenario3_StartDragAsync.xaml.h | 57 +++++ Samples/XamlDragAndDrop/cpp/pch.cpp | 5 + Samples/XamlDragAndDrop/cpp/pch.h | 10 + .../XamlDragAndDrop/cs/Assets/dropcursor.png | Bin 0 -> 2127 bytes Samples/XamlDragAndDrop/cs/Assets/symbols.txt | 9 + .../cs/DragAndDropSampleManaged.csproj | 185 ++++++++++++++ .../cs/DragAndDropSampleManaged.sln | 40 +++ .../XamlDragAndDrop/cs/Package.appxmanifest | 54 ++++ .../XamlDragAndDrop/cs/SampleConfiguration.cs | 36 +++ .../cs/Scenario1_ListView.xaml | 70 ++++++ .../cs/Scenario1_ListView.xaml.cs | 199 +++++++++++++++ .../cs/Scenario2_DragUICustomization.xaml | 85 +++++++ .../cs/Scenario2_DragUICustomization.xaml.cs | 128 ++++++++++ .../cs/Scenario3_StartDragAsync.xaml | 93 +++++++ .../cs/Scenario3_StartDragAsync.xaml.cs | 198 +++++++++++++++ Samples/XamlDragAndDrop/cs/project.json | 16 ++ Samples/XamlFocusVisuals/README.md | 11 +- Samples/XamlListView/README.md | 11 +- Samples/XamlMasterDetail/README.md | 11 +- Samples/XamlNavigation/README.md | 13 +- Samples/XamlPivot/README.md | 11 +- Samples/XamlPivot/cs/Scenario1.xaml.cs | 5 +- Samples/XamlPivot/cs/Scenario2.xaml.cs | 5 +- Samples/XamlPullToRefresh/README.md | 13 +- Samples/XamlResponsiveTechniques/README.md | 13 +- .../XamlResponsiveTechniques/cs/MainPage.xaml | 21 +- .../cs/MainPage.xaml.cs | 9 + Samples/XamlStateTriggers/README.md | 13 +- Samples/XamlTailoredMultipleViews/README.md | 22 +- Samples/XamlTransform3DAnimations/README.md | 11 +- Samples/XamlTransform3DParallax/README.md | 11 +- .../cs/Transform3DParallax.csproj | 2 +- Samples/XamlUIBasics/README.md | 13 +- .../cs/AppUIBasics/AppUIBasics.csproj | 16 +- .../Assets/contrast-black/Logo.scale-100.png | Bin 2992 -> 0 bytes .../contrast-black/SmallLogo.scale-100.png | Bin 1254 -> 0 bytes .../contrast-black/SplashScreen.scale-100.png | Bin 6678 -> 0 bytes .../contrast-black/storelogo.scale-100.png | Bin 1577 -> 0 bytes .../contrast-black/widelogo.scale-100.png | Bin 5433 -> 0 bytes .../Assets/contrast-white/Logo.scale-100.png | Bin 3177 -> 0 bytes .../contrast-white/SmallLogo.scale-100.png | Bin 1288 -> 0 bytes .../contrast-white/SplashScreen.scale-100.png | Bin 7519 -> 0 bytes .../contrast-white/storelogo.scale-100.png | Bin 1613 -> 0 bytes .../contrast-white/widelogo.scale-100.png | Bin 5433 -> 0 bytes .../cs/AppUIBasics/Package.appxmanifest | 9 +- Samples/XmlDocument/README.md | 9 +- Samples/XmlLite/README.md | 9 +- 317 files changed, 6589 insertions(+), 2910 deletions(-) delete mode 100644 Samples/AccountPictureName/README.md delete mode 100644 Samples/AccountPictureName/cpp/GetAccountPicture.xaml.cpp delete mode 100644 Samples/AccountPictureName/cpp/GetAccountPicture.xaml.h delete mode 100644 Samples/AccountPictureName/cpp/GetUserDisplayName.xaml.cpp delete mode 100644 Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.cpp delete mode 100644 Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.h delete mode 100644 Samples/AccountPictureName/cpp/SampleConfiguration.cpp delete mode 100644 Samples/AccountPictureName/cpp/SetAccountPicture.xaml.cpp delete mode 100644 Samples/AccountPictureName/cs/AccountPictureName.sln delete mode 100644 Samples/AccountPictureName/cs/GetAccountPicture.xaml.cs delete mode 100644 Samples/AccountPictureName/cs/GetUserDisplayName.xaml.cs delete mode 100644 Samples/AccountPictureName/cs/GetUserFirstAndLastName.xaml.cs delete mode 100644 Samples/AccountPictureName/cs/SampleConfiguration.cs delete mode 100644 Samples/AccountPictureName/cs/SetAccountPicture.xaml.cs delete mode 100644 Samples/AccountPictureName/js/html/getAccountPicture.html delete mode 100644 Samples/AccountPictureName/js/html/setAccountPicture.html delete mode 100644 Samples/AccountPictureName/js/html/userFirstAndLastName.html delete mode 100644 Samples/AccountPictureName/js/js/getAccountPicture.js delete mode 100644 Samples/AccountPictureName/js/js/sample-configuration.js delete mode 100644 Samples/AccountPictureName/js/js/setAccountPicture.js delete mode 100644 Samples/AccountPictureName/js/js/userDisplayName.js delete mode 100644 Samples/AccountPictureName/js/js/userFirstAndLastName.js delete mode 100644 Samples/AccountPictureName/shared/GetAccountPicture.xaml delete mode 100644 Samples/AccountPictureName/shared/SetAccountPicture.xaml create mode 100644 Samples/BackButton/README.md create mode 100644 Samples/BackButton/cs/App.xaml.cs create mode 100644 Samples/BackButton/cs/MainPage.xaml.cs create mode 100644 Samples/BackButton/cs/Package.appxmanifest create mode 100644 Samples/BackButton/cs/SampleConfiguration.cs rename Samples/{AccountPictureName/shared/GetUserDisplayName.xaml => BackButton/cs/Scenario1.xaml} (70%) create mode 100644 Samples/BackButton/cs/Scenario1.xaml.cs create mode 100644 Samples/BackButton/cs/SecondaryPage.xaml create mode 100644 Samples/BackButton/cs/SecondaryPage.xaml.cs create mode 100644 Samples/BackButton/cs/SystemBack.csproj create mode 100644 Samples/BackButton/cs/SystemBack.sln create mode 100644 Samples/DpiScaling/shared/assets/projector-stretch.png create mode 100644 Samples/DpiScaling/shared/assets/projector.scale-100.png create mode 100644 Samples/DpiScaling/shared/assets/projector.scale-140.png create mode 100644 Samples/DpiScaling/shared/assets/projector.scale-180.png create mode 100644 Samples/DpiScaling/shared/assets/projector.svg create mode 100644 Samples/DpiScaling/shared/xaml/Scenario1.xaml create mode 100644 Samples/DpiScaling/shared/xaml/Scenario2.xaml create mode 100644 Samples/UserInfo/README.md rename Samples/{AccountPictureName => UserInfo}/cpp/Package.appxmanifest (78%) create mode 100644 Samples/UserInfo/cpp/SampleConfiguration.cpp create mode 100644 Samples/UserInfo/cpp/SampleConfiguration.h create mode 100644 Samples/UserInfo/cpp/Scenario1_FindUsers.xaml.cpp rename Samples/{AccountPictureName/cpp/SetAccountPicture.xaml.h => UserInfo/cpp/Scenario1_FindUsers.xaml.h} (54%) create mode 100644 Samples/UserInfo/cpp/Scenario2_WatchUsers.xaml.cpp create mode 100644 Samples/UserInfo/cpp/Scenario2_WatchUsers.xaml.h rename Samples/{AccountPictureName/cpp/AccountPictureName.sln => UserInfo/cpp/UserInfo.sln} (93%) rename Samples/{AccountPictureName/cpp/AccountPictureName.vcxproj => UserInfo/cpp/UserInfo.vcxproj} (91%) rename Samples/{AccountPictureName/cpp/AccountPictureName.vcxproj.filters => UserInfo/cpp/UserInfo.vcxproj.filters} (76%) rename Samples/{AccountPictureName => UserInfo}/cpp/pch.cpp (100%) rename Samples/{AccountPictureName => UserInfo}/cpp/pch.h (80%) rename Samples/{AccountPictureName => UserInfo}/cs/Package.appxmanifest (78%) create mode 100644 Samples/UserInfo/cs/SampleConfiguration.cs create mode 100644 Samples/UserInfo/cs/Scenario1_FindUsers.xaml.cs create mode 100644 Samples/UserInfo/cs/Scenario2_WatchUsers.xaml.cs rename Samples/{AccountPictureName/cs/AccountPictureName.csproj => UserInfo/cs/UserInfo.csproj} (85%) create mode 100644 Samples/UserInfo/cs/UserInfo.sln rename Samples/{AccountPictureName => UserInfo}/cs/project.json (100%) rename Samples/{AccountPictureName => UserInfo}/js/Microsoft.WinJS.4.0/css/placeholder.txt (100%) rename Samples/{AccountPictureName => UserInfo}/js/Microsoft.WinJS.4.0/fonts/placeholder (100%) rename Samples/{AccountPictureName => UserInfo}/js/Microsoft.WinJS.4.0/js/en-US/placeholder.txt (100%) rename Samples/{AccountPictureName => UserInfo}/js/Package.appxmanifest (84%) rename Samples/{AccountPictureName/js/AccountPictureName.jsproj => UserInfo/js/UserInfo.jsproj} (93%) rename Samples/{AccountPictureName/js/AccountPictureName.sln => UserInfo/js/UserInfo.sln} (87%) rename Samples/{AccountPictureName => UserInfo}/js/css/placeholder.txt (100%) create mode 100644 Samples/UserInfo/js/html/scenario1-findUsers.html rename Samples/{AccountPictureName/js/html/userDisplayName.html => UserInfo/js/html/scenario2-watchUsers.html} (52%) rename Samples/{AccountPictureName => UserInfo}/js/images/placeholder.txt (100%) create mode 100644 Samples/UserInfo/js/js/sample-configuration.js create mode 100644 Samples/UserInfo/js/js/scenario1-findUsers.js create mode 100644 Samples/UserInfo/js/js/scenario2-watchUsers.js rename Samples/{AccountPictureName => UserInfo}/js/sample-utils/placeholder.txt (100%) rename Samples/{AccountPictureName/shared/GetUserFirstAndLastName.xaml => UserInfo/shared/Scenario1_FindUsers.xaml} (61%) create mode 100644 Samples/UserInfo/shared/Scenario2_WatchUsers.xaml create mode 100644 Samples/XamlDragAndDrop/README.md create mode 100644 Samples/XamlDragAndDrop/cpp/Assets/dropcursor.png create mode 100644 Samples/XamlDragAndDrop/cpp/Assets/symbols.txt create mode 100644 Samples/XamlDragAndDrop/cpp/DesignTimeResources.xaml create mode 100644 Samples/XamlDragAndDrop/cpp/DragAndDropSampleNative.sln create mode 100644 Samples/XamlDragAndDrop/cpp/DragAndDropSampleNative.vcxproj create mode 100644 Samples/XamlDragAndDrop/cpp/DragAndDropSampleNative.vcxproj.filters create mode 100644 Samples/XamlDragAndDrop/cpp/Package.appxmanifest rename Samples/{AccountPictureName/cpp/GetUserDisplayName.xaml.h => XamlDragAndDrop/cpp/SampleConfiguration.cpp} (54%) rename Samples/{AccountPictureName => XamlDragAndDrop}/cpp/SampleConfiguration.h (54%) create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario1_ListView.xaml create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario1_ListView.xaml.cpp create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario1_ListView.xaml.h create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario2_DragUICustomization.xaml create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario2_DragUICustomization.xaml.cpp create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario2_DragUICustomization.xaml.h create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario3_StartDragAsync.xaml create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario3_StartDragAsync.xaml.cpp create mode 100644 Samples/XamlDragAndDrop/cpp/Scenario3_StartDragAsync.xaml.h create mode 100644 Samples/XamlDragAndDrop/cpp/pch.cpp create mode 100644 Samples/XamlDragAndDrop/cpp/pch.h create mode 100644 Samples/XamlDragAndDrop/cs/Assets/dropcursor.png create mode 100644 Samples/XamlDragAndDrop/cs/Assets/symbols.txt create mode 100644 Samples/XamlDragAndDrop/cs/DragAndDropSampleManaged.csproj create mode 100644 Samples/XamlDragAndDrop/cs/DragAndDropSampleManaged.sln create mode 100644 Samples/XamlDragAndDrop/cs/Package.appxmanifest create mode 100644 Samples/XamlDragAndDrop/cs/SampleConfiguration.cs create mode 100644 Samples/XamlDragAndDrop/cs/Scenario1_ListView.xaml create mode 100644 Samples/XamlDragAndDrop/cs/Scenario1_ListView.xaml.cs create mode 100644 Samples/XamlDragAndDrop/cs/Scenario2_DragUICustomization.xaml create mode 100644 Samples/XamlDragAndDrop/cs/Scenario2_DragUICustomization.xaml.cs create mode 100644 Samples/XamlDragAndDrop/cs/Scenario3_StartDragAsync.xaml create mode 100644 Samples/XamlDragAndDrop/cs/Scenario3_StartDragAsync.xaml.cs create mode 100644 Samples/XamlDragAndDrop/cs/project.json delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-black/Logo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-black/SmallLogo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-black/SplashScreen.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-black/storelogo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-black/widelogo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-white/Logo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-white/SmallLogo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-white/SplashScreen.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-white/storelogo.scale-100.png delete mode 100644 Samples/XamlUIBasics/cs/AppUIBasics/Assets/contrast-white/widelogo.scale-100.png diff --git a/.gitattributes b/.gitattributes index 5aec15cdd7..39d53163de 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,8 +19,10 @@ *.inf text eol=crlf *.inx text eol=crlf *.js text eol=crlf +*.json text eol=crlf *.jsproj text eol=crlf *.rc text eol=crlf +*.resjson text eol=crlf *.rgs text eol=crlf *.sln text eol=crlf *.vcxproj text eol=crlf diff --git a/README.md b/README.md index 37876aaebb..4b4ce0dc1f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Universal Windows app samples + This repo contains the samples that demonstrate the API usage patterns for the Universal Windows Platform (UWP) in the Windows Software Development Kit (SDK) for Windows 10. These code samples were created with the Universal Windows templates available in Visual Studio, and are designed to run on desktop, mobile, and future devices that support the Universal Windows Platform. ## Universal Windows Platform development + These samples require Visual Studio 2015 and the Windows Software Development Kit (SDK) for Windows 10 to build, test, and deploy your Universal Windows apps. [Get a free copy of Visual Studio 2015 Community Edition with support for building Universal Windows apps](http://go.microsoft.com/fwlink/?LinkID=280676) @@ -11,17 +13,30 @@ Additionally, to stay on top of the latest updates to Windows and the developmen [Become a Windows Insider](https://insider.windows.com/) ## Using the samples -The easiest way to use these samples without using Git is to download the zip file containing the current version (using the link below or by clicking the "Download ZIP" button on the repo page). You can then unzip the samples and use them in Visual Studio 2015. + +The easiest way to use these samples without using Git is to download the zip file containing the current version (using the link below or by clicking the "Download ZIP" button on the repo page). You can then unzip the entire archive and use the samples in Visual Studio 2015. [Download the samples ZIP](../../archive/master.zip) + **Notes:** + * Before you unzip the archive, right-click it, select Properties, and then select Unblock. + * Be sure to unzip the entire archive, and not just individual samples. The samples all depend on the SharedContent folder in the archive. + * In Visual Studio 2015, the platform target defaults to ARM, so be sure to change that to x64 or x86 if you want to test on a non-ARM device. + The samples use Linked files in Visual Studio to reduce duplication of common files, including sample template files and image assets. These common files are stored in the SharedContent folder at the root of the repository and referred to in the project files using links. +**Reminder:** If you unzip individual samples, they will not build due to references to other portions of the ZIP file that were not unzipped. You must unzip the entire archive if you intend to build the samples. + For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, please refer to the guidance, tutorials, and reference topics provided in the Windows 10 documentation available in the [Windows Developer Center](https://dev.windows.com). These samples are provided as-is in order to indicate or demonstrate the functionality of the programming models and feature APIs for Windows. ## Contributions + These samples are direct from the feature teams and we welcome your input on issues and suggestions for new samples. At this time we are not accepting new samples from the public, but check back here as we evolve our contribution model. +## See also + +For additional Windows samples, see [Windows on GitHub](http://microsoft.github.io/windows/). + ## Samples by category @@ -116,44 +131,45 @@ These samples are direct from the feature teams and we welcome your input on iss - + + - + - + - + - + - + - + - +
Context menu (XAML) Downloadable fonts (DirectWrite)Line spacing (DirectWrite)Drag and drop
Line spacing (DirectWrite) Focus visuals Full screen modeHTML WebView control
HTML WebView control ListView and GridView Lock screen appsMessage dialog
Message dialog Multiple views OCRPrinting
Printing Pull to refresh Window resizingScaling according to DPI
Scaling according to DPI Splash screen State triggersTitle bar
Title bar Disabling selection User interaction modeCommanding
Commanding Downloadable fonts (XAML) Responsiveness techniquesTailored multiple views
Tailored multiple views XAML UI basics
@@ -212,10 +228,10 @@ These samples are direct from the feature teams and we welcome your input on iss Accelerometer Activity detection sensor - AllJoyn consumer experiences + AllJoyn Consumer experiences - AllJoyn producer experiences + AllJoyn Producer experiences Altimeter Background sensors @@ -334,7 +350,7 @@ These samples are direct from the feature teams and we welcome your input on iss Identity, security, and encryption - Account picture name + User information Credential locker Credential picker @@ -376,11 +392,12 @@ These samples are direct from the feature teams and we welcome your input on iss Navigation + Back Button Master/detail Pivot - Projection + Projection XAML navigation menu XHR, handling navigation errors, and URL schemes @@ -451,7 +468,7 @@ These samples are direct from the feature teams and we welcome your input on iss Tiles, toasts, and notifications - Badge + Notifications Secondary tiles \ No newline at end of file diff --git a/Samples/Accelerometer/README.md b/Samples/Accelerometer/README.md index 4c5b435a4e..fc88df7d5c 100644 --- a/Samples/Accelerometer/README.md +++ b/Samples/Accelerometer/README.md @@ -1,4 +1,4 @@ - @@ -54,9 +54,10 @@ When you choose the **Enable** button for the **Data Events** option, the app be ## Build the sample -1. Start Microsoft Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**. -2. Go to the directory to which you unzipped the sample. Then go to the subdirectory containing the sample in the language you desire - either C++ or C\#. Double-click the Visual Studio 2015 Solution (.sln) file. -3. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. +1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build. +2. Start Microsoft Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**. +3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample, then the subfolder for your preferred language (C++, C#, or JavaScript). Double-click the Visual Studio 2015 Solution (.sln) file. +4. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. ## Run the sample diff --git a/Samples/AccountPictureName/README.md b/Samples/AccountPictureName/README.md deleted file mode 100644 index 789d459ba8..0000000000 --- a/Samples/AccountPictureName/README.md +++ /dev/null @@ -1,53 +0,0 @@ - -# Account picture name sample - -This sample demonstrates different ways of getting the name of the user that is currently logged in. It also demonstrates how to get and set the image used for the user's tile. - -Specifically, this sample demonstrates the following scenarios: - -- How to get the [**DisplayName**](http://msdn.microsoft.com/library/windows/apps/hh921595) for the current logged on user. -- How to get the first and last name for the current logged on user. (This is available only for Microsoft accounts. An empty string is returned if a Microsoft account is not available.) -- How to obtain the logged on user's account picture as a bitmap. You can get request three different types: small, large, and video. If the size that is requested is not available an empty file is returned. -- How to set the account picture for the currently logged on user. You can set three different types: small, large, and video. (More than one type can be set in the same call, but a small image must be accompanied by a large image and/or video.) -- How to register for a change event for account picture updates. - -**Note** The Universal Windows app samples require Visual Studio 2015 to build and Windows 10 to execute. - -To obtain information about Windows 10, go to [Windows 10](http://go.microsoft.com/fwlink/?LinkID=532421) - -To obtain information about Microsoft Visual Studio 2015 and the tools for developing Windows apps, go to [Visual Studio 2015](http://go.microsoft.com/fwlink/?LinkID=532422) - -## Related topics - -### Reference - -[**Windows.System.UserProfile** namespace](http://msdn.microsoft.com/library/windows/apps/br241881) - -## System requirements - -**Client:** Windows 10 - -**Server:** Windows Server 2016 Technical Preview - -**Phone:** Not supported - -## Build the sample - -1. Start Microsoft Visual Studio 2015 and select **File** \> **Open** \> **Project/Solution**. -2. Go to the directory to which you unzipped the sample. Then go to the subdirectory containing the sample in the language you desire - either C++, C#, or JavaScript. Double-click the Visual Studio 2015 Solution (.sln) file. -3. Press Ctrl+Shift+B, or select **Build** \> **Build Solution**. - -## Run the sample - -The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it. - -### Deploying the sample - -- Select Build > Deploy Solution. - -### Deploying and running the sample - -- To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging. - diff --git a/Samples/AccountPictureName/cpp/GetAccountPicture.xaml.cpp b/Samples/AccountPictureName/cpp/GetAccountPicture.xaml.cpp deleted file mode 100644 index 6570deefcc..0000000000 --- a/Samples/AccountPictureName/cpp/GetAccountPicture.xaml.cpp +++ /dev/null @@ -1,155 +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. -// -//********************************************************* - -#include "pch.h" -#include "GetAccountPicture.xaml.h" - -using namespace SDKTemplate; - -using namespace concurrency; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Storage; -using namespace Windows::Storage::Streams; -using namespace Windows::System::UserProfile; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Media::Imaging; -using namespace Windows::UI::Xaml::Navigation; - -GetAccountPicture::GetAccountPicture() : rootPage(MainPage::Current) -{ - InitializeComponent(); -} - -void GetAccountPicture::GetSmallImageButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - HideImageAndVideoControls(); - - if (UserInformation::NameAccessAllowed) - { - auto smallImageFile = UserInformation::GetAccountPicture(AccountPictureKind::SmallImage); - if (smallImageFile != nullptr) - { - rootPage->NotifyUser("Path = " + smallImageFile->Path, NotifyType::StatusMessage); - create_task(smallImageFile->OpenReadAsync()).then( - [this](task imageStreamTask) - { - try - { - auto imageStream = imageStreamTask.get(); - auto bitmapImage = ref new BitmapImage(); - bitmapImage->SetSource(imageStream); - SmallImage->Source = bitmapImage; - SmallImage->Visibility = Windows::UI::Xaml::Visibility::Visible; - } - catch (Exception^ ex) - { - rootPage->NotifyUser("Error opening stream: " + ex->Message, NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("Small account picture is not available.", NotifyType::ErrorMessage); - } - } - else - { - rootPage->NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } -} - -void GetAccountPicture::GetLargeImageButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - HideImageAndVideoControls(); - - if (UserInformation::NameAccessAllowed) - { - auto largeImageFile = UserInformation::GetAccountPicture(AccountPictureKind::LargeImage); - if (largeImageFile != nullptr) - { - rootPage->NotifyUser("Path = " + largeImageFile->Path, NotifyType::StatusMessage); - create_task(largeImageFile->OpenReadAsync()).then( - [this](task imageStreamTask) - { - try - { - auto imageStream = imageStreamTask.get(); - auto bitmapImage = ref new BitmapImage(); - bitmapImage->SetSource(imageStream); - LargeImage->Source = bitmapImage; - LargeImage->Visibility = Windows::UI::Xaml::Visibility::Visible; - } - catch (Exception^ ex) - { - rootPage->NotifyUser("Error opening stream: " + ex->Message, NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("No large account picture image returned for current user.", NotifyType::ErrorMessage); - } - } - else - { - rootPage->NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } -} - -void GetAccountPicture::GetVideoButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - HideImageAndVideoControls(); - - if (UserInformation::NameAccessAllowed) - { - auto videoFile = UserInformation::GetAccountPicture(AccountPictureKind::Video); - if (videoFile != nullptr) - { - rootPage->NotifyUser("Path = " + videoFile->Path, NotifyType::StatusMessage); - create_task(videoFile->OpenReadAsync()).then( - [this](task videoStreamTask) - { - try - { - auto videoStream = videoStreamTask.get(); - MediaPlayer->SetSource(videoStream, "video/mp4"); - MediaPlayer->Visibility = Windows::UI::Xaml::Visibility::Visible; - } - catch (Exception^ ex) - { - rootPage->NotifyUser("Error opening stream: " + ex->Message, NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("Video is not available.", NotifyType::ErrorMessage); - } - } - else - { - rootPage->NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } -} - -void GetAccountPicture::HideImageAndVideoControls() -{ - SmallImage->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - LargeImage->Visibility = Windows::UI::Xaml::Visibility::Collapsed; - MediaPlayer->Visibility = Windows::UI::Xaml::Visibility::Collapsed; -} diff --git a/Samples/AccountPictureName/cpp/GetAccountPicture.xaml.h b/Samples/AccountPictureName/cpp/GetAccountPicture.xaml.h deleted file mode 100644 index 0d6ad31bd4..0000000000 --- a/Samples/AccountPictureName/cpp/GetAccountPicture.xaml.h +++ /dev/null @@ -1,31 +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. -// -//********************************************************* - -#pragma once - -#include "GetAccountPicture.g.h" -#include "MainPage.xaml.h" - -namespace SDKTemplate -{ - [Windows::Foundation::Metadata::WebHostHidden] - public ref class GetAccountPicture sealed - { - public: - GetAccountPicture(); - private: - MainPage^ rootPage; - void GetSmallImageButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - void GetLargeImageButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - void GetVideoButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - void HideImageAndVideoControls(); - }; -} diff --git a/Samples/AccountPictureName/cpp/GetUserDisplayName.xaml.cpp b/Samples/AccountPictureName/cpp/GetUserDisplayName.xaml.cpp deleted file mode 100644 index ecc0c71d6c..0000000000 --- a/Samples/AccountPictureName/cpp/GetUserDisplayName.xaml.cpp +++ /dev/null @@ -1,55 +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. -// -//********************************************************* - -#include "pch.h" -#include "GetUserDisplayName.xaml.h" - -using namespace SDKTemplate; - -using namespace concurrency; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::System::UserProfile; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -GetUserDisplayName::GetUserDisplayName() : rootPage(SDKTemplate::MainPage::Current) -{ - InitializeComponent(); -} - -void GetUserDisplayName::GetDisplayNameButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - if (UserInformation::NameAccessAllowed) - { - create_task(UserInformation::GetDisplayNameAsync()).then([this](String^ displayName) - { - if (displayName != nullptr) - { - rootPage->NotifyUser("Display name = " + displayName, NotifyType::StatusMessage); - } - else - { - rootPage->NotifyUser("No display name was returned.", NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("Access to name disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } -} diff --git a/Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.cpp b/Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.cpp deleted file mode 100644 index d1fa5cda87..0000000000 --- a/Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.cpp +++ /dev/null @@ -1,77 +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. -// -//********************************************************* - -#include "pch.h" -#include "GetUserFirstAndLastName.xaml.h" - -using namespace SDKTemplate; - -using namespace concurrency; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::System::UserProfile; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -GetUserFirstAndLastName::GetUserFirstAndLastName() : rootPage(MainPage::Current) -{ - InitializeComponent(); -} - -void GetUserFirstAndLastName::GetFirstNameButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - if (UserInformation::NameAccessAllowed) - { - create_task(UserInformation::GetFirstNameAsync()).then([this](String^ firstName) - { - if (firstName != nullptr) - { - rootPage->NotifyUser("First name = " + firstName, NotifyType::StatusMessage); - } - else - { - rootPage->NotifyUser("No first name was returned.", NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("Access to name disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } -} - -void GetUserFirstAndLastName::GetLastNameButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - if (UserInformation::NameAccessAllowed) - { - create_task(UserInformation::GetLastNameAsync()).then([this](String^ lastName) - { - if (lastName != nullptr) - { - rootPage->NotifyUser("Last name = " + lastName, NotifyType::StatusMessage); - } - else - { - rootPage->NotifyUser("No last name was returned.", NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("Access to name disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } -} diff --git a/Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.h b/Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.h deleted file mode 100644 index c337a2bb0f..0000000000 --- a/Samples/AccountPictureName/cpp/GetUserFirstAndLastName.xaml.h +++ /dev/null @@ -1,29 +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. -// -//********************************************************* - -#pragma once - -#include "GetUserFirstAndLastName.g.h" -#include "MainPage.xaml.h" - -namespace SDKTemplate -{ - [Windows::Foundation::Metadata::WebHostHidden] - public ref class GetUserFirstAndLastName sealed - { - public: - GetUserFirstAndLastName(); - private: - MainPage^ rootPage; - void GetFirstNameButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - void GetLastNameButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); - }; -} diff --git a/Samples/AccountPictureName/cpp/SampleConfiguration.cpp b/Samples/AccountPictureName/cpp/SampleConfiguration.cpp deleted file mode 100644 index a28a93699c..0000000000 --- a/Samples/AccountPictureName/cpp/SampleConfiguration.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. - -#include "pch.h" -#include "MainPage.xaml.h" -#include "SampleConfiguration.h" - -using namespace SDKTemplate; -using namespace Platform; -using namespace Windows::ApplicationModel; -using namespace Windows::ApplicationModel::Activation; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Interop; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Navigation; - -Platform::Array^ MainPage::scenariosInner = ref new Platform::Array -{ - { "Get display name", "SDKTemplate.GetUserDisplayName" }, - { "Get first and last name", "SDKTemplate.GetUserFirstAndLastName" }, - { "Get account picture", "SDKTemplate.GetAccountPicture" }, - { "Set account picture and listen for changes", "SDKTemplate.SetAccountPicture" } -}; - -void App::OnActivated(IActivatedEventArgs^ args) -{ - // Check to see if the app was activated via a protocol - if (args->Kind == ActivationKind::Protocol) - { - auto protocolArgs = safe_cast(args); - if (protocolArgs->Uri->SchemeName->Equals("ms-accountpictureprovider")) - { - if (Window::Current->Content == nullptr) - { - auto rootFrame = ref new Frame(); - TypeName pageType = { "SDKTemplate.MainPage", TypeKind::Custom }; - rootFrame->Navigate(pageType); - Window::Current->Content = rootFrame; - Window::Current->Activate(); - } - - MainPage::Current->NavigateToScenario("SDKTemplate.SetAccountPicture"); - } - } -} diff --git a/Samples/AccountPictureName/cpp/SetAccountPicture.xaml.cpp b/Samples/AccountPictureName/cpp/SetAccountPicture.xaml.cpp deleted file mode 100644 index 4b565f9ff7..0000000000 --- a/Samples/AccountPictureName/cpp/SetAccountPicture.xaml.cpp +++ /dev/null @@ -1,160 +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. -// -//********************************************************* - -#include "pch.h" -#include "SetAccountPicture.xaml.h" - -using namespace SDKTemplate; - -using namespace concurrency; -using namespace Platform; -using namespace Windows::Foundation; -using namespace Windows::Foundation::Collections; -using namespace Windows::Storage; -using namespace Windows::Storage::Streams; -using namespace Windows::Storage::Pickers; -using namespace Windows::System::UserProfile; -using namespace Windows::UI::Core; -using namespace Windows::UI::Xaml; -using namespace Windows::UI::Xaml::Controls; -using namespace Windows::UI::Xaml::Controls::Primitives; -using namespace Windows::UI::Xaml::Data; -using namespace Windows::UI::Xaml::Input; -using namespace Windows::UI::Xaml::Media; -using namespace Windows::UI::Xaml::Media::Imaging; -using namespace Windows::UI::Xaml::Navigation; - -SetAccountPicture::SetAccountPicture() : rootPage(MainPage::Current) -{ - InitializeComponent(); -} - -void SetAccountPicture::OnNavigatedTo(NavigationEventArgs^ e) -{ - accountPictureChangedToken = UserInformation::AccountPictureChanged += ref new EventHandler(this, &SetAccountPicture::PictureChanged); -} - -void SetAccountPicture::OnNavigatedFrom(NavigationEventArgs^ e) -{ - UserInformation::AccountPictureChanged -= accountPictureChangedToken; -} - -void SetAccountPicture::SetImageButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - FileOpenPicker^ imagePicker = ref new FileOpenPicker(); - imagePicker->ViewMode = PickerViewMode::Thumbnail; - imagePicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary; - imagePicker->FileTypeFilter->Append(".jpg"); - imagePicker->FileTypeFilter->Append(".jpeg"); - imagePicker->FileTypeFilter->Append(".png"); - imagePicker->FileTypeFilter->Append(".bmp"); - - create_task(imagePicker->PickSingleFileAsync()).then( - [this](StorageFile^ imageFile) - { - if (imageFile != nullptr) - { - rootPage->NotifyUser("Setting " + imageFile->Name + " as account picture ...", - NotifyType::StatusMessage); - create_task(UserInformation::SetAccountPictureAsync(imageFile)).then( - [this](SetAccountPictureResult setPictureResult) - { - if (setPictureResult == SetAccountPictureResult::Success) - { - rootPage->NotifyUser("Successfully updated account picture.", NotifyType::StatusMessage); - } - else - { - rootPage->NotifyUser("Setting account picture failed.", NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("No image was selected.", NotifyType::StatusMessage); - } - }); -} - -void SetAccountPicture::SetVideoButton_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e) -{ - FileOpenPicker^ videoPicker = ref new FileOpenPicker(); - videoPicker->ViewMode = PickerViewMode::Thumbnail; - videoPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary; - videoPicker->FileTypeFilter->Append(".mp4"); - videoPicker->FileTypeFilter->Append(".wmv"); - videoPicker->FileTypeFilter->Append(".mpeg"); - videoPicker->FileTypeFilter->Append(".mov"); - - create_task(videoPicker->PickSingleFileAsync()).then( - [this](StorageFile^ videoFile) - { - if (videoFile != nullptr) - { - rootPage->NotifyUser("Setting " + videoFile->Name + " as account picture ...", - NotifyType::StatusMessage); - create_task(UserInformation::SetAccountPictureAsync(videoFile)).then( - [this](SetAccountPictureResult setPictureResult) - { - if (setPictureResult == SetAccountPictureResult::Success) - { - rootPage->NotifyUser("Successfully updated account picture.", NotifyType::StatusMessage); - } - else - { - rootPage->NotifyUser("Setting account picture failed.", NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("No video was selected.", NotifyType::StatusMessage); - } - }); -} - -void SetAccountPicture::PictureChanged(Platform::Object^ sender, Platform::Object^ e) -{ - Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() - { - if (UserInformation::NameAccessAllowed) - { - auto largeImageFile = UserInformation::GetAccountPicture(AccountPictureKind::LargeImage); - if (largeImageFile != nullptr) - { - create_task(largeImageFile->OpenReadAsync()).then( - [this](task imageStreamTask) - { - try - { - auto imageStream = imageStreamTask.get(); - auto bitmapImage = ref new BitmapImage(); - bitmapImage->SetSource(imageStream); - AccountPictureImage->Source = bitmapImage; - AccountPictureImage->Visibility = Windows::UI::Xaml::Visibility::Visible; - } - catch (Exception^ ex) - { - rootPage->NotifyUser("Failed to read from stream. " + ex->Message, NotifyType::ErrorMessage); - } - }); - } - else - { - rootPage->NotifyUser("No large account picture image returned for current user.", NotifyType::ErrorMessage); - } - } - else - { - rootPage->NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType::ErrorMessage); - } - })); -} diff --git a/Samples/AccountPictureName/cs/AccountPictureName.sln b/Samples/AccountPictureName/cs/AccountPictureName.sln deleted file mode 100644 index 8924a9375e..0000000000 --- a/Samples/AccountPictureName/cs/AccountPictureName.sln +++ /dev/null @@ -1,43 +0,0 @@ - - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.22609.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AccountPictureName", "AccountPictureName.csproj", "{CF1CD0D5-BF6B-457A-9927-8079FC667CA4}" -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 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|ARM.ActiveCfg = Debug|ARM - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|ARM.Build.0 = Debug|ARM - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|ARM.Deploy.0 = Debug|ARM - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|x64.ActiveCfg = Debug|x64 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|x64.Build.0 = Debug|x64 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|x64.Deploy.0 = Debug|x64 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|x86.ActiveCfg = Debug|x86 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|x86.Build.0 = Debug|x86 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Debug|x86.Deploy.0 = Debug|x86 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|ARM.ActiveCfg = Release|ARM - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|ARM.Build.0 = Release|ARM - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|ARM.Deploy.0 = Release|ARM - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|x64.ActiveCfg = Release|x64 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|x64.Build.0 = Release|x64 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|x64.Deploy.0 = Release|x64 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|x86.ActiveCfg = Release|x86 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|x86.Build.0 = Release|x86 - {CF1CD0D5-BF6B-457A-9927-8079FC667CA4}.Release|x86.Deploy.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal - - diff --git a/Samples/AccountPictureName/cs/GetAccountPicture.xaml.cs b/Samples/AccountPictureName/cs/GetAccountPicture.xaml.cs deleted file mode 100644 index 53a4af871a..0000000000 --- a/Samples/AccountPictureName/cs/GetAccountPicture.xaml.cs +++ /dev/null @@ -1,151 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; -using System; -using Windows.Storage; -using Windows.Storage.Streams; -using Windows.UI.Xaml.Media.Imaging; -using Windows.System.UserProfile; - -namespace SDKTemplate -{ - public sealed partial class GetAccountPicture : Page - { - private MainPage rootPage; - - public GetAccountPicture() - { - this.InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - rootPage = MainPage.Current; - } - - private async void GetSmallImageButton_Click(object sender, RoutedEventArgs e) - { - HideImageAndVideoControls(); - - if (UserInformation.NameAccessAllowed) - { - // The small picture returned by GetAccountPicture() is 96x96 pixels in size. - StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.SmallImage) as StorageFile; - if (image != null) - { - rootPage.NotifyUser("Path = " + image.Path, NotifyType.StatusMessage); - - try - { - IRandomAccessStream imageStream = await image.OpenReadAsync(); - BitmapImage bitmapImage = new BitmapImage(); - bitmapImage.SetSource(imageStream); - SmallImage.Source = bitmapImage; - SmallImage.Visibility = Visibility.Visible; - } - catch (Exception ex) - { - rootPage.NotifyUser("Error opening stream: " + ex.ToString(), NotifyType.ErrorMessage); - } - } - else - { - rootPage.NotifyUser("Small account picture is not available.", NotifyType.StatusMessage); - } - } - else - { - rootPage.NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType.ErrorMessage); - } - } - - private async void GetLargeImageButton_Click(object sender, RoutedEventArgs e) - { - HideImageAndVideoControls(); - - if (UserInformation.NameAccessAllowed) - { - // The large picture returned by GetAccountPicture() is 448x448 pixels in size. - StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.LargeImage) as StorageFile; - if (image != null) - { - rootPage.NotifyUser("Path = " + image.Path, NotifyType.StatusMessage); - - try - { - IRandomAccessStream imageStream = await image.OpenReadAsync(); - BitmapImage bitmapImage = new BitmapImage(); - bitmapImage.SetSource(imageStream); - LargeImage.Source = bitmapImage; - LargeImage.Visibility = Visibility.Visible; - } - catch (Exception ex) - { - rootPage.NotifyUser("Error opening stream: " + ex.ToString(), NotifyType.ErrorMessage); - } - } - else - { - rootPage.NotifyUser("Large account picture is not available.", NotifyType.StatusMessage); - } - } - else - { - rootPage.NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType.ErrorMessage); - } - } - - private async void GetVideoButton_Click(object sender, RoutedEventArgs e) - { - HideImageAndVideoControls(); - - if (UserInformation.NameAccessAllowed) - { - // The video returned from getAccountPicture is 448x448 pixels in size. - StorageFile video = UserInformation.GetAccountPicture(AccountPictureKind.Video) as StorageFile; - if (video != null) - { - rootPage.NotifyUser("Path: " + video.Path, NotifyType.StatusMessage); - - try - { - IRandomAccessStream videoStream = await video.OpenAsync(FileAccessMode.Read); - MediaPlayer.SetSource(videoStream, "video/mp4"); - MediaPlayer.Visibility = Visibility.Visible; - } - catch (Exception ex) - { - rootPage.NotifyUser("Error opening stream: " + ex.ToString(), NotifyType.ErrorMessage); - } - } - else - { - rootPage.NotifyUser("Video is not available.", NotifyType.StatusMessage); - } - } - else - { - rootPage.NotifyUser("Access to account picture disabled by Privacy Setting or Group Policy.", NotifyType.ErrorMessage); - } - } - - private void HideImageAndVideoControls() - { - SmallImage.Visibility = Visibility.Collapsed; - LargeImage.Visibility = Visibility.Collapsed; - MediaPlayer.Visibility = Visibility.Collapsed; - } - - } -} diff --git a/Samples/AccountPictureName/cs/GetUserDisplayName.xaml.cs b/Samples/AccountPictureName/cs/GetUserDisplayName.xaml.cs deleted file mode 100644 index 9288f48a59..0000000000 --- a/Samples/AccountPictureName/cs/GetUserDisplayName.xaml.cs +++ /dev/null @@ -1,54 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; -using System; -using Windows.System.UserProfile; - -namespace SDKTemplate -{ - public sealed partial class GetUserDisplayName : Page - { - private MainPage rootPage; - - public GetUserDisplayName() - { - this.InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - rootPage = MainPage.Current; - } - - private async void GetDisplayNameButton_Click(object sender, RoutedEventArgs e) - { - if (UserInformation.NameAccessAllowed) - { - string displayName = await UserInformation.GetDisplayNameAsync(); - if (string.IsNullOrEmpty(displayName)) - { - rootPage.NotifyUser("No display name was returned.", NotifyType.StatusMessage); - } - else - { - rootPage.NotifyUser("Display name = " + displayName, NotifyType.StatusMessage); - } - } - else - { - rootPage.NotifyUser("Access to name disabled by Privacy Setting or Group Policy.", NotifyType.ErrorMessage); - } - } - } -} diff --git a/Samples/AccountPictureName/cs/GetUserFirstAndLastName.xaml.cs b/Samples/AccountPictureName/cs/GetUserFirstAndLastName.xaml.cs deleted file mode 100644 index ba1643b7b7..0000000000 --- a/Samples/AccountPictureName/cs/GetUserFirstAndLastName.xaml.cs +++ /dev/null @@ -1,74 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; -using System; -using Windows.System.UserProfile; - -namespace SDKTemplate -{ - public sealed partial class GetUserFirstAndLastName : Page - { - private MainPage rootPage; - - public GetUserFirstAndLastName() - { - this.InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - rootPage = MainPage.Current; - } - - private async void GetFirstNameButton_Click(object sender, RoutedEventArgs e) - { - if (UserInformation.NameAccessAllowed) - { - string firstName = await UserInformation.GetFirstNameAsync(); - if (string.IsNullOrEmpty(firstName)) - { - rootPage.NotifyUser("No first name was returned.", NotifyType.StatusMessage); - } - else - { - rootPage.NotifyUser("First name = " + firstName, NotifyType.StatusMessage); - } - } - else - { - rootPage.NotifyUser("Access to name disabled by Privacy Setting or Group Policy.", NotifyType.ErrorMessage); - } - } - - private async void GetLastNameButton_Click(object sender, RoutedEventArgs e) - { - if (UserInformation.NameAccessAllowed) - { - string lastName = await UserInformation.GetLastNameAsync(); - if (string.IsNullOrEmpty(lastName)) - { - rootPage.NotifyUser("No last name was returned.", NotifyType.StatusMessage); - } - else - { - rootPage.NotifyUser("Last name = " + lastName, NotifyType.StatusMessage); - } - } - else - { - rootPage.NotifyUser("Access to name disabled by Privacy Setting or Group Policy.", NotifyType.ErrorMessage); - } - } - } -} diff --git a/Samples/AccountPictureName/cs/SampleConfiguration.cs b/Samples/AccountPictureName/cs/SampleConfiguration.cs deleted file mode 100644 index acbb82e6ef..0000000000 --- a/Samples/AccountPictureName/cs/SampleConfiguration.cs +++ /dev/null @@ -1,82 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using System; -using System.Collections.Generic; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - -namespace SDKTemplate -{ - public partial class MainPage : Page - { - public const string FEATURE_NAME = "Account picture name C# sample"; - - List scenarios = new List - { - new Scenario() { Title = "Get display name", ClassType = typeof(GetUserDisplayName) }, - new Scenario() { Title = "Get first and last name", ClassType = typeof(GetUserFirstAndLastName) }, - new Scenario() { Title = "Get account picture", ClassType = typeof(GetAccountPicture) }, - new Scenario() { Title = "Set account picture and listen for changes", ClassType = typeof(SetAccountPicture) } - }; - - public void NavigateToScenario(Type type) - { - for (int index = 0; index < scenarios.Count; index++) - { - if (scenarios[index].ClassType == type) - { - ScenarioControl.SelectedIndex = index; - break; - } - } - } - } - - public class Scenario - { - public string Title { get; set; } - public Type ClassType { get; set; } - } - - /// - /// Provides sample-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - protected override void OnActivated(IActivatedEventArgs args) - { - // Check to see if the app was activated via a protocol - if (args.Kind == ActivationKind.Protocol) - { - var protocolArgs = (ProtocolActivatedEventArgs)args; - - // This app was activated via the Account picture apps section in PC Settings / Personalize / Account picture. - // Here you would do app-specific logic so that the user receives account picture selection UX. - if (protocolArgs.Uri.Scheme == "ms-accountpictureprovider") - { - // The Content might be null if App has not yet been activated, if so first activate the main page. - if (Window.Current.Content == null) - { - Frame rootFrame = new Frame(); - rootFrame.Navigate(typeof(MainPage)); - Window.Current.Content = rootFrame; - Window.Current.Activate(); - } - MainPage.Current.NavigateToScenario(typeof(SDKTemplate.SetAccountPicture)); - } - } - } - } -} diff --git a/Samples/AccountPictureName/cs/SetAccountPicture.xaml.cs b/Samples/AccountPictureName/cs/SetAccountPicture.xaml.cs deleted file mode 100644 index a6cfa5be6f..0000000000 --- a/Samples/AccountPictureName/cs/SetAccountPicture.xaml.cs +++ /dev/null @@ -1,158 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; -using System; - -using System.Linq; -using System.Collections.Generic; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.Graphics.Display; -using Windows.UI.ViewManagement; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Core; -using Windows.Storage.Pickers; -using Windows.Storage; -using Windows.Storage.Streams; -using Windows.UI.Xaml.Media.Imaging; -using Windows.System.UserProfile; - - -namespace SDKTemplate -{ - /// - /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class SetAccountPicture : Page - { - MainPage rootPage = MainPage.Current; - - public SetAccountPicture() - { - this.InitializeComponent(); - } - - protected override void OnNavigatedTo(NavigationEventArgs e) - { - rootPage = MainPage.Current; - - //Listen to AccountPictureChanged event - UserInformation.AccountPictureChanged += this.PictureChanged; - } - - protected override void OnNavigatedFrom(NavigationEventArgs e) - { - //Remove listener to AccountPictureChanged event - UserInformation.AccountPictureChanged -= this.PictureChanged; - } - - private async void SetImageButton_Click(object sender, RoutedEventArgs e) - { - - FileOpenPicker imagePicker = new FileOpenPicker - { - ViewMode = PickerViewMode.Thumbnail, - SuggestedStartLocation = PickerLocationId.PicturesLibrary, - FileTypeFilter = { ".jpg", ".jpeg", ".png", ".bmp" } - }; - - StorageFile imageFile = await imagePicker.PickSingleFileAsync(); - if (imageFile != null) - { - // SetAccountPictureAsync() accepts 3 storageFile objects for setting the small image, large image, and video. - // More than one type can be set in the same call, but a small image must be accompanied by a large image and/or video. - // If only a large image is passed, the small image will be autogenerated. - // If only a video is passed, the large image and small will be autogenerated. - // Videos must be convertable to mp4, <=5MB, and height and width >= 448 pixels. - - // Setting the Account Picture will fail if user disallows it in PC Settings. - SetAccountPictureResult result = await UserInformation.SetAccountPicturesAsync(null, imageFile, null); - if (result == SetAccountPictureResult.Success) - { - rootPage.NotifyUser("Account picture was successfully changed.", NotifyType.StatusMessage); - } - else - { - rootPage.NotifyUser("Account picture could not be changed.", NotifyType.StatusMessage); - AccountPictureImage.Visibility = Visibility.Collapsed; - } - } - } - - private async void SetVideoButton_Click(object sender, RoutedEventArgs e) - { - FileOpenPicker videoPicker = new FileOpenPicker - { - ViewMode = PickerViewMode.Thumbnail, - SuggestedStartLocation = PickerLocationId.VideosLibrary, - FileTypeFilter = { ".mp4", ".mpeg", ".wmv", ".mov" } - }; - - StorageFile videoFile = await videoPicker.PickSingleFileAsync(); - if (videoFile != null) - { - // SetAccountPictureAsync() accepts 3 storageFile objects for setting the small image, large image, and video. - // More than one type can be set in the same call, but small image must be accompanied by a large image and/or video. - // If only a large image is passed, the small image will be autogenerated. - // If only a video is passed, the large image and small will be autogenerated. - // Videos must be convertable to mp4, <=5MB, and height and width >= 448 pixels. - - // Setting the Account Picture will fail if a user disallows it in PC Settings. - SetAccountPictureResult result = await UserInformation.SetAccountPicturesAsync(null, null, videoFile); - if (result == SetAccountPictureResult.Success) - { - rootPage.NotifyUser("Video account picture was successfully changed.", NotifyType.StatusMessage); - } - else - { - rootPage.NotifyUser("Account picture could not be changed.", NotifyType.StatusMessage); - AccountPictureImage.Visibility = Visibility.Collapsed; - } - } - } - - private async void PictureChanged(object sender, object e) - { - await this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => - { - // The large picture returned by GetAccountPicture() is 448x448 pixels in size. - StorageFile image = UserInformation.GetAccountPicture(AccountPictureKind.LargeImage) as StorageFile; - if (image != null) - { - try - { - IRandomAccessStream imageStream = await image.OpenReadAsync(); - BitmapImage bitmapImage = new BitmapImage(); - bitmapImage.SetSource(imageStream); - rootPage.NotifyUser("LargeImage path = " + image.Path, NotifyType.StatusMessage); - AccountPictureImage.Source = bitmapImage; - AccountPictureImage.Visibility = Visibility.Visible; - } - catch (Exception ex) - { - rootPage.NotifyUser("Error opening stream: " + ex.ToString(), NotifyType.ErrorMessage); - } - } - else - { - rootPage.NotifyUser("Large Account Picture is not available.", NotifyType.StatusMessage); - } - }); - } - - } -} diff --git a/Samples/AccountPictureName/js/html/getAccountPicture.html b/Samples/AccountPictureName/js/html/getAccountPicture.html deleted file mode 100644 index 269a568d35..0000000000 --- a/Samples/AccountPictureName/js/html/getAccountPicture.html +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - -
-
-

Description:

-
-

Get the Account Picture for the current user. You can get request three different types: small, large, and video. If the size that is requested is not available an empty file is returned.

-
-
-
- - - -
- image holder - image holder - -
-
-
- - - \ No newline at end of file diff --git a/Samples/AccountPictureName/js/html/setAccountPicture.html b/Samples/AccountPictureName/js/html/setAccountPicture.html deleted file mode 100644 index dbceeee048..0000000000 --- a/Samples/AccountPictureName/js/html/setAccountPicture.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - -
-
-

Description:

-
-

Set the Account Picture image for the current logon user. The setAccountPicture method takes three parameters as input: small image, large image, and video. More than one type can be set in the same call, but a small image must be accompanied - by a large image and/or video. Pass a null for parameters you don't want to set. A change event can be listened to for Account Picture updates. The images below change by listening to the update.

-
-
-
- - - image holder - image holder - -
-
- - - \ No newline at end of file diff --git a/Samples/AccountPictureName/js/html/userFirstAndLastName.html b/Samples/AccountPictureName/js/html/userFirstAndLastName.html deleted file mode 100644 index dff866477e..0000000000 --- a/Samples/AccountPictureName/js/html/userFirstAndLastName.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - -
-
-

Description:

-
-

Get the First and Last Name for the current user. This is only available for Microsoft Accounts, an empty string will be returned if not available.

-
-
- - -
- - - \ No newline at end of file diff --git a/Samples/AccountPictureName/js/js/getAccountPicture.js b/Samples/AccountPictureName/js/js/getAccountPicture.js deleted file mode 100644 index 3f09d36e5d..0000000000 --- a/Samples/AccountPictureName/js/js/getAccountPicture.js +++ /dev/null @@ -1,71 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved - -(function () { - "use strict"; - var page = WinJS.UI.Pages.define("/html/getAccountPicture.html", { - ready: function (element, options) { - hideVisibleHolders(); - document.getElementById("getSmallImage").addEventListener("click", getSmallImage, false); - document.getElementById("getLargeImage").addEventListener("click", getLargeImage, false); - document.getElementById("getVideo").addEventListener("click", getVideo, false); - } - }); - - function getSmallImage() { - hideVisibleHolders(); - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - // The small picture returned by getAccountPicture() is 96x96 pixels in size. - var image = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.smallImage); - if (image) { - document.getElementById("smallImageHolder").style.visibility = "visible"; - document.getElementById("smallImageHolder").src = URL.createObjectURL(image, { oneTimeOnly: true }); - WinJS.log && WinJS.log("Path: " + image.path, "sample", "status"); - } else { - WinJS.log && WinJS.log("Small account picture is not available.", "sample", "status"); - } - } else { - WinJS.log && WinJS.log("Access to account picture disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } - - function getLargeImage() { - hideVisibleHolders(); - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - // The large picture returned by getAccountPicture() is 448x448 pixels in size. - var image = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.largeImage); - if (image) { - document.getElementById("largeImageHolder").style.visibility = "visible"; - document.getElementById("largeImageHolder").src = URL.createObjectURL(image, { oneTimeOnly: true }); - WinJS.log && WinJS.log("Path: " + image.path, "sample", "status"); - } else { - WinJS.log && WinJS.log("Large account picture is not available.", "sample", "status"); - } - } else { - WinJS.log && WinJS.log("Access to account picture disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } - - function getVideo() { - hideVisibleHolders(); - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - // The video returned from getAccountPicture is 448x448 pixels in size. - var video = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.video); - if (video) { - document.getElementById("videoHolder").style.visibility = "visible"; - document.getElementById("videoHolder").src = URL.createObjectURL(video, { oneTimeOnly: true }); - document.getElementById("videoHolder").play(); - WinJS.log && WinJS.log("Path: " + video.path, "sample", "status"); - } else { - WinJS.log && WinJS.log("Video is not available.", "sample", "status"); - } - } else { - WinJS.log && WinJS.log("Access to account picture disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } - - function hideVisibleHolders() { - document.getElementById("smallImageHolder").style.visibility = "hidden"; - document.getElementById("largeImageHolder").style.visibility = "hidden"; - document.getElementById("videoHolder").style.visibility = "hidden"; - } -})(); diff --git a/Samples/AccountPictureName/js/js/sample-configuration.js b/Samples/AccountPictureName/js/js/sample-configuration.js deleted file mode 100644 index de7c2f0022..0000000000 --- a/Samples/AccountPictureName/js/js/sample-configuration.js +++ /dev/null @@ -1,32 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved - -(function () { - "use strict"; - - var sampleTitle = "Account picture name JS sample"; - - var scenarios = [ - { url: "/html/userDisplayName.html", title: "Get display name" }, - { url: "/html/userFirstAndLastName.html", title: "Get first and last name" }, - { url: "/html/getAccountPicture.html", title: "Get account picture" }, - { url: "/html/setAccountPicture.html", title: "Set account picture and listen for changes" } - ]; - - WinJS.Navigation.addEventListener("navigating", function (e) { - if (e.detail && e.detail.state && e.detail.state.activatedEventArgs) { - var uri = e.detail.state.activatedEventArgs[0].uri; - if (uri && uri.schemeName === "ms-accountpictureprovider") { - // This app was activated via the Account picture apps section in Settings. - // Here you would do app-specific logic for providing the user with account picture selection UX - setImmediate(function () { - WinJS.Navigation.navigate(scenarios[3].url).done(); - }); - } - } - }); - - WinJS.Namespace.define("SdkSample", { - sampleTitle: sampleTitle, - scenarios: new WinJS.Binding.List(scenarios) - }); -})(); diff --git a/Samples/AccountPictureName/js/js/setAccountPicture.js b/Samples/AccountPictureName/js/js/setAccountPicture.js deleted file mode 100644 index 12d0d68a48..0000000000 --- a/Samples/AccountPictureName/js/js/setAccountPicture.js +++ /dev/null @@ -1,102 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved - -(function () { - "use strict"; - var page = WinJS.UI.Pages.define("/html/setAccountPicture.html", { - ready: function (element, options) { - hideVisibleHolders(); - document.getElementById("setImage").addEventListener("click", setImage, false); - document.getElementById("setVideo").addEventListener("click", setVideo, false); - Windows.System.UserProfile.UserInformation.addEventListener("accountpicturechanged", accountPictureChanged); - } - }); - - function setImage() { - hideVisibleHolders(); - var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); - openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail; - openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary; - openPicker.fileTypeFilter.replaceAll([".bmp", ".png", ".jpg", ".jpeg"]); - - openPicker.pickSingleFileAsync().done(function (file) { - if (file) { - // setAccountPictureAsync() accepts 3 storageFile objects for setting the small image, large image, and video. - // More than one type can be set in the same call, but small image must be accompanied by a large image and/or video. - // If only a large image is passed, the small image will be autogenerated. - // If only a video is passed, the large image and small will be autogenerated. - // Videos must be convertable to mp4, <=5MB, and height and width >= 448 pixels. - Windows.System.UserProfile.UserInformation.setAccountPicturesAsync(null, file, null).done(function (result) { - // A user might turn off access to the Account Picture in PC Settings, therefore we need to check the result for success. - if (result === Windows.System.UserProfile.SetAccountPictureResult.success) { - WinJS.log && WinJS.log("Successfully updated account picture.", "sample", "status"); - } else { - // A user might turn off access to the account - WinJS.log && WinJS.log("Setting account picture failed.", "sample", "status"); - } - }); - } else { - WinJS.log && WinJS.log("No image was selected.", "sample", "status"); - } - }); - } - - function setVideo() { - hideVisibleHolders(); - var openPicker = new Windows.Storage.Pickers.FileOpenPicker(); - openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail; - openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary; - openPicker.fileTypeFilter.replaceAll([".mov", ".mp4", ".wmv"]); - - openPicker.pickSingleFileAsync().done(function (file) { - if (file) { - // setAccountPictureAsync() accepts 3 storageFile objects for setting the small image, large image, and video. - // More than one type can be set in the same call, but small image must be accompanied by a large image and/or video. - // If only a large image is passed, the small image will be autogenerated. - // If only a video is passed, the large image and small will be autogenerated. - // Videos must be convertable to mp4, <=5MB, and height and width >= 448 pixels. - Windows.System.UserProfile.UserInformation.setAccountPicturesAsync(null, null, file).done(function (result) { - // A user might turn off access to the Account Picture in PC Settings, therefore we need to check the result for success. - if (result === Windows.System.UserProfile.SetAccountPictureResult.success) { - WinJS.log && WinJS.log("Successfully updated account picture.", "sample", "status"); - } else { - // A user might turn off access to the account - WinJS.log && WinJS.log("Setting account picture failed.", "sample", "status"); - } - }); - } else { - WinJS.log && WinJS.log("No video was selected.", "sample", "status"); - } - }); - } - - // This function is the handler for the AccountPictureChangedEvent, the event listener is added in initialize() below. - function accountPictureChanged() { - hideVisibleHolders(); - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - var smallImage = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.smallImage); - if (smallImage) { - document.getElementById("smallImageHolder").src = URL.createObjectURL(smallImage, { oneTimeOnly: true }); - document.getElementById("smallImageHolder").style.visibility = "visible"; - } - var largeImage = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.largeImage); - if (largeImage) { - document.getElementById("largeImageHolder").src = URL.createObjectURL(largeImage, { oneTimeOnly: true }); - document.getElementById("largeImageHolder").style.visibility = "visible"; - } - var video = Windows.System.UserProfile.UserInformation.getAccountPicture(Windows.System.UserProfile.AccountPictureKind.video); - if (video) { - document.getElementById("videoHolder").src = URL.createObjectURL(video, { oneTimeOnly: true }); - document.getElementById("videoHolder").style.visibility = "visible"; - } - } else { - WinJS.log && WinJS.log("Access to account picture disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } - - function hideVisibleHolders() { - document.getElementById("smallImageHolder").style.visibility = "hidden"; - document.getElementById("largeImageHolder").style.visibility = "hidden"; - document.getElementById("videoHolder").style.visibility = "hidden"; - WinJS.log && WinJS.log(" ", "sample", "status"); - } -})(); diff --git a/Samples/AccountPictureName/js/js/userDisplayName.js b/Samples/AccountPictureName/js/js/userDisplayName.js deleted file mode 100644 index 040dbdfda3..0000000000 --- a/Samples/AccountPictureName/js/js/userDisplayName.js +++ /dev/null @@ -1,24 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved - -(function () { - "use strict"; - var page = WinJS.UI.Pages.define("/html/userDisplayName.html", { - ready: function (element, options) { - document.getElementById("getDisplayName").addEventListener("click", getDisplayName, false); - } - }); - - function getDisplayName() { - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - Windows.System.UserProfile.UserInformation.getDisplayNameAsync().done(function (result) { - if (result) { - WinJS.log && WinJS.log("Display name = " + result, "sample", "status"); - } else { - WinJS.log && WinJS.log("No display name was returned.", "sample", "status"); - } - }); - } else { - WinJS.log && WinJS.log("Access to name disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } -})(); diff --git a/Samples/AccountPictureName/js/js/userFirstAndLastName.js b/Samples/AccountPictureName/js/js/userFirstAndLastName.js deleted file mode 100644 index b2e2e66d10..0000000000 --- a/Samples/AccountPictureName/js/js/userFirstAndLastName.js +++ /dev/null @@ -1,39 +0,0 @@ -//// Copyright (c) Microsoft Corporation. All rights reserved - -(function () { - "use strict"; - var page = WinJS.UI.Pages.define("/html/userFirstAndLastName.html", { - ready: function (element, options) { - document.getElementById("getFirstName").addEventListener("click", getFirstName, false); - document.getElementById("getLastName").addEventListener("click", getLastName, false); - } - }); - - function getFirstName() { - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - Windows.System.UserProfile.UserInformation.getFirstNameAsync().done(function (result) { - if (result) { - WinJS.log && WinJS.log("First name = " + result, "sample", "status"); - } else { - WinJS.log && WinJS.log("No first name was returned.", "sample", "status"); - } - }); - } else { - WinJS.log && WinJS.log("Access to name disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } - - function getLastName() { - if (Windows.System.UserProfile.UserInformation.nameAccessAllowed) { - Windows.System.UserProfile.UserInformation.getLastNameAsync().done(function (result) { - if (result) { - WinJS.log && WinJS.log("Last name = " + result, "sample", "status"); - } else { - WinJS.log && WinJS.log("No last name was returned.", "sample", "status"); - } - }); - } else { - WinJS.log && WinJS.log("Access to name disabled by Privacy Setting or Group Policy.", "sample", "error"); - } - } -})(); diff --git a/Samples/AccountPictureName/shared/GetAccountPicture.xaml b/Samples/AccountPictureName/shared/GetAccountPicture.xaml deleted file mode 100644 index 96bd210cb6..0000000000 --- a/Samples/AccountPictureName/shared/GetAccountPicture.xaml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - Get the Account Picture for the current user. - - - - - - - You can request three different types: small, large and video (dynamic image). If the type that is requested is not available, an empty file is returned. - - - + +
+
+ +
+ + + + + \ No newline at end of file diff --git a/Samples/AccountPictureName/js/html/userDisplayName.html b/Samples/UserInfo/js/html/scenario2-watchUsers.html similarity index 52% rename from Samples/AccountPictureName/js/html/userDisplayName.html rename to Samples/UserInfo/js/html/scenario2-watchUsers.html index b04d02fff0..5058754575 100644 --- a/Samples/AccountPictureName/js/html/userDisplayName.html +++ b/Samples/UserInfo/js/html/scenario2-watchUsers.html @@ -7,7 +7,7 @@ - + @@ -15,13 +15,15 @@

Description:

-

Get the DisplayName for the current user.

+ Maintain a list of users with a UserWatcher
- +
+ + +
+
diff --git a/Samples/AccountPictureName/js/images/placeholder.txt b/Samples/UserInfo/js/images/placeholder.txt similarity index 100% rename from Samples/AccountPictureName/js/images/placeholder.txt rename to Samples/UserInfo/js/images/placeholder.txt diff --git a/Samples/UserInfo/js/js/sample-configuration.js b/Samples/UserInfo/js/js/sample-configuration.js new file mode 100644 index 0000000000..02578298f1 --- /dev/null +++ b/Samples/UserInfo/js/js/sample-configuration.js @@ -0,0 +1,17 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var sampleTitle = "Account picture name JS sample"; + + var scenarios = [ + { url: "/html/scenario1-findUsers.html", title: "Find users" }, + { url: "/html/scenario2-watchUsers.html", title: "Watch users" }, + ]; + + WinJS.Namespace.define("SdkSample", { + sampleTitle: sampleTitle, + scenarios: new WinJS.Binding.List(scenarios) + }); +})(); diff --git a/Samples/UserInfo/js/js/scenario1-findUsers.js b/Samples/UserInfo/js/js/scenario1-findUsers.js new file mode 100644 index 0000000000..7b3e000c5c --- /dev/null +++ b/Samples/UserInfo/js/js/scenario1-findUsers.js @@ -0,0 +1,131 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var System = Windows.System; + var User = System.User; + var KnownUserProperties = System.KnownUserProperties; + var UserPictureSize = System.UserPictureSize; + + var userTypeNames = [ "LocalUser", "RemoteUser", "LocalGuest", "RemoteGuest" ]; + var authenticationStatusNames = [ "Unauthenticated", "LocallyAuthenticated", "RemotelyAuthenticated" ]; + + var nextUserNumber = 1; + var userList; + var resultsText; + var profileImage; + + var page = WinJS.UI.Pages.define("/html/scenario1-findUsers.html", { + ready: function (element, options) { + userList = document.getElementById("userList"); + resultsText = document.getElementById("resultsText"); + profileImage = document.getElementById("profileImage"); + + document.getElementById("showPropertiesButton").addEventListener("click", showProperties, false); + + return fillUsersAsync(); + } + }); + + function fillUsersAsync() { + nextUserNumber = 1; + User.findAllAsync().then(function (users) { + return addNextUserAsync(0); + + function addNextUserAsync(i) { + if (i < users.length) { + var user = users[i]; + return user.getPropertyAsync(KnownUserProperties.displayName).then(function (displayName) { + // Choose a generic name if we do not have access to the actual name. + if (displayName == "") { + displayName = "User #" + nextUserNumber; + ++nextUserNumber; + } + + var newOption = document.createElement("option"); + newOption.text = displayName; + newOption.value = user.nonRoamableId; + newOption.selected = false; + userList.add(newOption); + + return addNextUser(i + 1); + }); + } + } + }); + } + + function showProperties() { + if (userList.selectedIndex >= 0) { + resultsText.innerText = ""; + profileImage.src = ""; + WinJS.log && WinJS.log("", "sample", "status"); + + var userId = userList[userList.selectedIndex].value; + try { + var user = User.getFromId(userId); + } catch (ex) { + WinJS.log && WinJS.log(ex.message, "sample", "error"); + return; + } + + // Build a list of all the properties we want. + var desiredProperties = [ + KnownUserProperties.firstName, + KnownUserProperties.lastName, + KnownUserProperties.providerName, + KnownUserProperties.accountName, + KnownUserProperties.guestHost, + KnownUserProperties.principalName, + KnownUserProperties.domainName, + KnownUserProperties.sessionInitiationProtocolUri + ]; + + // Issue a bulk query for all of the properties above. + // NOTE: Bulk queries do not work from JS right now. + // user.getPropertiesAsync(desiredProperties).then(function (values) { + simulateGetPropertiesAsync(user, desiredProperties).then(function (values) { + // Generate the results. + var result = "NonRoamableId: " + user.nonRoamableId + "\n"; + result += "Type: " + userTypeNames[user.type] + "\n"; + result += "AuthenticationStatus: " + authenticationStatusNames[user.authenticationStatus] + "\n"; + desiredProperties.forEach(function (propertyName) { + result += propertyName + ": "+ values[propertyName] + "\n"; + }); + + resultsText.innerText = result; + }).then(function () { + return user.getPictureAsync(UserPictureSize.size64x64); + }).then(function (streamReference) { + return streamReference && streamReference.openReadAsync(); + }).then(function (stream) { + if (stream) { + profileImage.src = URL.createObjectURL(stream, { oneTimeOnly: true }); + // Close the stream once the image is loaded. + profileImage.onload = function () { stream.close(); }; + } + }); + } + } + + // Bulk queries do not work from JS right now, so we simulate it by + // issuing a series of single-property queries. + function simulateGetPropertiesAsync(user, desiredProperties) { + var values = {}; + return addNextPropertyAsync(0); + + function addNextPropertyAsync(i) { + if (i < desiredProperties.length) { + var propertyName = desiredProperties[i]; + return user.getPropertyAsync(propertyName).then(function (result) { + values[propertyName] = result; + return addNextPropertyAsync(i + 1); + }); + } else { + return values; + } + } + } + +})(); diff --git a/Samples/UserInfo/js/js/scenario2-watchUsers.js b/Samples/UserInfo/js/js/scenario2-watchUsers.js new file mode 100644 index 0000000000..0e01e27d72 --- /dev/null +++ b/Samples/UserInfo/js/js/scenario2-watchUsers.js @@ -0,0 +1,136 @@ +//// Copyright (c) Microsoft Corporation. All rights reserved + +(function () { + "use strict"; + + var System = Windows.System; + var User = System.User; + var KnownUserProperties = System.KnownUserProperties; + + var startButton; + var stopButton; + var userList; + + var nextUserNumber = 1; + var userWatcher; + + var page = WinJS.UI.Pages.define("/html/scenario2-watchUsers.html", { + ready: function (element, options) { + startButton = document.getElementById("startButton"); + stopButton = document.getElementById("stopButton"); + userList = document.getElementById("userList"); + + startButton.addEventListener("click", startWatching, false); + stopButton.addEventListener("click", stopWatching, false); + }, + unload: stopWatching + }); + + function startWatching() { + WinJS.log && WinJS.log("", "sample", "status"); + + nextUserNumber = 1; + userList.innerHTML = ""; // remove all children + + userWatcher = User.createWatcher(); + userWatcher.addEventListener("added", onUserAdded); + userWatcher.addEventListener("updated", onUserUpdated); + userWatcher.addEventListener("removed", onUserRemoved); + userWatcher.addEventListener("enumerationcompleted", onEnumerationCompleted); + userWatcher.addEventListener("stopped", onWatcherStopped); + userWatcher.start(); + startButton.disabled = true; + stopButton.disabled = false; + } + + function stopWatching() { + if (userWatcher) { + userWatcher.removeEventListener("added", onUserAdded); + userWatcher.removeEventListener("updated", onUserUpdated); + userWatcher.removeEventListener("removed", onUserRemoved); + userWatcher.removeEventListener("enumerationCompleted", onEnumerationCompleted); + userWatcher.removeEventListener("stopped", onWatcherStopped); + userWatcher.stop(); + userWatcher = null; + userList.innerHTML = ""; // remove all children + startButton.disabled = false; + stopButton.disabled = true; + } + } + + function findOptionByUserId(userId) { + // make it safe to put inside "..." + var sanitized = userId.replace("\\", "\\\\").replace("'", "\\'"); + return userList.querySelector("option[value='" + sanitized + "']"); + } + + function getDisplayNameOrGenericNameAsync(user) { + return user.getPropertyAsync(KnownUserProperties.displayName).then(function (displayName) { + // Choose a generic name if we do not have access to the actual name. + if (displayName == "") { + displayName = "User #" + nextUserNumber; + ++nextUserNumber; + } + return displayName; + }); + } + + function onUserAdded(e) { + var user = e.user; + + // Create the user with "..." as the temporary display name. + // Add it right away, because it might get removed while the + // getDisplayNameOrGenericNameAsync is running. + + var newOption = document.createElement("option"); + newOption.text = "\u2026"; + newOption.value = user.nonRoamableId; + newOption.selected = false; + userList.add(newOption); + + // Uncomment this line, and the behavior in the TODO changes! + // Instead of setting only the first character, it sets only the first word. + //newOption.text = "Bogga"; + + // Try to get the display name. + getDisplayNameOrGenericNameAsync(user).then(function (displayName) { + // TODO: Figure out why only the first character gets set. + newOption.text = displayName; + }); + } + + function onUserUpdated(e) { + var user = e.user; + + // Look for the user in our collection and update the display name. + var option = findOptionByUserId(user.nonRoamableId); + + // Try to update the display name. + getDisplayNameOrGenericNameAsync(user).then(function (displayName) { + // TODO: Figure out why only the first character gets set. + option.text = displayName; + }); + } + + function onUserRemoved(e) { + var user = e.user; + + // Look for the user in our collection and remove it. + var option = findOptionByUserId(user.nonRoamableId); + + if (option) { + userList.remove(option); + } + } + + function onEnumerationCompleted() + { + WinJS.log && WinJS.log("Enumeration complete. Watching for changes...", "sample", "status"); + } + + function onWatcherStopped() + { + stopWatching(); + } + +})(); diff --git a/Samples/AccountPictureName/js/sample-utils/placeholder.txt b/Samples/UserInfo/js/sample-utils/placeholder.txt similarity index 100% rename from Samples/AccountPictureName/js/sample-utils/placeholder.txt rename to Samples/UserInfo/js/sample-utils/placeholder.txt diff --git a/Samples/AccountPictureName/shared/GetUserFirstAndLastName.xaml b/Samples/UserInfo/shared/Scenario1_FindUsers.xaml similarity index 61% rename from Samples/AccountPictureName/shared/GetUserFirstAndLastName.xaml rename to Samples/UserInfo/shared/Scenario1_FindUsers.xaml index 37cc636fb0..4a76dacf6e 100644 --- a/Samples/AccountPictureName/shared/GetUserFirstAndLastName.xaml +++ b/Samples/UserInfo/shared/Scenario1_FindUsers.xaml @@ -11,7 +11,7 @@ //********************************************************* --> - - + - Get the first and last name for the current user. This is only available for Microsoft Accounts. An empty string will be returned if not available. + Find users and display user properties + +