diff --git a/STranslate/Helper/HotkeysHelper.cs b/STranslate/Helper/HotkeysHelper.cs index 5156123..122cd2a 100644 --- a/STranslate/Helper/HotkeysHelper.cs +++ b/STranslate/Helper/HotkeysHelper.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Windows; using System.Windows.Interop; +using WpfScreenHelper; using static STranslate.Helper.NativeMethodHelper; namespace STranslate.Helper @@ -46,6 +47,19 @@ namespace STranslate.Helper { keymap[id] = callBack; } + + /// + /// 屏幕分辨率以及文本显示比例变更对应的消息标志 + /// + private const int WmDisplayChange = 0x007e; + /// + /// 文本显示比例变更消息标志 + /// + private const int WmTextChange = 0x02E0; + /// + /// window消息定义的 注册的热键消息标志 + /// + private const int WmHotkeys = 0x0312; /// /// 快捷键消息处理 /// @@ -53,7 +67,7 @@ namespace STranslate.Helper { switch (msg) { - case 0x0312: //这个是window消息定义的 注册的热键消息 + case WmHotkeys: int id = wParam.ToInt32(); if (keymap.TryGetValue(id, out var callback)) { diff --git a/STranslate/Properties/AssemblyInfo.cs b/STranslate/Properties/AssemblyInfo.cs index bb022e5..7fe7b94 100644 --- a/STranslate/Properties/AssemblyInfo.cs +++ b/STranslate/Properties/AssemblyInfo.cs @@ -47,6 +47,6 @@ using System.Windows; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.2.1.0")] -[assembly: AssemblyFileVersion("0.2.1.0")] +[assembly: AssemblyVersion("0.2.2.0")] +[assembly: AssemblyFileVersion("0.2.2.0")] [assembly: Guid("CE252DD8-179F-4544-9989-453F5DEA378D")] \ No newline at end of file diff --git a/STranslate/View/MainWindow.xaml.cs b/STranslate/View/MainWindow.xaml.cs index 0aaab0e..3980752 100644 --- a/STranslate/View/MainWindow.xaml.cs +++ b/STranslate/View/MainWindow.xaml.cs @@ -20,6 +20,13 @@ namespace STranslate.View vm.Mainwin = this; InitialTray(); + + Microsoft.Win32.SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged; + } + + private void SystemEvents_DisplaySettingsChanged(object sender, EventArgs e) + { + InitIcon(); } /// @@ -67,14 +74,24 @@ namespace STranslate.View public readonly NotifyIcon NotifyIcon = new NotifyIcon(); #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 .GetResourceStream(new Uri("Images/translate.ico", UriKind.Relative))?.Stream; + if (NotifyIcon.Icon != null) + { + NotifyIcon.Icon.Dispose(); + } if (stream != null) + { 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.BalloonTipText = $@"{app} already started..."; NotifyIcon.ShowBalloonTip(500); diff --git a/Updater/MainWindow.xaml.cs b/Updater/MainWindow.xaml.cs index fb467c9..f6394c2 100644 --- a/Updater/MainWindow.xaml.cs +++ b/Updater/MainWindow.xaml.cs @@ -144,14 +144,14 @@ namespace Updater if (unresult) { SetStatus("更新完成!", false); - Process tai = new Process(); - ProcessStartInfo startInfo = new ProcessStartInfo(System.IO.Path.Combine(unpath, "Tai.exe")); - tai.StartInfo = startInfo; - tai.Start(); + Process p = new Process(); + ProcessStartInfo startInfo = new ProcessStartInfo(System.IO.Path.Combine(unpath, "STranslate.exe")); + p.StartInfo = startInfo; + p.Start(); } else { - SetStatus("解压文件时发生异常,请重试!通常情况可能是因为Tai主程序尚未退出。", false); + SetStatus("解压文件时发生异常,请重试!通常情况可能是因为 STranslate 主程序尚未退出。", false); UpdateBtn.Visibility = Visibility.Visible; } diff --git a/Updater/Updater.csproj b/Updater/Updater.csproj index 0baadba..19b3713 100644 --- a/Updater/Updater.csproj +++ b/Updater/Updater.csproj @@ -102,6 +102,7 @@ ResXFileCodeGenerator Resources.Designer.cs + Designer