3. Topics Windows Phone hardware examined Processor and operating system Graphical Display Touch input Location sensors Camera Memory Network
4. The Windows Phone Device The Windows Phone is a pretty powerful device Best regarded as a computer that can make phone calls Runs an operating system specially optimised for mobile devices
5. Windows Phone processor speed The Windows phone hardware standard requires that a Windows Phone device will have a processor “clock speed” of at least 1 GHz This means that something will go “tick” inside the phone 1,000,000,000 times a second A tick lasts a nanosecond, the time it takes light to travel around 30 cm
6. Processors and Clocks Each time the clock in a Central Processor Unit (CPU) goes “tick” a particular low-level operation will be performed Perform part of a hardware instruction Load data from memory Store data into memory The faster the clock ticks, the faster the processor is running
7. Clocks and speeds A Windows PC processor runs at 2-4 GHz, a A Windows Phone processors start at 1 GHz This does not mean a phone is around half the speed of a desktop PC The clock speed is just one factor that determines computer speed A bit like engine size in a car
8. Speed and processors Some processors need more “ticks” to perform the same action Phones use “Reduced Instruction Set Computing” designs which reduce the amount they can do per clock tick The desktop PC may contain multiple processors The Windows Phone cannot run at full speed all the time as this would flatten the battery
9. Performance and programs When you write a Windows Phone application you have to worry about performance There is not the spare processing power available to compensate for poor programming techniques Performance must be considered at all times This will turn us into better programmers The techniques we are going to learn will improve all the programs we write
10. Windows Phone Operating System Windows Phone 7 is not based on the Windows 7 operating system The numbering is coincidental Windows Phone is actually based on Windows Compact Edition (Windows CE) This is an operating system specially built for use in battery operated devices with low power processors
11. Operating Systems and Programs From the point of view of a programmer the operating system is becoming less important We are going to write Silverlight and XNA applications that make method calls to use the underlying system How that underlying system works does not affect our programs directly They can run on any platform 11
12. Windows Phone Graphical Display The Windows Phone has a high resolution display with at least 800x480 pixel resolution This makes a lot of work for the hardware The higher the resolution of the display the more work needed to keep it up to date The display can be used in landscape and portrait mode The phone will detect how it is being held and a program can change the display to match
13. Graphics Hardware Acceleration Desktop PCs have used graphical acceleration for a long time The Graphical Processing Unit (GPU) draws the display and performs image processing on it GPUs are now appearing in mobile phones The Windows Phone contains a GPU Used to render user Silverlight user interfaces Also used to create 3D games in XNA
14. Touch Input Modern mobile devices are making increasing use of touch screens These are now provided in addition to a keyboard The Windows Phone user interface is entirely touch based, using a capacitive multi-touch input device
15. Resistive Touch Input Screens Early mobile devices used resistive touch screens Touching the screen connects two plastic membranes to form a circuit The resistance across this circuit is used to work out the location of the touch This technology is very precise (particularly if a stylus is used) But it cannot easily detect more than one touch
16. Capacitive Touch Input Capacitive touch sensors detect the change in capacitance caused by touch event There is no physical movement The touch sensor can be printed on a glass screen The resolution of a capacitive screen is not as great as a resistive one This is not a problem as the user will be touching with a finger, not a stylus A capacitive screen can track multiple touches
17. Touch and Gestures Gestures are particular movements made with one or more finger Dragging an item on the screen Pinching movements to zoom in and out The Windows Phone operating system has built in support for gesture input A program can be sent a message when a user has performed a particular gesture
18. Location Support A Windows Phone contains a Global Positioning System (GPS) receiver Works well when outdoors with a view of the sky The phone will also other location information Location of cellphone towers in use Location of WiFi access point This “assisted” positioning makes it possible to determine position when inside buildings
19. Accelerometer The accelerometer can measure acceleration in three directions (X, Y and Z) This can be used to detect movement of the phone It can also be used to determine how the phone is being held This orientation information can be used to control games by tipping the phone
20. Camera The camera will be at least 5Megapixels This makes for good quality pictures The pictures which are taken are stored within the phone and transferred to the Windows PC using the Zune software Programs can load these pictures, and other pictures from the media in the phone Your programs can also initiate a photograph
21. Camera Limitations Our programs can’t read a live video feed from the camera in this Windows Phone release This is not a hardware limitation Our programs can’t take a picture without user involvement This is to stop the creation of “spyware” applications that take pictures without user consent
22. Hardware Buttons All Windows Phones have a specific set of physical buttons Start, Back, Lock, Search, Camera, Volume These will work in exactly the same way on every version of the phone Programs are required to use them in a particular way too
23. Start Button Starts a new program When the user presses Start they are always taken to the start menu to choose a program to run The application that was running when Start was pressed is removed from memory This is part of the way that Windows Phone enforces the “one program at a time” rule 23
24. Back button This button has several uses Within a particular program it moves you back to the previous menu When at the top level menu of a program it is used to exit the program and return to the Start menu At the Start menu the back button will return the user to the program they were running when they pressed Start to do something new 24
25. The Back button and the Phone UI Back is rather hard to explain But very easy for users to get to grips with It makes it easy to drop in and out of applications on the phone without having to keep finding them and restarting them For us developers it means that programs may be “woken up” from having been stopped 25
26. Other Buttons Lock Button Stops the currently running program and locks the phone Search Starts a search operation. Your program should respond to search appropriately Camera Stop the current program and take a picture 26
27. Phone Keyboard Some Windows Phone devices will be fitted with hardware keyboards The system provides a “software” keyboard that uses the touch screen When we design our programs we need to make sure that they can be used with or without a physical keyboard 27
28. Phone Memory There are two flavours of memory Main memory This is where programs are loaded and executed Fast memory chips connected directly to the processor Mass storage memory This is where program, data and media are stored Slower storage that holds its data when the power is turned off 28
29. Main Memory A Windows Phone will have at least 256Mbytes of main memory A few years ago this was a huge amount, but these days it is not quite as impressive It can soon get eaten up by programs that use a lot of graphics in their user interfaces In contrast a desktop PC will have around 8 times that memory space, with at least 2Gbytes of RAM 29
30. Mass Storage A Windows Phone will have at least 8Gbytes of mass storage In program terms this is a lot, but most of it will be used store media A single music track is around 8 Mbytes A high quality picture is around 2 Mbytes An hour of good quality video is around 1Gbyte 30
31. Network Windows Phones have lots of connectivity options: WiFi wireless network (high speed) 3G phone network (high to media speed) GPRS phone network (low speed) Out of coverage (no speed) Software on a mobile device must deal with all these types of network 31
32. Programming Considerations A Windows Phone is an amazing device But it is limited by size and battery power Users will expect a high quality experience This will be based on their experience on much more powerful devices which are not mobile Our job as developers is to make the most of what the platform gives us This gives us more to think about when we write our programs
33. The Good News Programming for a phone is fun! The range of features a device has, and the fact it is mobile makes it possible to invent completely new applications The development environment is really powerful and easy to use You get a lot of help from the system in creating great user interfaces 33
34. Review Windows Phone is a computer, but one working specifically in the mobile environment All Windows Phone devices are built to a particular standard with standard features Performance and storage is restricted and our program design must reflect this Network connectivity is variable on a phone Programming a phone is harder than a desktop, but still fun 34
36. Topics The ecosystem that surrounds the Windows Phone device Zune media management and connection Windows Live and Xbox Live and Windows Phone Bing search and Windows Phone Bing Maps and Windows Phone Windows Phone Notification Services
37. Windows Phone Ecosystem A Windows Phone device is surrounded by other services which provide an “ecosystem” These services bind to software in the phone device We can write software that makes use of these services to create brand new solutions In this section we are going to take a look at the services and consider how we might use them 37
38. Zune Software The Zune software provides the link between the Windows Phone and the PC It allows media to be synchronised with the phone It also provides the link to the device for development with Visual Studio
39. Windows Live and Xbox Live A Windows Phone owner can register their phone with Xbox Live This will also connect them with their Xbox Gamertag if they have one Games can use the gamertag to manage achievements and high scores 39
40. Bing Maps Programs in the phone can request maps from the Bing service There is also a Silverlight control you can add to your programs to view and navigate the map You can also make searches for items near your position 40
41. Windows Notification Service It is often the case that external systems need to send a message to a program in a phone Tell you that your dry cleaning is ready Challenge a gamer to a duel Applications register with the Windows Phone notification service and servers can then use this to send messages to the phone user These are buffered if the phone is not connected when the message is sent 41
42. Creating a service of your own There is no reason why you can’t create your own network based service for a Windows Phone client to use You need to write the server application too You can write both ends of the service in C# and you could host the service in the Windows Azure cloud Students can get free access to some cloud services 42
43. Review A mobile phone is now a connected component of a much larger “ecosystem” A Windows Phone can use several of these Zune PC connection and media synchronisation Windows Live and Xbox Live Bing Maps Windows Notification Service Your programs can use these elements to make brand new connected applications 43
45. Topics The Windows Phone Operating System Multi-tasking on Windows Phone Windows Phone and Managed Code Just in Time compilation Program “sandboxes” and Managed Code Developer Implications
46. The Windows Phone Operating System Windows Phone 7 does not use Windows 7 as an operating system The fact they have the same number is just a coincidence Windows Phone instead uses an operating system called Windows CE This is specially designed for use on small, battery powered, devices
47. Multi-Tasking Multi-tasking means running multiple programs at once Windows PCs let you do this You can have IE and Word both running at once Unfortunately multi-tasking places heavy demands on the processor and uses a lot of memory Therefore the first version of Windows Phone does not provide multi-tasking 47
48. Missing Multi-Tasking A mobile device does not really have a screen large enough to view two programs at once The phone has been designed to make it as easy as possible to switch between programs Must users want task switching rather than multi-tasking The operating system itself can multi-task The music player and email programs can both run at the same time as user programs 48
49. Programs on Windows Phone Programs for Windows Phone are written in .NET and run within a Managed Code environment on the device The phone performs Just in Time compilation of the intermediate language (Microsoft Intermediate Language – MSIL) The programs that run are assemblies that are signed by the developer This is used to prove where the code came from
50. Microsoft .NET .NET is the name for an architecture from Microsoft that runs programs It includes standards for the following: Design of MSIL and program file format Data types System libraries C# programming language VB .NET programming language 50
51. The Microsoft Intermediate Language The Microsoft Intermediate Language (MSIL) is a half way house between a high level language and machine code It is designed to be easy to translate into machine code The phone can run MSIL from any .NET compiler C#, Visual Basic, F#, IronPython, IronRuby, C++ The user interface code must be C#
52. Running .NET Assemblies When a .NET program needs to run something has to convert the intermediate language into real machine code for the target processor This happens in the instant before the program actually runs It is called “Just In Time” compilation 52
53. Just in Time Compilation Visual Studio Development Environment C# source file C# compiler Target hardware Windows PC Xbox Windows Phone Assembly file containing MSIL Just In Time compiler Machine code in memory
54. Just in Time Compilation Visual Studio Development Environment C# source file C# compiler Target hardware Windows PC Xbox Windows Phone Assembly file containing MSIL Just In Time compiler Programmer writes the program Machine code in memory
55. Just in Time Compilation Visual Studio Development Environment C# source file C# compiler Target hardware Windows PC Xbox Windows Phone Assembly file containing MSIL Just In Time compiler Visual Studio compiles the source Machine code in memory
56. Just in Time Compilation Visual Studio Development Environment C# source file C# compiler Target hardware Windows PC Xbox Windows Phone Assembly file containing MSIL Just In Time compiler The assembly file is transferred to the target Machine code in memory
57. Just in Time Compilation Visual Studio Development Environment C# source file C# compiler Target hardware Windows PC Xbox Windows Phone Assembly file containing MSIL Just In Time compiler When the program runs the Just In Time compiler converts the MSIL into binary Machine code in memory
58. Just in Time Compilation Visual Studio Development Environment C# source file C# compiler Target hardware Windows PC Xbox Windows Phone Assembly file containing MSIL Just In Time compiler The machine code runs inside the target Machine code in memory
59. Intermediate Language Good things about intermediate languages Can run on a range of platforms Can use lots of different programming languages (as long as they compile down to MSIL) Programs are smaller than machine code Programs can be digitally signed and verified Bad things about intermediate languages The need to Just In Time (JIT) compile them slows down program execution
60. Managed Code When your program runs on Windows Phone it actually runs in a “managed” environment This means that what it does is validated before the program is allowed to do it Array subscripts are checked Program not allowed to attempt to control hardware directly This stops the phone from being affected by a rogue application 60
61. Review The built-in programs inside the phone can multi-task but only one application can run at a time in the phone The phone users the .NET Microsoft Intermediate Language for applications These are “Just in Time” compiled when they are started and run inside a managed shell This trades raw speed for safety and portability 61
63. Topics Writing programs for Windows Phone The Windows Phone emulator Using the Windows Phone features from software Silverlight and XNA program development Development tools Windows Phone Marketplace
64. Windows Phone Programming Writing programs for Windows Phone is the same as writing for any .NET platform Edit, compile and debug within Visual Studio But you need to remember you are writing for a platform a bit more constrained than a PC You can incorporate .third party NET libraries (assemblies) into your applications 64
65. Windows Phone Emulator The emulator runs on your PC It contains exactly the same code as the real phone, but compiled for the Windows PC It lets you see what your programs look like and whether they work correctly It does not show you what the application performance will be like on a real device 65
66. Using Windows Phone from software Windows Phone provides a library of “Launchers” and “Choosers” that your programs can invoke Launchers start other tasks in the phone Start a phone call Choosers allow the user to select an option and then restart your program so it can use the returned value Select a contact from the Address Book
67. Network Connectivity A Windows Phone will be able to use the 3G phone network and WIFI to connect to the internet Your programs will be able to interact with servers, call web services and engage in REST sessions In the present version of the operating system there is no support for direct socket connections
68. Silverlight and XNA applications You can build two kinds of applications for a Windows Phone Silverlight Business applications and simple casual games XNA XNA is a game development environment with support for 2D and 3D games with hardware accelerated graphics
69. Silverlight Applications This is not a very good looking Silverlight application But it does show that you can build displays for user applications using Silverlight There are lots of custom display components for the phone that you can use 69
70. XNA Applications XNA is a game development environment for Windows PC, Xbox and now Windows Phone Existing XNA games are very easy to move onto the phone The phone provides 3D graphics support for games Built in shaders 70
71. Creating an Application You select the type of your application (XNA or Silverlight) when you create the new project in Visual Studio It is not possible to create a single program that uses both technologies There is no technical reason why you could not create a Silverlight game or an XNA business application 71
72. Development Tools The Development Tools for the platform are a free download They tools provide a version of Visual Studio and the Windows Phone emulator These will also integrate into an existing Visual Studio installation You can also obtain free versions of the Expression Blend user interface design tools for Silverlight 72
73. Windows Phone Marketplace You can develop and test your application on the emulator for free To sell your application or deploy it to a real device you must register as a developer This costs $99 per year Students can become developers for free via Microsoft DreamSpark 73
74. Marketplace Rules In a year of your subscription you can publish any number of “paid” applications and up to 5 free ones To distribute more free applications costs $20 per application When you sell an application you get 70% of the price you charge You can distribute “demo” and “time trialed” versions of your application 74
75. Marketplace approval A program submitted for sale via marketplace is submitted to an approvals process This includes checks for matters of taste and decency, along with proper application behaviour If the program fails the process you will be given a report and can re-submit the application 75
76. Review Windows Phone programs are developed in the same way as any other .NET application The Windows Phone emulator does not emulate the speed of the platform Programs can make use of phone functions Windows Phone programs either Silverlight (business) or XNA (game) based The development tools are all free You need to join the marketplace to sell apps