操作步骤:
1、创建一个C# Windows窗体应用项目,命名为“IconTwinkle”:

2、双击解决方案中的“Resources.resx”,点击“添加资源”,选择图标并导入:

3、可见选定的图标已导入项目中:

4、双击右侧工具箱中的控件ContextMenuStrip、NotifyIcon、Timer,以将其添加至窗体中:

5、设置“contextMenuStrip1”,添加4个列表项,将Text属性分别改为“显示、隐藏、闪烁、退出”:

6、设置“notifyIcon1”,将ContextMenuStrip属性改为“contextMenuStrip1”、Text属性改为“这里是托盘图标!”、Icon属性设置为“ichat.ico”:

7、编写相应事件的功能代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;namespace IconTwinkle
{public partial class Form1 : Form{private Icon blank = Properties.Resources.blank;private Icon normal = Properties.Resources.ichat;private bool _status = true;private bool _isBlank = false;public Form1(){InitializeComponent();}private void toolStripMenuItem1_Click(object sender, EventArgs e){this.Visible = true;}private void toolStripMenuItem2_Click(object sender, EventArgs e){this.Visible = false;}private void toolStripMenuItem3_Click(object sender, EventArgs e){if (_isBlank == false){_isBlank = true;timer1.Enabled = true;timer1.Start();}else{_isBlank = false;timer1.Stop();//气泡提示notifyIcon1.ShowBalloonTip(5000, "提示", "关闭闪烁效果!", ToolTipIcon.Info);}}private void toolStripMenuItem4_Click(object sender, EventArgs e){Application.Exit();}//定时器中修改图标的状态,定时反转图标private void timer1_Tick(object sender, EventArgs e){if (_status){notifyIcon1.Icon = normal;}else{notifyIcon1.Icon = blank;}_status = !_status;}private void Form1_Load(object sender, EventArgs e){}}
}
//本段代码部分来源于网络,感谢大佬~
8、运行测试:












