WPF 系统托盘 图标闪烁
WPF消息通知
系统托盘,图标闪烁
using System.Windows.Forms;
using System.Windows.Threading;
public partial class Window : Window
{
private NotifyIcon notifyIcon;
DispatcherTimer icoTimer = new DispatcherTimer();
string icoUrl = @"../../Red.ico";
string icoUrl2 = @"../../Red2.ico";
public long i = ;
public Window()
{
InitializeComponent();
//不在任务栏显示
this.ShowInTaskbar = false;
this.notifyIcon = new NotifyIcon();
this.notifyIcon.BalloonTipText = "系统监控中... ...";
this.notifyIcon.ShowBalloonTip();
this.notifyIcon.Text = "系统监控中... ...";
//this.notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
this.notifyIcon.Icon = new System.Drawing.Icon(@"../../Red.ico");
this.notifyIcon.Visible = true;
//打开菜单项
System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("Open");
open.Click += new EventHandler(Show);
//退出菜单项
System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("Exit");
exit.Click += new EventHandler(Close);
//关联托盘控件
System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { open, exit };
notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);
this.notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler((o, e) =>
{
if (e.Button == MouseButtons.Left) this.Show(o, e);
//this.Visibility = System.Windows.Visibility.Visible;
//this.ShowInTaskbar = true;
//this.Activate();
NavigationWindow win = new MainWindow();
this.notifyIcon.Visible = false;
win.ShowDialog();
});
//闪烁图标
icoTimer.Interval = TimeSpan.FromSeconds(0.3);
icoTimer.Tick += new EventHandler(IcoTimer_Tick);
icoTimer.Start();
}
public void IcoTimer_Tick(object sender, EventArgs e)
{
i=i+;
if (i % != )
{
this.notifyIcon.Icon = new System.Drawing.Icon(icoUrl);
}
else
{
this.notifyIcon.Icon = new System.Drawing.Icon(icoUrl2);
}
}
private void Show(object sender, EventArgs e)
{
this.Visibility = System.Windows.Visibility.Visible;
this.ShowInTaskbar = true;
this.Activate();
}
private void Hide(object sender, EventArgs e)
{
this.ShowInTaskbar = false;
this.Visibility = System.Windows.Visibility.Hidden;
}
private void Close(object sender, EventArgs e)
{
System.Windows.Application.Current.Shutdown();
}
转自:http://www.cnblogs.com/ke10/archive/2012/11/16/NotifyIcon.html
记得对System.Windows.Forms添加引用。
WPF 系统托盘 图标闪烁的更多相关文章
- WPF/.net core WPF 系统托盘支持
WPF 原生不支持系统托盘图标,需要依靠其它方式处理. 1 使用 WinForm 的支持 WPF最小到系统托盘 - Arvin.Mei - 博客园 2 使用 wpf-notifyicon 库 hard ...
- WPF 任务栏图标闪烁提醒
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServi ...
- WPF 任务栏背景闪烁提醒
原文:WPF 任务栏图标闪烁提醒 public static class FlashWindow { [DllImport("user32.dll")] [return: Ma ...
- WPF应用最小化至系统托盘运行
原文:WPF应用最小化至系统托盘运行 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/lordwish/article/details/5178889 ...
- 解决由腾讯qq浏览器引起win10系统桌面图标不停的闪烁问题
win10系统桌面图标不停的闪烁,虽然不会引起太大问题,但是看着实在郁闷在网上搜索了很久,像停止问题报告服务,重置为默认应用都无解,了解到大概是软件兼容性问题于是打开服务管理器,一个一个关闭不是微软的 ...
- PE下挂载注册表文件然后清除系统托盘空白图标缓存
清除了右下角通知栏图标缓存TrayNotify(否则会出现一堆空白图标)清除缓存批处理脚本.bat如何在PE系统环境下清除宿主系统的托盘图标缓存? 清除了右下角通知栏图标缓存TrayNotify(否则 ...
- electron--Tray添加图标和上下文菜单到系统通知区(系统托盘)
const { app, Menu, Tray } = require('electron'); //系统托盘图标目录 appTray = new Tray(path.join(__dirname, ...
- 利用批处理文件删除系统托盘上的图标(适用于Windows各个版本)
对于我这种强迫症患者来说,如果我已经删除了一些软件,但是系统托盘里面还有它,我会很难受.所以,没办法,必须想办法把它清除掉,还自己一片安宁!!!不知各位是否遇到过和我一样的问题,下面贴一段批处理文件的 ...
- WP7系统托盘和应用程序栏
(一)系统托盘和应用程序栏系统托盘(1)显示系统级别的状态信息(2)Apps能隐藏和显示系统托盘Micosoft.Phone.Shell.SystemTray.IsVisible=true;应用程序栏 ...
随机推荐
- Android小项目之九 两种上下文的区别
------- 源自梦想.永远是你IT事业的好友.只是勇敢地说出我学到! ---------- 按惯例,写在前面的:可能在学习Android的过程中,大家会和我一样,学习过大量的基础知识,很多的知识点 ...
- Android Chronometer的正常暂停和继续
最近做了个小实验--一个小的计数秒表,实现开始计时,暂停计时,重置的功能.界面如下
- java 生成UUID
UUID(Universally Unique Identifier)全局唯一标识符,是一个128位长的数字,一般用16进制表示. 算法的核心思想是结合机器的网卡.当地时间.一个随即数来生成UUID, ...
- DML 数据操控语言
一.DML数据操作语言 (DQL select ) 主要用于检索.插入和修改数据库信息.它是最常用的SQL命令,如INSERT(插入).UPDATE(更新).SELECT(选择).DELETE(删 ...
- http请求数据
/// <summary> /// http请求post数据 /// </summary> /// <param name=&q ...
- CF Sea and Islands
Sea and Islands time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
- hdu 3311 斯坦纳树
思路:虚拟一个0号节点,将每个点建一条到0号节点的边,权值为挖井需要的价值.并要保证0号节点同另外n个寺庙一样被选择即可. 然后就是求斯坦纳树了. #include<map> #inclu ...
- Angularjs 使用filter格式化输出href
工作中,由于是多级菜单,如果上级菜单为空,就会访问Angularjs 默认的state,然后再展开菜单,我找资料之后,才知道是通过filter来格式化输出数据的,格式是{{ expression | ...
- 【转】用java实例学习MVC模式
.1 MVC模式 MVC是三个单词的缩写,这三个单词分别为:模型(Model).视图(View)和控制(Controller).MVC模式的目的就是实现Web系统的职能分工.下面以J2EE开发进行介绍 ...
- php学习笔记7--php中的数组
php中的数组 1.数组的定义:显式方式:$arr = array(1,2,3,4,5); $arr1 = array('name'=>'dqrcsc','age'=>'24');隐式方式 ...