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;应用程序栏 ...
随机推荐
- Dapper使用方法:dapper-dot-net/Tests/Tests.cs解析(1)方法:TestMultiMapWithConstructor
sql: SELECT * FROM users; SELECT * FROM posts; SELECT * FROM Posts p LEFT JOIN Users u ON u.Id= p.Ow ...
- 转载:Character data is represented incorrectly when the code page of the client computer differs from the code page of the database in SQL Server 2005
https://support.microsoft.com/en-us/kb/904803 Character data is represented incorrectly when the cod ...
- 浅析console和浏览器命令行API
一.console对象: F12或者Control+Shift+i(Win)/ Alt+Command+i(Mac)打开浏览器自带的开发工具,选择顶部tab中的最后一项console,这样你就可以尽情 ...
- ListView优化-getView优化
ListView作为Android中最常用的组件之一,其优化方式也比较多. 在使用ListView或是GridView的时候,往往需要自定义数据适配器.一般我们都需要复习getView方法.对于此方法 ...
- Part 82 to 85 Talking about Generic queue, stack collection class
Part 82 Generic queue collection class Part 83 Generic stack collection class Part 84 Real tim ...
- Part 71 Code snippets in visual studio
- 2015影响因子Excel版
现在终于有影响因子2015的Excel版了,这个版本除了还包括杂志全称和缩写等基本信息还,包括中科院分区, 应该是迄今2015影响因子最奢华的版本了吧. 看了这个版本,发现中国的SCI杂志还是不少的, ...
- 使用SQLite3持久保存应用程序数据
前言 SQL是一种数据库查询语言,用于存取数据以及查询.更新和管理关系数据库系统,因为强大的查询功能和简单的语法,已经成为主流数据库的标准语言.SQLite3是一种嵌入式的数据库,无需服务器支持,它将 ...
- UI3_UIView自动布局
// // ViewController.m // UI3_UIView自动布局 // // Created by zhangxueming on 15/7/1. // Copyright (c) 2 ...
- AMQ学习笔记 - 21. 异步发送
原文地址:Async Sends 背景 ActiveMQ支持同步.异步两种发送的模式将消息发送到broker,模式的选择对发送延时有巨大的影响.producer能达到怎样的产出率[1],主要受发送延时 ...