📄 nofityiconanimatehelper.cs
字号:
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;
namespace gowk.forms
{
/// <summary>
/// NofityIconAnimateHelper 的摘要说明。
/// </summary>
public class NofityIconAnimateHelper
{
private NotifyIcon ni;
private Icon normal_icon;
private IconCollection icons;
private System.Windows.Forms.Timer tmr;
int cur=0;
public NofityIconAnimateHelper(System.Windows.Forms.NotifyIcon ni)
{
this.ni=ni;
this.icons=new IconCollection();
this.tmr=new Timer();
this.tmr.Tick+=new EventHandler(tmr_Tick);
}
public void Animate(Image img)
{
this.icons.Clear();
this.icons.Add(gowk.controls.UT.ConvertImage2Icon(img));
this.icons.Add(gowk.controls.UT.ConvertImage2Icon(gowk.controls.UT.GetDisableImage(img)));
this.Animate();
}
public int Rate
{
get{return (int)(1000/this.tmr.Interval);}
set{this.tmr.Interval=(int)(1000/value);}
}
public bool IsAnimating
{
get{return this.tmr.Enabled;}
}
public void Animate()
{
this.tmr.Enabled=true;
}
public void StopAnimate()
{
this.tmr.Enabled=false;
this.ni.Icon=this.normal_icon;
}
public Icon NormalIcon
{
get{return this.normal_icon;}
set{this.normal_icon=value;}
}
public IconCollection Icons
{
get{return this.icons;}
set{this.icons=value;}
}
private void tmr_Tick(object sender, EventArgs e)
{
if(this.icons.Count<1)this.StopAnimate();
this.ni.Icon=this.icons[this.cur];
this.cur++;
this.cur=this.cur%this.icons.Count;
}
public class IconCollection:System.Collections.ArrayList
{
public new Icon this[int index]
{
get{return (Icon)base[index];}
set{base[index]=value;}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -