Lập trình ứng dụng cho Mobile

681 324 0
Lập trình ứng dụng cho Mobile

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Lập trình ứng dụng cho Mobile

Table of Contents BackCover The Definitive Guide to the .NET Compact Framework Chapter 1: The .NET Compact Framework Understanding the .NET Compact Framework What's Missing from NETCF? Differences Between eVB and VB .NET Working Between .NET and .NETCF Using Compiler Directives Summary Chapter 2: Smart Device Extensions Languages Supported by SDE SDE Within the VS .NET IDE Step-by-Step Tutorial: Hello World .NET Summary Chapter 3: Designing an Effective Interface Pocket PC Design Standards Larry Roof's Design Rules Step-by-Step Tutorial: Panel-Based Interface Windows Forms The Code Behind a Form Working with Forms Working with Dialog Boxes Step-by-Step Tutorial: Building a Custom Dialog Box Summary Chapter 4: NETCF Controls The Button Control The CheckBox Control The ComboBox Control The ContextMenu Control The DataGrid Control The DomainUpDown Control The HScrollBar Control The ImageList Control The InputPanel Control The Label Control The ListBox Control The ListView Control The MainMenu Control The NumericUpDown Control The OpenFileDialog Control The Panel Control The PictureBox Control The ProgressBar Control The RadioButton Control The SaveFileDialog Control The StatusBar Control The TabControl Control The TextBox Control The Timer Control The Timer Control The ToolBar Control The TrackBar Control The TreeView Control The VScrollBar Control Summary Chapter 5: Creating Controls Types of Custom Controls Creating an Inherited Control Step-by-Step Tutorial: Creating a Hybrid TextBox Creating an Owner-Drawn Control Step-by-Step Tutorial: Creating an Owner-Drawn Control Creating a Component Starting a Component Adding Design-Time Support Summary Chapter 6: Menus, Toolbars, and Status Bars Building Menus Building Context-Sensitive Menus Building ToolBars Building Status Bars Step-by-Step Tutorial: Menus and Toolbars Summary Chapter 7: Graphics Some Basic Knowledge Okay, Let's Draw Something Step-by-Step Tutorial: Creating a New Button Working with Images Step-by-Step Tutorial: Displaying a Simple Image Step-by-Step Tutorial: Scrolling an Image Summary Chapter 8: Files and Directories System.IO Namespace Managing Directories Managing Files Working with Files Step-by-Step Tutorial: Building a Text File Demo Step-by-Step Tutorial: Building a Binary File Demo Summary Chapter 9: Introduction to ADO .NET System.Data Namespace Data Providers The Connection Classes The Command Classes The DataReader Classes The DataAdapter Classes The DataSet Class The DataTable Class The DataRow Class The DataColumn Class The DataView Class Step-by-Step Tutorial: Working with ADO .NET Step-by-Step Tutorial: Working with ADO .NET Summary Chapter 10: Data Binding Binding to Controls Moving Between Items Adding an Item Deleting an Item Canceling an Edit in Progress Validating Input Creating a Master-Detail Form Permanently Saving Data Working with the BindingContext Object Step-by-Step Tutorial: Working with Bound Controls Summary Chapter 11: Introduction to SQL Server CE What Can You Do with SQL CE? SQL CE Architecture Installing SQL Server CE 2.0 Getting Started Licensing SQL Server CE Summary Chapter 12: Working with Server-Based Data My Data, Get My Data Summary Chapter 13: Working with Device-Based Data Covering the Database Basics Remote Data Access Step-by-Step Tutorial: Beyond Anonymous Merge Replication RDA or Replication, That Is the Question Summary Chapter 14: Working with XML Basic XML Step-by-Step Tutorial: Creating a Configuration Reader DOM Navigation of Your Documents Working with XML Data Using a DataSet Looking at Data Schemas Using XML Serialization Summary Chapter 15: Mobile Networking Working with the HTTP Protocol Working with the TCP Objects Step-by-Step Tutorial: Working with TCP Working with the IrDA Objects Step-by-Step Tutorial: Working with IrDA Summary Chapter 16: XML Web Services Understanding XML Web Services Web Service Limitations with NETCF Creating an XML Web Service Creating a Web Service Client Passing Data from XML Web Services Passing Data from XML Web Services Asynchronous Calls to Web Services Step-by-Step Tutorial: Building a Web Service Client Summary Chapter 17: Working with Unmanaged Code Examining DllImport Reasons to Use Unmanaged Code Applied Examples Step-by-Step Tutorial: Creating an Unmanaged DLL Summary Chapter 18: Working with POOM The Pocket Outlook Object Model Accessing POOM from NETCF Working with Tasks Step-by-Step Tutorial: Working with Tasks Working with Contacts Step-by-Step Tutorial: Working with Contacts Working with Appointments Step-by-Step Tutorial: Working with Appointments Summary Chapter 19: Building Help Systems A Pocket PC Help System Constructing Help Systems Step-By-Step Tutorial: Building a Help File Implementing Help Files Summary Chapter 20: Application Settings Developing the Foundation Working with Settings in an INI File Working with Settings in an XML File Working with Settings in the Registry Summary Chapter 21: Creating Setups for Your Applications Setup Fundamentals Building Cab Files Step-by-Step Tutorial: Examining a Basic Cab Build Step-by-Step Tutorial: Building a Custom Installation A Note on Testing Setups Summary Chapter 22: Producing Reports Producing HTML Reports Examining the HTML Reporting Sample The HTMLViewer Alternative Approach Summary of Producing HTML Reports Producing Printed Reports Producing Printed Reports with PrinterCE.NetCF Working with the PrinterCE Object Summary of Printing with PrinterCE.NetCF Printing Reports with the Mobile Printing Toolkit Summary of Printing with the Mobile Printing Toolkit Pocket PC Report Generation with Report CE Summary of Printing with Report CE Summary of Printing with Report CE Summary Appendix A: Setting Up Your Development Environment - A Quick Step-Through Install Visual Studio .NET 2003 Install ActiveSync Install SQL Server and SQL Server CE Install the eMbedded Tools Summary Appendix B: Working with the Emulator Launching the Emulator Running the Emulator Without a Network Connection Configuring the Emulator Moving Files to the Emulator Appendix C: Resources Web Sites Developer Tools Training Appendix D: Sample Applications Unpacking the Sample Applications Obtaining Sample Updates Loading a Sample Application Running a Sample Application Removing an Application Problems with a Sample Application Appendix E: Error Handling Handling Errors Visual Basic Style The Try, Catch, Finally Statements Catching Exceptions Handling Exceptions Creating an Exception " Safety Net " Obtaining Detailed Error Information Tracking Exceptions Causing Exceptions to Occur Summary Appendix F: Custom Controls in C# Summary Index Index_B Index_C Index_D Index_E Index_F Index_G Index_H Index_I-J Index_K Index_L Index_M Index_N Index_O Index_P Index_Q Index_Q Index_R Index_S Index_T Index_U Index_V Index_W Index_X-Y Index_Z List of Figures List of Tables List of Code Examples List of Sidebars The Definitive Guide to the .NET Compact Framework by Dan Fergus and Larry Roof ISBN:1590590953 Apress © 2003 (1032 pages) This comprehensive guide targets both first-time and experienced mobile developers, and examines key mobile topics including developing effective Pocket PC interfaces, working with SQL Server CE databases, moving data to and from devices, and more. Table of Contents The Definitive Guide to the .NET Compact Framework Chapter 1 - The .NET Compact Framework Chapter 2 - Smart Device Extensions Chapter 3 - Designing an Effective Interface Chapter 4 - NETCF Controls Chapter 5 - Creating Controls Chapter 6 - Menus, Toolbars, and Status Bars Chapter 7 - Graphics Chapter 8 - Files and Directories Chapter 9 - Introduction to ADO .NET Chapter 10 - Data Binding Chapter 11 - Introduction to SQL Server CE Chapter 12 - Working with Server-Based Data Chapter 13 - Working with Device-Based Data Chapter 14 - Working with XML Chapter 15 - Mobile Networking Chapter 16 - XML Web Services Chapter 17 - Working with Unmanaged Code Chapter 18 - Working with POOM Chapter 19 - Building Help Systems Chapter 20 - Application Settings Chapter 21 - Creating Setups for Your Applications Chapter 22 - Producing Reports Appendix A - Setting Up Your Development Environment—A Quick Step-Through Appendix B - Working with the Emulator Appendix C - Resources Appendix D - Sample Applications Appendix E - Error Handling Appendix F - Custom Controls in C# Index List of Figures List of Tables List of Code Examples List of Sidebars Back Cover The .NET Compact Framework brings the world of managed code and XML Web services to smart devices, and it enables the execution of secure, downloadable applications on devices such as personal digital assistants (PDAs), mobile phones, and set-top boxes. The Definitive Guide to the .NET Compact Framework targets both first-time and experienced mobile developers, and is a comprehensive guide to building mobile applications using the .NET Compact Framework (CF) and Smart Device Extensions (SDE) for Visual Studio .NET. Expert authors Larry Roof and Dan Fergus provide developers with everything they need to produce robust applications, including how to create effective user interfaces, work with device-based data sources, access enterprise data, leverage Web services, incorporate XML into applications, build help systems, and generate setup routines. About the Authors Dan Fergus currently works as a consultant and trainer teaching a Compact Framework course along with Visual Basic .NET and ASP.NET courses. Dan has been working with .NET and the Compact Framework since the beginning, and currently has several applications on the PocketPC on the market. Before becoming an independent contractor, Dan worked at NuMega Technologies as the development lead on Visual Basic 6 debugging tools. Dan also speaks at developer conferences around the world and writes for several magazines. Larry Roof has been a key individual in the Windows CE market from the beginning. He authored the first book on developing mobile applications with Visual Basic for Windows CE, is a frequent speaker at major technical conferences, writes a monthly column for MSDN Voices, and runs face-to-face training on developing mobile applications. The Definitive Guide to the .NET Compact Framework Larry Roof Dan Fergus Apress™ Copyright © 2003 Larry Roof and Dan Fergus All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. 1-59059-095-3 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Technical Reviewer: Ron Miller Editorial Board: Dan Appleman, Craig Berry, Gary Cornell, Tony Davis, Steven Rycroft, Julian Skinner, Martin Streicher, Jim Sumser, Karen Watterson, Gavin Wray, John Zukowski Assistant Publisher: Grace Wong Project Manager: Tracy Brown Collins Copy Editor: Ami Knox Production Manager: Kari Brooks Compositor, Proofreader, Artist: Kinetic Publishing Services, LLC Indexer: Ron Strauss Cover Designer: Kurt Krames Manufacturing Manager: Tom Debolski Distributed to the book trade in the United States by Springer-Verlag New York, Inc., 175 Fifth Avenue, New York, NY, 10010 and outside the United States by Springer-Verlag GmbH & Co. KG, Tiergartenstr. 17, 69112 Heidelberg, Germany. In the United States, phone 1-800-SPRINGER, email orders@springer-ny.com, or visit http://www.springer-ny.com. Outside the United States, fax +49 6221 345229, email orders@springer.de, or visit http://www.springer.de. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549- 5939, email info@apress.com, or visit http://www.apress.com. The information in this book is distributed on an "as is" basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Downloads section. You will need to answer questions pertaining to this book in order to successfully download the code. To Carol, my love, my life. I would not be here without you. —Larry Roof To Susie and the boys. Thanks for putting up with the late nights and the times when I came home tired after traveling, or staying up too late working on this book. I love you. —Dan Fergus About the Authors Larry Roof has long been considered an expert in the field of mobile application development. He is a frequent speaker at leading conferences including Microsoft TechEd, the Windows CE Developer's Conference, and the Visual Basic Insider's Technical Conference. He has written for a number of industry-leading magazines and has a monthly MSDN Voices column called "Two for the Road." Larry heads up one of the premier mobile solution development companies. His company specializes in creating integrated mobile solutions that extend enterprise environments. In addition to writing and consulting, Larry offers training in both face-to-face and video-based formats. He has been recognized by Microsoft as an eMbedded Most Valuable Professional (eMVP) for his contributions to the mobile development community. You can contact Larry at larry.roof@larryroof.com and can obtain more information about the consulting and training services offered by his company at http://www.larryroof.com. It's been a long time since that first computer course in COBOL back in 1973. But instead of getting a degree, Dan Fergus got a little side-tracked and spent the next 12 years as an EMT and paramedic in Hillsborough County, Florida. spent the next 12 years as an EMT and paramedic in Hillsborough County, Florida. After Dan hung up his scissors, he went back to school at the University of South Florida and received a B.S. in biology and a B.S. in chemical engineering. While working as an engineer and living in Japan for two years as a technical liaison for a chemical company, Dan picked up a copy of Turbo C while on a trip to Taiwan for $5, just to keep up his programming skills. When that job ended, Dan started out on his own and worked as a consultant in the Dallas/Fort Worth area for several years before going to work for NuMega Technologies. While there, Dan was the lead developer for CodeReview and FailSafe, both Visual Basic debugging products. Dan's last position at Compuware (formally NuMega) was that of a technical evangelist, spending 2 years doing nothing but working, learning, teaching, and writing about .NET. Dan is again an independent consultant who specializes in .NET in general and the .NET Compact Framework in particular. When not working, Dan spends time with his wife raising their four young boys. In addition to his family, Dan's passion is baseball. As such, he spends the summer coaching and umpiring Little League and high school baseball games. About the Technical Reviewer Ron Miller works as a senior engineer at Pitney Bowes developing new shipping systems. He has been in the IT industry for over 20 years and has developed a variety of solutions from distributed asset management systems to those providing daily sales figures to handhelds. He is constantly searching for a better solution to the problem at hand. In his spare time, Ron takes pleasure in restoring older Lancias and BMWs. Acknowledgments Thanks to Karen, Tracy, Ami, Kari, and the many other members of the Apress family who made this a great book. Our special thanks to Ron Miller for his often insightful technical evaluation of our writing. I would like to thank Gary Cornell for finding a writing partner for me to complete my book after I was injured. Additionally, I would like to thank those staff members at Apress for the aid they provided while I struggled through the process of wrapping up this book, for understanding my physical limitations and helping me in any way that they could. I would also like to thank Dan for becoming a part of my project and picking up the writing load while I recovered. —Larry Roof I would like to thank Gary Cornell for asking me to help with the book. Jason Bock and I had almost completed a book on Pocket PC development with the eMbedded tools when the .NET Compact Framework was being released. That project was put on hold in lieu of this book. I'm glad I got the chance to finish aproject this time. Chapter 17, lovingly called the "unmanaged" chapter, almost got out of hand several times. There was just so much to cover and so little time to do it. I appreciate the help that Chris Tacke provided in his review of the material to make sure nothing stupid slipped through. —Dan Fergus [...]... of that limitations imposed by Windows CE devices and the demands associated with creating mobile applications, and I can safely say that you've got your work cut out for you Now don't get me wrong I'm not trying to scare you away from creating mobile solutions In fact, just the opposite is true I believe that mobile applications are the next frontier of the tech world What I'm attempting to do is to... They trimmed the number of overloads for each method They removed functionality that would less likely be useful in developing mobile applications What does all this mean to you? That it's unlikely you'll be able to take your NET experience as it exists today and use it to create mobile applications without experiencing some frustration, heartaches, and despair You're going to have to adjust your programming... for a positive spin Table 1-2 lists NET Framework controls that didn't make it into NETCF The absence of most of these controls is not going to be of any significance to mobile developers Since printing has such a limited role in mobile applications, removing the whole family of print-related controls is not an issue That takes care of the CrystalReportViewer, PageSetupDialog, PrintDialog, PrintDocument,... extrapolate it to mobile application development The Pocket PC becomes the bag with its limited space The NET Framework becomes the item you want to take with you While you would like to take the whole NET Framework, it won't fit on the Pocket PC Enter the NET Compact Framework, or simply NETCF It's a subset of the NET Framework, comprised of just the items that you need to "survive" as a mobile developer... APIs into your application At the same time, the need for the use of these functions is far less with NETCF in comparison to eVB Still, having that functionality available allows you to create robust mobile applications with the NET Compact Framework Your only concern as a developer when bridging managed to unmanaged code is garbage collection If you allocate memory outside managed code, you run the... this is to use the Marshall class More on this subject can be found in Chapter 17 C# NET doesn't suffer from this same limitation Note For more on leveraging external functions and subroutines from your mobile applications, see Chapter 17 .NET Compact Framework Class Library The NET Compact Framework class library is a collection of reusable classes that tightly integrate with the common language runtime... and XML Classes The NET Compact Framework includes a set of classes that allow you to easily incorporate data, whether that is from a relational or nonrelational data source, and XML content into your mobile applications These classes are defined under the System.Data and System.Xml namespaces The implementation of both data and XML classes under NETCF is a subset of those found in the NET Framework... Compact Framework into logical components By delivering components as separate DLLs, or as they are referred to within the NET Compact Framework, assemblies, Microsoft gives you the option of picking and choosing the features you need, and only those features that your target device has the space to hold An example of this is the System.SR assembly, which contains error message strings Including this assembly... coding, but it's an alternative In some cases, they haven't provided an alternative For the most part, these totally abandoned features were either too big in size or considered to be of marginal use to mobile developers Understanding the NET Compact Framework Microsoft developed the NET Compact Framework with one intention in mind: to build applications By applications, I don't mean drivers, COM components,... missing controls that I'd like most to have added would be the DateTimePicker, MonthCalendar, and RichTextBox The functionality offered by these controls would be immediately beneficial in developing mobile solutions Note As luck would have it, other developers feel the same way and have done something about it For a list of third-party controls, see Appendix C XML Functionality As much as the NET . with PrinterCE.NetCF Printing Reports with the Mobile Printing Toolkit Summary of Printing with the Mobile Printing Toolkit Pocket PC Report Generation. comprehensive guide targets both first-time and experienced mobile developers, and examines key mobile topics including developing effective Pocket PC interfaces,

Ngày đăng: 15/03/2014, 01:08

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan