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

This is a little trickier that it sounds, as you will need to handle both the old and new formats correctly. When you are finished, your application should not only write the new file version but also be able to open both the old and new file types.

6.8RECAP

This is a good place to close out our discussion on file dialogs. In this chapter, we rewrote the menu bar and began using the MyPhotoAlbum project developed in chapter 5. We saw how to open multiple files simultaneously, and supported the ability to save and open album files from our application.

We seem to have a knack for introducing little bugs into our application. So far our image is distorted and stretched out of proportion, we are unable to scroll when the actual image is displayed, and in this chapter we threw out a newly created album while loading a new one. The next two chapters will clear up these problems while introducing the idea of drawing and scrolling on a form in chapter 7, followed by a discussion of interactive dialog boxes in chapter 8.

More .NET The FileDialog class, as well as the OpenFileDialog and SaveFileDialog classes, are referred to as common dialogs. Common dialogs are dialog boxes provided by the .NET Framework that implement a standard interface for common functionality required by applications. The FileDialog class inherits from the CommonDialog class directly.

Two other common dialogs provided by .NET are the ColorDialog and FontDialog classes. The ColorDialog class permits a user to select a color and corresponding Color structure, while the FontDialog class permits a user to select a font name, family, size, and corresponding Font class instance. The use of these dialogs is similar to what is shown for the FileDialog objects in this chapter, although the actual windows are quite different.

Also of note are the PageSetupDialog and PaintDialog classes. These common dialogs are used when printing from Windows Forms applications, and are discussed in chapter 18.

Finally, we should also note that common dialogs, including the OpenFileDialog and SaveFileDialog classes used in this chapter can be configured directly in the Windows Forms Designer window. They are available in the Toolbox window, and can be dragged onto the form and configured in the Properties window much like any other component. We elected not to do this here since the dialogs would then exist for the life of the form, which is not really necessary for our purposes.

RECAP

193

Con-

C H A P T E R

7

 

 

Drawing and scrolling

7.1Form class hierarchy 195

7.2Image drawing 198

7.3Automated scrolling 212

7.4Panels 215

7.5Recap 222

As you may have noticed, the main window for our application is built using the Form class. We have poked and prodded the edges of this class without really looking inside this complex but very important .NET object. In this and the next chapter we will investigate the Form class in more detail.

Earlier development environments from Microsoft distinguished among the different types of windows an application may display. In MFC, for example, there is one hierarchy (CFrameWnd) for framed windows such as MDI windows and control bars, another (CDialog) for dialog boxes, and yet another (CView) for the various document view classes.

The .NET Framework has taken a very different approach. In .NET, the trol class is the basis for all controls, including the various types of window objects. The Form class, as we shall see, encompasses all types of windows be they MDI frames, MDI child windows, floating tool bars, or dialog boxes.

The next two chapters will take a closer look at the Form class to understand how to interact with this object in our applications. In this chapter we will:

Explore the Form class hierarchy.

Draw the current photograph directly on our form.

194

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