From b84e2e596876a827f8e1d8abd67123fbcc75e1a1 Mon Sep 17 00:00:00 2001 From: zggsong Date: Mon, 4 Mar 2024 10:14:10 +0800 Subject: [PATCH] perf: OCR shortcut key copy --- STranslate/ViewModels/OCRViewModel.cs | 13 +++++++++++-- STranslate/Views/OCRView.xaml | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/STranslate/ViewModels/OCRViewModel.cs b/STranslate/ViewModels/OCRViewModel.cs index 374cc227..6aee07dc 100644 --- a/STranslate/ViewModels/OCRViewModel.cs +++ b/STranslate/ViewModels/OCRViewModel.cs @@ -325,8 +325,8 @@ private void QRCode(BitmapSource bs) [RelayCommand] private void Translate(System.Collections.Generic.List obj) { - string content = (obj.FirstOrDefault() as string) ?? ""; - Window? ocrView = (obj.LastOrDefault() as Window); + var content = obj.FirstOrDefault() as string ?? ""; + var ocrView = obj.LastOrDefault() as Window; //OCR结果翻译关闭界面 if (Singleton.Instance.CurrentConfig?.CloseUIOcrRetTranslate ?? false) @@ -352,6 +352,15 @@ private void Translate(System.Collections.Generic.List obj) Singleton.Instance.TranslateCommand.Execute(null); } + [RelayCommand] + private void HotkeyCopy() + { + if (string.IsNullOrEmpty(GetContent)) return; + + Clipboard.SetDataObject(GetContent, true); + ToastHelper.Show("复制成功", WindowType.OCR); + } + #region ContextMenu [RelayCommand] diff --git a/STranslate/Views/OCRView.xaml b/STranslate/Views/OCRView.xaml index 3c4e404b..18745f11 100644 --- a/STranslate/Views/OCRView.xaml +++ b/STranslate/Views/OCRView.xaml @@ -29,7 +29,8 @@ Command="{Binding StickyCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Window}}" Modifiers="Ctrl+Shift" /> - + +