ISBN-10:
1861006314
ISBN-13:
9781861006318
Pub. Date:
06/27/2002
Publisher:
Apress
GDI+ Programming: Creating Custom Controls Using C# / Edition 1

GDI+ Programming: Creating Custom Controls Using C# / Edition 1

by WHITE, Chris Garrett

Hardcover

Current price is , Original price is $0.01. You

Temporarily Out of Stock Online

Please check back later for updated availability.

This item is available online through Marketplace sellers.

This item is available online through Marketplace sellers.

Overview

This book is designed for the professional developer or tecnhical lead who needs to write GDI+ code for either Windows Forms or for Web Forms applications. Upon completion of this book, the reader will be able to:

*Program in GDI+ and understand the concepts on which GDI+ is based
*Build custom controls in Windows Forms and Web forms
*Enhance design-time support
*Construct a custom server side bitmap file and display it on a Web page
*Create a Web Service that serves up custom images

The book is oriented towards a business applications audience and presents designs and techniques that will be useful in such an environment. The information in the book regarding the semantics of GDI+ is language agnostic and the examples are written in C#. A good working knowledge of C# syntax and of the .Net framework is assumed.

Author Biography: Eric White is an independent software consultant with over 20 years experience in building Management Information Systems, accounting systems, and other types of rich client and n-tier database applications. He has written custom controls in numerous windowing systems, including all versions of Microsoft Windows, Macintosh, OS/2, X/Motif, and others. Eric has particular interest in Object-Oriented design methodologies, including use case analysis, UML, and design patterns. After years of working with too many varieties of technologies to list, he is currently specializing in C#, VB.NET, ASP.NET, ADO.NET, XML, COM+, GDI+, SQL Server and other Microsoft technologies.

Product Details

ISBN-13: 9781861006318
Publisher: Apress
Publication date: 06/27/2002
Edition description: 2002
Pages: 500
Product dimensions: 0.00(w) x 0.00(h) x 0.04(d)

Table of Contents

