diff --git a/Samples/BackgroundTransfer/cpp/Tasks/CompletionGroupTask.cpp b/Samples/BackgroundTransfer/cpp/Tasks/CompletionGroupTask.cpp index c58f14a48e..5af2fd8db4 100644 --- a/Samples/BackgroundTransfer/cpp/Tasks/CompletionGroupTask.cpp +++ b/Samples/BackgroundTransfer/cpp/Tasks/CompletionGroupTask.cpp @@ -104,6 +104,8 @@ BackgroundDownloader^ CompletionGroupTask::CreateBackgroundDownloader() builder->SetTrigger(completionGroup->Trigger); + // The system automatically unregisters the BackgroundTransferCompletionGroup task when it triggers. + // You do not need to unregister it explicitly. BackgroundTaskRegistration^ taskRegistration = builder->Register(); BackgroundDownloader^ downloader = ref new BackgroundDownloader(completionGroup); diff --git a/Samples/BackgroundTransfer/cs/Tasks/CompletionGroupTask.cs b/Samples/BackgroundTransfer/cs/Tasks/CompletionGroupTask.cs index 48375f1ded..8f0e8e9334 100644 --- a/Samples/BackgroundTransfer/cs/Tasks/CompletionGroupTask.cs +++ b/Samples/BackgroundTransfer/cs/Tasks/CompletionGroupTask.cs @@ -133,6 +133,8 @@ public static BackgroundDownloader CreateBackgroundDownloader() builder.TaskEntryPoint = "Tasks.CompletionGroupTask"; builder.SetTrigger(completionGroup.Trigger); + // The system automatically unregisters the BackgroundTransferCompletionGroup task when it triggers. + // You do not need to unregister it explicitly. BackgroundTaskRegistration taskRegistration = builder.Register(); BackgroundDownloader downloader = new BackgroundDownloader(completionGroup); diff --git a/Samples/BackgroundTransfer/js/js/completionGroupBackgroundTask.js b/Samples/BackgroundTransfer/js/js/completionGroupBackgroundTask.js index 1085830b79..fc0b1bb35a 100644 --- a/Samples/BackgroundTransfer/js/js/completionGroupBackgroundTask.js +++ b/Samples/BackgroundTransfer/js/js/completionGroupBackgroundTask.js @@ -73,6 +73,9 @@ var builder = new Windows.ApplicationModel.Background.BackgroundTaskBuilder(); builder.taskEntryPoint = taskEntryPoint; builder.setTrigger(completionGroup.trigger); + + // The system automatically unregisters the BackgroundTransferCompletionGroup task when it triggers. + // You do not need to unregister it explicitly. var taskRegistration = builder.register(); var downloader = new Windows.Networking.BackgroundTransfer.BackgroundDownloader(completionGroup); diff --git a/Samples/BackgroundTransfer/vb/Tasks/CompletionGroupTask.vb b/Samples/BackgroundTransfer/vb/Tasks/CompletionGroupTask.vb index fa9150b12a..5c6687e804 100644 --- a/Samples/BackgroundTransfer/vb/Tasks/CompletionGroupTask.vb +++ b/Samples/BackgroundTransfer/vb/Tasks/CompletionGroupTask.vb @@ -90,7 +90,11 @@ Namespace Global.Tasks Dim builder As BackgroundTaskBuilder = New BackgroundTaskBuilder() builder.TaskEntryPoint = "Tasks.CompletionGroupTask" builder.SetTrigger(completionGroup.Trigger) + + ' The system automatically unregisters the BackgroundTransferCompletionGroup task when it triggers. + ' You do not need to unregister it explicitly. Dim taskRegistration As BackgroundTaskRegistration = builder.Register() + Dim downloader As BackgroundDownloader = New BackgroundDownloader(completionGroup) Return downloader End Function diff --git a/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp b/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp index 173c217aa5..1e71de9e3f 100644 --- a/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp +++ b/Samples/DeviceEnumerationAndPairing/cpp/DisplayHelpers.cpp @@ -128,6 +128,24 @@ namespace SDKTemplate return ref new DeviceSelectorInfo("UPnP", DeviceClass::All, "System.Devices.Aep.ProtocolId:=\"{0e261de4-12f0-46e6-91ba-428607ccef64}\"", DeviceInformationKind::AssociationEndpoint); } + void AddVideoCastingIfSupported(Vector^ selectors) + { + try + { + selectors->Append(DeviceSelectorChoices::VideoCasting); + } + catch (Exception^ ex) + { + if (ex->HResult == HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)) + { + // Video casting not supported by the system. + } + else + { + throw; + } + } + } IVectorView^ DeviceSelectorChoices::DevicePickerSelectors::get() { @@ -138,7 +156,7 @@ namespace SDKTemplate selectors->Append(BluetoothLEUnpairedOnly); selectors->Append(WiFiDirect); selectors->Append(PointOfServicePrinter); - selectors->Append(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors->Append(DialAllApps); return selectors->GetView(); @@ -161,7 +179,7 @@ namespace SDKTemplate selectors->Append(BluetoothLE); selectors->Append(WiFiDirect); selectors->Append(PointOfServicePrinter); - selectors->Append(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors->Append(DialAllApps); selectors->Append(Wsd); selectors->Append(Upnp); @@ -176,7 +194,7 @@ namespace SDKTemplate selectors->Append(BluetoothLEPairedOnly); selectors->Append(WiFiDirectPairedOnly); selectors->Append(PointOfServicePrinter); - selectors->Append(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors->Append(DialAllApps); selectors->Append(Wsd); selectors->Append(Upnp); @@ -191,7 +209,7 @@ namespace SDKTemplate selectors->Append(BluetoothLE); selectors->Append(WiFiDirect); selectors->Append(PointOfServicePrinter); - selectors->Append(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors->Append(Wsd); selectors->Append(Upnp); diff --git a/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs b/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs index 433b7da94a..b7c725913d 100644 --- a/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs +++ b/Samples/DeviceEnumerationAndPairing/cs/DisplayHelpers.cs @@ -195,6 +195,18 @@ public static DeviceSelectorInfo Upnp } } + public static void AddVideoCastingIfSupported(List selectors) + { + try + { + selectors.Add(VideoCasting); + } + catch (Exception ex) when (ex.HResult == unchecked((int)0x80070032)) // HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) + { + // Video casting is not supported by the system. + } + } + public static List DevicePickerSelectors { get @@ -207,7 +219,7 @@ public static List DevicePickerSelectors selectors.Add(BluetoothLEUnpairedOnly); selectors.Add(WiFiDirect); selectors.Add(PointOfServicePrinter); - selectors.Add(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors.Add(DialAllApps); return selectors; @@ -238,7 +250,7 @@ public static List DeviceWatcherSelectors selectors.Add(BluetoothLE); selectors.Add(WiFiDirect); selectors.Add(PointOfServicePrinter); - selectors.Add(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors.Add(DialAllApps); selectors.Add(Wsd); selectors.Add(Upnp); @@ -257,7 +269,7 @@ public static List BackgroundDeviceWatcherSelectors selectors.Add(BluetoothLEPairedOnly); selectors.Add(WiFiDirectPairedOnly); selectors.Add(PointOfServicePrinter); - selectors.Add(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors.Add(DialAllApps); selectors.Add(Wsd); selectors.Add(Upnp); @@ -279,7 +291,7 @@ public static List PairingSelectors selectors.Add(BluetoothLE); selectors.Add(WiFiDirect); selectors.Add(PointOfServicePrinter); - selectors.Add(VideoCasting); + AddVideoCastingIfSupported(selectors); selectors.Add(Wsd); selectors.Add(Upnp); diff --git a/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js b/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js index 37febab114..535d361049 100644 --- a/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js +++ b/Samples/DeviceEnumerationAndPairing/js/js/displayhelpers.js @@ -36,7 +36,17 @@ var wiFiDirect = { displayName: "Wi-Fi Direct", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector(Windows.Devices.WiFiDirect.WiFiDirectDeviceSelectorType.associationEndpoint) }; var wiFiDirectPairedOnly = { displayName: "Wi-Fi Direct (paired)", selector: Windows.Devices.WiFiDirect.WiFiDirectDevice.getDeviceSelector() }; var pointOfServicePrinter = { displayName: "Point of Service Printer", selector: Windows.Devices.PointOfService.PosPrinter.getDeviceSelector() }; - var videoCasting = { displayName: "Video Casting", selector: Windows.Media.Casting.CastingDevice.getDeviceSelector(Windows.Media.Casting.CastingPlaybackTypes.video) }; + + try { + var videoCasting = { displayName: "Video Casting", selector: Windows.Media.Casting.CastingDevice.getDeviceSelector(Windows.Media.Casting.CastingPlaybackTypes.video) }; + } catch (e) { + if (e.number === 0x80070032 | 0) { // HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) + // Video casting not supported by the system. + } else { + throw e; + } + } + var dialAllApps = { displayName: "DIAL (All Apps)", selector: Windows.Media.DialProtocol.DialDevice.getDeviceSelector("") }; // WSD and UPnP are unique in that there are currently no general WSD or UPnP APIs to USE the devices once you've discovered them. @@ -53,7 +63,7 @@ devicePickerArray.push(bluetoothLEUnpairedOnly); devicePickerArray.push(wiFiDirect); devicePickerArray.push(pointOfServicePrinter); - devicePickerArray.push(videoCasting); + videoCasting && devicePickerArray.push(videoCasting); devicePickerArray.push(dialAllApps); var devicePickerSelectors = new WinJS.Binding.List(devicePickerArray); @@ -68,7 +78,7 @@ deviceWatcherArray.push(bluetoothLE); deviceWatcherArray.push(wiFiDirect); deviceWatcherArray.push(pointOfServicePrinter); - deviceWatcherArray.push(videoCasting); + videoCasting && deviceWatcherArray.push(videoCasting); deviceWatcherArray.push(dialAllApps); deviceWatcherArray.push(wsd); deviceWatcherArray.push(upnp); @@ -79,7 +89,7 @@ backgroundDeviceWatcherArray.push(bluetoothLEPairedOnly); backgroundDeviceWatcherArray.push(wiFiDirectPairedOnly); backgroundDeviceWatcherArray.push(pointOfServicePrinter); - backgroundDeviceWatcherArray.push(videoCasting); + videoCasting && backgroundDeviceWatcherArray.push(videoCasting); backgroundDeviceWatcherArray.push(dialAllApps); backgroundDeviceWatcherArray.push(wsd); backgroundDeviceWatcherArray.push(upnp); @@ -90,7 +100,7 @@ pairingArray.push(bluetoothLE); pairingArray.push(wiFiDirect); pairingArray.push(pointOfServicePrinter); - pairingArray.push(videoCasting); + videoCasting && pairingArray.push(videoCasting); pairingArray.push(wsd); pairingArray.push(upnp); var pairingSelectors = new WinJS.Binding.List(pairingArray); diff --git a/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj b/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj index 7367f97fb3..0a7c9ef082 100644 --- a/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj +++ b/Samples/EnterpriseDataProtection/cs/EnterpriseDataProtection.csproj @@ -242,8 +242,8 @@ - - Windows Mobile Extensions for the UWP + + Windows Desktop Extensions for the UWP diff --git a/Samples/IoT-GPIO/README.md b/Samples/IoT-GPIO/README.md index d417397798..bb52e8b601 100644 --- a/Samples/IoT-GPIO/README.md +++ b/Samples/IoT-GPIO/README.md @@ -37,9 +37,9 @@ This sample demonstrates the following: **Note** The Windows universal samples require Visual Studio 2017 to build and Windows 10 IoT Core to execute. -To obtain information about Windows 10 IoT Core, go to [Windows on Devices](http://windowsondevices.com) +To obtain information about Windows 10 IoT Core, go to [Windows on Devices](http://windowsondevices.com). -To see more samples specifically describing how to leverage Windows 10 IoT Core, click on the [Samples tab here](http://ms-iot.github.io/content/win10/StartCoding.htm). +You can find more Windows IoT Core samples in the [Windows 10 Internet of Things (IoT) Samples repo](https://go.microsoft.com/fwlink/?linkid=860459). To obtain information about Microsoft Visual Studio and the tools for developing Windows apps, go to [Visual Studio](http://go.microsoft.com/fwlink/?LinkID=532422) diff --git a/Samples/IoT-I2C/README.md b/Samples/IoT-I2C/README.md index d21717b24a..42110b6cb9 100644 --- a/Samples/IoT-I2C/README.md +++ b/Samples/IoT-I2C/README.md @@ -38,7 +38,7 @@ The sample shows the following techniques: To obtain information about Windows 10 IoT Core, go to [Windows on Devices](http://windowsondevices.com) -To see more samples specifically describing how to leverage Windows 10 IoT Core, click on the [Samples tab here](http://ms-iot.github.io/content/win10/StartCoding.htm). +You can find more Windows IoT Core samples in the [Windows 10 Internet of Things (IoT) Samples repo](https://go.microsoft.com/fwlink/?linkid=860459). To obtain information about Microsoft Visual Studio and the tools for developing Windows apps, go to [Visual Studio](http://go.microsoft.com/fwlink/?LinkID=532422) diff --git a/Samples/IoT-SPI/README.md b/Samples/IoT-SPI/README.md index 85030b41b2..8b018a185b 100644 --- a/Samples/IoT-SPI/README.md +++ b/Samples/IoT-SPI/README.md @@ -39,7 +39,7 @@ The sample shows the following techniques: To obtain information about Windows 10 IoT Core, go to [Windows on Devices](http://windowsondevices.com). -To see more samples specifically describing how to leverage Windows 10 IoT Core, click on the [Samples tab here](http://ms-iot.github.io/content/win10/StartCoding.htm). +You can find more Windows IoT Core samples in the [Windows 10 Internet of Things (IoT) Samples repo](https://go.microsoft.com/fwlink/?linkid=860459). To obtain information about Microsoft Visual Studio and the tools for developing Windows apps, go to [Visual Studio](http://go.microsoft.com/fwlink/?LinkID=532422) diff --git a/Samples/JumpList/cpp/App.xaml.cpp b/Samples/JumpList/cpp/App.xaml.cpp deleted file mode 100644 index aefdacbe86..0000000000 --- a/Samples/JumpList/cpp/App.xaml.cpp +++ /dev/null @@ -1,140 +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 "MainPage.xaml.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; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409 - -/// -/// Initializes the singleton application object. This is the first line of authored code -/// executed, and as such is the logical equivalent of main() or WinMain(). -/// -App::App() -{ - InitializeComponent(); - Suspending += ref new Windows::UI::Xaml::SuspendingEventHandler(this, &SDKTemplate::App::OnSuspending); -} - -/// -/// Invoked when the application is launched normally by the end user. Other entry points -/// will be used such as when the application is launched to open a specific file. -/// -/// Details about the launch request and process. -void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) -{ -#if _DEBUG - // Show graphics profiling information while debugging. - if (IsDebuggerPresent()) - { - // Display the current frame rate counters - DebugSettings->EnableFrameRateCounter = false; - } -#endif - - auto rootFrame = dynamic_cast(Window::Current->Content); - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == nullptr) - { - // Create a Frame to act as the navigation context and associate it with - // a SuspensionManager key - rootFrame = ref new Frame(); - - // Set the default language - rootFrame->Language = Windows::Globalization::ApplicationLanguages::Languages->GetAt(0); - - rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed); - - if (e->PreviousExecutionState == ApplicationExecutionState::Terminated) - { - // TODO: Restore the saved session state only when appropriate, scheduling the - // final launch steps after the restore is complete - } - - if (rootFrame->Content == nullptr) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); - } - // Place the frame in the current Window - Window::Current->Content = rootFrame; - // Ensure the current window is active - Window::Current->Activate(); - } - else - { - if (rootFrame->Content == nullptr) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments); - } - // Ensure the current window is active - Window::Current->Activate(); - } - - if (!e->Arguments->IsEmpty()) - { - MainPage::Current->LaunchParam = "arguments: " + e->Arguments; - } -} - -void App::OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs^ args) -{ - if (args->Files->Size == 1) - { - MainPage::Current->LaunchParam = "file: " + args->Files->GetAt(0)->Name; - } -} - -/// -/// Invoked when application execution is being suspended. Application state is saved -/// without knowing whether the application will be terminated or resumed with the contents -/// of memory still intact. -/// -/// The source of the suspend request. -/// Details about the suspend request. -void App::OnSuspending(Object^ /* sender */, SuspendingEventArgs^ /* e */) -{ - //TODO: Save application state and stop any background activity -} - - -/// -/// Invoked when Navigation to a certain page fails -/// -/// The Frame which failed navigation -/// Details about the navigation failure -void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e) -{ - throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name); -} \ No newline at end of file diff --git a/Samples/JumpList/cpp/App.xaml.h b/Samples/JumpList/cpp/App.xaml.h deleted file mode 100644 index ffc2c5bb48..0000000000 --- a/Samples/JumpList/cpp/App.xaml.h +++ /dev/null @@ -1,34 +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 "App.g.h" - -namespace SDKTemplate -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - ref class App sealed - { - protected: - virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override; - virtual void OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs^ args) override; - - internal: - App(); - - private: - void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e); - void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e); - }; -} diff --git a/Samples/JumpList/cpp/JumpList.vcxproj b/Samples/JumpList/cpp/JumpList.vcxproj index ad15bed1e0..59cd9a4dce 100644 --- a/Samples/JumpList/cpp/JumpList.vcxproj +++ b/Samples/JumpList/cpp/JumpList.vcxproj @@ -138,7 +138,7 @@ - + ..\..\..\SharedContent\xaml\App.xaml @@ -183,7 +183,7 @@ - + ..\..\..\SharedContent\xaml\App.xaml diff --git a/Samples/JumpList/cpp/SampleConfiguration.cpp b/Samples/JumpList/cpp/SampleConfiguration.cpp index 7aab34f716..88a94cda32 100644 --- a/Samples/JumpList/cpp/SampleConfiguration.cpp +++ b/Samples/JumpList/cpp/SampleConfiguration.cpp @@ -14,6 +14,7 @@ #include "SampleConfiguration.h" using namespace SDKTemplate; +using namespace Windows::ApplicationModel::Activation; Platform::Array^ MainPage::scenariosInner = ref new Platform::Array { @@ -36,4 +37,20 @@ void MainPage::LaunchParam::set(Platform::String^ value) ScenarioControl->SelectedIndex = 0; } -} \ No newline at end of file +} + +void App::Partial_LaunchCompleted(LaunchActivatedEventArgs^ e) +{ + if (!e->Arguments->IsEmpty()) + { + MainPage::Current->LaunchParam = "arguments: " + e->Arguments; + } +} + +void App::OnFileActivated(FileActivatedEventArgs^ args) +{ + if (args->Files->Size == 1) + { + MainPage::Current->LaunchParam = "file: " + args->Files->GetAt(0)->Name; + } +} diff --git a/Samples/JumpList/cpp/SampleConfiguration.h b/Samples/JumpList/cpp/SampleConfiguration.h index 6a19777fd8..fbb363c113 100644 --- a/Samples/JumpList/cpp/SampleConfiguration.h +++ b/Samples/JumpList/cpp/SampleConfiguration.h @@ -55,4 +55,11 @@ namespace SDKTemplate Platform::String^ Title; Platform::String^ ClassName; }; + + partial ref class App + { + void Partial_LaunchCompleted(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e); + public: + void OnFileActivated(Windows::ApplicationModel::Activation::FileActivatedEventArgs^ args) override; + }; } diff --git a/Samples/JumpList/cpp/pch.h b/Samples/JumpList/cpp/pch.h index 1dcc72eba4..2662955e22 100644 --- a/Samples/JumpList/cpp/pch.h +++ b/Samples/JumpList/cpp/pch.h @@ -7,4 +7,5 @@ #include #include +#include "SampleConfiguration.h" #include "App.xaml.h" diff --git a/Samples/JumpList/cs/App.xaml.cs b/Samples/JumpList/cs/App.xaml.cs deleted file mode 100644 index dc7b00f811..0000000000 --- a/Samples/JumpList/cs/App.xaml.cs +++ /dev/null @@ -1,127 +0,0 @@ -//********************************************************* -// -// Copyright (c) Microsoft. All rights reserved. -// This code is licensed under the MIT License (MIT). -// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF -// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY -// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR -// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. -// -//********************************************************* - -using System; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Navigation; - -// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409 - -namespace SDKTemplate -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Construct(); - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs e) - { - -#if DEBUG - if (System.Diagnostics.Debugger.IsAttached) - { - this.DebugSettings.EnableFrameRateCounter = false; - } -#endif - - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - // Set the default language - rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - - if (!string.IsNullOrEmpty(e.Arguments)) - { - MainPage.Current.LaunchParam = "arguments: " + e.Arguments; - } - - // Ensure the current window is active - Window.Current.Activate(); - } - - private Frame CreateRootFrame() - { - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - // Set the default language - rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; - rootFrame.NavigationFailed += OnNavigationFailed; - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - return rootFrame; - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - // Add any application contructor code in here. - partial void Construct(); - } -} diff --git a/Samples/JumpList/cs/JumpList.csproj b/Samples/JumpList/cs/JumpList.csproj index 6f95e41e16..af5a126893 100644 --- a/Samples/JumpList/cs/JumpList.csproj +++ b/Samples/JumpList/cs/JumpList.csproj @@ -90,7 +90,8 @@ - + + App.xaml.cs App.xaml diff --git a/Samples/JumpList/cs/SampleConfiguration.cs b/Samples/JumpList/cs/SampleConfiguration.cs index 6fabbc800c..017b38bba7 100644 --- a/Samples/JumpList/cs/SampleConfiguration.cs +++ b/Samples/JumpList/cs/SampleConfiguration.cs @@ -65,6 +65,14 @@ protected override void OnFileActivated(FileActivatedEventArgs args) MainPage.Current.LaunchParam = "file: " + args.Files[0].Name; } } + + partial void LaunchCompleted(LaunchActivatedEventArgs e) + { + if (!string.IsNullOrEmpty(e.Arguments)) + { + MainPage.Current.LaunchParam = "arguments: " + e.Arguments; + } + } } public class Scenario diff --git a/Samples/MapControl/README.md b/Samples/MapControl/README.md index 0ab9d6d91e..d005ff4e91 100644 --- a/Samples/MapControl/README.md +++ b/Samples/MapControl/README.md @@ -37,6 +37,7 @@ Specifically, this sample shows: * Finding and downloading Offline Maps * Customizing the map appearance by using style sheets * Customizing the map elements appearance more deeply by using style entries and states +* Overlay and animate custom tiled images on the map This sample is written in XAML. diff --git a/Samples/MapControl/cpp/MapControl.vcxproj b/Samples/MapControl/cpp/MapControl.vcxproj index 2aa75f58f1..73b6f07c6d 100644 --- a/Samples/MapControl/cpp/MapControl.vcxproj +++ b/Samples/MapControl/cpp/MapControl.vcxproj @@ -180,6 +180,9 @@ ..\shared\Scenario11.xaml + + ..\shared\Scenario12.xaml + @@ -224,6 +227,9 @@ Designer + + Designer + @@ -285,6 +291,9 @@ ..\shared\Scenario11.xaml + + ..\shared\Scenario12.xaml + diff --git a/Samples/MapControl/cpp/MapControl.vcxproj.filters b/Samples/MapControl/cpp/MapControl.vcxproj.filters index 3f5167d6af..475d6537f8 100644 --- a/Samples/MapControl/cpp/MapControl.vcxproj.filters +++ b/Samples/MapControl/cpp/MapControl.vcxproj.filters @@ -34,6 +34,7 @@ + @@ -51,6 +52,7 @@ + @@ -71,6 +73,7 @@ + diff --git a/Samples/MapControl/cpp/Package.appxmanifest b/Samples/MapControl/cpp/Package.appxmanifest index 595544dcd8..9948e9b841 100644 --- a/Samples/MapControl/cpp/Package.appxmanifest +++ b/Samples/MapControl/cpp/Package.appxmanifest @@ -21,7 +21,7 @@ - + diff --git a/Samples/MapControl/cpp/SampleConfiguration.cpp b/Samples/MapControl/cpp/SampleConfiguration.cpp index cc99e99777..c891da3446 100644 --- a/Samples/MapControl/cpp/SampleConfiguration.cpp +++ b/Samples/MapControl/cpp/SampleConfiguration.cpp @@ -31,6 +31,7 @@ Platform::Array^ MainPage::scenariosInner = ref new Platform::Array timestamps{ L"900913-m50m", L"900913-m45m", L"900913-m40m", L"900913-m35m", L"900913-m30m", L"900913-m25m", L"900913-m20m", L"900913-m15m", L"900913-m10m", L"900913-m05m", L"900913" }; + +Scenario12::Scenario12() +{ + InitializeComponent(); +} + +void Scenario12::MyMapLoaded(Object^ sender, RoutedEventArgs^ e) +{ + myMap->Center = ref new Geopoint({ 39.1887643719098, -92.8261546188403 }); + myMap->ZoomLevel = 5; + + std::wstring timestampStr = L"{timestamp}"; + size_t index = urlTemplate.find(timestampStr); + + for (auto timestamp : timestamps) + { + std::wstring url(urlTemplate); + urls.push_back(ref new String(url.replace(index, timestampStr.size(), timestamp).c_str())); + } +} + +void Scenario12::AddAnimatedTilesClick(Object^ sender, RoutedEventArgs^ e) +{ + if (httpTileSource == nullptr) + { + auto httpMapTileDataSource = ref new HttpMapTileDataSource(); + httpMapTileDataSource->UriRequested += ref new TypedEventHandler(this, &Scenario12::HttpMapTileDataSourceUriRequested); + httpTileSource = ref new MapTileSource(httpMapTileDataSource); + httpTileSource->FrameCount = (int)timestamps.size(); + typedef std::chrono::duration, std::nano>> timespan_units; + httpTileSource->FrameDuration = TimeSpan{ timespan_units(500ms).count() }; + myMap->TileSources->Append(httpTileSource); + } +} + +void Scenario12::HttpMapTileDataSourceUriRequested(HttpMapTileDataSource^ sender, MapTileUriRequestedEventArgs^ e) +{ + e->Request->Uri = ref new Uri(urls[e->FrameIndex]); +} + +void Scenario12::PlayAnimationTapped(Object^ sender, TappedRoutedEventArgs^ e) +{ + if (httpTileSource != nullptr) + { + httpTileSource->Play(); + } +} + +void Scenario12::PauseAnimationTapped(Object^ sender, TappedRoutedEventArgs^ e) +{ + if (httpTileSource != nullptr) + { + httpTileSource->Pause(); + } +} + +void Scenario12::StopAnimationTapped(Object^ sender, TappedRoutedEventArgs^ e) +{ + if (httpTileSource != nullptr) + { + httpTileSource->Stop(); + } +} diff --git a/Samples/MapControl/cpp/Scenario12.xaml.h b/Samples/MapControl/cpp/Scenario12.xaml.h new file mode 100644 index 0000000000..970b30f801 --- /dev/null +++ b/Samples/MapControl/cpp/Scenario12.xaml.h @@ -0,0 +1,37 @@ +//********************************************************* +// +// 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 "Scenario12.g.h" +#include "MainPage.xaml.h" + +namespace SDKTemplate +{ + [Windows::Foundation::Metadata::WebHostHidden] + public ref class Scenario12 sealed + { + public: + Scenario12(); + private: + MainPage ^ rootPage = MainPage::Current; + + std::vector urls; + Windows::UI::Xaml::Controls::Maps::MapTileSource^ httpTileSource; + + void MyMapLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void AddAnimatedTilesClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e); + void HttpMapTileDataSourceUriRequested(Windows::UI::Xaml::Controls::Maps::HttpMapTileDataSource^ sender, Windows::UI::Xaml::Controls::Maps::MapTileUriRequestedEventArgs^ e); + void PlayAnimationTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); + void PauseAnimationTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); + void StopAnimationTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e); + }; +} diff --git a/Samples/MapControl/cs/MapControl.csproj b/Samples/MapControl/cs/MapControl.csproj index 11e1ca08f8..0f36d84efa 100644 --- a/Samples/MapControl/cs/MapControl.csproj +++ b/Samples/MapControl/cs/MapControl.csproj @@ -141,6 +141,9 @@ Scenario11.xaml + + Scenario12.xaml + @@ -218,6 +221,11 @@ Designer MSBuild:Compile + + Scenario12.xaml + Designer + MSBuild:Compile + diff --git a/Samples/MapControl/cs/Package.appxmanifest b/Samples/MapControl/cs/Package.appxmanifest index 06a0f345b4..30fddc349b 100644 --- a/Samples/MapControl/cs/Package.appxmanifest +++ b/Samples/MapControl/cs/Package.appxmanifest @@ -22,7 +22,7 @@ - + diff --git a/Samples/MapControl/cs/SampleConfiguration.cs b/Samples/MapControl/cs/SampleConfiguration.cs index 801c673458..8747ceb00f 100644 --- a/Samples/MapControl/cs/SampleConfiguration.cs +++ b/Samples/MapControl/cs/SampleConfiguration.cs @@ -34,6 +34,7 @@ public partial class MainPage : Page new Scenario() { Title="Find and download Offline Maps", ClassType=typeof(Scenario8)}, new Scenario() { Title="Custom map appearance", ClassType=typeof(Scenario9)}, new Scenario() { Title="Custom map elements appearance", ClassType=typeof(Scenario11)}, + new Scenario() { Title="Animated MapTileSource", ClassType=typeof(Scenario12)}, }; public static readonly Geopoint SeattleGeopoint = new Geopoint(new BasicGeoposition() { Latitude = 47.604, Longitude = -122.329 }); diff --git a/Samples/MapControl/cs/Scenario12.xaml.cs b/Samples/MapControl/cs/Scenario12.xaml.cs new file mode 100644 index 0000000000..fdf9977538 --- /dev/null +++ b/Samples/MapControl/cs/Scenario12.xaml.cs @@ -0,0 +1,88 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +using System; +using Windows.Devices.Geolocation; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Maps; + +namespace SDKTemplate +{ + /// + /// An empty page that can be used on its own or navigated to within a Frame. + /// + public sealed partial class Scenario12 : Page + { + // The data source is contributed by Iowa Environmental Mesonet of Iowa State University. + private string urlTemplate = "http://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-{timestamp}/{zoomlevel}/{x}/{y}.png"; + //The time stamps values for the IEM service for the last 50 minutes broken up into 5 minute increments. + private string[] timestamps = { "900913-m50m", "900913-m45m", "900913-m40m", "900913-m35m", "900913-m30m", "900913-m25m", "900913-m20m", "900913-m15m", "900913-m10m", "900913-m05m", "900913" }; + private MapTileSource httpTileSource = null; + + public Scenario12() + { + this.InitializeComponent(); + } + + private void MyMapLoaded(object sender, RoutedEventArgs e) + { + myMap.Center = new Geopoint(new BasicGeoposition() { Latitude = 39.1887643719098, Longitude = -92.8261546188403 }); + myMap.ZoomLevel = 5; + } + + private void AddAnimatedTilesClick(object sender, Windows.UI.Xaml.RoutedEventArgs e) + { + if (httpTileSource == null) + { + var httpMapTileDataSource = new HttpMapTileDataSource(); + httpMapTileDataSource.UriRequested += HttpMapTileDataSourceUriRequested; + httpTileSource = new MapTileSource() + { + DataSource = httpMapTileDataSource, + FrameCount = timestamps.Length, + FrameDuration = TimeSpan.FromMilliseconds(500), + }; + + myMap.TileSources.Add(httpTileSource); + } + } + + private void HttpMapTileDataSourceUriRequested(HttpMapTileDataSource sender, MapTileUriRequestedEventArgs args) + { + args.Request.Uri = new Uri(urlTemplate.Replace("{timestamp}", timestamps[args.FrameIndex])); + } + + private void PlayAnimationTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) + { + if (httpTileSource != null) + { + httpTileSource.Play(); + } + } + + private void PauseAnimationTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) + { + if (httpTileSource != null) + { + httpTileSource.Pause(); + } + } + + private void StopAnimationTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) + { + if (httpTileSource != null) + { + httpTileSource.Stop(); + } + } + } +} diff --git a/Samples/MapControl/shared/Scenario12.xaml b/Samples/MapControl/shared/Scenario12.xaml new file mode 100644 index 0000000000..ff8ccd441f --- /dev/null +++ b/Samples/MapControl/shared/Scenario12.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + Overlay and animate custom tiled images on a map control. + + + + +