All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
计算两者相差几个月零几天_[PHP教程]
判断网页浏览器支持javascript的方法_JavaScript技术_编程技术
Visual,Studio,2008中的SQL数据库发布_[Asp.Net教程]
在atlas里面的UpdatePanel控件中调用javascript,以及updatePanel的_[Asp.Net教程]
将一个图片按比例缩放显示在一个Frame中_[Asp.Net教程]
用ImessageFilter实现截获键盘动作_[Asp.Net教程]
XML WebService完全实例详细解析_[XML教程]
c#判断数据NULL值的方法_[Asp.Net教程]
在使用ASP.NET网站管理工具出现“遇到错误。请返回上一页并重试。”的解决办法!_[Asp.Net教程]
Asp.NET大文件上传开发总结(一)_[Asp.Net教程]
Reading number is top 10 pictures
性感丰满身材火爆de美女1
奇趣的世界记录2
Sora aoi on twitter3
心有鱼而力不足
Players in the eyes of a perfect love2
Breasts woman big set 2
Plump, too plump!2
A letter to parents choose world of warcraft seven big reason
2013中国四川省高考作文
超级大兔子
Download software ranking
Ashlynn Video4
I for your crazy
Popkart Cracked versions Mobile phone games
Tram sex maniac 2 (H) rar bag5
DreamWeaver8
功夫熊猫2(上集)
VeryCD电驴(EasyMule) V1.1.9 Build09081
Tram sex maniac 2 (H) rar bag12
Such love down(擒爱记)
Professional killers2 for Android
qq published in(发表于) 2014/7/11 9:20:02 Edit(编辑)
C#中的 ImageAnimator类的应用

C#中的 ImageAnimator类的应用

C#中的 ImageAnimator类的应用

ImageAnimator类的应用

运行程序,单击【播放动画】按钮,播放Gif动画,单击【停止播放】按钮,停止播放Gif动画,如图1所示。



图1 ImageAnimator类播放GIF动画

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _7_04

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

Bitmap bitmap = new Bitmap("1.gif");

bool current = False;

public void AnimateImage()

{

if (!current)

{

ImageAnimator.Animate(bitmap, new EventHandler(this.OnFrameChanged));

current = True;

}

}

private void OnFrameChanged(object o, EventArgs e)

{

this.Invalidate();

}

protected override void OnPaint(PaintEventArgs e)

{

AnimateImage();

ImageAnimator.UpdateFrames();

e.Graphics.DrawImage(this.bitmap, new Point(0, 0));

}

private void button1_Click(object sender, EventArgs e)

{

ImageAnimator.StopAnimate(bitmap, new EventHandler(this.OnFrameChanged));//停止

}

private void button2_Click(object sender, EventArgs e)

{

ImageAnimator.Animate(bitmap, new EventHandler(this.OnFrameChanged));//播放

}

}

}

完整程序代码如下:

★ ★★★★Form1.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace _7_04

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

Bitmap bitmap = new Bitmap("1.gif");

bool current = false;

public void AnimateImage()

{

if (!current)

{

ImageAnimator.Animate(bitmap, new EventHandler(this.OnFrameChanged));

current = true;

}

}

private void OnFrameChanged(object o, EventArgs e)

{

this.Invalidate();

}

protected override void OnPaint(PaintEventArgs e)

{

AnimateImage();

ImageAnimator.UpdateFrames();

e.Graphics.DrawImage(this.bitmap, new Point(0, 0));

}

private void button1_Click(object sender, EventArgs e)

{

ImageAnimator.StopAnimate(bitmap, new EventHandler(this.OnFrameChanged));//停止

}

private void button2_Click(object sender, EventArgs e)

{

ImageAnimator.Animate(bitmap, new EventHandler(this.OnFrameChanged)); //播放

}

}

}

★ ★★★★Form1.designer.cs窗体设计文件完整程序代码★★★★★

namespace _7_04

{

partial class Form1

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

/// 清理所有正在使用的资源。

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.button1 = new System.Windows.Forms.Button();

this.button2 = new System.Windows.Forms.Button();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(539, 139);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "停止播放";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// button2

//

this.button2.Location = new System.Drawing.Point(439, 139);

this.button2.Name = "button2";

this.button2.Size = new System.Drawing.Size(75, 23);

this.button2.TabIndex = 1;

this.button2.Text = "播放动画";

this.button2.UseVisualStyleBackColor = true;


添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.