Пример #1
0
        private void SetIcon(string text)
        {
            try
            {
                this.notifyIcon1.Text = text;

                if (text.Length > 0)
                {
                    // 动态生成一个文字图标对象,用于托盘图标的显示
                    Icon icon = ImageCreater.CreateTrayIcon(text);
                    if (icon != null)
                    {
                        notifyIcon1.Icon = icon;
                    }
                }
                else
                {
                    // 如果没有相关文字信息则使用主窗口图标作为托盘图标
                    notifyIcon1.Icon = Business_Cmpp.Properties.Resources.main;
                }
            }
            catch (Exception)
            {
            }
        }