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

Source: Internet
Author: User

 

To improve the image performance, add a method to the Renderer to scale the image. Then we can scale each image after it is loaded, and only in beecontrol
And the version after scaling is used in the honeycomb form.



Do the following:


① Add a resizeimage to the Renderer
Method



All images saved in the project are saved as bitmap
Object format. The following is a static method for scaling an image.
--
Add it
Renderer
Class:



 

② Give beecontrol
Add this
Resizecells
Method



Your beecontrol
You can store your own
Bitmap
Object
--
In an array. This array can be generated below to scale each image to a proper size:



 

③ Modify the switch
Statement to make it use
Cells
Array instead of using resources



Beecontrol's
Tick
There is
Switch
Statement, which is used to set its
Backgroundimage
:



 

Set Properties. Resources. bee_animation_1
Replace
Cells [0]
. Sort other
Case
The code line is also replaced
Cells
So that only the scaled image is displayed.



④ To beecontrol
Add
Resizecells
() Method call



You need to add resizecells twice
() Method call. First, add it to the constructor.
--
Then change
Backgroundimagelayout
The property is
None
. Then add
Beecontrol
Of
Resize
Event processing method, called in it
Resizecells
() Method
--
In this way, the animation is scaled every time the form is scaled.



⑤ Manually set the background of the form


In the Properties window, set the background image of the honeycomb form to none.
. Then, set the image size to the appropriate size in the constructor.



 

Running the simulator now is much faster!

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.