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

2.5Recap

In this chapter, we recreated the application from chapter 1 using Visual Studio

.NET. While much of the code was quite similar, we saw how Visual Studio generates the InitializeComponent method for initializing the controls created in the Windows Forms Designer window. We discussed the AssemblyInfo.cs file generated by Visual Studio, and how version numbers are specified within this file. We also looked at exception handling, and its integration into C# and use by the .NET Framework.

This ends part 1 of the book. The MyPhotos application will serve as the basis for much of the rest of the book. Part 2 begins a systematic discussion of Windows Forms controls, and will begin with the MyPhotos project created in this chapter.

RECAP

65

P A R T 2

Basic Windows Forms

If you have actually read part 1 of this book, then you have a good idea where we are going here. Chapter 2 constructed our program using Visual Studio .NET and extended the discussion of the .NET architecture and Windows Forms programming provided in chapter 1. Here we pick up where chapter 2 left off and provide a somewhat systematic discussion of basic Windows Forms development. The goal here is to cover the essential concepts and classes needed in most Windows Forms applications.

Following our practice in chapter 2, the complete steps required to create each example are provided. For the most part, the MyPhotos application is used throughout the book. In a couple places we create alternate applications to provide variety and because I felt the topics were better presented separately.

For all applications, the code used for each section in the book is available on the book’s web site at www.manning.com/eebrown. Follow the instructions and links to the version number corresponding to the desired section in order to retrieve the appropriate files.

We begin this part of the book with chapter 3 on “Menus,” and add various types of menus to the MyPhotos application. This chapter also presents the foundations of the Windows Forms class hierarchy and the handling of events in Visual Studio .NET. By the end of this chapter our application will be able to load a photographic image from disk and display it in various ways within the main window.

Chapter 4 covers “Status bars” containing both simple text and a set of panels. A status bar is used to provide feedback to the user during potentially long operations,

and to summarize what is displayed in the main window. An introduction to the .NET drawing interface is presented by way of a custom status bar panel.

Chapter 5 on “Reusable libraries” steps out of Windows Forms momentarily to create a reusable photo album library. This chapter discusses collection classes in .NET and the concept of interfaces. A detailed discussion of the penultimate ancestor, the object class, is also provided.

Chapter 6 integrates our new library into the MyPhotos application during the course of presenting “Common file dialogs.” A new menu bar is created and file dialogs are used to access, store, and load image and album data on disk. The idea of painting on a Form is also introduced.

Chapter 7 takes the painting idea further in “Drawing and scrolling.” Painting on both form and panel controls is discussed, and automated scrolling is introduced and used to scroll an image that is larger than the display area.

Chapter 8 continues the discussion of the Form class as it relates to “Dialog boxes.” The difference between modal and modeless dialogs is discussed, and the most basic of modal dialogs, the message box, is presented. A custom modal and nonmodal dialog is created, and the relationship between closing and disposing of objects is covered in detail.

Chapter 9 on “Basic controls” begins a systematic review of the standard Windows Forms controls available in the .NET Framework. The concept of form inheritance is discussed, and dialogs including labels, text boxes, and buttons are created. The difference between Panel and GroupBox objects is presented, and concepts such as C# delegates and control validation are also covered.

Chapter 10 presents “List controls,” namely the ListBox and ComboBox controls. Various aspects of these controls such as single and multiple selection, dynamic update, and owner-drawn list items are presented while creating a new MyAlbumEditor application. The new application leverages the library built in chapter 5 to support reading and writing of photo album data.

Chapter 11 rounds out our discussion on controls with the hot topic of “More controls.” Additional controls are presented and used in the MyAlbumEditor application, including the TabControl, TabPage, DateTimePicker, and MonthCalendar controls. Here we discuss how to move an existing set of controls into a container control, customized data strings, and processing click events within a month calendar control.

Chapter 12 returns to the MyPhotos application to present “A .NET assortment.” Topics presented here include keyboard and mouse events, image buttons, and form and application icons.

The final topic in this part is “Tool bars and tips” in chapter 13. A ToolBar control is added to the application, along with various styles of ToolBarButton components. Tool tips for controls using the ToolTip class are also presented here and used with the dialog boxes created in chapter 9.

Part 3 of this book will expand on these chapters to cover more advanced Windows Forms topics.

68

BASIC WINDOWS FORMS

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