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
C # and Visual Studio ide make a lot of things simple
With C # And vs, you get all the excellent features without any extra work.
These features allow you:
Quickly build applications. Create with C #ProgramIs a piece of cake. C #
④ 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
Double Buffering is built in the form and Control
You can use bitmapFor double buffering,C #And. NetThe built-in support makes this easier. You only needDoublebufferedSet propertyTrue. BackZoomerUser Control--Put itsDoublebufferedSetTrueIt will
Beecontrol andPictureboxVery similar...So we inherit fromPictureboxLet's get started.
The controls in the toolbox are all objects, so it is easy to create a new control. You only need to create a new class to inherit an existing control and add
③ 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.
Use usecontrolIs a good way to create controls
There is a simple method to create controls, using ideAddUsercontrol.UsercontrolIs similar to the form, you can drag the control in the toolbox, you can also useIDEForm Designer. You can also use
Take a closer look at the performance issues
The pictures of the bees you downloaded are huge. This means that pictureboxIt takes a lot of time to scale the image while displaying them. The reason why the program slows down when many bees
Use graphicsObject ScalingBitmap
Let's take a closer look at the resizeimage added to the Renderer.() Method. First, it createsBitmapThe size of the image to be scaled. Then useGraphics. fromimage() Method to create a newGraphicsObject.
Add garden and honeycomb forms to the Project
Put beecontrolAdd to project. Add two more forms.
Find out where you are
You need to understand that the honeycomb is in the filedPosition of the form. Use the Properties
⑤ 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
The simplest application of a simple factory
Using system;Using system. Collections. Generic;Using system. LINQ;Using system. text;
Namespace consoleapplication1{Class Program{Static void main (string [] ARGs){Calculate Cal = factory.
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
Author: NLP Source: China self-learning Programming Network collection and sorting Release Date:
// Note:// In computer programming, a stream is a Class Object. Input and Output operations on many files are provided by class member
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