public static TaskBarService GetInstance() { if (instance == null) { lock (_lock) { if (instance == null) { instance = new TaskBarService(); } } } return(instance); }
private NotifyIconManager() { NotifyIcon = new NotifyIcon { Text = "Snap Desktop", Icon = Resources.SnapNewIcon, Visible = true, ContextMenu = new ContextMenu(new[] { new MenuItem("壁纸", (sender, e) => WindowManager.GetOrAddWindow <WallpaperWindow>().Show()), itemCenterTask, MenuItemSeparator, new MenuItem("更新", new[] { new MenuItem("检查更新", async(sender, e) => await UpdateService.GetInstance().HandleUpdateCheckAsync(false)), new MenuItem("手动下载", (sender, e) => Process.Start("https://github.com/DGP-Studio/DGP.Snap/releases")), }), itemAutorun,//自动启动 MenuItemSeparator, new MenuItem("关于", (sender, e) => WindowManager.GetOrAddWindow <AboutWindow>().Show()), new MenuItem("退出", (sender, e) => LifeCycleService.Application_ExitAsync()) }) }; NotifyIcon.Click += (sender, e) => { if (((MouseEventArgs)e).Button == MouseButtons.Left) { System.Windows.Window sideWindow = WindowManager.GetOrAddWindow <SideWindow>(); if (sideWindow.IsVisible) { sideWindow.Close(); } else { sideWindow.Show(); } } }; //设置check NotifyIcon.ContextMenu.Popup += (sender, e) => { itemAutorun.Checked = AutoStartupService.IsAutorun(); itemCenterTask.Checked = TaskBarService.GetInstance().Applied; }; }