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动画.
  • 相关阅读:
    进程对象的属性或方法详解
    进程理论以及开启子进程的两种方式
    计算机发展史(多道技术)
    基于socketserver实现的并发(tcp和udp)
    基于udp协议的套接字及udp协议粘包问题
    模拟ssh的远程网络传输
    周考题目及答案
    c/s架构搭建
    网络编程基础
    10.16模拟赛(湖南集训)
  • 原文地址:https://www.cnblogs.com/ttssrs/p/2396505.html
Copyright © 2011-2022 走看看