|
|
@ -20,6 +20,13 @@ namespace STranslate.View
|
|
|
|
vm.Mainwin = this;
|
|
|
|
vm.Mainwin = this;
|
|
|
|
|
|
|
|
|
|
|
|
InitialTray();
|
|
|
|
InitialTray();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
InitIcon();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -67,14 +74,24 @@ namespace STranslate.View
|
|
|
|
public readonly NotifyIcon NotifyIcon = new NotifyIcon();
|
|
|
|
public readonly NotifyIcon NotifyIcon = new NotifyIcon();
|
|
|
|
|
|
|
|
|
|
|
|
#region Initial TrayIcon
|
|
|
|
#region Initial TrayIcon
|
|
|
|
private void InitialTray()
|
|
|
|
private void InitIcon()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var app = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly()?.Location);
|
|
|
|
|
|
|
|
NotifyIcon.Text = $@"{app} {SettingsVM.Instance.Version}";
|
|
|
|
|
|
|
|
var stream = Application
|
|
|
|
var stream = Application
|
|
|
|
.GetResourceStream(new Uri("Images/translate.ico", UriKind.Relative))?.Stream;
|
|
|
|
.GetResourceStream(new Uri("Images/translate.ico", UriKind.Relative))?.Stream;
|
|
|
|
|
|
|
|
if (NotifyIcon.Icon != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NotifyIcon.Icon.Dispose();
|
|
|
|
|
|
|
|
}
|
|
|
|
if (stream != null)
|
|
|
|
if (stream != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
NotifyIcon.Icon = new System.Drawing.Icon(stream);
|
|
|
|
NotifyIcon.Icon = new System.Drawing.Icon(stream);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private void InitialTray()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var app = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly()?.Location);
|
|
|
|
|
|
|
|
NotifyIcon.Text = $@"{app} {SettingsVM.Instance.Version}";
|
|
|
|
|
|
|
|
InitIcon();
|
|
|
|
NotifyIcon.Visible = true;
|
|
|
|
NotifyIcon.Visible = true;
|
|
|
|
NotifyIcon.BalloonTipText = $@"{app} already started...";
|
|
|
|
NotifyIcon.BalloonTipText = $@"{app} already started...";
|
|
|
|
NotifyIcon.ShowBalloonTip(500);
|
|
|
|
NotifyIcon.ShowBalloonTip(500);
|
|
|
|