HandyOrg / HandyControl

Contains some simple and commonly used WPF controls
https://handyorg.github.io/
MIT License
6.17k stars 1.04k forks source link

Bug title #1632

Open LickBag opened 3 months ago

LickBag commented 3 months ago

Describe the bug

我通过xaml的方式增加托盘图标,但是每次通过mstsc远程连接运行这个软件的电脑后就会创建一个新的托盘图标,mstsc远程连接N次,那么托盘图标就会有N+1个,但是使用C#代码在窗口Load的时候创建托盘图标就没问题。

`

` `private void InitTray() { HandyControl.Controls.NotifyIcon notifyIcon = new HandyControl.Controls.NotifyIcon(); notifyIcon.Token = "SimulatorNotifyIconToken"; notifyIcon.Text = "模拟器"; var contextMenu = new ContextMenu(); var menuItem = new MenuItem(); menuItem.Header = "开机启动,并模拟"; menuItem.IsCheckable = true; menuItem.IsChecked = this.AutoBoot; menuItem.StaysOpenOnClick = true; menuItem.Checked += (s, a) => { this.AutoBoot = true; }; menuItem.Unchecked += (s, a) => { this.AutoBoot = false; }; contextMenu.Items.Add(menuItem); Separator separator = new Separator(); separator.BorderBrush = Brushes.LightGray; separator.BorderThickness = new Thickness(1); separator.Margin = new Thickness(-30, 0, 0, 0); contextMenu.Items.Add(separator); var menuItem1 = new MenuItem(); menuItem1.Header = "显示主窗口"; menuItem1.Command = this.PushMainWindow2Top; contextMenu.Items.Add(menuItem1); var menuItem2 = new MenuItem(); menuItem2.Header = "退出程序"; menuItem2.Command = this.ExitCommand; contextMenu.Items.Add(menuItem2); notifyIcon.ContextMenu = contextMenu; HandyControl.Controls.NotifyIcon.Register(notifyIcon.Token, notifyIcon); notifyIcon.Init(); }` ### Steps to reproduce the bug 详见描述 ### Expected behavior _No response_ ### Screenshots _No response_ ### NuGet package version None ### IDE Visual Studio 2022 ### Framework type .Net Framework 4.8 ### Windows version _No response_ ### Additional context _No response_
LickBag commented 3 months ago

公司不能上传文件,没法上传demo