//窗体加载事件, 在窗体加载前触发, 此时窗体尚未加载 /*private void TrayCheat_Load(object sender, EventArgs e) * { * MessageBox.Show("窗体加载中......", "提示"); * }*/ //窗体激活事件, 每次窗体被激活(选中), 都会触发这个方法 /*private void TrayCheat_Activated(object sender, EventArgs e) * { * MessageBox.Show("窗体被激活", "提示"); * }*/ #endregion //当窗体第一次显示前, 会执行这个方法, 此时窗体已经加载完毕 private void TrayCheat_Shown(object sender, EventArgs e) { //MessageBox.Show("这是窗体的第一次显示", "提示"); currentWindowPtr = WindowsForm.MyGetForegroundWindow();//获取窗口句柄, 必须在窗口被激活之后执行这句代码 notifyIcon_360.Text = @"360安全卫士 - 安全防护中心完全开启"; notifyIcon_360.Icon = icon_360; notifyIcon_360.MouseDoubleClick += NotifyIcon_TrayCheat_MouseDoubleClick; notifyIcon_360bug.Text = @"360杀毒 - 文件系统实时防护已开启"; notifyIcon_360bug.Icon = icon_360bug; notifyIcon_360bug.MouseDoubleClick += NotifyIcon_TrayCheat_MouseDoubleClick; //打开定时器 Timer_IconEffect.Start(); //修改按钮文本显示 switch (currentIconEffect) { case EffectFlickOrSpin.Effect_Spin: ICONEffect.Text = "当前图标效果: 旋转"; break; case EffectFlickOrSpin.Effect_Flick: ICONEffect.Text = "当前图标效果: 闪烁"; break; case EffectFlickOrSpin.Effect_Still: ICONEffect.Text = "当前图标效果: 无"; break; default: break; } }
//特效控制器 private void ICONEffect_Click(object sender, EventArgs e) { switch (currentIconEffect)//判断当前效果 { case EffectFlickOrSpin.Effect_Spin: currentIconEffect = EffectFlickOrSpin.Effect_Flick; //旋转切换为闪烁 ICONEffect.Text = "当前图标效果: 闪烁"; //修改按钮文本显示 Timer_IconEffect.Stop(); //停止计时器 Timer_IconEffect.Interval = 300; //设置定时器时间间隔 Timer_IconEffect.Start(); //开启计时器 break; case EffectFlickOrSpin.Effect_Flick: currentIconEffect = EffectFlickOrSpin.Effect_Still; //闪烁切换为静止 ICONEffect.Text = "当前图标效果: 无"; //修改按钮文本显示 break; case EffectFlickOrSpin.Effect_Still: currentIconEffect = EffectFlickOrSpin.Effect_Spin; //静止切换为旋转 ICONEffect.Text = "当前图标效果: 旋转"; //修改按钮文本显示 Timer_IconEffect.Stop(); //停止计时器 Timer_IconEffect.Interval = 50; //设置定时器时间间隔 Timer_IconEffect.Start(); //开启计时器 break; default: break; } }