using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Microsoft.VisualBasic;
namespace 闪烁
{
/// <summary>
///BabyCrazy
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.ComponentModel.IContainer components;
//在此先实例化,不能在后面实例化,要不这些对象就会丢失。找不到了
//在此你可以自己找些ICO放在程序目录下。根据自己需求改。
//我使用的ICO"MOON01.ICO",在所有的2000系统中都可以搜索到。你自己搜索一下
private Icon ico1 = new Icon("MOON01.ICO");
private Icon ico2 = new Icon("MOON02.ICO");
private Icon ico3 = new Icon("MOON03.ICO");
private Icon ico4 = new Icon("MOON04.ICO");
private Icon ico5 = new Icon("MOON05.ICO");
private Icon ico6 = new Icon("MOON06.ICO");
private Icon ico7 = new Icon("MOON07.ICO");
private Icon ico8 = new Icon("MOON08.ICO");
//用语存放以上的实例
private ArrayList ay = new ArrayList();
//时间控制
private System.Windows.Forms.Timer timer1;
//记数器
private int i = 0;
public Form1()
{
InitializeComponent();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.timer1 = new System.Windows.Forms.Timer(this.components);
//
// notifyIcon1
//
this.notifyIcon1.ContextMenu = this.contextMenu1;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
this.notifyIcon1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseUp);
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem3});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.Text = "闪烁";
this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "停止";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "退出";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
//窗口起始状态
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
//窗体完全透明,这个可要可不要。.
// this.Opacity = 0;
//不显示在任务栏
this.ShowInTaskbar = false;
//将所有ICO对象放进集合中
ay.Add(ico1);
ay.Add(ico2);
ay.Add(ico3);
ay.Add(ico4);
ay.Add(ico5);
ay.Add(ico6);
ay.Add(ico7);
ay.Add(ico8);
//timer时间间隔
this.timer1.Interval = 100;
this.notifyIcon1.Icon = ico1;
this.notifyIcon1.ContextMenu = contextMenu1;
}
private void notifyIcon1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
//得到右健菜单
contextMenu1.GetContextMenu();
}
private void menuItem1_Click(object sender, System.EventArgs e)
{
//开始记时
this.timer1.Enabled = true;
}
private void timer1_Tick(object sender, System.EventArgs e)
{
//ICO转换控制。
if(i < 8)
{
notifyIcon1.Icon = (Icon)ay[i];
i++;
return;
}
else
notifyIcon1.Icon = (Icon)ay[0];
i=1;
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
//停止记时
this.timer1.Enabled = false;
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
//关闭程序
this.Close();
}
}
}