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 系统托盘 图标闪烁的更多相关文章

  1. WPF/.net core WPF 系统托盘支持

    WPF 原生不支持系统托盘图标,需要依靠其它方式处理. 1 使用 WinForm 的支持 WPF最小到系统托盘 - Arvin.Mei - 博客园 2 使用 wpf-notifyicon 库 hard ...

  2. WPF 任务栏图标闪烁提醒

    using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServi ...

  3. WPF 任务栏背景闪烁提醒

    原文:WPF 任务栏图标闪烁提醒   public static class FlashWindow { [DllImport("user32.dll")] [return: Ma ...

  4. WPF应用最小化至系统托盘运行

    原文:WPF应用最小化至系统托盘运行 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/lordwish/article/details/5178889 ...

  5. 解决由腾讯qq浏览器引起win10系统桌面图标不停的闪烁问题

    win10系统桌面图标不停的闪烁,虽然不会引起太大问题,但是看着实在郁闷在网上搜索了很久,像停止问题报告服务,重置为默认应用都无解,了解到大概是软件兼容性问题于是打开服务管理器,一个一个关闭不是微软的 ...

  6. PE下挂载注册表文件然后清除系统托盘空白图标缓存

    清除了右下角通知栏图标缓存TrayNotify(否则会出现一堆空白图标)清除缓存批处理脚本.bat如何在PE系统环境下清除宿主系统的托盘图标缓存? 清除了右下角通知栏图标缓存TrayNotify(否则 ...

  7. electron--Tray添加图标和上下文菜单到系统通知区(系统托盘)

    const { app, Menu, Tray } = require('electron'); //系统托盘图标目录 appTray = new Tray(path.join(__dirname, ...

  8. 利用批处理文件删除系统托盘上的图标(适用于Windows各个版本)

    对于我这种强迫症患者来说,如果我已经删除了一些软件,但是系统托盘里面还有它,我会很难受.所以,没办法,必须想办法把它清除掉,还自己一片安宁!!!不知各位是否遇到过和我一样的问题,下面贴一段批处理文件的 ...

  9. WP7系统托盘和应用程序栏

    (一)系统托盘和应用程序栏系统托盘(1)显示系统级别的状态信息(2)Apps能隐藏和显示系统托盘Micosoft.Phone.Shell.SystemTray.IsVisible=true;应用程序栏 ...

随机推荐

  1. 神马小说:使用opensearch打造高性能搜索服务

    神马小说--- 使用opensearch打造高性能搜索服务 [使用背景] 神马小说是最早使用opensearch的用户,和opensearch一起成长.目前神马小说每天2亿搜索pv,1000w 用户. ...

  2. 【Android Api 翻译1】Android Texting(2)Testing Fundamentals 测试基础篇

    Testing Fundamentals The Android testing framework, an integral part of the development environment, ...

  3. extjs中grid对于其中表单的表头的读取以及是否隐藏的判断

    //获取grid的表头信息 var columns=baseGrid.columns;                     alert(columns.length); //判断列是否隐藏并输出表 ...

  4. Oracle 常用的SQL语法和数据对象

    一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, 字段名2, ……) VALUES ( 值1, 值2, ……);  INSE ...

  5. Oracle基础<4>--程序包

    一:程序包定义(包括1.程序包规范 2.程序包主体) 程序包是一种数据库对象,它是对相关pl/sql 类型.子程序.游标.异常.变量和常量的封装. 1.程序包规范:可以声明类型.变量.常量.异常.游标 ...

  6. 上架第一个APP到苹果商店被拒绝5次

    - : Metadata Rejected (APP中的注册时跳转的 - 用户协议视图没有内容).Waiting For Review 6天  In Review 1天 第二次被拒绝 -- : Met ...

  7. GetImage

    check路径是是否有效,网络访问地址.notfound查找不到,httpstatuscode枚举数较多,根据自己想要的设置就好了. public bool checkValid(string pat ...

  8. 话说Centos下nginx,php,mysql以及phpmyadmin的配置

    大话centos下部署phalcon框架 Centos还是ubuntu? 当我沿用这个标题的时候,心里在想"我能说我之前用的windows吗?",windows下xampp,wam ...

  9. 浅谈实现placeholder效果的几种方案

    placeholder是html5<input>的一个属性,它提供可描述输入字段预期值的提示信息(hint), 该提示会在输入字段为空时显示.高端浏览器支持此属性(ie10/11在获得焦点 ...

  10. sql Truncate 与 delete的区别

    Truncate 语法 TRUNCATE TABLE     [ { database_name .[ schema_name ] . | schema_name . } ]     table_na ...