Object-Oriented and Modern COM
At its heart, the WinRT provides an object-oriented API to access a wide range of operating system capabilities, aimed at building modern applications. For example, using the webcam from a Windows Store app built in C# looks like this:
using Windows.Foundation;using Windows.Media.Capture;using Windows.Storage;using Windows.Storage.Streams;using Windows.UI.Xaml.Media.Imaging;...public async Task<BitmapImage> TakePictureAsync(){ CameraCaptureUI cameraUI = new CameraCaptureUI(); cameraUI.PhotoSettings.AllowCropping = true; cameraUI.PhotoSettings.CroppedAspectRatio = new Size(4, 3); cameraUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Png; StorageFile file = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Photo); ...
Get C# 5.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.