基本信息
源码名称:利用定时器、双缓存在窗体上实现动画
源码大小:0.07M
文件格式:.rar
开发语言:C#
更新时间:2019-10-10
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 3 元×
微信扫码支付:3 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
利用定时器、双缓存在窗体上画图,并实现动画
利用定时器、双缓存在窗体上画图,并实现动画
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace MyForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{//启动有窗体定时器
if (this.timer11.Enabled == false)
{
this.timer11.Start();
}
x = 10;
y = 50;
}
private void button2_Click(object sender, EventArgs e)
{//关闭有窗体定时器
this.timer11.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
x = x 2;
w = 40;
h = 40;
Bitmap bmp = new Bitmap(this.Width, this.Height-50);
Graphics buffergraphics = Graphics.FromImage(bmp);
Color bc = this.BackColor;
buffergraphics.FillRectangle(new SolidBrush(bc), 0, 0, this.Width - 1, this.Height - 1);
buffergraphics.DrawEllipse(Pens.Blue, x, y, w, h);
//4、将内存画布画到窗口中
Graphics g;
g = this.CreateGraphics();
g.DrawImage(bmp, 0, 50);
}
public int x, y, w, h;
private void Form1_Load(object sender, EventArgs e)
{//初始化图形数据
this.timer11.Interval = 20;
x = 10;
y = 50;
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
}
}