From 4a15460c7540c3ddad14b20f13dd6d531a675cc7 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BO4HSG\\ksat" Date: Mon, 19 Dec 2022 16:59:18 +0800 Subject: [PATCH] tmp update struct --- README.md | 7 ++- STranslate/Images/crossword.ico | Bin 0 -> 2837 bytes STranslate/Images/input.ico | Bin 0 -> 3053 bytes STranslate/Images/screenshot.ico | Bin 0 -> 5210 bytes STranslate/Images/window.ico | Bin 0 -> 2369 bytes STranslate/MainWindow.xaml | 10 ++-- STranslate/MainWindow.xaml.cs | 2 +- STranslate/Model/HotKeys.cs | 34 ------------ STranslate/Properties/Resources.Designer.cs | 40 ++++++++++++++ STranslate/Properties/Resources.resx | 12 +++++ STranslate/STranslate.csproj | 13 ++++- STranslate/Utils/HotKeysUtil.cs | 56 ++++++++++++++++---- STranslate/Utils/NativeMethod.cs | 16 +++--- 13 files changed, 126 insertions(+), 64 deletions(-) create mode 100644 STranslate/Images/crossword.ico create mode 100644 STranslate/Images/input.ico create mode 100644 STranslate/Images/screenshot.ico create mode 100644 STranslate/Images/window.ico delete mode 100644 STranslate/Model/HotKeys.cs diff --git a/README.md b/README.md index 9644224..f0f45d3 100644 --- a/README.md +++ b/README.md @@ -7,12 +7,13 @@ WPF 开发的一款即用即走的翻译工具 - [x] 添加百度翻译 API - [x] 实现基本翻译功能 - [x] 优化防止多开 +- [x] 添加划词翻译 - [ ] 优化 DeepL 服务并打包成库引入进项目 - [ ] 添加缓存功能 -- [ ] 添加划词翻译 - [ ] 添加 OCR 翻译 - [ ] 设置 UI 化 - [ ] 使用说明 UI 化 +- [ ] 优化划词翻译(未选中则取消翻译) - [ ] 软件层面识别语种(UI 提示识别语种) - [ ] 翻译制作成插件方式 - [ ] 优化软件发布方式(自动升级) @@ -21,6 +22,8 @@ WPF 开发的一款即用即走的翻译工具 首先在软件运行目录的 `STranslate.yml` 中添加自己的配置,这里推荐百度通用翻译 API 免费版 [申请教程(参照Bob WIKI)](https://bobtranslate.com/service/translate/baidu.html) -打开软件后会静默在后台,等待调用,全局监听快捷键(日后升级成自定义)`Alt` + `A` 即可打开软件主界面,输入需要翻译的内容,选择目标语言,如果识别语种不正确则手动指定即可,翻译结束后选择复制或点击一键复制即可 +打开软件后会静默在后台,等待调用,全局监听快捷键(日后升级成自定义) +- `Ctrl` + `A` 即可打开软件主界面,输入需要翻译的内容,选择目标语言,如果识别语种不正确则手动指定即可,翻译结束后选择复制或点击一键复制即可 +- `Ctrl` + `D` 即可复制当前鼠标选中内容并翻译 点击软件外部界面任意处或点击 ESC,Ctrl+Shift+Q 软件则会自动隐藏到后台,即用即走。 diff --git a/STranslate/Images/crossword.ico b/STranslate/Images/crossword.ico new file mode 100644 index 0000000000000000000000000000000000000000..e9111626eb50b1f4b829ccdefb7e6f4edbb09ce8 GIT binary patch literal 2837 zcmdT``8(A67yryyFUcB0jBJTW%90TwOc=6^kS(quOEb2SrJ2gjB?fn_*I2Tr8;WQs zTQVZ)S~7Ps*=NWyV;jc$)nD*^p6_#i`JVH;ShC5|BBv03n#Qh2u}}&%@7sB-n92%K#wI1GBj597A2E*@eg?s+Tpw6Y`^|o2mPU30l#_`~}@Y=I3u=J&;P$ zhtDi%5zcmKCWq&OKkMzwUQ!Lek2WBWiYdvQdVH(QBl5DN(-nR6D*aK+!@edkMaszI zQ@~Pf`~Y_a@0dkHof@;it>0Zr`CZQi`}r``D0Uk85N5f5GoVx==kPXmHe~CV4?9XB zLy7s76Wz8{#45OHFP{HF;c_`0iWx+!6yBvnLy^m-d&e&+_O$hYi@}O8eDTp?2qg*}oRCTZCJ5$W&xO9$f zzr^C{%P=3ZuW9E5sI& zIffolFPp)m4Mn=QDn?*@RT?Hlp%Sh$Vv(y#kw2O*jIKg9Z=Lb#>j(kX!?@?Ep=l{ljdTsk=0}Ah?lqwk#zf5V}DSR667Fs z$LikW_Vb&6htEF}g!(PP=1{h4B9@FJ1}ho9$(h{FXG z`Fnm!Rk2xKa2*cc3e@K$h%FJ^vi zYv&Ymb?-;b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K?zd#y;t*PKK(SSz5IzaRi}Dv zC!MiE=7fV^Fe+=&g|P6Wq3qt9U`R$EZ!vkzhD$Ox+55)nt8pOvr-se6g!d*^8bW_n zUS)9i8(*Kd?Zh2&T3=@{3AEipqxTPksbzN$Ity$^_9P8cBMGCEhkA9zE*Q{4}9j^asyP z^VIO+bRPW#P>R8%LwBl9p8`loL!AE5vFvWCdWbXdY?{@XsNfelKuP<9D}GLu*+x0} vTyHDLCjkmg>#OTs)7eie=Tqwca0r6%NB+8AGe$jHYysFcxJ9j*&%^%!gsU1K literal 0 HcmV?d00001 diff --git a/STranslate/Images/input.ico b/STranslate/Images/input.ico new file mode 100644 index 0000000000000000000000000000000000000000..1b738427e101fe224fbab5ba5e6f2851005d8080 GIT binary patch literal 3053 zcmbVO2T+q+7XAZDq=~>2q=OVekSaxxAP6YJlM*Qbq(6F82rUvIN>h4~UV;>Z(u5!- z0f~r6lOj?AgeslH&=;gE?#}GIoj1EPyWgEN=ggd$@0_`J?spCVfKJXYfB<1&gc$(1 zPU7b#cW<#W@iLu+tOmDr&3PZS<*X2; zC*nCWFpd)l+i*R!10p%3pIQ|}h>M#$h^$1WXB;u^vjsULv0R08+$rTBE;^k1gf1zx z2>P9l5m_ddvt~G{LL!s$j*!)SVkGJ^b?fdcx4z9r(i;lI%{WkNP${@~SxNZf{{jES z!mws`QDGu48PfTMonv;C7q@*e$2F8!AP#Tlplz#LY>>%ZHe()eG|1ezSNLUq$qX8o zKC##kC9Ceo=kAoCpg-{%w^%X8f%_P@Jn~*aJD9CGfKS!uia_lrJ>BfK-#FuZUfieB z?@-_t~1?;&arB(C|^{04AToP8ka@5z6e=!<<)(K~%Rct-}vd!3Rki9wXouotoznzbC|2;Lq_zb)K#QlIgCm}b+ z?J%8Gg*$$@nuWvWv`XLB4*RsQaXGb~7j*qDal_LA!A}Vu&&gP$YaaN|vUN3So<)iJ zvf<8Hb6e@ap)n~bfIc9zT3_h7tzgddg-c#PQh!4;UVh}b^XzIWgr&8Z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xb;O;r zw}%Zsar;U?!tQ#lJ-XubQXb)ft{?j{I1+8xL$y}CQqyxQXmc+v(8BS{H@1?M^43q4 zUJIXfp=J9 zWCf$J-dd96#}tFNYzph9y=RkEzq4U*yR^h`?~*m{+ohca^wo-X)u}-P?h(al^?6NTOmjgq7(l$!?Io)wz zGEe8DtF~MBlZOnghyE%d-zqa}?frz~iuyi$2nl#(y;6H3`!IM>>0@TM$2s50WC8`z z*YMy?KAr?iugPvVwlwzhvR9Vv!a`9j=?*~VIR04x@v}Dy160S4ZzA7~=3J1t(-YItPa9)p=QW_c!BhRDAp5q{8|G{?RG{D9qv;aV^1mN!$!~56sB*|?$^UXX R{`(FBv>zbVt5t2o{{xLVd8q&Z literal 0 HcmV?d00001 diff --git a/STranslate/Images/window.ico b/STranslate/Images/window.ico new file mode 100644 index 0000000000000000000000000000000000000000..b19ddb805dca1764a8f880549315eeb20c6ec00d GIT binary patch literal 2369 zcmeHJ`#017AAfICWRs6vawk5?8k&%~_4$Ny3*RP}TyjgHvSqTF%LqlW#Y(i2Pn2$= z5OSF=+UCw&!emS?Wj-iu3|~IqU%uyjKi~8H2fmNjd7kIvJYVN|Ij`qA&({+GK$~X^ zAV3p9>;M3TO`iS_7dt6QWywt{e*xv&n`bqqO8g3%@Egt>$reO{b*4+_yZ>1g{c1%Cn_ z{)4S?f!W}raITrMKO5=?MT8Zfs!cMV$PMhtbah!pzj-eSop`XCZ|QtLYE|t*h*X=g z$EL4smZeb!lDkra#8rj`Qb#z_dSY{yK%2qHyXd9Y$q|RTZ!K}YzGNAG)P&SE4fLs) zNn^#lBnre`uUhMrr`M};;oj{0QjV;fC~0J2AL%J_D6LRh0`!)N4#(0so`iHi1WecTRW@FnGiz8jo-4a(kJBFn&4)xUCqJ zaq3~kB*OiNaoJVrt#)(c=&~Tbpdjvi$LOHmv`KCj|Fwb~o z5@l953wwqj8?CD?J1;er=EyZ7>64k=gtVUfb)=#D0Y0KyO9znem?}?+iyf4|JD#VcqpG`M}64!#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++ b/STranslate/MainWindow.xaml @@ -38,12 +38,8 @@ Visibility="Visible" Icon="/Images/translate2.ico"> - - - - + @@ -55,7 +51,7 @@ Header="输入翻译" /> + Header="显示主界面" /> diff --git a/STranslate/MainWindow.xaml.cs b/STranslate/MainWindow.xaml.cs index 461474d..5ccaab2 100644 --- a/STranslate/MainWindow.xaml.cs +++ b/STranslate/MainWindow.xaml.cs @@ -17,7 +17,7 @@ namespace STranslate { InitializeComponent(); - vm = (MainVM)this.DataContext; + vm = (MainVM)DataContext; } /// diff --git a/STranslate/Model/HotKeys.cs b/STranslate/Model/HotKeys.cs deleted file mode 100644 index 739fd81..0000000 --- a/STranslate/Model/HotKeys.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static STranslate.Utils.NativeMethod; - -namespace STranslate.Model -{ - public static class HotKeys - { - public static class InputTranslate - { - public static byte Modifiers = (byte)KeyModifiers.Alt; - public static int Key = 65; - public static String Text = "A"; - public static bool Conflict = false; - } - public static class CrosswordTranslate - { - public static byte Modifiers = (byte)KeyModifiers.Ctrl; - public static int Key = 68; - //public static String Text = "F2"; - public static bool Conflict = false; - } - public static class ScreenShotTranslate - { - public static byte Modifiers = (byte)KeyModifiers.Alt; - public static int Key = 83; - public static String Text = "S"; - public static bool Conflict = false; - } - } -} diff --git a/STranslate/Properties/Resources.Designer.cs b/STranslate/Properties/Resources.Designer.cs index 9008840..0224332 100644 --- a/STranslate/Properties/Resources.Designer.cs +++ b/STranslate/Properties/Resources.Designer.cs @@ -70,6 +70,36 @@ namespace STranslate.Properties { } } + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon crossword { + get { + object obj = ResourceManager.GetObject("crossword", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon input { + get { + object obj = ResourceManager.GetObject("input", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon screenshot { + get { + object obj = ResourceManager.GetObject("screenshot", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 /// @@ -79,5 +109,15 @@ namespace STranslate.Properties { return ((System.Drawing.Icon)(obj)); } } + + /// + /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。 + /// + internal static System.Drawing.Icon window { + get { + object obj = ResourceManager.GetObject("window", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } } } diff --git a/STranslate/Properties/Resources.resx b/STranslate/Properties/Resources.resx index 56ccc9b..ee880f5 100644 --- a/STranslate/Properties/Resources.resx +++ b/STranslate/Properties/Resources.resx @@ -121,7 +121,19 @@ ..\images\copy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\images\crossword.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\images\input.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\images\screenshot.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\images\translate2.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\images\window.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/STranslate/STranslate.csproj b/STranslate/STranslate.csproj index a69fdf9..c49f38a 100644 --- a/STranslate/STranslate.csproj +++ b/STranslate/STranslate.csproj @@ -85,7 +85,6 @@ MSBuild:Compile Designer - @@ -140,6 +139,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/STranslate/Utils/HotKeysUtil.cs b/STranslate/Utils/HotKeysUtil.cs index 671990e..2ff2823 100644 --- a/STranslate/Utils/HotKeysUtil.cs +++ b/STranslate/Utils/HotKeysUtil.cs @@ -1,8 +1,35 @@ using STranslate.Model; using System; +using static STranslate.Utils.NativeMethod; namespace STranslate.Utils { + public static class HotKeys + { + public static class InputTranslate + { + public static byte Modifiers = (byte)KeyModifiers.MOD_CTRL; + public static int Key = 65; + public static String Text = "A"; + public static bool Conflict = false; + } + public static class CrosswordTranslate + { + public static byte Modifiers = (byte)KeyModifiers.MOD_CTRL; + public static int Key = 68; + public static String Text = "D"; + public static bool Conflict = false; + } + public static class ScreenShotTranslate + { + public static byte Modifiers = (byte)KeyModifiers.MOD_CTRL; + public static int Key = 83; + public static String Text = "S"; + public static bool Conflict = false; + } + } + + internal class HotKeysUtil { public static IntPtr mainFormHandle; @@ -16,6 +43,11 @@ namespace STranslate.Utils public static int ScreenShotTranslateId = 856; public static byte ScreenShotTranslateModifiers; public static int ScreenShotTranslateKey; + + /// + /// 注册快捷键 + /// + /// public static void RegisterHotKey(IntPtr mainFormHandle) { HotKeysUtil.mainFormHandle = mainFormHandle; @@ -41,23 +73,29 @@ namespace STranslate.Utils } } + /// + /// 注销快捷键 + /// public static void UnRegisterHotKey() { - NativeMethod.UnregisterHotKey(mainFormHandle, InputTranslateId); - NativeMethod.UnregisterHotKey(mainFormHandle, CrosswordTranslateId); - NativeMethod.UnregisterHotKey(mainFormHandle, ScreenShotTranslateId); + UnregisterHotKey(mainFormHandle, InputTranslateId); + UnregisterHotKey(mainFormHandle, CrosswordTranslateId); + UnregisterHotKey(mainFormHandle, ScreenShotTranslateId); } + /// + /// 重新注册快捷键 + /// public static void ReRegisterHotKey() { if (HotKeys.InputTranslate.Key == 0) { - NativeMethod.UnregisterHotKey(mainFormHandle, InputTranslateId); + UnregisterHotKey(mainFormHandle, InputTranslateId); } else if (InputTranslateModifiers != HotKeys.InputTranslate.Modifiers || InputTranslateKey != HotKeys.InputTranslate.Key) { { - NativeMethod.UnregisterHotKey(mainFormHandle, InputTranslateId); + UnregisterHotKey(mainFormHandle, InputTranslateId); HotKeys.InputTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, InputTranslateId, HotKeys.InputTranslate.Modifiers, HotKeys.InputTranslate.Key); } } @@ -66,12 +104,12 @@ namespace STranslate.Utils if (HotKeys.CrosswordTranslate.Key == 0) { - NativeMethod.UnregisterHotKey(mainFormHandle, CrosswordTranslateId); + UnregisterHotKey(mainFormHandle, CrosswordTranslateId); } else if (CrosswordTranslateModifiers != HotKeys.CrosswordTranslate.Modifiers || CrosswordTranslateKey != HotKeys.CrosswordTranslate.Key) { { - NativeMethod.UnregisterHotKey(mainFormHandle, CrosswordTranslateId); + UnregisterHotKey(mainFormHandle, CrosswordTranslateId); HotKeys.CrosswordTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, CrosswordTranslateId, HotKeys.CrosswordTranslate.Modifiers, HotKeys.CrosswordTranslate.Key); } } @@ -80,11 +118,11 @@ namespace STranslate.Utils if (HotKeys.ScreenShotTranslate.Key == 0) { - NativeMethod.UnregisterHotKey(mainFormHandle, ScreenShotTranslateId); + UnregisterHotKey(mainFormHandle, ScreenShotTranslateId); } else if (ScreenShotTranslateModifiers != HotKeys.ScreenShotTranslate.Modifiers || ScreenShotTranslateKey != HotKeys.ScreenShotTranslate.Key) { - NativeMethod.UnregisterHotKey(mainFormHandle, ScreenShotTranslateId); + UnregisterHotKey(mainFormHandle, ScreenShotTranslateId); HotKeys.ScreenShotTranslate.Conflict = !NativeMethod.RegisterHotKey(mainFormHandle, ScreenShotTranslateId, HotKeys.ScreenShotTranslate.Modifiers, HotKeys.ScreenShotTranslate.Key); } ScreenShotTranslateModifiers = HotKeys.ScreenShotTranslate.Modifiers; diff --git a/STranslate/Utils/NativeMethod.cs b/STranslate/Utils/NativeMethod.cs index 917ad4d..15caf9e 100644 --- a/STranslate/Utils/NativeMethod.cs +++ b/STranslate/Utils/NativeMethod.cs @@ -206,17 +206,13 @@ namespace STranslate.Utils [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hPos, int x, int y, int cx, int cy, uint nflags); - /// - /// 定义了辅助键的名称(将数字转变为字符以便于记忆,也可去除此枚举而直接使用数值) - /// - [Flags()] - public enum KeyModifiers + internal enum KeyModifiers { - None = 0, - Alt = 1, - Ctrl = 2, - Shift = 4, - WindowsKey = 8 + MOD_NONE = 0x0, + MOD_ALT = 0x1, + MOD_CTRL = 0x2, + MOD_SHIFT = 0x4, + MOD_WIN = 0x8 } #region Clipboard