
For the last 5-7 years, we have all witnessed a phenomenon that analysts call IT consumerization. Without going into the history and details of this phenomenon, which is characteristic not only of the IT industry, it is worth noting that it is the “concierge” that today creates the lion's share of the notorious added value - sometimes with its large number, sometimes with the ability and desire to overpay for new items and interesting ideas.
The Windows operating system, which became widespread on the wave of consumerization of the mid-nineties, systematically developed until the middle of the “zero”, when the personalization of computing received a new powerful impetus - real mobility and accessibility.
At the same time, with the filing of Apple and simply due to the cheaper production of the corresponding screens, the touch-interface began to gain enormous popularity when the user works with applications using touches and gestures, directly touching the screen with his fingers.
![clip_image003 [6] clip_image003[6]](https://habrastorage.org/getpro/habr/post_images/493/f5f/259/493f5f25970ba75c03a394e4e2a4be6e.png)
Another significant shift that greatly influenced the minds of application developers was the consequence of the total mobilization of computation — simplifying applications. No, people did not work less with "complex" applications and their performance did not fall. They began to work and play with the computer (in the form of a phone, tablet or laptop) an order of magnitude more often, almost constantly, on the go. People have become much more needed applications.
![clip_image005 [4] clip_image005[4]](https://habrastorage.org/getpro/habr/post_images/5cd/862/ae9/5cd862ae9a7dba1a5305113cb5b47de1.png)
But, as a result of the environment and the size of the devices, all these applications became very simple, most often aimed at the consumption of content or the game. In other words, without reducing the demand for
building applications, there was a huge, substantially greater need for applications for
consumption .
Another characteristic phenomenon has become the popularity of app stores. This simple idea solved two major tasks: for the user, where to get the application, for the developer, where to sell it. For all the simplicity of the idea, for many years the so-called “sales channel” was a headache for consumer application developers. This is the case when direct instructions on where to buy and where to sell make the path from the developer to the buyer the shortest. And, of course, an important factor in the success of modern app stores has become the simplicity with which individual developers or small teams can post their creations for sale. This, by the way, is one of the few differences between app stores and classic retail.
Each of us today, working with Visual Studio, AutoCAD, Photoshop, Excel or 1C, performs the same task for the world of software and computer manufacturers as it bought home and bread 15-20 years ago. Taking a smartphone or tablet in your hands, you become a buyer of “sneakers and orbits”, that is, goods with either significantly higher turnover or, more often, “and”, with a higher added value.
![clip_image007 [4] clip_image007[4]](https://habrastorage.org/getpro/habr/post_images/573/d87/3ce/573d873ced55a3ffeabbe168a9ad5bf1.jpg)
Windows developers, long before the advent of the iPad, began a project to develop a new generation of the flagship operating system, where 3 tasks were solved:
1. Increase battery life in three ways - general optimization, transfer to other architectures (ARM) and, finally, the development of rules for developers when the application minimizes resources consumed.
2. Optimization for touch-interface.
3. Creating an ecosystem for the sale and promotion of applications.
As a result, a new Windows began to crystallize, promising to be the most significant shift in the paradigm of Microsoft operating systems and, at the same time, the most risky. Since the days of Windows 95, we have not proposed such drastic changes for developers and users. And given the huge prevalence of Windows, today's changes are the biggest in history.
At the same time, Windows 8 is the largest developer opportunity ever. After all, every Windows user has a Windows Store — an application store, which is the main (and in some cases the only) application source for his computer, be it a desktop, laptop, or tablet. Windows 8 economy is a good topic for a separate article. Now is the time to move on to application development.
If you have not downloaded Windows 8 Release Preview and Visual Studio 2012 RC yet, now is the time to put them on download. Windows 8 can be downloaded
from here , and Visual Studio 2012 RC is available
here . For development for Windows 8, you need Windows 8 itself.
What is Metro
The main changes for the user and the developer in Windows 8 can be described in one word - METRO. This term includes two new concepts: Windows Runtime (WinRT) and Metro UI.
Speaking of “metro-applications”, we mean not only a new interface, but also a new development platform. It is important.
What is a metro style app? In short, this is a fusion of a new interface paradigm, a new efficient API and a corresponding development platform, plus integration with the system and other applications.
Applications have one window with support for multiple views.
Unlike classic applications, Metro-style apps contain one window without chrome, which by default takes up the entire screen so that the user is not distracted by unnecessary details.
![clip_image008 [4] clip_image008[4]](https://habrastorage.org/getpro/habr/post_images/2f6/c0f/42d/2f6c0f42d7705d2ffa75f92dc202b1f0.png)
A Metro style application can support various layouts and views to provide a dynamic and convenient user experience with various design parameters and screen sizes of devices.
![clip_image009 [4] clip_image009[4]](https://habrastorage.org/getpro/habr/post_images/477/1d6/e97/4771d6e9713ebaf7fbb6f2a7efb210af.png)
Applications allow you to use touch input? pen input, keyboard and mouse
Metro style apps work seamlessly with various input sources, including pen, mouse, keyboard, and touch input. For all of these input sources, you can use a single set of events. Metro style apps include a default set of styles to ensure the normal operation of user interface elements with touch input.
![clip_image003 [7] clip_image003[7]](https://habrastorage.org/getpro/habr/post_images/493/f5f/259/493f5f25970ba75c03a394e4e2a4be6e.png)
')
Applications can interact with each other.
Application contracts are an opportunity for users to easily search across multiple applications and share content between them. They extend the practical utility of your application, eliminating the need to interact with various API standards for specific applications when you need to access data stored in another application or created by it. At the same time, the user remains in your proprietary environment. You do not need to know anything about the target application, except for the support of the target contract announced by him - it just works.
New controls and interface areas are available in applications.
Metro style apps contain several new controls that simplify the organization of effective user interaction. Among these elements, you can select the application command bar (App Bar) and the charms button (Charms).
App command line (App Bar)
The application command line is located outside the application window and is its main command interface. Use the command line to place navigation elements, commands and tools for users. By default, the application's command line is hidden and appears when the user moves his finger in the direction from the top or bottom edge of the screen. It is the cover for the content of the application and can be hidden by the user if he runs his finger along the edge of the screen or interacts with the application.
![clip_image010 [4] clip_image010[4]](https://habrastorage.org/getpro/habr/post_images/3f8/9e1/4d7/3f89e14d79d97befa1a43ca997c86805.png)
Wonder buttons (Charms)
Wonder buttons are a defined and consistent set of buttons used in all applications to search, send, connect, configure, and launch. We believe that these are the main working scenarios that all users want to run in almost every application they use. Users can:
- Search for content hosted by your or another application. In addition, the search for content in your application is possible from another application.
- Share content from your app with contacts or services.
- Go straight to your Home screen .
- Connect to devices and send content, stream multimedia, and print documents.
- Use the settings to customize the application on your own.
![clip_image011 [4] clip_image011[4]](https://habrastorage.org/getpro/habr/post_images/872/2f6/531/8722f65318036c2dadaa196e725fd9ff.png)
Apps use tiles instead of icons (Tiles vs. Icons)
When the user installs your application, it appears on the initial screen as a tile. If you touch or click a tile, the application will be launched.
![clip_image012 [4] clip_image012[4]](https://habrastorage.org/getpro/habr/post_images/df6/fee/e7a/df6feee7a3207aff15e03429ef85af92.png)
An application can provide content using a tile, even when not in use. Using
dynamic tiles ( Live Tiles) , the application is capable of displaying useful data in short form with a minimum battery consumption of the device.
An application can configure the system to periodically request updates in a web service, regardless of whether it works. In addition, Windows push notification service (WNS) settings are available in applications to send messages directly from the web service to dynamic tile.
![clip_image013 [4] clip_image013[4]](https://habrastorage.org/getpro/habr/post_images/b11/b01/64d/b11b0164d1a309930c95aedf64eccdc3.png)
Writing applications in a familiar developer language
You can create Metro style apps in languages ​​that you know best, for example, in JavaScript, C #, Visual Basic, or C ++. Moreover, you can create components in one language and use them in an application written in another programming language.
Selling apps through the Windows Store
The main source of Metro-style apps is the Windows Store. You create an application, specify a price, and Windows Store offers your application on the world market in more than 100 languages.
![clip_image014 [4] clip_image014[4]](https://habrastorage.org/getpro/habr/post_images/493/36e/21c/49336e21c7abf334288981b541c9ce79.png)
Winrt
Until recently, Windows developers used two main API groups: native through the Win32 API and managed through the .NET Framework. At the same time, the second group gradually developed, receiving various models for creating a user interface, working with data and services, building source code and application architecture, and so on.
Meanwhile, Windows itself - that is, the Win32 API received not so many real impetus to the development of the basic development model. Perhaps the last significant phenomenon was COM. All these years the computers themselves were not standing still. All sorts of sensors, network devices (including 3G / LTE, etc.), cameras, touch-sensitive screens appeared. Finally, power consumption has become increasingly important.
Thus, creating a new Windows, we realized that it was necessary to develop a new API, which, being native for the operating system, would meet certain minimum requirements and trends of time. As a result, the Windows Runtime (WinRT) was born.
What WinRT carries with it:
1. This is a native API that works in conjunction with an optimized COM API. At the same time, it is possible to work manage-environments on top of WinRT (and the .NET Framework in Windows 8 - for example).
2. This is an object-oriented API, including a universal type metadata format.
3. WinRT includes support for many modern properties of personal computers (sensors, cameras, etc.). and energy saving is extremely important here.
4. This is a language-independent API that initially supports various models:
a. C ++
b. .NET Framework with C # and Visual Basic
c. HTML5 and JavaScript
5. The modern declarative model for developing interfaces on XAML or HTML5 has become part of the Windows API, and not a superstructure above it.
As a result, Windows applications were divided into 2 groups:
1. Classic desktop applications.
2. New metro applications.
![clip_image016 [4] clip_image016[4]](https://habrastorage.org/getpro/habr/post_images/b98/fc9/a7a/b98fc9a7a1b153577a557b6ed70eaaae.jpg)
WinRT itself, in addition to the actual functionality responsible for performing certain functions, received a number of important components.
![clip_image018 [4] clip_image018[4]](https://habrastorage.org/getpro/habr/post_images/d20/5f1/78d/d205f178d602d5a6ce9848794a21c77e.jpg)
These components are:
1. Subsystem of metadata and language projections.
Thanks to her, components written in different programming languages ​​can call each other.
2. Brokers. These components have two important functions:
a. Supports data exchange between applications. For example, in those cases when you want to send data from an application through an email client.
b. Protection of some important calls through the capabilities mechanism and explicit permissions. For example, if an application wants to use a camera, the system will first ask the user if it allows it. Similarly and, for example, with GPS, the application should indicate such a need at the design stage, plus the user can explicitly allow or forbid him to use the location information.
There are also two other important parts of the Windows API available and used by metro applications:
1. Application Model and Windows Store API.
This group manages important components of the application:
a. The composition of the components.
b. Capabilities affecting the security and operation of the system, such as access to a location, file system, network, user identification, all sorts of integration points with the system, and so on.
c. Interaction with Windows Store and information about the application, which, as we already know, in most cases, will be installed from there.
2.
DirectX and a
subset of Win32 and COM API available for components and applications developed in C ++.
On the one hand, they are necessary for developers of games and multimedia applications (DirectX), on the other hand, for porting existing code (a subset of Win32).
Application Execution Model in WinRT
Separately, it is necessary to dwell on the execution model or, as you can still say, the life of the application in Windows 8 and WinRT.
The life cycle of a metro application differs significantly from that of classical applications. It can be divided into three groups:
1. Installation.
2. Execution.
3. Removal.
With the first and third, everything is more or less clear, although the Windows Store provides additional features here. But the execution cycle itself requires separate attention.
The stages of application execution are precisely described by the
ApplicationExecutionState enumeration.
![clip_image019 [4] clip_image019[4]](https://habrastorage.org/getpro/habr/post_images/65e/d52/104/65ed521043f904dd0cbc7c9dc2f97114.png)
Simply put, if the user is not working right now with your application, the application itself does not work either. It either sleeps (suspended) or is completely unloaded. Read more about this in the
Application lifecycle article.
However, one should not think that it is impossible to perform background processes in WinRT. Two remarkable documents describe very well the approaches and rules for developing background processes.
File system and application data in WinRT
Another feature of WinRT is how to work with files and data. To begin with, it should be said that, in the general case, the data of metro-applications are isolated from each other. This ensures the stability and security of both the applications themselves and the system as a whole.
You can read more about these applications
here , but the point is that every metro application has three types of file storage:
1. Local.
2. Temporarily.
3. Portable (roaming).
The first type, as the name implies, contains the files and folders that the application creates on the local computer in a special area allocated to this application.
The second type is very similar to the first, with the exception that as soon as the application is unloaded, the system can delete such temporary data at any time.
The third type of storage, roaming, is the files and folders synchronized between all devices with Windows 8, where the same user who originally created the data in your application registered. The user is identified by Microsoft ID, which is also known by everyone under the name LiveID.
File system and permissions
All this does not mean that the application can not access files located on the rest of the disk space of the device. There are two mechanisms for this:
File Pickers and
Libraries .
The first mechanism allows access to files through a user request to select such files. He explicitly selects them, thus giving access to these files to your application.
The second mechanism gives direct access to the Windows
document library files: Documents, Pictures, Videos, etc. This approach requires two conditions:
1.
Declarations of the fact that you want to access the libraries. The declaration is made at the stage of application development. By installing it from the Windows Store, the user sees which libraries the application will have access to.
2. For some types of libraries (Documents and files on external devices) it is necessary to determine the
association of an application with file types . And it is to the files of these types that it will get access.
You can read more about all this
here .
Application Manifest and capabilities
Above, the text has already repeatedly mentioned capabilities (characteristics) in the context of a declaration by the application of certain actions that it plans to perform in the system.
Indeed, the scheme of an application package is important in itself, and the manifest file as its part says a lot about the program's functionality.
Read more about it
here . Also watch and listen to
this session of the BUILD conference.
Further steps
This article provides an overview of the basic ideas of Windows 8:
· Why it was created exactly
· What is Metro and Windows Runtime (WinRT)
· What are the features of the functioning of applications in WinRT
Now it's time to run Visual Studio 2012 in the already installed Windows 8 and try to write your first application.
To do this, there is an excellent step-by-step tutorial on “
Developing Metro style apps with Visual Studio 2012 RC ”.
![clip_image020 [4] clip_image020[4]](https://habrastorage.org/getpro/habr/post_images/995/7a6/ff3/9957a6ff38cba2cc9fa19e00505417ff.png)
It is very important to plan the application correctly - its interface, organization chart, possibilities for integration with the system, etc. The
Metro style app guide will help you with this.
useful links