tailieunhanh - gdi programming with c sharp phần 10
Trong các chương trước của cuốn sách này, bạn đã học làm thế nào để vẽ đồ họa hình dạng, đường cong, và hình ảnh. Trong tất cả các trường hợp này, các đối tượng đồ họa là chịu trách nhiệm về bản vẽ. Khi chúng tôi đang vẽ đối tượng đồ họa từ bên trong một trình đơn hoặc xử lý sự kiện click nút, | This document was created by an unregistered ChmMagic please go to http to register it. Thanks Team LiB 4 PREVIOUS NEXT This document was created by an unregistered ChmMagic please go to http to register it. Thanks Understanding the Rendering Process In previous chapters of this book you learned how to draw graphics shapes curves and images. In all of these cases the Graphics object is responsible for the drawing. When we re drawing graphics objects from within a menu or button click event handler a call to theInvalidate method becomes imperative. If we don t call this method the form will not paint itself but if we write the same code on a form s OnPaint or paint event handler there is no need to invalidate the form. In this section we will find out why that s so. Understanding the Paint Event Paint event functionality is defined in the class which is the base class for Windows Forms controls such as Label ListBox DataGrid and TreeView. A paint event is fired when a control is redrawn. Th Form class itself is inherited from theControl class. Figure shows the Form class hierarchy. Figure . The Form class hierarchy The PaintEventArgs class provides data for the paint event. It provides two read-only propertiesClipRectangle and indicates the rectangle in which to paint and the Graphics property indicates theGraphics object associated with the paint event of a particular control including the form itself . Always be careful when you re dealing with the paint event because it is unpredictable and called automatically. The Control class also provides OnPaint methods which can be overridden in the derived classes to fire the paint event. The signature of the OnPaint method is defined as follows protected virtual void OnPaint PaintEventArgs e This document was created by an unregistered ChmMagic please go to http to register it. Thanks As this .
đang nạp các trang xem trước