编辑器加载中...
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;using System.Drawing.Drawing2D;using System.Drawing.Imaging;using System.Drawing.Text;namespace WindowsFormsApplication1{public partial class Form1 : Form {//首先创建一个窗体级的变量,来表示动画。 private Bitmap bmp;public Form1() { InitializeComponent(); }//给窗体添加load时间处理程序 private void Form1_Load(object sender, EventArgs e) { bmp = new Bitmap("te.gif"); ImageAnimator.Animate(bmp, new EventHandler(this.OnFrameChanged)); }//如果手工制作,就需要吧这行代码添加到InitializeComponent()中://private void InitializeComponent(){//this.load += new System.EventHandler(this.Form1_Load);}//然后需要Paint事件处理程序 private void Form1_Paint(object sender, PaintEventArgs e) {//get the next frame ready for rendering ImageAnimator.UpdateFrames();//Draw the next frame in the animation. e.Graphics.DrawImage(this.bmp, new Point(0, 0)); }private void OnFrameChanged(object o, EventArgs e) {//Invalidate the window to force a call to the paint event handler.//if we had more items in the window than just the animation,we coule //invalidate just the area occupied by the animation. this.Invalidate(); } }}//为了使这个例子运行起来,加载的文件必须是一个GIF动画.
转载于:https://www.cnblogs.com/ttssrs/archive/2012/03/14/2396505.html
