Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# ПІДРУЧНИКИ / c# / Manning - Windows.forms.programming.with.c#.pdf
Скачиваний:
108
Добавлен:
12.02.2016
Размер:
14.98 Mб
Скачать
Sys-

about this book

The .NET Framework contains such a large selection of topics that it is impossible to cover all of them in a single book of any depth. This section introduces the focus of this book, and provides an overview of the contents and conventions used in the text. The end of this section describes the online forum available for any questions or comments on the book, and explains how the source code used in the book can be downloaded from the Internet.

Before we discuss the book specifically, we should introduce the concept of namespaces. A namespace defines a group, or scope, of related classes, structures, and other types. A namespace is a bit like a family: it defines a group of distinct members with a common name and some shared sense of purpose.

All objects in the .NET Framework, and indeed in C# itself, are organized into namespaces. The System namespace, for example, includes objects related to the framework itself, and most namespaces defined by .NET are nested within the

tem namespace. The System.Windows namespace defines types and namespaces related to the Windows operating system, while the System.Web namespace defines types and namespaces related to web pages and servers.

This organization into namespaces permits two objects with the same base name to be distinct, much like two people can both share the same first name. For example, the Button class in the System.Web.UI.WebControls namespace represents a button on a web page, while the Button class in the System.Windows.Forms namespace represents a button in an application window. Other namespaces in .NET include the System.IO namespace for file and directory related objects, the System.Data namespace for database-related objects, the System.Drawing namespace for graphical objects, and the System.Security namespace for security objects. An overview of the more commonly used namespaces in .NET is provided in appendix B.

THE WINDOWS FORMS NAMESPACE

In addition to imposing structure on the vast collection of objects supported by the

.NET Framework, the namespace concept also provides some direction and focus for writing a book. This book focuses on the System.Windows.Forms namespace,

xix

affectionately known as Windows Forms. Windows Forms applications are programs that are executed by the Windows operating system, and that employ the user interface features familiar to Windows desktop users everywhere.

The book attempts to provide a somewhat methodical approach to the Windows Forms namespace. Most of the types defined by this namespace are covered in the book. Appendix C provides a class diagram of the Windows Forms namespace, and includes a reference to the location in the book where each class or other type is discussed.

The book contains 18 chapters organized into three parts.

PART 1: HELLO WINDOWS FORMS

The first part of the book introduces fundamental concepts behind C# in general and Windows Forms specifically. Chapter 1 creates the application shown in figure 1 using a text editor. We discuss how a Windows Forms application is executed by the

.NET Framework, and how a Windows Forms program is structured in C#.

In chapter 2 we begin using Visual Studio .NET, the graphical development environment from Microsoft for creating applications in the .NET Framework. This chapter recreates the application constructed manually in chapter 1. We will call this application MyPhotos.

Figure 1

The MyPhotos application as it appears in part 1.

PART 2: BASIC WINDOWS FORMS

In part 2 we begin a systematic approach to the classes in the Windows Forms namespace. This part continues the development of our MyPhotos application, shown in figure 2 as it appears in chapter 13. As you can see, part 2 covers the core user interface components required to build Windows Forms applications, including menus, status bars, dialog windows, text boxes, and combo boxes.

xx

ABOUT THIS BOOK

The MyPhotos application will display the contents of a photo album consisting of one or more image files, or photographs. The application stores each photo album in a file, and permits the user to view the images one at a time and edit the properties of both albums and photographs.

Figure 2 The MyPhotos application from chapter 13. This figure shows the main window along with a dialog box for editing the properties of a specific photograph.

PART 3: ADVANCED WINDOWS FORMS

More advanced topics such as list views and drag and drop are covered in part 3 of the book. Part 3 builds a few different applications using the photo album concept, including an application similar to Windows Explorer for browsing photo albums, and a data-driven application that shows how to bind the contents of Windows Forms controls to values taken from a data source.

Figure 3 shows the main window for our MyPhotos application as it appears in chapter 18. The application is converted into a multiple document interface that can display multiple albums. A number of additional features are added here as well, such as dragging photos between albums and displaying the book’s web site from within the application.

THE WINDOWS FORMS NAMESPACE

xxi

Соседние файлы в папке c#