Head first C # Chinese Version chapter 13th controls and graphics page596

Source: Internet
Author: User

 

Draw an image on the form


Create a form application. When you click the form, an image is drawn on the form.


Do the following:


① Add a click to the form
Event handling method started



Event processing method from a using
Statement. You use
GDI +
It will use a lot of implementations.
Idisposable
Interface object. If you do not process these objects, they will consume your computer resources until you close the program. So you need a lot
Using
Statement:



 

② Pay attention to the order of drawing on the form


We need the background of the sky blue, so first draw a blue rectangle, followed by the drawing on it. You need to use the clientrectangle of the form.
It specifies the boundary of the form.



 

③ Draw bees and flowers


You already know drawimage
() How to use the method.



 

④ Add a pen for drawing.



When you draw a line, you need to use a pen
Object To define the color and line width. Built-in
Pens
Class provides you with a lot
Pen
. You can also use
Pen
To create its own instance, its constructor must accept
Brush
Object and a floating point number that represents a thick line.
Brush
Is used to draw a fill image, there is
Brushes
Class, it provides you with a variety of color brushes.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.