Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
(ebook) Visual Studio .NET Mastering Visual Basic.pdf
Скачиваний:
120
Добавлен:
17.08.2013
Размер:
15.38 Mб
Скачать

SUMMARY 615

Listing 13.24: Programming the FileSystemWatcher’s Error Event

Private Sub FileSystemWatcher1_Error(ByVal sender As Object, _ ByVal e As System.IO.ErrorEventArgs) _

Handles FileSystemWatcher1.Error Dim status As Boolean

status = FileSystemWatcher1.EnableRaisingEvents FileSystemWatcher1.EnableRaisingEvents = False FileSystemWatcher1.InternalBufferSize = _

2 * FileSystemWatcher1.InternalBufferSize FileSystemWatcher1.EnableRaisingEvents = status

End Sub

Summary

The System.IO class exposes all the objects you need to interact with the file system and access files. As you have seen, writing to and reading from files is fairly straightforward with the reader and writer objects discussed in this chapter. However, there’s another option for saving complicated objects to files; namely the Serializer class, which was discussed in Chapter 11.

The topic of storing data is not exhausted with the techniques discussed in this chapter. For large amounts of data, especially structured data, you should consider setting up a database, a topic discussed in the fifth part of this book. A database is more than an elaborate mechanism for storing data; it also allows you to retrieve data instantly based on keys, field values, even combinations of field values.

Copyright ©2002 SYBEX, Inc., Alameda, CA

www.sybex.com

Copyright ©2002 SYBEX, Inc., Alameda, CA

www.sybex.com

Part IV

Intermediate

Programming

In this section:

Chapter 14: Drawing and Painting with Visual Basic

Chapter 15: Printing with VB.NET

Chapter 16: The TreeView and ListView Controls

Chapter 17: Error Handling and Debugging

Chapter 18: Recursive Programming

Chapter 19: The Multiple Document Interface

Copyright ©2002 SYBEX, Inc., Alameda, CA

www.sybex.com

Chapter 14

Drawing and Painting with Visual Basic

One of the most interesting and fun parts of a programming language is its graphics elements. In general, graphics fall into two major categories: vector and bitmap. Vector graphics are images generated by graphics methods such as the DrawLine and DrawEllipse methods. The drawing you create is based on mathematical descriptions of the various shapes. Bitmap graphics are images that can be displayed on various controls and processed on a pixel-by-pixel basis. The difference between vector and bitmap graphics is that vector graphics aren’t tied to a specific monitor resolution; that is, they can be displayed at various resolutions.

Vector graphics can be redrawn at any resolution. Bitmap graphics, on the other hand, have a fixed resolution. An image 600 pixels wide and 400 pixels tall has that specific resolution. If you attempt to use it to fill a monitor that’s 1280 pixels wide and 1024 pixels tall, you’ll have to repeat some pixels. Image-processing software can interpolate between pixels, but when you blow up a bitmap, you see its block-like structure.

Despite their inherent limitations, bitmap graphics are quite useful and much more common than vector graphics. For example, you can’t create the image of a landscape with graphics commands. On the other hand, it doesn’t make sense to display the bitmap of a circle when a simple Circle command can produce the same image faster and more cleanly. Both types of graphics have their place, and you can mix them to produce the desired result.

Text belongs to the vector graphics category, because the characters in various fonts are described mathematically and can be rendered at various sizes with no loss of quality. Figure 14.1 shows a string printed at 96 points (at the top) and the same string printed at 48 points and enlarged 200%. The upper string is as smooth as it can be, while the lower one has too many artifacts around its edges. I could have made the upper string even smoother by turning on the anti-aliasing feature, but then the comparison wouldn’t be fair. The .NET Framework provides rich tools for rendering text, and we’ll examine them along with the other vector drawing methods. If the differences between the two strings aren’t obvious on the printed page, you can open the file VectorBitmap.tif in this chapter’s folder on the CD, which is the electronic version of the same image.

Copyright ©2002 SYBEX, Inc., Alameda, CA

www.sybex.com