Create your first animation control
You need to create an animation control that displays an animated bee. This does not sound so difficult: drawing an image one by one can produce the animation effect. We are lucky,C #And. NetThe way
UseSystem. DrawingTo process the image by yourself
graphics belong to system. drawing namespace. . net The framework contains many picturebox more powerful tools. You can draw images and use fonts for complex graphic
View code
Using the singleton mode in an MDI form can effectively prevent the same form from being instantiated multiple times.
// ==================== Modify the word form ======================================/1. change the constructor to
It takes time to draw an image to the form even if it is not scaled.
suppose you have scaled all the images. It still takes time to plot the bees, flowers, and honeycomb. We use graphics draw the image to the form. If your eyes capture the
Dual buffering can make the animation smoother
Go Back To The image zoom box and play the trackbar . Did you notice a lot of flashes when dragging the slider? This is because each time the slider moves a little, paint the event
④ Bees and flowers already know their locations
We usePointThere is a reason for storing the locations of bees and flowers.BeeObject Location to set its correspondingBeecontrolLocation:
⑤ If a bee does not have a corresponding
Q: In PhotoshopIsn't it better to zoom in the image?
A: You can control these image resources. In fact, these images may be read-only or online resources.
Q: But in. netIt is always better to narrow it down.?
A: If you are sure that you will not
Use bitmapObject andDrawimage() Method, and the knowledge of forms and user controls to create and useTrackbarTo zoom in the image.
① Add two trackbars to a new user controlWidget
Create a new form application. Add a user control --Name itZoomer
③ Set the honeycomb and garden forms for the dual-buffering Animation
Removes the background image setting code from the form constructor. Remove the controls on all forms and put the doublebufferedSet propertyTrue. Add two formsPaintEvent
Create a button to add beecontrol to the form
Adding a widget to a form is simple --Add itControlsSet. The removal process is as simple as that. However, all controls are implemented.IdisposableTo delete the object after the control is removed.
Beecontrol also needs to release its own controls
The control class implementsIdisposableInterface, so you need to make sure that each used control is released.BeecontrolContainsTimerControl, but it cannot be released. This is a problem.
Because the form completes the work for you.
IDE overwrites it for youDispose() Method, when the form is to be released, it will be releasedControlsAll controls in the set. Now, if you want to create controls or remove them from the set, you
Image resources are stored in bitmapObject
How can graphic files be processed when they are included in a project? You already know that you can use proPerties. ResourcesTo access them. But how can they be processed?
. NetBitmapThe format of the
⑤ Add an arrow pointing to the flowers
Graphics has some methods to acceptPointArray and connect them with straight lines or curves. We will useDrawlines() Method to draw arrows, useDrawcurve() Method to draw the arrow.
6. Add a font to draw
Understand user requirements before starting building a program
Before we start writing this Address Book Program-or any program-we need to spend some time thinking about who will use this program and what they need to do?
1. The CEO needs to
C # download Learning Resources
Cve-2017.doc
Csung advanced programming (second edition)
C ++ high-level programming (English edition)
Csung Design Model
C#advanced Programming Technology
CEN Chinese edition
Csung tutorial
A small
Several thread synchronization objects in C #
Thread Synchronization is inevitable when writing multi-threaded programs. What is thread synchronization?
For example, if there is a variable in a company that records the salary count of someone t = 1
I have finally decoded all the GPS data through my efforts over the past few days. I believe that people who have read my logs have been waiting for a long time. Only by sharing resources can we make progress; compared with the direct call interface
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