OGBG_Launcher/PUBG2017PSLauncher/App.xaml.cs

43 lines
1.1 KiB
C#

using System.Reflection;
using System.Windows;
using System.Drawing;
namespace PUBG2017PSLauncher
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
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;
}
}
}