zoukankan      html  css  js  c++  java
  • 播放动画

    编辑器加载中...

    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动画.
  • 相关阅读:
    元素设置float属性后,其后面的元素的位置问题
    Vue.js经典开源项目汇总
    ES6-模块导入导出
    JavaScript内存泄漏
    父元素高度比子元素高度多几个像素的解决方法
    jasmine —— Spies(转)
    用npm-run自动化任务(转)
    AngularJS中页面传参方法
    Path模块部分常用函数解析——NodeJS
    html特殊字符表
  • 原文地址:https://www.cnblogs.com/ttssrs/p/2396505.html
Copyright © 2011-2022 走看看