• 大小: 0.09M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2020-12-14
  • 语言: C#
  • 标签: 动态  图标  源码  托盘  C#  

资源简介

【实例简介】

C# 实现动态托盘图标 可替换任意图像


【核心代码】

 private void timer_Tick(object sender, EventArgs e)
        {
            //根据指定的类型依次设置相应的图标实现动态效果
            switch (type)
            {
                case 1:
                    if (c == 0) { notifyIcon.Icon = Properties.Resources.stop; c  ; }
                    else { c = 0; notifyIcon.Icon = Properties.Resources._null; }
                    break;
                case 2:
                    if (c == 0) { notifyIcon.Icon = Properties.Resources.pixel1; c  ; }
                    else if (c == 1) { notifyIcon.Icon = Properties.Resources.pixel2; c  ; }
                    else if (c == 2) { notifyIcon.Icon = Properties.Resources.pixel3; c  ; }
                    else if (c == 3) { notifyIcon.Icon = Properties.Resources.pixel4; c  ; }
                    else { c = 0; notifyIcon.Icon = Properties.Resources._null; }
                    break;
                case 3:
                    if (c == 0) { notifyIcon.Icon = Properties.Resources.circle1; c  ; }
                    else if (c == 1) { notifyIcon.Icon = Properties.Resources.circle2; c  ; }
                    else if (c == 2) { notifyIcon.Icon = Properties.Resources.circle3; c  ; }
                    else if (c == 3) { notifyIcon.Icon = Properties.Resources.circle4; c  ; }
                    else if (c == 4) { notifyIcon.Icon = Properties.Resources.circle5; c = 0; }

                    break;
                case 4:
                    if (c == 0) { notifyIcon.Icon = (Icon)Properties.Resources.arrow1; c  ; }
                    else if (c == 1) { notifyIcon.Icon = Properties.Resources.arrow2; c  ; }
                    else if (c == 2) { notifyIcon.Icon = Properties.Resources.arrow3; c  ; }
                    else if (c == 3) { notifyIcon.Icon = Properties.Resources.arrow4; c = 0; }
                    break;
            }
        }


资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HelloCsharp_ico
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
        public int type = 1;
        private void button1_Click(object sender EventArgs e)
        {
            type = 1;
        }

        private void trackBar_ValueChanged(object sender EventArgs e)
        {
            timer.Interval = trackBar.Value;
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }
        int c = 0;
        private void timer_Tick(object sender EventArgs

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2014-08-02 01:21  《实现动态托盘图标源码》\
     目录           0  2014-07-22 23:03  《实现动态托盘图标源码》\bin\
     目录           0  2014-07-23 13:19  《实现动态托盘图标源码》\bin\Debug\
     文件       39936  2014-08-02 01:21  《实现动态托盘图标源码》\bin\Debug\HelloCsharp_ico.exe
     文件       38400  2014-08-02 01:21  《实现动态托盘图标源码》\bin\Debug\HelloCsharp_ico.pdb
     文件       22712  2014-08-02 01:21  《实现动态托盘图标源码》\bin\Debug\HelloCsharp_ico.vshost.exe
     文件         490  2013-06-18 20:28  《实现动态托盘图标源码》\bin\Debug\HelloCsharp_ico.vshost.exe.manifest
     目录           0  2014-07-22 23:03  《实现动态托盘图标源码》\bin\Release\
     文件        3011  2020-04-14 10:39  《实现动态托盘图标源码》\frmMain.cs
     文件        6874  2014-08-02 01:21  《实现动态托盘图标源码》\frmMain.Designer.cs
     文件        6209  2014-08-02 01:21  《实现动态托盘图标源码》\frmMain.resx
     文件        4770  2014-07-22 23:18  《实现动态托盘图标源码》\HelloCsharp_ico.csproj
     文件        5120  2014-08-02 01:20  《实现动态托盘图标源码》\HelloCsharp_ico.v12.suo
     目录           0  2014-07-22 22:28  《实现动态托盘图标源码》\obj\
     目录           0  2014-07-22 22:28  《实现动态托盘图标源码》\obj\x86\
     目录           0  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\
     文件       37800  2014-08-02 01:20  《实现动态托盘图标源码》\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        8128  2014-08-02 01:20  《实现动态托盘图标源码》\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件        2405  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.csproj.FileListAbsolute.txt
     文件        1450  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.csproj.GenerateResource.Cache
     文件        1759  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.csprojResolveAssemblyReference.cache
     文件       39936  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.exe
     文件         180  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.frmMain.resources
     文件       38400  2014-08-02 01:21  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.pdb
     文件       27008  2014-07-22 23:18  《实现动态托盘图标源码》\obj\x86\Debug\HelloCsharp_ico.Properties.Resources.resources
     目录           0  2014-07-22 23:18  《实现动态托盘图标源码》\obj\x86\Debug\TempPE\
     文件        6144  2014-07-22 23:18  《实现动态托盘图标源码》\obj\x86\Debug\TempPE\Properties.Resources.Designer.cs.dll
     文件         498  2014-08-02 01:20  《实现动态托盘图标源码》\Program.cs
     目录           0  2014-07-22 23:15  《实现动态托盘图标源码》\Properties\
     文件        1407  2014-07-23 13:24  《实现动态托盘图标源码》\Properties\AssemblyInfo.cs
     文件        8634  2014-07-22 23:18  《实现动态托盘图标源码》\Properties\Resources.Designer.cs
............此处省略19个文件信息

评论

共有 条评论