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

about the cover illustration

The figure on the cover of Windows Forms Programming with C# is a “Pescador del Cabo de buena Esperanza,” a fisherman from the Cape of Good Hope in Africa. This fisherman is especially appropriate here, since the author, Erik Brown, worked with the U.S. Peace Corps in Botswana, which is not too far from the Cape of Good Hope. The illustration is taken from a Spanish compendium of regional dress customs first published in Madrid in 1799. The book’s title page states:

Coleccion general de los Trages que usan actualmente todas las Nacionas del Mundo desubierto, dibujados y grabados con la mayor exactitud por R.M.V.A.R. Obra muy util y en special para los que tienen la del viajero universal

which we translate, as literally as possible, thus:

General collection of costumes currently used in the nations of the known world, designed and printed with great exactitude by R.M.V.A.R. This work is very useful especially for those who hold themselves to be universal travelers.

Although nothing is known of the designers, engravers, and workers who colored this illustration by hand, the “exactitude” of their execution is evident in this drawing. The “Pescador del Cabo de buena Esperanza” is of course just one of many figures in this colorful collection. Their diversity speaks vividly of the uniqueness and individuality of the world’s towns and regions just 200 years ago. This was a time when the dress codes of two towns, separated by a few dozen miles, identified people uniquely as belonging to one or the other. The collection brings to life a sense of isolation and distance of that period and of every other historic period except our own hyperkinetic present.

Dress codes have changed since then and the diversity by region, so rich at the time, has faded away. It is now often hard to tell the inhabitant of one continent from another. Perhaps, trying to view it optimistically, we have traded a cultural and visual richness for a more varied personal life. Or a more varied and interesting intellectual and technical life.

xxxii

We at Manning celebrate the inventiveness, the initiative, and the fun of the computer business with book covers based on the colorful tapestry of regional life of two centuries ago brought back to life by the pictures from this collection.

WINDOWS FORMS OVERVIEW

xxxiii

P A R T 1

Hello Windows Forms

It is common practice to write some sort of “Hello” program at the beginning of a book. This book is no different, and we begin our discussion on Windows Forms with the most basic of forms: an empty window. While this book is all about Windows Forms, Microsoft’s new interactive development environment Visual Studio

.NET is an important part of creating .NET applications. To introduce both Windows Forms and Visual Studio .NET, we will create the same program in two subsequent chapters.

Chapter 1 is titled “Getting started with Windows Forms.” This chapter introduces Windows Forms programming and covers some fundamentals of the C# language and the .NET Framework. Here we use the C# command-line compiler in order to focus on a sample program and not get distracted by the graphical environment. While the remainder of the book will use Visual Studio .NET for the examples, enough detail about the command-line tools is provided in case you want to follow along using an alternate editor.

Chapter 2 covers “Getting started with Visual Studio .NET.” Here we rebuild the example from Chapter 1 within the Visual Studio .NET interactive development environment. This will give us a chance to cover additional subtleties of .NET and C#, and give you the reader a second go at understanding any code you missed in chapter 1.

Part 2 of this book will extend the program built in chapter 2 as it continues our investigation of the new world order for Windows application development.

C H A P T E R

1

 

 

Getting started with

Windows Forms

1.1Programming in C# 4

1.2Adding controls 13

1.3Loading files 18

1.4Resizing forms 26

1.5Recap 33

With the introduction behind us, we can get down to business. We will start with a basic application of the “Hello World” variety, adding some functionality to introduce some key features and concepts. We will take a quick look at the following aspects of Windows Forms programming:

The Form class: creating a blank form.

Program execution: how the Microsoft .NET Framework executes a program.

Controls: how each control is a distinct class, and how controls are added to a form.

C# classes: different kinds of class members, and how to use them in our program.

Files: opening an image file in C#.

Events: using C# events to process user actions.

As you likely know, part of the .NET experience is a new interactive development environment called Visual Studio .NET. Within this environment, a set of command-

3

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