Reference: http://msdn.microsoft.com/library/windows/apps/br211386/
Summary: Ms's getting started briefly describes how to use various methods to create a Metro program. Here, we only try to see how Ms supports JS Metro programs.
(1) development methods and languages supported by the metro Program
For Metro-style application development, you can use js to implement the Program Logic, design user interfaces in combination with HTML5/css3, or use C ++, C #, or VB in combination with XAML to implement user interfaces, use native C ++ or host C # Or VB to implement application logic. For Metro-style C ++ games, you can use native C ++'s dx11 library and HLSL.
For Win8, local extensions allow users to build Reusable Component Libraries. You can use C ++, C #, or VB to build components, then, these components are called in the program using JS or other Supported languages.
(2) The following are the project options supported by metro in vs11 pre-view provided by Win8.
(3) Hello, Metro implemented using JS
Implementing hello and Metro is simple. Use vs 11 to create a simple JavaScript project. The default Project template is as follows:
In simple analysis, the CSS folder contains the imagesfolder, The JS folder, The winjsfolder, The default.html file, and a manifest file. Actually, the general web program is similar. default.html is the "start page", and CSS and images and JS folders are some referenced files. Winjs folder. It should be noted that it is a JS library created by Win8 for js-based Metro programs. For the moment, I have understood so much. Then package. appxmanifest is familiar to developers. A list file is used for packaging. In vs, you can double-click it to open it and edit it using the UI. When ult.html is opened, some references to other CSS/JS files are provided, which provides a simple template project.
At this point, I have probably guessed that the JS-based Metro program should be packaged and put on a "Virtual Machine"/"RunTime" to run, I thought Ms would compile js to binary and become a native program. This will be further proved below.
For simplified projects, delete css1_jsfolder and winjs folder, and only the images1_default.html and package. appxmanifest contents are left at the end. In fact, this is a "simplest" js-based Metro Project. The content of default.html is as follows:
<!DOCTYPE html>
Then, use start without debuging of Vs to run the program on the metro interface.
Several problems found:
1. Some content in JS is not supported. For example, some common things such as alert are not supported. You need to use some things in winjs for implementation. Refer to examples.
function alert(theMessage) {Windows.UI.Popups.MessageDialog(theMessage).showAsync().then();}function doingSomethingAndWantToShowAnAlert() { alert("Hello Nurse");}
2. There are some problems with vs11 smart prompts. For example, the above JS Implementation of windows... does not have any prompts and is completely handwritten.
3. after running vs, return to the Vs of desktop, and use vs again to run the program (No compilation error, but the problem is running), prompting "The Shenma file is opened by other Shenma ", at first glance, we can see that the file is being used. I have to use the task manager to kill the process of the metro program before starting it again with. PS: if this is the case, it is not troublesome for others to write programs and test them. You need to use the task manager to run once.
4. The memory occupied by the above simple Metro program can reach 10 MB or more. Even in desktop, the process is in the sudedded state and remains unchanged. PS: I don't know much about memory usage or whether it is normal. However, it doesn't mean how Win8 optimizes memory management.
5. For the above js-based Metro program, in the task manager, right-click the process and go to worker. For example, the weather program (which may be written based on JS ). So far, we have a bold guess: This wwahost.exe is the "virtual machine" of these js-based Metro programs ", let me see again that the so-called js-based Metro program is native and should not. For more information, I am not a brick-and-mortar expert.
(4) Analysis of js-based Metro programs
The above has probably tried the JS-based Metro program. Continue the analysis.
1. Project projects-> Properties
Let's take a look at the projects-> properties of the js Metro Project and see if there are any configuration options. We found that there was almost nothing. Once again, we saw the similarities between it and the web, so we continued to make bold guesses, for JS Metro programs, there is no concept of "Compilation and linking". It is a "packaging" process, then, we threw a "RunTime" (I like to call it a "Virtual Machine") for execution, just like HTML/JS/CSS running on IE "RunTime/virtual machine, so, where is native!
2. vs 11 error mechanisms for JS Metro programs
In order to check vs 11's processing of HTML/JS again and see if it can check "error ". You can make a mess in HTML, or click "wrong" JS, such as <SCRIPT> test () </SCRIPT>. Use vs to build it, there will be no errors, indicating that vs 11 has no "static" error checking capability. You can find these errors by running debug. Similar to the functions of Chrome's developer tools, we can see that JS-based Metro actually parses HTML to runtime, similar to running the Web in a browser. Therefore, it is naturally more efficient, you know.
PS: I have been analyzing whether JS metro will run native. It doesn't mean that running HTML with Runtime is not feasible. Instead, I want to see if MS is running.NewSomething, get a runtime to run HTML, it is no longer a new thing, those WebKit-based mobile on the "client" program is such a principle, I really want to see if there is any way to "compile" Js for native to run. Of course, this may be really difficult.
3. build and deploy
Since there is no "Compilation, Link", let's look at what is in the build menu: build and deploy.
I think build is the packaging process, and deploy is the deployment process. PS: It reminds me of the android project. To say something more similar, it reminds me of the WAC program, package it, deploy it, and throw it to runtime to run HTML, JS, and CSS, there are so many such things that have been "hyped" in HTML5 today! In this case, let's take a look at how vs is packaged and deployed.
Let's take a look at what we can get with Build:
There is a BLD folder and a debug folder under the project directory. After deletion, the build will still be generated. As for the content in bld, I will not study it carefully for the moment. Open it in Notepad. It is estimated that it is some intermediate files. (In the manifest configuration of the project, there is a package name configuration, it's a bunch of ba6a209b-2b36-4a5e-a4d8-c122dce439e0 stuff, and the name of the subfolders in BLD is the package name ). Then there is the debug folder, which generates an XML file, an appxrecipe (also XML) file, and a prj file. The two XML files are some configuration information. VS
These files are obtained after build.
So what about deploy:
What will deploy generate after build? After you try it out, uninstall the program on the Start interface first, and then find that there is no such program on the Start interface after building. After deploy, the program will appear on the Start interface. So what exactly does vs deploy? (after deployment, deleting the vs project will certainly run the program )?
After searching, all the metro programs of deploy in vs are in C: \ Users \ <User Name> \ appxlayouts, where the package name of the program is organized as a folder. Some of the files deployed in the project contain the default.html file of the project. After the deployment, the program source code is displayed. It can be seen that it is probably a package and then thrown to the hidden IE ("RunTime") for parsing and running. Are these files necessary for running? Try to delete it and find that there is only resource. the prj file cannot be deleted (it can only be deleted after uninstall on the Start interface). After deleting all the other files, the program can still run normally. You can see resource. prj contains all the content required for running (HTML, JS, CSS, and images). What are the functions of the other deleted files, it may be related to upgrading the management program.
Note: The deployed program appears on the Start interface, where the information on the Start interface is stored, or how does it know how to start the resource. the prj file, I believe that this information is stored in a certain corner (it should be the Registry), such as getting a place to save the list of all applications on the Start interface, for each program, there is an attribute. For JS Metro programs, get an attribute called "JS Metro" and a property to specify the location of the file corresponding to the program, then, you will know how to start the desktop program at startup (the desktop program can also be displayed on the Start interface, refer to the previous article) or start Js.
Metro, or start other types. In short, everything is speculation. Specifically, where is this information and is not interested in finding it for the moment .)
4. Package the program
This package is really packed. Here, a natural problem is that the above program can be built and deploy. So what if I want to run the program on someone else's computer?
Ms introduces the store mode. The specific store does not seem to have been created yet. In the store menu of Vs, there are some content, such as the create app package ), the other is something that requires a store account. What else can be uploaded to the store. Here we will talk about packaging. After the create app pakage is used, a packages folder is generated under the project. The main file is a bat file and an installation script. An appx file can be understood as a packaged file. A Cer file may be related to authentication. You only need to run a BAT file to install it on your computer. (PS: I chose to use it only on a local machine, so it is certainly no problem. Can I get another machine to run it, or do I have to pass Ms?
Store upload/download is not clear. In short, this mode should be similar to App Store ). After installation, you can see the program on the Start interface, but this program should always have some "installation files". I thought it would also be in the appxlayouts folder of deploy, actually, no. Where is it .... I really don't want to find it. MS will know how to play with us. By chance, the C: the Update Time of the apprepository folder under the \ programdata \ Microsoft \ Windows directory is the time when I install and uninstall, that is, it is likely to be saved here. Ms is playing mysterious with me again. This folder cannot be opened. Of course, it must be a permission problem, but I don't know how to get the magic horse permission. I can't open it anyway.
Summary: Because I am not a leader, the content above may be a bit cool and simple, because I also sat here one afternoon. If I think of something, I should try it first, and then I will immediately record my thoughts, I hope I can see something innovative about ms, but I really don't see it. Apart from getting a Metro style on the interface, there is basically no innovation, including its store model. Of course, this is just a JS-based Metro program. Some Metro programs based on other languages must be similar to the above, but some may be different. (For example, I think the above HTML, CSS, and JS should be running on a runtime of the IE kernel, just as many HTML on mobile run on the runtime of WebKit, however, based on C ++, you may be able to get an EXE executable file and then execute it in native. It is unclear for the moment ). As for how to write programs and how to use winjs, these should not be a big problem, and how to get the Web or how to get it. Finally, the metro interface is good, that is, we hope that when the real Win8 is coming out, we do not want to mix the desktop interface with the Metro interface. It is unnecessary and ugly to use Metro on a PC.