Introduction1
Who is this Book For?2
What Does this Book Cover?2
What You Need to Use this Book4
Style Conventions5
Customer Support and Feedback6
Source Code and Updates6
Errata6
Technical Support7
p2p.wrox.com7
Chapter 1An Overview of GDI+ and Custom Controls11
GDI+ and .NET12
What is GDI+?13
The GDI+ Namespaces16
Custom Controls17
Building Windows Forms Custom Controls17
Web Forms Custom Controls18
Creating Generic Code for both Windows Forms and Web Forms20
A First Example20
Summary35
Chapter 2Drawing Surfaces37
Drawing Surfaces38
Raster-based and Vector-based Drawing Surfaces38
The Characteristics of a Drawing Surface39
The Color Structure41
Drawing Surfaces in Different Environments44
A Summary of Drawing Surfaces46
The Graphics Class47
The GDI+ Coordinate System51
Summary62
Chapter 3Pens and Brushes65
Drawing with the Pen Object66
Controlling Properties of the Pen67
The Pens Class75
Filling with the Brush Object76
Using the Brush Classes76
The Brushes Class90
Creating a Pen from a Brush90
A Note about Performance91
Summary92
Chapter 4Text and Fonts95
An Overview of Text and Fonts96
Working with Fonts in GDI+97
Drawing Basic Text101
Formatting Text103
Font Styles104
Lines, Alignment, and Orientation105
Dealing with Fonts114
Finding Available Fonts114
Font Metrics and Precision Text Placement115
Quality of Text121
Summary127
Chapter 5Images131
An Overview of Image Handling132
The Image, Bitmap, and Metafile Classes132
Different Types of Bitmap135
Encoders and Decoders136
Pixel Format138
Displaying Images141
Checking the Size and Resolution142
Changing the Resolution of a Bitmap145
Image Resizing and Interpolation146
Manipulating Images148
Cropping an Image148
Skewing, Reflecting, and Rotating an Image149
Cloning an Image151
Getting a Thumbnail of an Image152
Creating and Drawing into an Image153
Creating a New Bitmap153
Double-buffering156
Working with Alpha in Images157
Getting and Setting Pixels160
Setting Alpha for an Entire Image162
Playing an Animation165
Converting a BMP to a JPEG167
Summary169
Chapter 6GraphicsPaths and Regions171
What are GraphicsPaths and Regions?171
The GraphicsPath Class172
The Region Class181
Summary187
Chapter 7Clipping and Invalidation191
The Clipping Region192
Cropping with the Clipping Region192
Selective Repainting with the Clipping Region198
Clipping at the Pixel Level207
Invalidation209
Using State in our Control209
How Invalidation Works210
A Few Clipping Tips214
Summary215
Chapter 8Transformations219
Transformations in GDI+219
Coordinate Systems and Transformations221
World Transformations222
Invalidation and Clipping235
Transformations and Custom Controls236
Summary236
Chapter 9Printing239
The Printing Process240
The Printing-related Classes in GDI+241
How is a Document Printed or Print-previewed?242
Using the Printing Classes243
A Simple Printing Example244
Selecting the Unit of Measurement254
Default Graphics Units255
The Ruler Printing Example256
Printing Metrics258
Displaying Printing Metrics260
Controlling the Printer Drawing Surface262
Where the User Changes the Settings266
Summary267
Chapter 10An Alternative Coordinate System271
Defining the Problem272
The Outline Model Coordinate System276
The GraphicsOM Class276
Creating a 3D Effect282
Summary286
Chapter 11Architecture and Design of Windows Forms Custom Controls289
Basic Principles290
What is a Component?291
What is a Custom Control?294
Building a Windows Forms Custom Control295
The Simple Custom Control Sample295
Using a Custom Control297
Creating a Test Application299
Adding Properties to our Custom Control301
Custom Control with Properties Example301
Creating a Test Application305
Default Values of Properties306
Custom Control with Default Property Values Sample306
Focus310
Focus Cues310
Steps to Implement a Focusable Control311
Focusable Control Example312
Creating a Test Application320
Generating Events322
Overview of Delegates and Events322
Events Example323
Create a Test Application326
Deriving from an Existing Control327
NumberTextBox Example327
Creating the Control328
Creating a Test Application332
Composite Custom Controls333
DataButtons Example334
Create a Test Application336
Designing Components and Custom Controls337
Advantages of Non-Procedural Constructs338
Designing Components Using this Philosophy339
Designing Events340
Summary340
Chapter 12Design-Time Support343
Basic Concepts343
Editing Properties in the Properties Window344
Editing the Control in the Design View346
Categorizing Properties and Events347
Improved Editing in the Properties Window348
The NumberRange Struct350
The TypeConverter-Derived Class351
The NumberTextBoxA Control356
Creating a Test Application358
Debugging Design-Time Code358
Creating a Modal Dialog Box Property Editor359
The NumberTextBoxB Control360
The NumberRangeDialog361
The NumberRangeEditor363
Creating a Test Application366
Creating a Drop-Down Property Editor367
The NumberRangeDropDown Control367
The NumberRangeEditor371
Creating a Test Application372
Implementing a Custom Designer373
The SimpleBlankControl374
The SimpleLineControl376
Summary382
Chapter 13Scrolling385
Building a Scrolling Sample386
Setting the Scrollbar Position387
Drawing in a Viewport388
Scrolling Techniques389
Which Approach do I Use?390
Placing a Non-Scrollable Control in a Panel392
Smooth Scrolling393
The SmoothScrollableControl Sample393
Testing the Control400
Summary401
Chapter 14Mouse Events and Cursors403
Mouse Events404
Mouse Cursors405
Standard Mouse Cursors406
The CursorsExample406
Custom Mouse Cursors408
Hit Testing and Drawing During Mouse Events409
The HitTestExample410
Mouse Event Routing414
The RoutingMouseEvents Sample415
Handling the CaptureChanged Event418
GDI and BitBlt421
Why Use GDI?422
Using BitBlt()423
The Simple BitBltExample424
Drawing While Dragging425
The AlphaDragExample425
Drag-Scrolling432
Demonstrating the 'Wiggle-the-Mouse Bug'433
Removing the Wiggle Bug441
Summary443
Chapter 15GDI+ Images in ASP.NET445
Internet Information Services (IIS)446
Documentation448
Security and Virtual Directories449
Reading and Serving Images450
Streams452
Reading an Image from a Remote Web Server453
Mixing HTML and Dynamic Images455
Modifying Images457
Creating a New Image462
Pie Charts466
Summary469
Chapter 16Creating Custom ASP.NET Server Controls471
Custom Controls472
Creating an ASP.NET User Control473
User Control Properties475
A Custom Button User Control476
Creating a Thumbnail Control481
Making a Thumbnail481
Creating a Custom Control484
Creating a Thumbnail Picture Gallery486
Design-Time Support488
Creating a Toolbox Icon488
Other Design-Time Features489
Summary490
Chapter 17Web Services and GDI+493
What are Web Services?493
How can GDI+ be used with a Web Service?494
A Simple Web Service495
The Hello World Web Service495
Returning an Image URL498
The Image URL Web Service501
Returning Image Data503
Summary507
Index509

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews