GDIplus Custom Controls with Visual C# 2005, Packt

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
  Title:  GDI+ Custom Controls with Visual C# 2005
  Author(s):  Tiberiu Radu, Iulian Serban, Dragos Brezoi, Adam Ward
  Edition:  Packt Publishing (June 20, 2006)
  Format:  Paperback: 276 pages
  ISBN:  1904811604
  Overall Rating:  Image:stars4.gif The Bottom Line
C# Online.NET:Reviews: Book Reviews  •  Educ./Train. Reviews  •  Software Reviews  •  Top 10 Books

Contents


C# Online.NET Book Review

Read a chapter from the book!

If you are not familiar with them, Packt books are lightweight and practical. They focus on quick results, examples, and illustrations rather than depth, detail, or theory. Concepts are often explained after they have been introduced by examples. Consequently, an hour or so with a Packt book will usually yield immediate results. And, this book is firmly in that tradition.

First a caveat—this book deals only with Windows application custom control development and not with Web control development. If this is what you need, read on…

The book begins by discussing on the fundamentals of controls—their component parts and the objects and concepts needed to draw controls. Next, the GraphicsPath object is illustrated to draw complex objects with lines, curves, polygons, etc. Also, Transformations are explained. The focus of these chapters is primarily on object drawing; but, there is some illustration of text handling. Control parts are discussed; and, screenshots of their appearances in each of their states are included.

My favorite topics include: the ControlPaint class for drawing control parts, borders, and decorations; how to change and display images; and double-buffering—a technique for improving performance by holding painted images of controls in memory. One chapter explicates design considerations—appearance, intuitiveness, and stability. I wish more people would focus on these GUI concenpts instead of the technical aspects. Finally, a custom PieChart control is created in an attempt to illustrate all the major topics introduced in a single project.

The reader will appreciate this book as a great guide to getting started quickly. Topics are introduced and illustrated but not belabored in great detail: this is not a compendious reference book. The ideal reader might be someone with only basic knowledge of GDI+ and a passing acquatance with custom controls. The book will help such a reader learn to develop custom controls for the Windows environment (only).

Thanks to the editor, the overall style is pleasantly readable—not an easy task with multiple first-time authors. Source code examples and screenshots are abundant.

All of the source code examples are written in the C# language.


Bottom line

GDI+ Custom Controls is a fine introductory tutorial on control development for C# applications (only).

Publisher's description

The amount of built-in functionality included in the .NET Framework is amazing. One could create complex applications with lots of functionality by simply assembling the pieces you're offered for free. Among those pieces you'll find lots of powerful, flexible, and configurable controls. Who would ever need to build their own controls, right?

While some can get away without ever needing to build a custom control, many don't, or don't want to. Sometimes building a custom control is a necessity, because what you want to achieve doesn't exist, or is too expensive to buy. This is particularly true for controls with customized shapes, which need to be drawn instead of reusing other existing controls.

In some other cases, developers build custom controls as part of their architecture, allowing them to reuse more efficiently common functionality (and code) that they trust and like. There are many circumstances where building a custom control can make a programmer's life easier.

Unfortunately, programmers frequently avoided learning how to build custom controls because learning all the complexities consume lots of time and energy. Comprehensive and advanced books on the subject well exceed 1,000 pages, and the excessive amount of information can indeed be intimidating.

This book takes a lighter approach, guiding you step by step into building your first custom controls, and writing quality code. You'll build a new example in each chapter, and in the end you'll build a completely functional custom control where you'll apply most of what you've learned in the book.

A fast-paced example-driven tutorial to building custom controls using Visual C# 2005 Express Edition and .NET 2.0. If you want to build custom controls with C# but you don't know where to start, or you are intimidated by the huge amount of information that needs to be absorbed, then this book is for you. This friendly tutorial is based on numerous examples with real-world applicability, and includes a case study featuring the development of a fully functional PieChart control. Showing you how to use the free Visual C# 2005 Express Edition environment to develop your controls, Building Custom Controls with Visual C# 2005 will teach you how to create professional, reusable custom controls for your desktop applications in no time. This book has been written with the intermediate C# developer in mind. Assuming a working knowledge of C#, the book teaches you how to implement custom controls using Visual C# 2005 Express Edition and all other versions of Visual C#, and GDI+ with .NET 2.0

