5. Roaming profiles
• Local settings saving
var localSettings =
Windows.Storage.ApplicationData.Current.LocalSettings;
localSettings.Values["currentPage"] = MyBook.CurrentPage;
• Roaming Settings Saving
var roamingSettings =
Windows.Storage.ApplicationData.Current.RoamingSettings;
roamingSettings.Values["currentPage"] = MyBook.CurrentPage;
– If there is no roaming profile, It will default to local storage
8. WinRT
• WinRT is the Object Oriented Programming
replacement for Win32.
– An unmanaged native layer and its API is object
oriented that can be consumed both from native or
managed languages
– Written in C++ and designed from the beginning to
be object oriented.
– A COM-based API, relying on an enhanced COM
that implements the IInspectable interface
9. Relation between .NET & WinRT
• .NET Client profile (C#,VB.NET applications)
– Desktop Application development
• .NET Metro profile (Windows 8 application)
– subset of types from the .NET Framework
• .NET has the ability to directly reference
WinRT components as if they were .NET
assemblies.
11. WinRT Projections
• New name for ‘Bindings”
• Projections are the process of exposing APIs to
three environments:
– Native
– HTML/JavaScript
– .NET
• Hide the use of Com
14. Asynchrony in a Nutshell
• Synchronous Wait for result before returning
– string DownloadString(...);
• Asynchronous Return now, call back with result
– void DownloadStringAsync(..., Action<string> callback);
• Asynchrony benefits
– UI responsiveness: Frees UI thread for interaction
– Server scalability: Thread can be reused for other requests
15. Asynchronous Methods
Goal: Just like synchronous programming
– You can have your cake and eat it too!
• Framework: Use Task<T> for all asynchrony
– Add Task<T> support to existing .NET and Silverlight APIs
– Easy for you to do the same
• Languages: Asynchronous Methods
– “async” modifier marks method or lambda as asynchronous
– “await” operator yields control until awaited task completes
16. Task<T>
• Represents “ongoing operation”
– Could be async I/O, background worker, anything...
– Single object for status, result and exceptions
• Composable callback model
– var task2 = task1.ContinueWith(t => … t.Result …);
– The “await” operator rewrites to continuations
• Combinators
– WhenAll, WhenAny, Delay, etc.
17. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcesAsFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
18. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
19. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
20. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
21. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
22. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
23. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
24. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
25. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
26. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
27. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
28. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
29. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
30. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
31. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
32. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
33. Asynchronous Control Flow
async void DoWorkAsync() {
var t1 =
ProcessFeedAsync("www.acme.com/rss");
var t2 =
ProcessFeedAsync("www.xyznews.com/rss");
async Task ProcessFeedAsync(string
await Task.WhenAll(t1, t2);
DisplayMessage("Done"); url) {
} var text = await
DownloadFeedAsync(url);
var doc =
ParseFeedIntoDoc(text);
await SaveDocAsync(doc);
ProcessLog.WriteEntry(url);
}
35. Windows 8 Application Requirements
Logo images: large & small
Splash screen
Privacy policy
State persistency
About
Test screens in 3 main resolutions
Help
37. Windows 8 Application Requirements
Search contract
Push notification
Toast notification
App bar application part
App bar item specific part
Title bar
Pin items
38. Windows 8 Application Requirements
Extended splash screen
Share contract
Transitions between screens
Animations
41. UI Changes
• New Features and capabilities should be
considered as part of the design of the new
application:
– Touch first, less chrome, fast, fluid;
– Live Tiles
– Application bar
– Charms
• New namespaces Windows.UI.Xaml vs
System.Windows
42. I/O changes
• Asynchronous only using async – await
keywords
• Functions name changed:
– System.IO.Stream.BeginRead to
System.IO.Stream.ReadAsync
43. Storage Changes?
• Instead of using the System.IO.IsolatedStorage
class, use the types in the Windows.Storage
Replace With
System.IO.IsolatedStorage. Windows.Storage.
IsolatedStorageFile ApplicationData.Current.LocalFolder
System.IO.IsolatedStorage. Windows.Storage.
IsolatedStorageSettings ApplicationData.Current.LocalSettings
44. Threading Changes
Replace With
System.Threading.Thread.MemoryBarrier Interlocked.MemoryBarrier method in the
method System.Threading namespace
System.Threading.Thread.ManagedThread Environment.CurrentManagedThreadId
Id property property in the System namespace
System.Threading.Thread.CurrentCulture CultureInfo.CurrentCulture property in
property the System.Globalization namespace
System.Threading.Thread.CurrentUICultur CultureInfo.CurrentUICulture property in
e property the System.Globalization namespace
Windows.System.Threading.ThreadPoolTi
System.Threading.Timer class
mer class
Windows.System.Threading.ThreadPool
System.Threading.ThreadPool class
class
45. Reflection changes
• Most members from the System.Type class
have been moved to the
System.Reflection.TypeInfo class.
• Retrieve the TypeInfo object by calling the
System.Reflection.
IntrospectionExtensions.GetTypeInfo(System.Type)
46. Extension methods - converting types
• System.IO.WindowsRuntimeStreamExtensions
– Converting between managed streams and streams in the
Windows Runtime.
• System.IO.WindowsRuntimeStorageExtensions
– Opening Windows Runtime files and folders as managed
streams.
• System.Runtime.InteropServices.WindowsRuntime.
WindowsRuntimeBufferExtensions
– Converting to and from IBuffer.
48. Features
• Files and Storage
– Several ways to access the same file
• Isolated Storage as WP7.1
• Storage APIs using URI: ms-appdata:///local/myfile.txt
• Storage APIs
– Compatibility
• WP8 Storage is subset of WinRT
• Not Supporting: Roaming and Temporary data, Local
and Roaming Settings
49. Features (Cont.)
• Reserved Folders
– Shared/Media – album display while playing audio
– Shared/ShellContent – background images for tiles
– Shared/Transfers – used by Background File
Transfer service
50. Features (Cont.)
• Background Agents
– Renew often
– Do not implement critical tasks
– For more reliable tasks use push notifications
• Tiles and Lock Screen Notifications
• Push Notifications
51. Features (Cont.)
• Resources
– Contacts and Calendars in Windows Phone
– Launchers and Choosers
– Alarms and reminders
– The Windows Phone camera
– The Windows Phone sensors
– Video content
52. Features (Cont.)
• App to App communication
– Auto-launching with File and Protocol associations
– File associations
– Protocol associations
• Network Communication
• Proximity Sensors and Bluetooth
53. Features (Cont.)
• Speech Input
• Maps and Location
• Wallet Support
• In-App Purchasing
59. Launchers and Choosers
• Launcher
– API that launches one of the built-in applications,
such as the Contacts application
– When the new application appears, the user can
choose to complete or cancel the task.
– When the user closes the new application, the
calling application is usually reactivated.
60. Launchers and Choosers
• Chooser
– API that launches one of the built-in applications,
such as the Contacts application or the camera,
through which the user completes a task.
– When the new application appears, the user can
choose to complete or cancel the task.
– When the user closes the new application, the
calling application is usually reactivated and
supplied with data and status.
63. Camera
• Ways to use Camera
– CameraCaptureTask chooser
• Photograph a picture
– PhotoCamera class
• Capture photos & video streams
– PhotoCaptureDevice or AudioVideoCaptureDevice
• Advance capturing
• Real time video processing app can be
registered as “Lens”
72. Conditional Block
• Enable/Disable lines of code based on
compilation platform
• Constants
– NETFX_CORE – Windows 8
– WINDOWS_PHONE – Windows Phone 8
• Use when there are small differences
• Otherwise difficult to maintain the code
76. Partial Classes & Methods
• Shared functionality on one code file
• Platform specific in additional code file
• Classes are marked as partial
• Link to shared functionality file in both
projects
Windows 8 Development for PCs, Tablets & Mobile Course Description:Learn all about the new app model (Metro style apps) that allows you to create powerful new apps. All while retaining the ability to use your existing apps. Web-connected and web-powered apps built using C# and XAML have access to the power of the PC. This course walks you through creating a complete Metro style app using C# with XAML. Metro style apps are focused, fluid, and elegant. From the new Start screen to new UI layout and controls, the presentation of your app is about showing off what it's great at. Windows 8 IntroductionWindows is the next version of Microsoft Windows, a series of operating systems produced by Microsoft for use on personal computers, including home and business desktops, laptops, netbooks, tablet PCs, and media center PCs. Windows 8 unified the UX for all the above devices. In this Module you will learn the Windows 8 UX principles and architecture. New desktop design Start screen Touch, Keyword and mouse activation in different platforms Roaming profiles Windows 8 architecture History VaultMetro Style Apps DevelopmentMetro style apps are full screen apps tailored to your users' needs, tailored to the device they run on, tailored for touch interaction, and tailored to the Windows user interface. Windows helps you interact with your users, and your users interact with your app. Controllers Overview Metro Infrastructure Metro style apps built-in controls Visual Studio 2011 and Bled 5 for developed Metro style Apps Developing basic Metro style apps using C# and XAML Metro style apps with OData and WCF RIA Services Debugging Metro style apps Metro Apps Packaging and DeploymentWindows Runtime (WinRT)Windows 8 features many improvements in security and privacy. In this module you will learn how to take advantages of those features and how to write more secure applications. Metro style apps secure environment principles SmartScreen filter Windows Defender Secured boot AppLockerBitLockerUpgrading your existing .NET Framework applicationsWhen converting existing .NET Framework code, you should be aware of the following changes you may need to make in your Metro style app: UI changes I/O changes Storage changes Threading changes Reflection changes Changes in general .NET Framework typesResilient File System (ReFS)ReFS is the next generation file system being introduced in Windows 8 replacing NTFS. In this module you will get an introduction of this new file system. Key goals Key design attributes and features Code reuse and compatibility On-disk structures
Here should be a live demo of Windows 8 operating system
Windows Runtime, or shortly WinRT, is Microsoft’s new programming model that makes the backbone of the new Metro-style apps (also known as Immersive) in the new Windows 8 operating system. WinRT solves many of the problems of Win32, from an apps perspective. Apps created for WinRT are safe, secure, and sandboxed, can’t wreck other apps and all install in just 2-3 seconds. They feature isolated storage, single folder installs (as per the Mac), and require user consent to access the general file system. This is part of it, a modern, truly different app platform that is far more different, and far more capable, than many people understand right now.
The WinRT type system relies strongly on WinRT components, which are COM objects implementing a specific set of interfaces and adhering to a certain ABI (Application Binary Interface). WinRT is essentially a COM-based API, relying on an enhanced COM that implements the IInspectable interface. The IInspectable interface enables projecting Win32 and COM features into JavaScript and other languages, such as C# and Visual Basic. *Implement the IInspectable interface when you want your class to be available in other programming environments. *The IInspectable interface is the base interface for all Windows Runtime classes. All Windows Runtime classes must implement the IInspectable interface. The IInspectable interface inherits from the IUnknown interface. so every WinRT object implements IUnknown and does refcounting (WinRT objects are reference counted like COM for memory management, with weak references to avoid circularity), and builds from there. It does add quite a lot of new concepts in comparison to COM of old, most of which come directly from .NET – for example, WinRT object model has delegates, and events are done .NET-style (with delegates and add/remove subscriber methods, one per event) rather than the old COM model of event sources and sinks. Of other notable things, WinRT also has parameterized (“generic”) interfaces.
WinRT collection interfaces such as IIterable and IVector become IEnumerable and IList; and so on. This goes both ways – if you have a .NET object that implements IEnumerable, and pass it back to WinRT, it’ll see it as IIterable.
What we call "bindings" Microsoft now calls "projections". Projections are the process of exposing APIs to three environments: Native (C and C++), HTML/JavaScript and .NET. If you author a component in C++ or a .NET language, its API will be stored in a WinMD file and you will be able to consume it from all three environments (Native, JavaScript and .NET). Even in C++ you are not exposed to COM. The use of COM is hidden behind the C++ projection tools. You use what looks and feels like a C++ object oriented API. To support the various constructs of WinRT, the underlying platform defines a basic set of types and their mappings to various environment. In particular, collection objects in WinRT are mapped to constructs that are native to each environment.
C++11 with WinRT: C++ Development A good news for C++ developers is that User interfaces in C++ will be written primarily in XAML for immersive applications. However, this is not available for classical, Win32 applications. This libraries for working with XAML have all been ported to C++ and are compiled to native x86. Metro applications written with XAML and C++ do not run on top of .NET, they get compiled directly to x86 just like any other Visual C++ application. Calling methods on UI controls is just like calling methods on any other object in C++.
Push notification – comes from serverToast notification – displayed on screen
Start grid application from template and explain structure
Examples of Chooser tasks include selecting a contact’s email address, selecting a photo from the phone, and saving a new ringtone.
WP8 course part 19Portable libraryMvvmShare files between projects in order to use partial classNavigation is different need common service
http://blogs.msdn.com/b/b8/archive/2012/01/16/building-the-next-generation-file-system-for-windows-refs.aspxData can get corrupted due to a number of reasons and therefore must be verified and, when possible, corrected automatically. Metadata must not be written in place to avoid the possibility of “torn writes,” which we will talk about in more detail below.Use scalable structures for everything. Don’t assume that disk-checking algorithms, in particular, can scale to the size of the entire file system.Assume that in the event of corruptions, it is advantageous to isolate the fault while allowing access to the rest of the volume. This is done while salvaging the maximum amount of data possible, all done live.