• 播放动画


    编辑器加载中...

    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动画.
  • 相关阅读:
    jqgrid 获取选中用户的数据插入
    jqgrid 自定义文本框、选择框等查询
    Java学习—— for循环
    Android中 Http请求
    异步消息处理机制——Handler用法
    ThreadLocal
    Android开发 学习笔记——HelloWorld
    eclipse 常用插件
    mysql 命令备份还原
    学习
  • 原文地址:https://www.cnblogs.com/ttssrs/p/2396505.html
Copyright © 2020-2023  润新知