What you will learn from this book

  • Understand the basics of custom controls
  • Use GDI+ to draw your own controls
  • Implement double buffering to speed up your forms
  • Add printing functionality to your custom controls
  • Handle the mouse events to improve the user experience
  • Offer design-time support for programmers using your control
  • Design intuitive interfaces for your users

Approach

Throughout the book the emphasis is on using examples to illustrate concepts and techniques. Code is shown in detail, and explained thoroughly. The examples themselves are intended to be both intructional and useful in their own right.

Who this book is written for

This book has been written with the intermediate C# developer in mind. Assuming a working knowledge of C#, the book teaches you how to implement custom controls using Visual C# 2005 Express Edition and all other versions of Visual C#, and GDI+ with .NET 2.0

What This Book Covers

Chapter 1: Introduction to Custom Controls will be your introduction to the world of .NET custom controls. You'll learn what controls are, why they are useful, what they are made of, and towards the end of the chapter you'll also create a simple yet functional custom control called TinyNoiseMaker.

Chapter 2: Introduction to GDI+ introduces you to the basics of drawing with GDI+. You will meet a few namespaces, classes, and events that form the foundations of drawing with .NET, and you'll see how to paint the surface of a custom control.

Chapter 3: Basic Drawing teaches you more about the coordinate system of GDI+, drawing lines and polygons using pens, brushes, and colors, and guides you to build a control named GradientLabel.

About the author(s)

Tiberiu Radu has been working with computers for over 10 years now, programming in a wide range of languages including Pascal, C/C++, Visual Basic, Delphi, and C#. As a Microsoft Student Partner in the Microsoft Academic Program, he's devoting a lot of time to many .NET-related technologies. Tiberiu is in the last year of studies with the Automatic Control and Computers Faculty of the Politehnica University of Bucharest. While researching for his own IT security business, he developed skills in embedded programming and new web technologies, and is seeking new and innovating networking security solutions.

Iulian Serban is a software architect who started programming at a very young age. He evolved through a lot of programming languages including Pascal, Delphi, C++ Builder, Visual C++ with MFC and finally .NET and C #. By the age of 17 he started working for Syncfusion, one of the largest .NET control builders in the US, writing code for professional custom controls. Nowadays he devotes most of his spare time to his own IT business, which is set to release significant software projects soon.

Dragos Brezoi started programming to create an application for processing and adding extra effects to his guitar's sound. Several years after, he got a Masters Degree in Computer Science from the Politehnica University of Bucharest, and is now researching for a Ph.D. in Advanced Automatics. Dragos currently works as a programmer for Mikon Systems, developing industrial software. His skills cover a wide area of specialization from PLC and DSP programming to SCADA, OPC, and DCS solutions. At this moment he is creating professional human-machine interfaces, with a focus on developing advanced custom controls with C#.

Adam Ward works for a communications technology company in Derby, England. Adam excels in experimental programming techniques and has a particular interest in high-speed algorithms and graphical methods. His professional work is based in a varied Research and Development environment and he thrives on tasks requiring innovation, skill, and fine-tuning. He has also been involved in experimental coding collaborations showcasing the power of C#. Away from work, Adam is turning his attentions to Linux systems and especially cross-platform programming under .NET-compatible systems.

Table of Contents (abbreviated)

Chapter 1: Introduction to Custom Controls
Chapter 2: Introduction to GDI+
Chapter 3: Basic Drawing
Chapter 4: Drawing Complex Shapes and Using Transformations
Chapter 5: Drawing Control Parts, Borders, and Adornments
Chapter 6: Working with Images
Chapter 7: Printing
Chapter 8: Collections
Chapter 9: Double Buffering
Chapter 10: Handling Mouse Events
Chapter 11: Implementing Design-Time Support
Chapter 12: Designing Intuitive Interfaces
Chapter 13: The PieChart Control
Appendix A: Distributing Custom Controls

Personal tools