UI字样标题
This commit is contained in:
parent
4f305ef7c8
commit
5adb329655
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows;
|
||||
using System.Windows.Interop;
|
||||
|
||||
@ -12,7 +12,7 @@ namespace FastGithub.UI
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private readonly System.Windows.Forms.NotifyIcon notifyIcon;
|
||||
private const string FAST_GITHUB = "FastGithub";
|
||||
private const string FASTGITHUB_UI = "FastGithub.UI";
|
||||
private const string PROJECT_URI = "https://github.com/dotnetcore/FastGithub";
|
||||
|
||||
public MainWindow()
|
||||
@ -25,10 +25,13 @@ namespace FastGithub.UI
|
||||
var exit = new System.Windows.Forms.MenuItem("退出(&C)");
|
||||
exit.Click += (s, e) => this.Close();
|
||||
|
||||
var version = this.GetType().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
|
||||
|
||||
this.Title = $"{FASTGITHUB_UI} v{version}";
|
||||
this.notifyIcon = new System.Windows.Forms.NotifyIcon
|
||||
{
|
||||
Visible = true,
|
||||
Text = FAST_GITHUB,
|
||||
Text = FASTGITHUB_UI,
|
||||
ContextMenu = new System.Windows.Forms.ContextMenu(new[] { about, exit }),
|
||||
Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath)
|
||||
};
|
||||
@ -42,15 +45,8 @@ namespace FastGithub.UI
|
||||
this.WindowState = WindowState.Normal;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var fileName = $"{FAST_GITHUB}.exe";
|
||||
if (File.Exists(fileName) == true)
|
||||
{
|
||||
var version = FileVersionInfo.GetVersionInfo(fileName);
|
||||
this.Title = $"{FAST_GITHUB} v{version.ProductVersion}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拦截最小化事件
|
||||
|
||||
@ -10,11 +10,15 @@ namespace FastGithub.UI
|
||||
{
|
||||
class Program
|
||||
{
|
||||
private const string MUTEX_NAME = "Global\\FastGithub.UI";
|
||||
private const string MAIN_WINDOWS = "MainWindow.xaml";
|
||||
private const string FASTGITHUB_PATH = "fastgithub.exe";
|
||||
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
|
||||
using var mutex = new Mutex(true, "Global\\FastGithub.UI", out var isFirstInstance);
|
||||
using var mutex = new Mutex(true, MUTEX_NAME, out var isFirstInstance);
|
||||
if (isFirstInstance == false)
|
||||
{
|
||||
return;
|
||||
@ -24,7 +28,7 @@ namespace FastGithub.UI
|
||||
SetWebBrowserVersion();
|
||||
|
||||
var app = new Application();
|
||||
app.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
|
||||
app.StartupUri = new Uri(MAIN_WINDOWS, UriKind.Relative);
|
||||
app.Run();
|
||||
}
|
||||
|
||||
@ -71,7 +75,7 @@ namespace FastGithub.UI
|
||||
/// <returns></returns>
|
||||
private static void StartFastGithub()
|
||||
{
|
||||
const string fileName = "fastgithub.exe";
|
||||
const string fileName = FASTGITHUB_PATH;
|
||||
if (File.Exists(fileName) == false)
|
||||
{
|
||||
return;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user