Creating Smart Device Applications


One key difference that you should have noticed by now, in your initial understanding about Visual Studio .NET is that it combines the development capabilities of multiple toolsets into a common environment, with common build/project management tools, common debugging tools, and even common design tools. That has been a key philosophy behind Visual Studio .NET. A key feature added into the 2003 version release was the capability to develop mobile applications; specifically , Visual Studio .NET supports development of mobile ASP.NET applications as well as Smart Device applications using .NET Compact Framework. In this section, you take a quick look at some of these capabilities. Mobile application development is discussed further in Chapter 10, "Take .NET with You: Developing Mobile Applications."

After you select project directories for the smart device application (Figure 5.22), you will be required to select what type of device you are targeting the application for ”the larger-form handheld PCs or the more PDA “oriented, functionality-based Pocket PCs ”as well as the project type (Figure 5.23).

Figure 5.22. Smart Device project wizard.

Figure 5.23. Smart Device project options for platform and project type.

After the project options for Smart Device development have been set, the base template is generated and the Smart Device Application designer is opened. Notice that the form is much shorter and looks more appropriate for smaller devices. Like Windows application development, you can simply drag and drop the controls on the canvas from the Device Controls palette and build the application user -interface visually, as shown in Figure 5.24.

Figure 5.24. Smart Device visual form designer.

After the application has been developed, compiled, and set up as the Startup Project, you can run the application. Running a smart device application is a much more involved activity because it requires actually deploying the application to the device through a cradle or another mechanism. Visual Studio .NET 2003 also provides an emulator device for initial prototyping, development, and debugging before you deploy the application to an actual device using the ActiveSync utility. As its name suggests, an emulator emulates the existence of a device with an appropriate platform.

After the application has been deployed to the appropriate device (in this case, the emulator, shown in Figure 5.25), the application will be executed on the device (Figure 5.26); using either the device stylus or onscreen keyboard, the application can be tested . If your device or emulator image doesn't have .NET Compact Framework, it is installed as well. (It is required for devices running operating systems earlier than Windows Mobile 2003 Software.)

Figure 5.25. Smart Device Application deploy utility.

Figure 5.26. Running the Smart Device application.

The source code for the .NET Compact Framework application generated through the visual designer follows :

 
 using System; using System.Drawing; using System.Collections; using System.Windows.Forms; using System.Data; namespace SmartDeviceApplication1 {    /// <summary>    /// Summary description for Form1.    /// </summary>    public class Form1 : System.Windows.Forms.Form    {       private System.Windows.Forms.Label label1;       private System.Windows.Forms.MainMenu mainMenu1;     public Form1()       {          //          // Required for Windows Form Designer support          //          InitializeComponent();          //          // TODO: Add any constructor code after InitializeComponent call          //       }       /// <summary>       /// Clean up any resources being used.       /// </summary>       protected override void Dispose( bool disposing )       {          base.Dispose( disposing );       }       #region Windows Form Designer generated code       /// <summary>       /// Required method for Designer support - do not modify       /// the contents of this method with the code editor.       /// </summary>       private void InitializeComponent()       {          this.mainMenu1 = new System.Windows.Forms.MainMenu();          this.label1 = new System.Windows.Forms.Label();          //          // label1          //          this.label1.Location = new System.Drawing.Point(48, 40);          this.label1.Size = new System.Drawing.Size(128, 32);          this.label1.Text = "Smart Device Application";          //          // Form1          //          this.Controls.Add(this.label1);          this.Menu = this.mainMenu1;          this.Text = "Form1";       }       #endregion       /// <summary>       /// The main entry point for the application.       /// </summary>       static void Main()       {          Application.Run(new Form1());       }    } } 

As you can see from the previous code, the application framework used to develop the Smart Device application and the Windows Form application both have a common base. In fact, Compact Framework “based applications should run unchanged on a normal desktop (with the full-blown .NET Framework runtime) after they are built for that platform.



Microsoft.Net Kick Start
Microsoft .NET Kick Start
ISBN: 0672325748
EAN: 2147483647
Year: 2003
Pages: 195
Authors: Hitesh Seth

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net