using System.Reflection; using System.Windows; using System.Drawing; namespace PUBG2017PSLauncher { /// /// Interaction logic for App.xaml /// public partial class App : System.Windows.Application { static NotifyIcon trayIcon; protected override void OnStartup(StartupEventArgs e) { trayIcon = new NotifyIcon() { Text = "OG:BG 启动器", Icon = Icon.ExtractAssociatedIcon(Assembly.GetEntryAssembly().ManifestModule.Name), ContextMenuStrip = new ContextMenuStrip() { Items = {new ToolStripMenuItem("退出启动器", null, ExitFromTray)} }, Visible = true }; trayIcon.Click += TrayLeftClicked; base.OnStartup(e); } void ExitFromTray(object sender, EventArgs e) { Current.Shutdown(); } void TrayLeftClicked(object sender, EventArgs e) { MainWindow.Visibility = Visibility.Visible; MainWindow.ShowInTaskbar = true; } } }