更新菜单标题

This commit is contained in:
陈国伟 2021-11-06 10:15:30 +08:00
parent 8bbdcaa2b9
commit b317584153

View File

@ -13,26 +13,25 @@ namespace FastGithub.UI
{ {
private readonly System.Windows.Forms.NotifyIcon notifyIcon; private readonly System.Windows.Forms.NotifyIcon notifyIcon;
private const string FASTGITHUB_UI = "FastGithub.UI"; private const string FASTGITHUB_UI = "FastGithub.UI";
private const string PROJECT_URI = "https://github.com/dotnetcore/FastGithub"; private const string RELEASES_URI = "https://github.com/dotnetcore/FastGithub/releases";
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
var about = new System.Windows.Forms.MenuItem("关于(&A)"); var upgrade = new System.Windows.Forms.MenuItem("检测更新(&U)");
about.Click += (s, e) => Process.Start(PROJECT_URI); upgrade.Click += (s, e) => Process.Start(RELEASES_URI);
var exit = new System.Windows.Forms.MenuItem("退出(&C)"); var exit = new System.Windows.Forms.MenuItem("关闭应用(&C)");
exit.Click += (s, e) => this.Close(); exit.Click += (s, e) => this.Close();
var version = this.GetType().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion; var version = this.GetType().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
this.Title = $"{FASTGITHUB_UI} v{version}"; this.Title = $"{FASTGITHUB_UI} v{version}";
this.notifyIcon = new System.Windows.Forms.NotifyIcon this.notifyIcon = new System.Windows.Forms.NotifyIcon
{ {
Visible = true, Visible = true,
Text = FASTGITHUB_UI, Text = FASTGITHUB_UI,
ContextMenu = new System.Windows.Forms.ContextMenu(new[] { about, exit }), ContextMenu = new System.Windows.Forms.ContextMenu(new[] { upgrade, exit }),
Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath) Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath)
}; };