⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ganimatebutton.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Imaging;

namespace gowk.controls
{
	/// <summary>
	/// GButton 的摘要说明。
	/// </summary>
	[DefaultEvent("Click")]
	public class GAnimateButton :GPanel
	{
		public GAnimateButton()
		{
			this.Size=new Size(60,20);
		}
	/*	protected override void OnPaint(PaintEventArgs e)
		{
			if(this.BackgroundImage==null)
			{
				base.OnPaint(e);return;
			}
			Graphics g=e.Graphics;
			Rectangle rect=this.ClientRectangle;
			if(this.Capture)rect.Offset(-1,-1);
			e.Graphics.DrawImage(this.BackgroundImage,rect,this.ClientRectangle,GraphicsUnit.Pixel);
	//		base.OnPaint(e);
		}*/

		protected override void OnPaint(PaintEventArgs e)
		{
			if(this.BackgroundImage!=null)
			{
				Graphics g=e.Graphics;
				Rectangle rect=this.ClientRectangle;
				if(this.Capture)rect.Offset(-1,-1);
				try
				{
					g.DrawImage(this.BackgroundImage,rect,this.ClientRectangle,GraphicsUnit.Pixel);
				}
				catch(System.Exception ex)
				{
					System.Diagnostics.Trace.WriteLine(ex.Message+"  "+ex.StackTrace);
					gowk.utility.Diagnostics.Debug.Write(ex);
				}
			}
			this.DrawBorder(e);
		}

		private void OnAnimate(object sender, System.EventArgs e)
		{
			try
			{
				ImageAnimator.UpdateFrames();
				this.Invalidate();
			}
			catch(System.Exception ex)
			{
				gowk.utility.Diagnostics.Debug.Write(ex);
			}
		//	ImageAnimator.Animate(this.BackgroundImage,new EventHandler(this.OnAnimate));
		}
		public override Image BackgroundImage
		{
			get
			{
				return base.BackgroundImage;
			}
			set
			{
				System.Diagnostics.Trace.WriteLine("SSSS");
				if(base.BackgroundImage==value)return;
				if(this.BackgroundImage!=null)ImageAnimator.StopAnimate(this.BackgroundImage,new System.EventHandler(OnAnimate));
				base.BackgroundImage = value;
				if(value!=null && ImageAnimator.CanAnimate(this.BackgroundImage))
				{
					ImageAnimator.Animate(this.BackgroundImage,new System.EventHandler(OnAnimate));
				}
			}
		}
		protected override void OnPaintBackground(PaintEventArgs pevent)
		{
			Graphics g=pevent.Graphics;
			if(this.BackColor==Color.Empty ||this.BackColor==Color.Transparent)
			{
				System.Drawing.Drawing2D.GraphicsState gs=g.Save();
				g.TranslateTransform(-this.Left,-this.Top);
				this.InvokePaintBackground(this.Parent,new PaintEventArgs(g,this.Bounds));
				g.Restore(gs);
				g.TranslateTransform(-this.Left,-this.Top);
				this.InvokePaint(this.Parent,new PaintEventArgs(g,this.Bounds));
				g.Restore(gs);
			}
			else
			{
				g.FillRectangle(new SolidBrush(this.BackColor),this.ClientRectangle);
			}
		}




	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -