From fe749a06cc302f43c52f0733f466fa528c192910 Mon Sep 17 00:00:00 2001 From: zggsong Date: Thu, 18 Jan 2024 22:59:26 +0800 Subject: [PATCH] feat: adapt to silent ocr and fix some bugs --- Attachments/iconfont/demo_index.html | 52 ++- Attachments/iconfont/iconfont.css | 14 +- Attachments/iconfont/iconfont.js | 2 +- Attachments/iconfont/iconfont.json | 14 + Attachments/iconfont/iconfont.ttf | Bin 15484 -> 16208 bytes Attachments/iconfont/iconfont.woff | Bin 9168 -> 9612 bytes Attachments/iconfont/iconfont.woff2 | Bin 7856 -> 8252 bytes STranslate.Model/ConstStr.cs | 1 + STranslate.Model/Hotkeys.cs | 6 +- STranslate.Style/Fonts/iconfont.ttf | Bin 15484 -> 16208 bytes STranslate/Helper/ConfigHelper.cs | 1 + STranslate/Helper/HotkeyHelper.cs | 59 ++- STranslate/STranslate_io3erein_wpftmp.csproj | 344 ++++++++++++++++++ STranslate/ViewModels/MainViewModel.cs | 16 +- STranslate/ViewModels/NotifyIconViewModel.cs | 52 ++- .../ViewModels/Preference/CommonViewModel.cs | 1 + STranslate/Views/NotifyIcon.xaml | 5 + STranslate/Views/NotifyIcon.xaml.cs | 7 +- STranslate/Views/Preference/HotkeyPage.xaml | 36 +- .../Views/Preference/HotkeyPage.xaml.cs | 59 ++- 20 files changed, 635 insertions(+), 34 deletions(-) create mode 100644 STranslate/STranslate_io3erein_wpftmp.csproj diff --git a/Attachments/iconfont/demo_index.html b/Attachments/iconfont/demo_index.html index d3a4d713..89cf3067 100644 --- a/Attachments/iconfont/demo_index.html +++ b/Attachments/iconfont/demo_index.html @@ -54,6 +54,18 @@

    +
  • + +
    OCR识别
    +
    
    +
  • + +
  • + +
    OCR
    +
    
    +
  • +
  • 密码显示隐藏-02
    @@ -378,9 +390,9 @@

    第一步:拷贝项目下面生成的 @font-face@font-face { font-family: 'iconfont'; - src: url('iconfont.woff2?t=1705480740490') format('woff2'), - url('iconfont.woff?t=1705480740490') format('woff'), - url('iconfont.ttf?t=1705480740490') format('truetype'); + src: url('iconfont.woff2?t=1705574336968') format('woff2'), + url('iconfont.woff?t=1705574336968') format('woff'), + url('iconfont.ttf?t=1705574336968') format('truetype'); }

    第二步:定义使用 iconfont 的样式

    @@ -406,6 +418,24 @@

    第三步:挑选相应图标并获取字体编码,应用于页面
      +
    • + +
      + OCR识别 +
      +
      .icon-OCRshibie +
      +
    • + +
    • + +
      + OCR +
      +
      .icon-OCR +
      +
    • +
    • @@ -892,6 +922,22 @@

      第二步:挑选相应图标并获取类名,应用于页面:
        +
      • + +
        OCR识别
        +
        #icon-OCRshibie
        +
      • + +
      • + +
        OCR
        +
        #icon-OCR
        +
      • +
      • 3Pdo>U ztZ6=qA8T&;a4&=}nw7M)PxrETg@L0z^ElxaEduQ%+OihX!w3B%$D(FW3m-bZZiX$t@OtUBX}@+GOJ>_y zqU%8@0+y-Ni^65SxkW^Y)-}Ruh=Is4&A_PVqQ0Yg0>?D*o}LxFdG2{SIMS`$(;Do* zWPq6XlRABsW34}U)!)!@BW*3D4PKvLh)uzN+Q^Qn;UedWqX{~+faWMLzt_|!DT}kg zG1{Q%ENx&2af^4zZd&qSwm#)^gvsuI#t*aaOgiUqE>{H2odQL!3=PBU`$IGg6jDP; zi1kWCGzhd8cFf-)>_3jeKfD3Ln@=ipV0j3n=6y5?!v_FLj?sLKeqzB}3iJM0Ja9v{K|K`&KMbbvzcyf2=FH-oeURajxv_CTC%->$HI z+Lcg2j~^e*q6an}MAo)VP(5qj4?4C|PXsgQ7#QO|H`Hn{ z(}1{rGgJd9@tii!;W#_lH3HafzD*nZO&v0MHkP1fUlhS;Kl2D`ucj-UHq4G$p6?fwft~>qQlV&Jt1bDfrF7} zM8nW{Uc{%u)tYoQxTxR7uwo&zXc>kCr#8$iScqYRrTZyQj_LAYk>~ZeA-3%7><`H? z;(b>_gKye9%5s=ogC^pd2-B8pQL>NW5F~!2K`{# z@qGs!OZ&|OhYl_GokNu1kmGZ$?+a%j7W5##rEj>C+soa=eH7lbHY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re;|#lx2E?&?kRfb35P;BbU1*{GTq`n^ z0jtG;G|p>-C>I4EBL_q0^r11a0R$6*A1Moz1-Bz3&Q2%Mbk=G`0a*ix$Cls-@(%v1 zOR>3a6|zMKGZw`@t6({%_;w!zGWnKNyb2lj&@}SgzKa?QVZKp3ax+?f!UqeS81-{QCa+ z{Ui5MOD&89Av>BVXb860Jo#;RkcT3>IBa4XFp|DSqj#vl!!;BYL98Ln(kuv3XG@ZW z=pY^Av3cHP9QjKe?z_Bn%_*I+5vTLa# z7k3|Kp&AVG;-N%1gx6&^Du`Obw#R7=c{$K3*i(this T t, KeyModifiers modifiers, KeyCodes key, string? text, bool conflict = false) where T : HotkeyBase { - t.Modifiers = modifiers; t.Key = key; + t.Modifiers = modifiers; t.Text = text; t.Conflict = conflict; return t; diff --git a/STranslate.Style/Fonts/iconfont.ttf b/STranslate.Style/Fonts/iconfont.ttf index fec9fa9c45933c0c683ab9b6bb39fa8844f62807..63d5a6b4c161c05ec8404c1be1179b78581bb22b 100644 GIT binary patch delta 1968 zcmY+DUu;uV9LK+>?b?oZYq#EeyFc!B+_F1xe{{E{Q#N7D#LNM6lV(IwamZkUZIG}K zrbxl?;Dd?a-~khfi6o*Xh6rLb3r50|CdiW^#6(TtzydEm=!1dP@97yRJ^kE!&hPyD z{l357y|@4B!J{38nawu=-({d|aL2^V_D|>kc^e2H0XhzhjgD+{=T38s-$`zahR|>R z3+&I4Wn+`m`>&x`1jJpAuTAWJV`O6YmTB%cIG&mu*}q3@5Q6hH95+slOpeAs={^gr z;?TEa&+fg`(UWbTodmkaXpqO|(ra?ydc}#Gp-fJZybRr5hiY4~?UA+rc&2`&N%(bp6nM+{N4z(75cs6#6nT|5B?k1_H% zs!_q9nvsT$73e@amZAYBT z^lRuYBvYWE?hG9X5H4G3kQcw?WUe0$+!>A$Snvz2a_6e1Mr1J`D z0-4lM9mqwf6J(u6WmPt4s2yadhAKjKX;4_k&KeD+h3wH#WXQD|$_?48q41D>8dWZ` zU&CZTZ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8;;VBU2|;k(z&>?k3hZk~_NcS4ffa($7nFv8Jj234NA6*< z>c~edUU%dumULM_-ePIak;_=R<;ZXRru~4N$MXA5@SsYKxnof-j^jItL& keymap = new(); @@ -125,15 +129,8 @@ private static void RegisterHotKey(IntPtr handle) OCRModifiers = Hotkeys!.OCR.Modifiers; OCRKey = Hotkeys!.OCR.Key; - if (Hotkeys!.ScreenShotTranslate.Key != 0) - { - Hotkeys!.ScreenShotTranslate.Conflict = !CommonUtil.RegisterHotKey( - handle, - ScreenShotTranslateId, - (byte)Hotkeys!.ScreenShotTranslate.Modifiers, - (int)Hotkeys!.ScreenShotTranslate.Key - ); - } + SilentOCRModifiers = Hotkeys!.SilentOCR.Modifiers; + SilentOCRKey = Hotkeys!.SilentOCR.Key; if (Hotkeys!.InputTranslate.Key != 0) { @@ -144,6 +141,7 @@ private static void RegisterHotKey(IntPtr handle) (int)Hotkeys!.InputTranslate.Key ); } + if (Hotkeys!.CrosswordTranslate.Key != 0) { Hotkeys!.CrosswordTranslate.Conflict = !CommonUtil.RegisterHotKey( @@ -153,6 +151,17 @@ private static void RegisterHotKey(IntPtr handle) (int)Hotkeys!.CrosswordTranslate.Key ); } + + if (Hotkeys!.ScreenShotTranslate.Key != 0) + { + Hotkeys!.ScreenShotTranslate.Conflict = !CommonUtil.RegisterHotKey( + handle, + ScreenShotTranslateId, + (byte)Hotkeys!.ScreenShotTranslate.Modifiers, + (int)Hotkeys!.ScreenShotTranslate.Key + ); + } + if (Hotkeys!.OpenMainWindow.Key != 0) { Hotkeys!.OpenMainWindow.Conflict = !CommonUtil.RegisterHotKey( @@ -162,6 +171,7 @@ private static void RegisterHotKey(IntPtr handle) (int)Hotkeys!.OpenMainWindow.Key ); } + if (Hotkeys!.MousehookTranslate.Key != 0) { Hotkeys!.MousehookTranslate.Conflict = !CommonUtil.RegisterHotKey( @@ -171,6 +181,7 @@ private static void RegisterHotKey(IntPtr handle) (int)Hotkeys!.MousehookTranslate.Key ); } + if (Hotkeys!.OCR.Key != 0) { Hotkeys!.OCR.Conflict = !CommonUtil.RegisterHotKey( @@ -180,6 +191,15 @@ private static void RegisterHotKey(IntPtr handle) (int)Hotkeys!.OCR.Key ); } + if (Hotkeys!.SilentOCR.Key != 0) + { + Hotkeys!.SilentOCR.Conflict = !CommonUtil.RegisterHotKey( + handle, + SilentOCRId, + (byte)Hotkeys!.SilentOCR.Modifiers, + (int)Hotkeys!.SilentOCR.Key + ); + } } /// @@ -310,6 +330,26 @@ public static void ReRegisterHotKey() } OCRModifiers = Hotkeys!.OCR.Modifiers; OCRKey = Hotkeys!.OCR.Key; + + if (Hotkeys!.SilentOCR.Key == 0) + { + CommonUtil.UnregisterHotKey(MainIntPtr, SilentOCRId); + } + else if ( + SilentOCRModifiers != Hotkeys!.SilentOCR.Modifiers + || SilentOCRKey != Hotkeys!.SilentOCR.Key + ) + { + CommonUtil.UnregisterHotKey(MainIntPtr, SilentOCRId); + Hotkeys!.SilentOCR.Conflict = !CommonUtil.RegisterHotKey( + MainIntPtr, + SilentOCRId, + (byte)Hotkeys!.SilentOCR.Modifiers, + (int)Hotkeys!.SilentOCR.Key + ); + } + SilentOCRModifiers = Hotkeys!.SilentOCR.Modifiers; + SilentOCRKey = Hotkeys!.SilentOCR.Key; } /// @@ -323,6 +363,7 @@ public static void UnRegisterHotKey(Window window) CommonUtil.UnregisterHotKey(MainIntPtr, OpenMainWindowId); CommonUtil.UnregisterHotKey(MainIntPtr, MousehookTranslateId); CommonUtil.UnregisterHotKey(MainIntPtr, OCRId); + CommonUtil.UnregisterHotKey(MainIntPtr, SilentOCRId); var hwnd = new WindowInteropHelper(window).Handle; _hwndSource = HwndSource.FromHwnd(hwnd); _hwndSource.RemoveHook(WndProc); diff --git a/STranslate/STranslate_io3erein_wpftmp.csproj b/STranslate/STranslate_io3erein_wpftmp.csproj new file mode 100644 index 00000000..321efbe8 --- /dev/null +++ b/STranslate/STranslate_io3erein_wpftmp.csproj @@ -0,0 +1,344 @@ + + + STranslate + obj\Debug\ + obj\ + D:\CodeHub\self\STranslate\STranslate\obj\ + <_TargetAssemblyProjectName>STranslate + + + + WinExe + net8.0-windows + enable + true + ..\STranslate.Style\Resources\favicon.ico + true + app.manifest + x64 + README.md + 1.0.2.0118 + 1.0.2.0118 + + + none + + + + + + + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/STranslate/ViewModels/MainViewModel.cs b/STranslate/ViewModels/MainViewModel.cs index 2748564e..58462923 100644 --- a/STranslate/ViewModels/MainViewModel.cs +++ b/STranslate/ViewModels/MainViewModel.cs @@ -126,28 +126,36 @@ private void Register(Window view) NotifyIconVM.OCRCommand.Execute(null); }); + HotkeyHelper.Register(HotkeyHelper.SilentOCRId, () => + { + NotifyIconVM.SilentOCRCommand.Execute(null); + }); + if (HotkeyHelper.Hotkeys!.InputTranslate.Conflict || HotkeyHelper.Hotkeys!.CrosswordTranslate.Conflict || HotkeyHelper.Hotkeys!.ScreenShotTranslate.Conflict || HotkeyHelper.Hotkeys!.OpenMainWindow.Conflict || HotkeyHelper.Hotkeys!.MousehookTranslate.Conflict - || HotkeyHelper.Hotkeys!.OCR.Conflict) + || HotkeyHelper.Hotkeys!.OCR.Conflict + || HotkeyHelper.Hotkeys!.SilentOCR.Conflict) { - MessageBox_S.Show("全局快捷键有冲突,请前往软件首选项中修改..."); + MessageBox_S.Show("全局热键冲突,请前往软件首选项中修改..."); } var msg = ""; if (!HotkeyHelper.Hotkeys!.InputTranslate.Conflict) msg += $"输入: {HotkeyHelper.Hotkeys.InputTranslate.Text}\n"; if (!HotkeyHelper.Hotkeys!.CrosswordTranslate.Conflict) msg += $"划词: {HotkeyHelper.Hotkeys.CrosswordTranslate.Text}\n"; - if (!HotkeyHelper.Hotkeys!.MousehookTranslate.Conflict) - msg += $"鼠标: {HotkeyHelper.Hotkeys.MousehookTranslate.Text}\n"; if (!HotkeyHelper.Hotkeys!.ScreenShotTranslate.Conflict) msg += $"截图: {HotkeyHelper.Hotkeys.ScreenShotTranslate.Text}\n"; if (!HotkeyHelper.Hotkeys!.OpenMainWindow.Conflict) msg += $"显示: {HotkeyHelper.Hotkeys.OpenMainWindow.Text}\n"; + if (!HotkeyHelper.Hotkeys!.MousehookTranslate.Conflict) + msg += $"鼠标: {HotkeyHelper.Hotkeys.MousehookTranslate.Text}\n"; if (!HotkeyHelper.Hotkeys!.OCR.Conflict) msg += $"识字: {HotkeyHelper.Hotkeys.OCR.Text}\n"; + if (!HotkeyHelper.Hotkeys!.SilentOCR.Conflict) + msg += $"静默: {HotkeyHelper.Hotkeys.SilentOCR.Text}\n"; NotifyIconVM.UpdateToolTip(msg.TrimEnd('\n')); } catch (Exception) diff --git a/STranslate/ViewModels/NotifyIconViewModel.cs b/STranslate/ViewModels/NotifyIconViewModel.cs index 581052c5..86a588c4 100644 --- a/STranslate/ViewModels/NotifyIconViewModel.cs +++ b/STranslate/ViewModels/NotifyIconViewModel.cs @@ -22,6 +22,8 @@ public partial class NotifyIconViewModel : ObservableObject public event Action? OnExit; + public event Action? OnShowBalloonTip; + [ObservableProperty] private bool _isForbiddenShortcuts = false; @@ -168,7 +170,7 @@ private void OCR(object obj) }); } - private void OCRHandler() + internal void OCRHandler() { ScreenshotView view = new(); ShowAndActive(view, false); @@ -191,6 +193,52 @@ private void OCRHandler() ); } + [RelayCommand] + private void SilentOCR(object obj) + { + if (obj == null) + { + SilentOCRHandler(); + return; + } + System.Threading.Tasks.Task + .Delay(200) + .ContinueWith(_ => + { + CommonUtil.InvokeOnUIThread(() => + { + SilentOCRHandler(); + }); + }); + } + + internal void SilentOCRHandler() + { + ScreenshotView view = new(); + ShowAndActive(view, false); + + view.BitmapCallback += ( + bitmap => + { + var bytes = BitmapUtil.ConvertBitmap2Bytes(bitmap); + + var getText = Singleton.Instance.Execute(bytes).Trim(); + + //取词前移除换行 + getText = + Singleton.Instance.CurrentConfig?.IsRemoveLineBreakGettingWords ?? false && !string.IsNullOrEmpty(getText) + ? StringUtil.RemoveLineBreaks(getText) + : getText; + + //写入剪贴板 + Clipboard.SetDataObject(getText, true); + + var tmp = getText.Length >= 9 ? getText[..9] + "..." : getText; + OnShowBalloonTip?.Invoke($"OCR识别成功: {tmp}"); + } + ); + } + [RelayCommand] private void ScreenShotTranslate(object obj) { @@ -210,7 +258,7 @@ private void ScreenShotTranslate(object obj) }); } - private void ScreenShotHandler() + internal void ScreenShotHandler() { ScreenshotView view = new(); ShowAndActive(view, false); diff --git a/STranslate/ViewModels/Preference/CommonViewModel.cs b/STranslate/ViewModels/Preference/CommonViewModel.cs index b26c7cb6..173eac8c 100644 --- a/STranslate/ViewModels/Preference/CommonViewModel.cs +++ b/STranslate/ViewModels/Preference/CommonViewModel.cs @@ -54,6 +54,7 @@ private void Reset() IsAdjustContentTranslate = Singleton.Instance.CurrentConfig?.IsAdjustContentTranslate ?? false; IsRemoveLineBreakGettingWords = Singleton.Instance.CurrentConfig?.IsRemoveLineBreakGettingWords ?? false; DoubleTapTrayFunc = Singleton.Instance.CurrentConfig?.DoubleTapTrayFunc ?? DoubleTapFuncEnum.InputFunc; + CustomFont = Singleton.Instance.CurrentConfig?.CustomFont ?? ConstStr.DEFAULTFONTNAME; ToastHelper.Show("重置配置", WindowType.Preference); if (IsStartup) diff --git a/STranslate/Views/NotifyIcon.xaml b/STranslate/Views/NotifyIcon.xaml index dbd35d67..918a2683 100644 --- a/STranslate/Views/NotifyIcon.xaml +++ b/STranslate/Views/NotifyIcon.xaml @@ -50,6 +50,11 @@ + + diff --git a/STranslate/Views/NotifyIcon.xaml.cs b/STranslate/Views/NotifyIcon.xaml.cs index f86bd602..b772f775 100644 --- a/STranslate/Views/NotifyIcon.xaml.cs +++ b/STranslate/Views/NotifyIcon.xaml.cs @@ -1,4 +1,6 @@ -using System.Windows; +using STranslate.Util; +using STranslate.ViewModels; +using System.Windows; using System.Windows.Controls; namespace STranslate.Views @@ -11,6 +13,9 @@ public partial class NotifyIcon : UserControl public NotifyIcon() { InitializeComponent(); + + Singleton.Instance.OnShowBalloonTip += (msg) + => TrayIcon.ShowBalloonTip("", msg, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.None); } /// diff --git a/STranslate/Views/Preference/HotkeyPage.xaml b/STranslate/Views/Preference/HotkeyPage.xaml index 499555a0..c197378d 100644 --- a/STranslate/Views/Preference/HotkeyPage.xaml +++ b/STranslate/Views/Preference/HotkeyPage.xaml @@ -220,7 +220,41 @@ Visibility="Hidden" /> - + + + + + + + + + diff --git a/STranslate/Views/Preference/HotkeyPage.xaml.cs b/STranslate/Views/Preference/HotkeyPage.xaml.cs index 8f2e3dc2..a27ab9b5 100644 --- a/STranslate/Views/Preference/HotkeyPage.xaml.cs +++ b/STranslate/Views/Preference/HotkeyPage.xaml.cs @@ -38,6 +38,7 @@ private void UserControl_Loaded(object sender, RoutedEventArgs e) OpenMainWindowTextBox.Text = conf.CurrentConfig!.Hotkeys!.OpenMainWindow.Text; MousehookTextBox.Text = conf.CurrentConfig!.Hotkeys!.MousehookTranslate.Text; OCRTextBox.Text = conf.CurrentConfig!.Hotkeys!.OCR.Text; + SilentOCRTextBox.Text = conf.CurrentConfig!.Hotkeys!.SilentOCR.Text; HotKeyConflictCheck(); } @@ -67,16 +68,16 @@ private void HotKeyTextBox_PreviewKeyDown(object sender, KeyEventArgs e) _hotkeysModifiers += 2; shortcutText.Append("Ctrl + "); } - if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) - { - _hotkeysModifiers += 4; - shortcutText.Append("Shift + "); - } if ((Keyboard.Modifiers & ModifierKeys.Alt) != 0) { _hotkeysModifiers += 1; shortcutText.Append("Alt + "); } + if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) + { + _hotkeysModifiers += 4; + shortcutText.Append("Shift + "); + } if (_hotkeysModifiers == 0 && (key < Key.F1 || key > Key.F12)) { _hotkeysKey = 0; @@ -233,18 +234,51 @@ private void OCR_KeyUp(object sender, KeyEventArgs e) RefreshNotifyToolTip(); } + private void SilentOCR_KeyUp(object sender, KeyEventArgs e) + { + Key key = (e.Key == Key.System ? e.SystemKey : e.Key); + if ( + key == Key.LeftShift + || key == Key.RightShift + || key == Key.LeftCtrl + || key == Key.RightCtrl + || key == Key.LeftAlt + || key == Key.RightAlt + || key == Key.LWin + || key == Key.RWin + ) + { + return; + } + conf.CurrentConfig!.Hotkeys!.SilentOCR.Modifiers = _hotkeysModifiers; + conf.CurrentConfig!.Hotkeys!.SilentOCR.Key = _hotkeysKey; + conf.CurrentConfig!.Hotkeys!.SilentOCR.Text = _hotkeysText.ToString(); + HotkeyHelper.ReRegisterHotKey(); + HotKeyConflictCheck(); + RefreshNotifyToolTip(); + } + private void HotKeyConflictCheck() { + InputHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.InputTranslate.Conflict + ? Visibility.Visible + : Visibility.Hidden; CrossWordHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.CrosswordTranslate.Conflict ? Visibility.Visible : Visibility.Hidden; ScreenshotHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.ScreenShotTranslate.Conflict ? Visibility.Visible : Visibility.Hidden; - InputHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.InputTranslate.Conflict + ShowMainwinHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.OpenMainWindow.Conflict ? Visibility.Visible : Visibility.Hidden; - ShowMainwinHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.OpenMainWindow.Conflict + MousehookHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.MousehookTranslate.Conflict + ? Visibility.Visible + : Visibility.Hidden; + OCRHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.OCR.Conflict + ? Visibility.Visible + : Visibility.Hidden; + SilentOCRHotKeyConflictLabel.Visibility = conf.CurrentConfig!.Hotkeys!.SilentOCR.Conflict ? Visibility.Visible : Visibility.Hidden; } @@ -256,14 +290,16 @@ private void RefreshNotifyToolTip() msg += $"输入: {conf.CurrentConfig!.Hotkeys!.InputTranslate.Text}\r\n"; if (!conf.CurrentConfig!.Hotkeys!.CrosswordTranslate.Conflict) msg += $"划词: {conf.CurrentConfig!.Hotkeys!.CrosswordTranslate.Text}\r\n"; - if (!conf.CurrentConfig!.Hotkeys!.MousehookTranslate.Conflict) - msg += $"鼠标: {conf.CurrentConfig!.Hotkeys!.MousehookTranslate.Text}\r\n"; if (!conf.CurrentConfig!.Hotkeys!.ScreenShotTranslate.Conflict) msg += $"截图: {conf.CurrentConfig!.Hotkeys!.ScreenShotTranslate.Text}\r\n"; if (!conf.CurrentConfig!.Hotkeys!.OpenMainWindow.Conflict) msg += $"显示: {conf.CurrentConfig!.Hotkeys!.OpenMainWindow.Text}\r\n"; + if (!conf.CurrentConfig!.Hotkeys!.MousehookTranslate.Conflict) + msg += $"鼠标: {conf.CurrentConfig!.Hotkeys!.MousehookTranslate.Text}\r\n"; if (!conf.CurrentConfig!.Hotkeys!.OCR.Conflict) msg += $"识字: {conf.CurrentConfig!.Hotkeys!.OCR.Text}\r\n"; + if (!conf.CurrentConfig!.Hotkeys!.SilentOCR.Conflict) + msg += $"静默: {conf.CurrentConfig!.Hotkeys!.SilentOCR.Text}\r\n"; Singleton.Instance.UpdateToolTip(msg.TrimEnd(['\r', '\n'])); } @@ -277,6 +313,7 @@ private void ResetHoskeys(object sender, RoutedEventArgs e) OpenMainWindowTextBox.Text = cHotkeys.OpenMainWindow.Text; MousehookTextBox.Text = cHotkeys.MousehookTranslate.Text; OCRTextBox.Text = cHotkeys.OCR.Text; + SilentOCRTextBox.Text = cHotkeys.SilentOCR.Text; conf.CurrentConfig!.Hotkeys!.CrosswordTranslate.Modifiers = cHotkeys.CrosswordTranslate.Modifiers; conf.CurrentConfig!.Hotkeys!.CrosswordTranslate.Key = cHotkeys.CrosswordTranslate.Key; @@ -302,6 +339,10 @@ private void ResetHoskeys(object sender, RoutedEventArgs e) conf.CurrentConfig!.Hotkeys!.OCR.Key = cHotkeys.OCR.Key; conf.CurrentConfig!.Hotkeys!.OCR.Text = cHotkeys.OCR.Text; + conf.CurrentConfig!.Hotkeys!.SilentOCR.Modifiers = cHotkeys.SilentOCR.Modifiers; + conf.CurrentConfig!.Hotkeys!.SilentOCR.Key = cHotkeys.SilentOCR.Key; + conf.CurrentConfig!.Hotkeys!.SilentOCR.Text = cHotkeys.SilentOCR.Text; + HotkeyHelper.ReRegisterHotKey(); HotKeyConflictCheck();