Presentation is loading. Please wait.

Presentation is loading. Please wait.

Universal Windows Platform One codebase for Mobile, Desktop, IoT, Xbox, HoloLens, etc. Gergely

Similar presentations


Presentation on theme: "Universal Windows Platform One codebase for Mobile, Desktop, IoT, Xbox, HoloLens, etc. Gergely"— Presentation transcript:

1 Universal Windows Platform One codebase for Mobile, Desktop, IoT, Xbox, HoloLens, etc. Gergely Kalapos @gregkalapos

2 About me Gergely Kalapos, Short: Gergö Working @Dynatrace as a Software Engineer Born in Hungary Studied Software Engineering at JKU in Linz Started with.NET development around 2008

3 Goal of the talk Give an overview about UWP E.g. if you have a product and you have to deliver a Windows client/version UWP can be relevant. After this talk you should be able to decide if UWP is the way to go. Show you an interesting concept (1 codebase (including UI!) for everything) E.g. if you are an iOS developer imagine that you write one codebase for Mac, Apple Watch, iPhone, iPad, and iWoaßNetWos This is not a deep dive talk on UWP

4 Goal of the talk I don’t work for Microsoft -> I will also tell you what I don’t like about it or what are thing which do not work well

5 Outline 1.What is UWP? Why did Microsoft create it? 2.Create a single UI: Phone(~4”) Surface hub 55” 3.Code sharing: IoT (Resberry Pi) Desktop PC (i7, 16GB Ram) 4.Cortana Integration

6 How to try it? Install Visual Studio 2015 and Windows 10 (It also works with a VM, it runs perfectly on my Mac with VMware!)

7 How to try it?

8 History Source: Microsoft

9 Windows Runtime

10 Windows Runtime – Why do we need it? public async Task LongRunningMethod() { var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("VeryBigFile.dat ", Windows.Storage.CreationCollisionOption.ReplaceExisting); using (var stream = await file.OpenStreamForWriteAsync()) { using (var streamWriter = new StreamWriter(stream)) { var lotsOfData = GetLotsOfData(); await streamWriter.WriteAsync(lotsOfData); }

11 Benefit

12 One UI for every Windows 10 device

13 Devices with very small (Phone) and very big (Xbox) display. What about the UI? Tailored UI selected manually. //Get the diagonal size of the integrated display var dsc = new DisplaySizeHelper.DisplaySizeClass(); double _actualSizeInInches = dsc.GetDisplaySizeInInches(); //If the diagonal size is <= 7" use the OneHanded optimized view if ( _actualSizeInInches >0 && _actualSizeInInches <= ONEHANDEDSIZE) { rootFrame.Navigate(typeof(MainPage_OneHanded), e.Arguments); } else { rootFrame.Navigate(typeof(MainPage), e.Arguments); } Avoid this if you can (it’s possible in most cases!)

14 Devices with very small (Phone) and very big (Xbox) display. What about the UI? Tailored UI, selected by the framework Avoid this if you can (it’s possible in most cases!)

15 Adaptive UI Adaptive triggers Declarative state transition Two built in trigger: MinWindowHeight, MinWindowWidth

16 Adaptive UI Adaptive State Setter Setting values in a visual state

17 Adaptive UI StateTriggers and Setters form a visual state. All the Setters are applied when the StateTrigger returns true.

18 Adaptive UI Recommendation: Use this, if there is no specific reason not to use Adaptive UI E.g. Continuum

19 Adaptive UI Demo (Hello World + PasswordWallet + Expression Blend)

20 One codebase for every Windows 10 device

21 Adaptive Code – How to take advantage of special hardware – The Windows 8.1 Solution 1 codebase 2 binaries Compilation directives C# Syntax #if WINDOWS_PHONE_APP Windows.Phone.UI.Input.HardwareButtons.BackPressed += this.HardwareButtons_BackPressed ; #endif C++ Syntax #if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP _backPressedEventToken = HardwareButtons ::BackPressed += ref new EventHandler (this, &NavigationHelper::HardwareButton_BackPressed); #endif And this was very- very ugly!

22 Adaptive Code – How to take advantage of special hardware – The UWP way There is really a single binary for every device family No ifdefs -> this is done in runtime There is a common API surface (More then 80% of all the APIs is there) All the rest are in so called platform specific APIs, which do not invalidate binaries! If you add a platform specific api you can light up device specific features only for a specific device family. (e.g. in a contacts app on mobile can also call a contact)

23 Adaptive Code – How to take advantage of special hardware – The UWP way Windows universal Desktop PC 2 in 1 Mobile Tablet Phablet Phone Xbox IoT Band IoT headless Raspberry Pi Home Automation Surface Hub Holographic HoloLens

24 Adaptive Code – How to take advantage of special hardware – The UWP way Platform Specific APIs can be added as new references

25 Testing for capabilities IsApiContractPresent IsEnumNamedValuePresent IsEventPresent IsMethodPresent IsPropertyPresent IsReadOnlyPropertyPresent IsTypePresent IsWriteablePropertyPresent Windows.Foundation.Metadata.ApiInformation

26 Testing for capabilities var api = "Windows.Phone.UI.Input.HardwareButtons"; if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent(api)) { Windows.Phone.UI.Input.HardwareButtons.CameraPressed += CameraButtonPressed; }

27 ApiInformation demo Demo

28 Limit the App to a specific device family By default the app runs on every device family. In the manifest you can change this Runs only on Mobile device family:

29 Cortana Integration

30 Demo Sample from Microsoft

31 Cortana Integration – 1. The VCD File Adventure Works, When is my trip to Las Vegas? When is my trip to Las Vegas? when is [my] trip to {destination} Looking for trip to {destination} Las Vegas Dallas New York

32 Cortana Integration – 2. Registering the VCD StorageFile vcdStorageFile = await Package.Current.InstalledLocation.GetFileAsync(@"AdventureWorksCommands.xml"); await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager.InstallCommandDefiniti onsFromStorageFileAsync(vcdStorageFile);

33 Cortana Integration – 3. AppService (Only for background stuff)

34 Summary

35 Resources A Developer’s guide to UWP https://mva.microsoft.com/en-us/training-courses/a-developer-s- guide-to-windows-10-11341 https://mva.microsoft.com/en-us/training-courses/a-developer-s- guide-to-windows-10-11341 About API contracts from Larry Osterman (Explains the low level implementation of API Contracts, very interesting!) https://channel9.msdn.com/Shows/Defrag-Tools/Defrag-Tools- 141-Larry-Osterman-API-Contracts https://channel9.msdn.com/Shows/Defrag-Tools/Defrag-Tools- 141-Larry-Osterman-API-Contracts Sample Apps https://github.com/Microsoft/Windows-universal-samples https://github.com/Microsoft/Windows-universal-samples

36 Why do I do this?

37 Thank you!


Download ppt "Universal Windows Platform One codebase for Mobile, Desktop, IoT, Xbox, HoloLens, etc. Gergely"

Similar presentations


Ads by Google