''If you're interested in developing for this burgeoning platform, there is no one better able to get you up-to-speed.β <I> <P style=''MARGIN: 0px''>βFrom the Foreword by Rob Tiffany, mobility architect, Microsoft</P> <P style=''MARGIN: 0px''>Β </P> <P style=''MARGIN: 0px''></I></P> <P style=''MA
Programming .NET Compact Framework 3.5 Second Edition
β Scribed by Yao, Paul;Durant, David
- Publisher
- Addison-Wesley Professional
- Year
- 2009
- Tongue
- English
- Leaves
- 740
- Edition
- 2nd edition
- Category
- Library
No coin nor oath required. For personal study only.
β¦ Synopsis
"If you're interested in developing for this burgeoning platform, there is no one better able to get you up-to-speed."-From the Foreword by Rob Tiffany, mobility architect, MicrosoftCompletely revised and updated for .NET Compact Framework 2.0 and 3.5, Visual Studio 2008, and Windows Mobile Smart Phones,Programming .NET Compact Framework 3.5, Second Edition,teaches you how to write highly effective applications for handheld wireless devices with small screens, limited memory, and finite battery life. This book is the definitive tutorial and reference for the .NET Compact Framework and Windows Mobile. If you're interested in developing for this burgeoning platform, there is no one better able to get you up to speed than industry veterans, master programmers, and teachers Paul Yao and David Durant. With this book you will learn how to Use each of the ten API sets available for Windows Mobile; when to use each; and, especially, when to use Win32 and the .NET Compact Framework 2.0 and 3.5
Write programs that make the most of a Windows Mobile device's limited battery life
Efficiently invoke Win32 APIs from the .NET Compact Framework
Write exceptional, data-driven applications using data binding and .NET controls
Manage device data with the object store, file I/O, and the registry
Work with databases using ADO.NET and LINQ
Synchronize mobile data with remote databases and the remote API
Make a mobile device work with the Windows Communication Foundation (WCF)
Create graphical output on Windows Mobile devices If you want to learn Windows Mobile development but only have limited experience with the .NET Framework, this is the only book you need.
β¦ Table of Contents
Cover......Page 1
Contents......Page 10
Figures......Page 18
Tables......Page 22
Foreword......Page 26
Preface......Page 28
Acknowledgments......Page 34
About the Authors......Page 38
1 Mobile Phone Programming......Page 40
1.1 Selecting an Application Programming Interface......Page 43
1.1.1 The Win32 API......Page 47
1.1.2 The .NET Compact Framework......Page 53
1.1.3 The Web Browser......Page 56
1.1.4 Rich Internet Applications (RIAs)......Page 57
1.2.1 Metadata Maps......Page 58
1.2.2 The JITted Code Pool......Page 59
1.2.3 Garbage Collector Pools......Page 61
1.2.4 Garbage Collection and Data......Page 62
1.2.5 Automatic Garbage Collection......Page 64
1.2.6 Special Handling of Managed Data......Page 66
1.2.7 Manual Memory Management of Native Data......Page 75
1.3 Conclusion......Page 76
2 Extending Battery Life......Page 78
2.1 What Is the Problem?......Page 79
2.1.2 Factors Influencing Battery Life......Page 80
2.2 Measuring Battery Usage......Page 82
2.2.1 Talk Time and Standby Time......Page 83
2.2.2 Power Measurement Method 1: Software-Only Approach......Page 84
2.2.3 Power Measurement Method 2: Dedicated Hardware......Page 87
2.3 Device Power Study......Page 90
2.3.1 Standby Power Usage......Page 92
2.3.2 Backlight Power Usage......Page 93
2.3.4 Multimedia Power Usage......Page 96
2.4 Conclusion......Page 97
3 Platform Invoke......Page 98
3.1 Overview of P/Invoke......Page 99
3.1.1 When to Use P/Invoke......Page 100
3.1.2 Why We Prefer .NET Compact Framework Classes over Win32 Functions......Page 102
3.1.3 Porting Native Code to Managed Code......Page 103
3.1.4 Component Object Model (COM) Support......Page 104
3.2.1 A Simple Function: MessageBox......Page 105
3.2.2 Native Function Details......Page 107
3.2.4 Getting Started: C-Style Function Declarations......Page 111
3.3 Supported P/Invoke Function Parameters......Page 114
3.3.2 Simple Data Types......Page 115
3.3.3 Passing Parameters by Value versus by Reference......Page 118
3.3.5 Structures......Page 121
3.3.6 Type of Types versus Type of Parameters......Page 127
3.3.7 Arrays......Page 129
3.4 A Sample Program: CallWin32......Page 132
3.5 Writing Win32 Dynamic Link Libraries......Page 135
3.5.1 Declaring C++ Functions in a DLL......Page 136
3.6 Manual P/Invoke Parameter Passing......Page 139
3.6.1 The Marshal Class......Page 140
3.6.2 Copying to Native Memory......Page 141
3.6.3 Fine-Tuning Structures with the MarshalAs Attribute......Page 144
3.7.1 The MessageWindow Class......Page 147
3.7.2 Other Ways to Communicate between Native and Managed Code......Page 150
3.8.1 Windows CEβSpecific Differences......Page 151
3.9 Conclusion......Page 152
4.1 Data Binding......Page 154
4.1.1 Data-Bindable Controls......Page 156
4.1.2 Data-Bindable Objects......Page 158
4.2 Complex Data Binding......Page 163
4.2.1 Using Complex Data Binding with ComboBox Controls......Page 164
4.3.1 The BindingsCollection Property......Page 165
4.3.2 Formatting and Parsing......Page 168
4.4 The DataGrid Control......Page 171
4.4.1 Using Complex Data Binding with the DataGrid Control......Page 175
4.4.2 Styling the Display of Data in a DataGrid Control......Page 176
4.4.3 Creating Table and Column Styles......Page 178
4.4.4 Creating Styles at Runtime......Page 181
4.4.5 Responding to User Input......Page 183
4.4.7 Accessing DataGrid Information......Page 188
4.4.8 Providing Drill-Down Capability......Page 194
4.4.9 Providing In-Place Editing Capability......Page 200
4.4.10 Providing Automated In-Place Editing Capability......Page 206
4.5 Conclusion......Page 216
5.1 Smart-Device Data Storage......Page 218
5.1.1 Installable File Systems......Page 220
5.1.3 ROM-Based Files......Page 221
5.2 File I/O......Page 222
5.2.1 The File and Directory Classes......Page 223
5.2.2 Byte-Level I/O......Page 224
5.2.3 Higher-Level I/O......Page 226
5.2.4 Encoding and Decoding Data......Page 229
5.2.5 Using the I/O Classes......Page 230
5.2.6 Text File I/O......Page 232
5.2.7 Binary File I/O......Page 235
5.2.8 Writing Binary Data......Page 236
5.2.9 Reading Binary Data......Page 238
5.2.10 Binary I/O and Structures......Page 239
5.2.11 XML File I/O......Page 242
5.2.12 Easier XML Serialization......Page 249
5.3 Registry Access......Page 252
5.3.1 Opening and Creating Registry Keys......Page 253
5.3.2 Reading and Writing Registry Values......Page 254
5.3.3 Updating the Storage Sample Application to Use the Registry......Page 256
5.4 Conclusion......Page 260
6 ADO.NET Programming......Page 262
6.1 Examining ADO.NET......Page 265
6.1.1 A Layered Approach......Page 266
6.1.2 The ADO.NET Classes......Page 268
6.1.3 ADO.NET Error Handling......Page 273
6.2 Working with Data Sets......Page 275
6.2.1 Creating and Accessing DataSet, DataTable, and DataView Objects......Page 276
6.2.2 Data Binding......Page 280
6.2.3 Reading and Writing a Data Set as XML......Page 291
6.3 Microsoft SQL Server CE......Page 293
6.3.1 SQL Server CE Files......Page 294
6.3.2 SQL Server CE Syntax......Page 295
6.3.3 SQL Server CE Query Analyzer......Page 298
6.3.4 Creating a SQL Server CE Database......Page 300
6.3.5 Populating a SQL Server CE Database......Page 302
6.3.6 Retrieving and Displaying Data......Page 305
6.3.7 Updating a SQL Server CE Database......Page 314
6.3.8 The SqlCeDataAdapter Class......Page 315
6.3.9 Querying Schema Information......Page 321
6.4 Microsoft SQL Server......Page 326
6.4.1 Connecting to SQL Server......Page 328
6.4.3 Using SQL Server Stored Procedures......Page 336
6.4.4 Using Stored Procedures with DataSet Objects......Page 342
6.4.6 Using Multi SELECT Stored Procedures......Page 346
6.4.7 Working with Typed Data Sets......Page 349
6.5 Web Services......Page 357
6.5.1 XML, XSD, and SOAP......Page 358
6.5.2 A Web Services Application......Page 360
6.5.3 A Web Services Client Application......Page 370
6.6 Conclusion......Page 374
7.1 Overview......Page 376
7.1.1 Set Classes in .NET......Page 379
7.1.2 LINQ in the Compact Framework......Page 380
7.1.3 Deferred Execution......Page 382
7.2 The Sample Application......Page 383
7.2.1 LINQ to Datasets......Page 387
7.2.2 LINQ to Objects......Page 394
7.2.3 Business Object Properties......Page 405
7.2.4 The Hybrid Version......Page 413
7.3 LINQ to XML......Page 417
7.4 Conclusion......Page 422
8 Synchronizing Mobile Data......Page 424
8.1 Understanding SQL Server CE Synchronization......Page 426
8.1.1 Three Synchronization Mechanisms......Page 427
8.1.2 IIS Connectivity......Page 428
8.1.3 Database Connectivity......Page 429
8.2.1 Creating the Virtual Directory......Page 431
8.2.2 Configuring Additional Components......Page 435
8.3.1 RDA Capabilities and Overhead......Page 436
8.3.2 Programming for RDA......Page 437
8.4 Using Merge Replication......Page 448
8.4.1 Using Good Design to Avoid Synchronization Failures......Page 449
8.4.2 Configuring Merge Replication......Page 454
8.4.3 Programming for Merge Replication......Page 455
8.6 Using Data Synchronization Services......Page 463
8.6.1 Understanding Data Synchronization Service Requirements......Page 464
8.6.2 Building a Data Synchronization Service......Page 466
8.7 Conclusion......Page 487
9.1 RAPI Fundamentals......Page 490
9.1.2 Building .NET ActiveSync Applications......Page 491
9.1.3 RAPI Startup and Shutdown......Page 497
9.2 Accessing the Object Store......Page 509
9.2.1 Using RAPI to Access Device Files......Page 510
9.2.2 Remote Access to Device Registry Entries......Page 525
9.2.3 Remote Access to Device Property Databases......Page 535
9.3 Detecting Changes in Device Connection State......Page 538
9.3.1 The Auto-Start Approach......Page 539
9.3.2 The Callback Approach......Page 540
9.4 Loading Programs and DLLs......Page 546
9.4.1 Running Device-Side Programs......Page 547
9.4.2 Loading Device-Side DLLs......Page 548
9.5 Conclusion......Page 553
10.1 What Is WCF?......Page 554
10.1.1 WCF Terminology......Page 557
10.1.2 WCF in the .NET Compact Framework......Page 561
10.2.1 Generating the Code......Page 562
10.2.2 Making a Windows MobileβCompatible WCF Service......Page 564
10.2.3 Setting the Host Address......Page 565
10.2.4 SmartMeter: A Sample WCF Service......Page 569
10.3.1 WCF Client Namespaces and Assemblies......Page 577
10.3.2 Generating the WCF Client Proxy......Page 578
10.3.3 Instantiating a WCF Client......Page 580
10.3.5 WCF Client Sample: ReadSmartMeter......Page 581
10.4 Conclusion......Page 585
11.1 An Introduction to .NET Compact Framework Graphics......Page 588
11.1.1 Drawing Surfaces......Page 590
11.1.2 Drawing Function Families......Page 592
11.1.3 .NET Compact Framework Graphics......Page 594
11.2 Drawing on the Display Screen......Page 600
11.2.1 Accessing a Graphics Object......Page 601
11.2.2 Drawing in Controls......Page 603
11.2.3 The Paint Event......Page 605
11.2.4 Non-Paint Event Drawing......Page 607
11.3.1 Specifying Colors......Page 609
11.3.2 Creating Brushes......Page 616
11.3.3 Creating Bitmaps......Page 618
11.3.4 Drawing Bitmaps......Page 630
11.3.5 A Sample Program: ShowBitmap......Page 635
11.4 Vector Graphics......Page 641
11.4.1 Creating Pens......Page 643
11.4.2 A Game: JaspersDots......Page 644
11.5 Conclusion......Page 658
12.1 Drawing Text......Page 660
12.1.1 Text-Drawing Support in the .NET Compact Framework......Page 661
12.1.2 The DrawString Method......Page 662
12.1.3 A Sample Program: SimpleDrawString......Page 663
12.2 Font Selection......Page 664
12.2.1 The Font Property of Controls......Page 665
12.2.3 A Sample Program: FontPicker......Page 666
12.2.4 A Sample Program: RotateText......Page 667
12.3 Placing Text......Page 671
12.3.1 Text Size and the MeasureString Method......Page 672
12.3.2 A Sample Program: MeasureString......Page 673
12.3.3 Text Alignment......Page 674
12.3.4 A Sample Program: TextAlign......Page 675
12.4 Conclusion......Page 679
A: Hungarian Notation for .NET Programs......Page 680
A.2 Guidelines......Page 681
A.3 .NET Naming Guidelines......Page 683
A.4 Hungarian Notation......Page 685
A.4.2 The m_ Prefix for Private Data......Page 686
A.4.3 Hungarian Prefixes for CTS Value Types......Page 688
B: Windows API Allocation and Cleanup Functions......Page 698
A......Page 708
B......Page 709
C......Page 710
D......Page 713
E......Page 715
G......Page 716
H......Page 717
K......Page 718
M......Page 719
N......Page 721
O......Page 722
P......Page 723
R......Page 725
S......Page 726
T......Page 729
V......Page 731
W......Page 732
X......Page 733
π SIMILAR VOLUMES
"If you're interested in developing for this burgeoning platform, there is no one better able to get you up-to-speed.β <I> <P style="MARGIN: 0px">βFrom the Foreword by Rob Tiffany, mobility architect, Microsoft</P> <P style="MARGIN: 0px">Β </P> <P style="MARGIN: 0px"> </I> </P> <P style="MARGIN:
.NET Compact Framework Programming with C# is the definitive tutorial and reference for the .NET Compact Framework (CF). It shows you how to transfer your skills and your code to the Pocket PC 2003 and other mobile and embedded smart devices.Authors Paul Yao and David Durant draw upon their years of
"For nearly two decades, Paul Yao and David Durant have been acknowledged as experts on the Windows platform, so itβs only natural that they would bring their experienced point of view to the .NET Compact Framework. With a unique combination of historical perspective and in-depth understanding of th
.NET Compact Framework Programming with Visual Basic .NET is the definitive tutorial and reference for the .NET Compact Framework (CF). It shows you how to transfer your skills and your code to the Pocket PC 2003 and other mobile and embedded smart devices. Authors Paul Yao and David Durant draw upo
Get a thorough introduction to ADO.NET Entity Framework 4 -- Microsoft's core framework for modeling and interacting with data in .NET applications. The second edition of this acclaimed guide provides a hands-on tour of the framework latest version in Visual Studio 2010 and .NET Framework 4. Not onl