├── .github ├── ISSUE_TEMPLATE │ ├── Bug_Report.md │ ├── Feature_Request.md │ └── TODO.md └── workflows │ └── build.yml ├── .gitignore ├── About.jpg ├── ArtificialTransHelperLibrary ├── ArtificialTransHelper.cs └── ArtificialTransHelperLibrary.csproj ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DictionaryHelperLibrary ├── DictionaryHelperLibrary.csproj ├── IDict.cs └── XxgJpzhDict.cs ├── Directory.Build.props ├── Directory.Build.targets ├── Directory.Packages.props ├── KeyboardMouseHookLibrary ├── FindWindowInfo.cs ├── GlobalHook.cs ├── GlobalHotKey.cs ├── KeyboardMouseHook.cs ├── KeyboardMouseHookLibrary.csproj └── NativeMethods.txt ├── KeyboardMouseMonitor ├── KeyboardMouseMonitor.cs ├── KeyboardMouseMonitor.csproj ├── NativeMethods.txt └── Properties │ └── LaunchSettings.json ├── LICENSE ├── MecabHelperLibrary ├── MecabHelper.cs └── MecabHelperLibrary.csproj ├── MisakaTranslator-WPF ├── AddOptWindow.xaml ├── AddOptWindow.xaml.cs ├── App.xaml ├── App.xaml.cs ├── Appearance.xaml ├── ArtificialTransAddWindow.xaml ├── ArtificialTransAddWindow.xaml.cs ├── ComicTranslator │ ├── ComicTransMainWindow.xaml │ ├── ComicTransMainWindow.xaml.cs │ ├── ImageProcWindow.xaml │ └── ImageProcWindow.xaml.cs ├── Common.cs ├── DictResWindow.xaml ├── DictResWindow.xaml.cs ├── GameGuideWindow.xaml ├── GameGuideWindow.xaml.cs ├── GlobalOCRWindow.xaml ├── GlobalOCRWindow.xaml.cs ├── GuidePages │ ├── ChooseLanguagePage.xaml │ ├── ChooseLanguagePage.xaml.cs │ ├── Completation.png │ ├── CompletationPage.xaml │ ├── CompletationPage.xaml.cs │ ├── Completation_small.png │ ├── Hook │ │ ├── ChooseGamePage.xaml │ │ ├── ChooseGamePage.xaml.cs │ │ ├── ChooseHookFuncPage.xaml │ │ ├── ChooseHookFuncPage.xaml.cs │ │ ├── ChooseTextRepairFuncPage.xaml │ │ ├── ChooseTextRepairFuncPage.xaml.cs │ │ ├── ReChooseHookFuncPage.xaml │ │ └── ReChooseHookFuncPage.xaml.cs │ ├── OCR │ │ ├── ChooseHandleFuncPage.xaml │ │ ├── ChooseHandleFuncPage.xaml.cs │ │ ├── ChooseHotKeyPage.xaml │ │ ├── ChooseHotKeyPage.xaml.cs │ │ ├── ChooseOCRAreaPage.xaml │ │ └── ChooseOCRAreaPage.xaml.cs │ └── PageChangeRoutedEventArgs.cs ├── IAppSettings.cs ├── MainWindow.xaml ├── MainWindow.xaml.cs ├── MisakaTranslator-WPF.csproj ├── Program.cs ├── Properties │ ├── App.config │ ├── App.manifest │ ├── AssemblyInfo.cs │ ├── LaunchSettings.json │ ├── NativeMethods.txt │ └── Package.appxmanifest ├── ScreenCaptureWindow.xaml ├── ScreenCaptureWindow.xaml.cs ├── SettingsPages │ ├── AboutPage.xaml │ ├── AboutPage.xaml.cs │ ├── Aboutv2.jpg │ ├── Aboutv2_small.jpg │ ├── ArtificialTransSettingsPage.xaml │ ├── ArtificialTransSettingsPage.xaml.cs │ ├── DictionaryPages │ │ ├── MecabDictPage.xaml │ │ ├── MecabDictPage.xaml.cs │ │ ├── XxgJpZhDictPage.xaml │ │ └── XxgJpZhDictPage.xaml.cs │ ├── HookSettingsPage.xaml │ ├── HookSettingsPage.xaml.cs │ ├── LESettingsPage.xaml │ ├── LESettingsPage.xaml.cs │ ├── OCRPages │ │ ├── BaiduFanyiOCRSettingsPage.xaml │ │ ├── BaiduOCRSettingsPage.xaml │ │ ├── BaiduOCRSettingsPage.xaml.cs │ │ ├── OCRGeneralSettingsPage.xaml │ │ ├── OCRGeneralSettingsPage.xaml.cs │ │ ├── TencentOCRSettingsPage.xaml │ │ ├── TesseractCliSettingsPage.xaml │ │ └── TesseractCliSettingsPage.xaml.cs │ ├── SoftwareSettingsPage.xaml │ ├── SoftwareSettingsPage.xaml.cs │ ├── TTSSettingsPage.xaml │ ├── TTSSettingsPage.xaml.cs │ └── TranslatorPages │ │ ├── AzureOpenAITransSettingsPage.xaml │ │ ├── AzureOpenAITransSettingsPage.xaml.cs │ │ ├── BaiduTransSettingsPage.xaml │ │ ├── BaiduTransSettingsPage.xaml.cs │ │ ├── CaiyunTransSettingsPage.xaml │ │ ├── CaiyunTransSettingsPage.xaml.cs │ │ ├── ChatGPTTransSettingsPage.xaml │ │ ├── ChatGPTTransSettingsPage.xaml.cs │ │ ├── DeepLTransSettingsPage.xaml │ │ ├── DeepLTransSettingsPage.xaml.cs │ │ ├── DreyeTransSettingsPage.xaml │ │ ├── DreyeTransSettingsPage.xaml.cs │ │ ├── IBMTransSettingsPage.xaml │ │ ├── IBMTransSettingsPage.xaml.cs │ │ ├── JbeijingTransSettingsPage.xaml │ │ ├── JbeijingTransSettingsPage.xaml.cs │ │ ├── KingsoftFAITTransSettingsPage.xaml │ │ ├── KingsoftFAITTransSettingsPage.xaml.cs │ │ ├── TencentFYJTransSettingsPage.xaml │ │ ├── TencentFYJTransSettingsPage.xaml.cs │ │ ├── TencentOldTransSettingsPage.xaml │ │ ├── TencentOldTransSettingsPage.xaml.cs │ │ ├── TranslatorGeneralSettingsPage.xaml │ │ ├── TranslatorGeneralSettingsPage.xaml.cs │ │ ├── XiaoniuTransSettingsPage.xaml │ │ ├── XiaoniuTransSettingsPage.xaml.cs │ │ ├── YandexTransSettingsPage.xaml │ │ ├── YandexTransSettingsPage.xaml.cs │ │ ├── YoudaoZhiyunTransSettingsPage.xaml │ │ └── YoudaoZhiyunTransSettingsPage.xaml.cs ├── SettingsWindow.xaml ├── SettingsWindow.xaml.cs ├── TransWinSettingsWindow.xaml ├── TransWinSettingsWindow.xaml.cs ├── TranslateWindow.xaml ├── TranslateWindow.xaml.cs ├── UserControls │ ├── GameNameDialog.xaml │ ├── GameNameDialog.xaml.cs │ ├── SelectTransLangDialog.xaml │ └── SelectTransLangDialog.xaml.cs ├── lang │ ├── en-US.xaml │ └── zh-CN.xaml ├── logo.ico └── textRepairPlugins │ ├── __init__.py │ └── example.py ├── MisakaTranslator.sln ├── NativeMethods.json ├── OCRLibrary ├── BaiduFanyiOCR.cs ├── BaiduGeneralOCR.cs ├── ConnectComponentImageProcImpl.cs ├── ImageProcFunc.cs ├── NativeMethods.txt ├── OCRCommon.cs ├── OCREngine.cs ├── OCRLibrary.csproj ├── ScreenCapture.cs ├── TencentOCR.cs ├── TesseractCli.cs ├── TesseractOCR.cs └── WindowsOCR.cs ├── README.md ├── README_EN.md ├── SQLHelperLibrary ├── GameLibraryHelper.cs ├── SQLHelper.cs └── SQLHelperLibrary.csproj ├── THANKLIST.MD ├── TTSHelperLibrary ├── TTSHelperLibrary.csproj └── TextSpeechHelper.cs ├── TextHookLibrary ├── ClipboardNotification.cs ├── NativeMethods.txt ├── ProcessHelper.cs ├── RecvEventArgs.cs ├── TextHookHandle.cs ├── TextHookHandle_DLL.cs ├── TextHookLibrary.csproj └── TextHostLib.cs ├── TextRepairLibrary ├── TextRepair.cs └── TextRepairLibrary.csproj ├── Tools └── ProcessHelperExt.cs ├── TransOptimizationLibrary ├── AfterTransHandle.cs ├── BeforeTransHandle.cs ├── NounTransOptimization.cs └── TransOptimizationLibrary.csproj ├── TranslatorLibrary ├── AlapiTranslator.cs ├── ArtificialTranslator.cs ├── AzureOpenAITranslator.cs ├── BaiduTranslator.cs ├── CaiyunTranslator.cs ├── ChatGPTTranslator.cs ├── CommonFunction.cs ├── DeepLTranslator.cs ├── DreyeTranslator.cs ├── GoogleCNTranslator.cs ├── IBMTranslator.cs ├── ITranslator.cs ├── JBeijingTranslator.cs ├── KingsoftFastAITTranslator.cs ├── TencentFYJTranslator.cs ├── TencentOldTranslator.cs ├── TranslatorLibrary.csproj ├── XiaoniuTranslator.cs ├── YandexTranslator.cs ├── YoudaoTranslator.cs └── YoudaoZhiyun.cs ├── background.png └── index.html /.github/ISSUE_TEMPLATE/Bug_Report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Bug 反馈 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | **关于哪一项功能** 17 | 18 | 19 | **问题描述** 20 | 21 | 22 | 23 | **应用版本** 24 | 25 | 26 | 27 | **系统信息** 28 | 29 | 30 | 31 | **错误信息** 32 | 33 | 34 | 35 | 36 | **附加截图** 37 | 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/Feature_Request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: 功能建议 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **关于哪一项功能** 11 | 12 | 13 | 14 | **期望的效果** 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/TODO.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: TODO 3 | about: 待办事项 4 | title: '' 5 | labels: todo 6 | assignees: '' 7 | 8 | --- 9 | 10 | **要实现的功能** 11 | 12 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [master] 5 | pull_request: 6 | 7 | jobs: 8 | build: 9 | runs-on: windows-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - uses: actions/setup-dotnet@v3 13 | - run: dotnet build 14 | - uses: actions/upload-artifact@master 15 | with: 16 | path: MisakaTranslator-WPF/bin 17 | -------------------------------------------------------------------------------- /About.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/About.jpg -------------------------------------------------------------------------------- /ArtificialTransHelperLibrary/ArtificialTransHelperLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 我该如何为这个项目作出贡献? 2 | 3 | ## 反馈BUG 4 | 5 | 请[新建Issue](https://github.com/hanmin0822/MisakaTranslator/issues/new/choose),并选择Bug Report模板,按照模板中的说明反馈BUG。 6 | 7 | ## 功能建议 8 | 9 | 请[新建Issue](https://github.com/hanmin0822/MisakaTranslator/issues/new/choose),并选择Feature Request模板,按照模板中的说明提交功能建议。 10 | 11 | ## 贡献代码 12 | 13 | 您可以直接Fork本项目,并且进行修改和编译,建议使用Visual Studio。 14 | 15 | 在修改时请注意,2.0beta3之前的版本运行时需要调用Textractor的CLI版本读输出,但原版的控制台输出可能导致本软件无法读取或读取存在问题,针对CLI版本的修改如下,请自行编译后使用。 16 | 17 | * [hanmin0822/Textractor](https://github.com/hanmin0822/Textractor) 18 | 19 | ### 代码规范 20 | 21 | 本项目代码质量并不高,代码风格也不要求统一,但请尽量追求清晰易读。 22 | 23 | 编码规范可以参考[C#编码规范](https://gist.github.com/zhuqling/a2700703d088b8746f0c) 24 | 25 | ### 提交Pull Requset 26 | 27 | 本项目不要求特定的PR格式,在正文中写清楚所做的更改即可。 28 | -------------------------------------------------------------------------------- /DictionaryHelperLibrary/DictionaryHelperLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /DictionaryHelperLibrary/IDict.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace DictionaryHelperLibrary 8 | { 9 | public interface IDict 10 | { 11 | /// 12 | /// 字典API初始化 13 | /// 14 | /// 参数一 一般是appID或者路径(为路径时参数二无效) 15 | /// 参数二 一般是密钥 16 | void DictInit(string param1, string param2); 17 | 18 | /// 19 | /// 查询一次辞典 20 | /// 21 | /// 源单词 22 | /// 查询结果,如果查询有错误会返回空,可以通过GetLastError来获取错误 23 | string SearchInDict(string sourceWord); 24 | 25 | /// 26 | /// 返回最后一次错误的ID或原因 27 | /// 28 | /// 29 | string GetLastError(); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DictionaryHelperLibrary/XxgJpzhDict.cs: -------------------------------------------------------------------------------- 1 | using SQLHelperLibrary; 2 | using System; 3 | using System.Linq; 4 | using System.Text.RegularExpressions; 5 | 6 | namespace DictionaryHelperLibrary 7 | { 8 | /// 9 | /// 小学馆日中词典 10 | /// 11 | public class XxgJpzhDict : IDict 12 | { 13 | private SQLHelper _sqlHelper; 14 | private string _errorInfo; 15 | 16 | public string GetLastError() 17 | { 18 | return _errorInfo; 19 | } 20 | 21 | public string SearchInDict(string sourceWord) 22 | { 23 | var lst = _sqlHelper.ExecuteReader($"SELECT explanation FROM xiaoxueguanrizhong WHERE word LIKE '%{sourceWord}%';", 1); 24 | 25 | if (lst != null) return lst.Aggregate(string.Empty, (current, t) => current + t[0] + "\n"); 26 | _errorInfo = "DB Error:" + _sqlHelper.GetLastError(); 27 | return null; 28 | 29 | } 30 | 31 | public void DictInit(string param1, string param2) 32 | { 33 | _sqlHelper = new SQLHelper(param1); 34 | } 35 | 36 | /// 37 | /// 去掉HTML标记,改为换行 38 | /// 39 | /// 40 | /// 41 | public static string RemoveHTML(string src) 42 | { 43 | if (src == null) 44 | { 45 | return null; 46 | } 47 | 48 | var tmp = Regex.Replace(src, "<[^>]+>", string.Empty); 49 | tmp = Regex.Replace(tmp, "&[^;]+;", string.Empty); 50 | 51 | var arr = tmp.Split(new[] { "\\n" }, StringSplitOptions.None); 52 | 53 | return arr.Aggregate(string.Empty, (current, s) => current + s + "\n"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 10.0.22621.0 5 | 7.0 6 | net472;net7.0-windows$(TargetPlatformVersion) 7 | AnyCPU;x64;ARM64 8 | 11.0 9 | 2.12.2.0 10 | true 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | false 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /Directory.Packages.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | true 5 | true 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /KeyboardMouseHookLibrary/FindWindowInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Windows.Win32; 9 | using Windows.Win32.Foundation; 10 | 11 | namespace KeyboardMouseHookLibrary 12 | { 13 | public class FindWindowInfo 14 | { 15 | /// 16 | /// 获取指定坐标处窗口的句柄 17 | /// 18 | public static IntPtr GetWindowHWND(Point point) 19 | { 20 | return PInvoke.WindowFromPoint(point); 21 | } 22 | 23 | /// 24 | /// 根据HWND获得窗口标题 25 | /// 26 | /// 27 | /// 28 | public static unsafe string GetWindowName(IntPtr hwnd) 29 | { 30 | Span name = stackalloc char[PInvoke.GetWindowTextLength((HWND)hwnd) + 1]; 31 | fixed(char* pName = name) 32 | { 33 | PInvoke.GetWindowText((HWND)hwnd, pName, name.Length); 34 | } 35 | return name.ToString(); 36 | } 37 | 38 | /// 39 | /// 根据HWND获得类名 40 | /// 41 | /// 42 | /// 43 | public static unsafe string GetWindowClassName(IntPtr hwnd) 44 | { 45 | Span name = stackalloc char[256]; 46 | fixed(char* pName = name) 47 | { 48 | name = name.Slice(0, PInvoke.GetClassName((HWND)hwnd, pName, 256) + 1); 49 | } 50 | return name.ToString(); 51 | } 52 | 53 | /// 54 | /// 根据HWND获得进程ID 55 | /// 56 | /// 57 | /// 58 | public static unsafe uint GetProcessIDByHWND(IntPtr hWnd) 59 | { 60 | uint result; 61 | PInvoke.GetWindowThreadProcessId((HWND)hWnd, &result); 62 | return result; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /KeyboardMouseHookLibrary/KeyboardMouseHookLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | true 5 | true 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /KeyboardMouseHookLibrary/NativeMethods.txt: -------------------------------------------------------------------------------- 1 | // enum 2 | Windows.Win32.UI.WindowsAndMessaging.WM_KEYDOWN 3 | Windows.Win32.UI.WindowsAndMessaging.WM_KEYUP 4 | Windows.Win32.UI.WindowsAndMessaging.WM_LBUTTONDBLCLK 5 | Windows.Win32.UI.WindowsAndMessaging.WM_LBUTTONDOWN 6 | Windows.Win32.UI.WindowsAndMessaging.WM_RBUTTONDBLCLK 7 | Windows.Win32.UI.WindowsAndMessaging.WM_RBUTTONDOWN 8 | Windows.Win32.UI.WindowsAndMessaging.WM_SYSKEYDOWN 9 | Windows.Win32.UI.WindowsAndMessaging.WM_SYSKEYUP 10 | 11 | // structure 12 | Windows.Win32.UI.WindowsAndMessaging.KBDLLHOOKSTRUCT 13 | Windows.Win32.UI.WindowsAndMessaging.MOUSEHOOKSTRUCT 14 | 15 | // function 16 | Windows.Win32.System.LibraryLoader.GetModuleHandle 17 | Windows.Win32.UI.Input.KeyboardAndMouse.GetKeyboardState 18 | Windows.Win32.UI.Input.KeyboardAndMouse.RegisterHotKey 19 | Windows.Win32.UI.Input.KeyboardAndMouse.ToAscii 20 | Windows.Win32.UI.Input.KeyboardAndMouse.UnregisterHotKey 21 | Windows.Win32.UI.WindowsAndMessaging.CallNextHookEx 22 | Windows.Win32.UI.WindowsAndMessaging.GetClassName 23 | Windows.Win32.UI.WindowsAndMessaging.GetWindowText 24 | Windows.Win32.UI.WindowsAndMessaging.GetWindowTextLength 25 | Windows.Win32.UI.WindowsAndMessaging.GetWindowThreadProcessId 26 | Windows.Win32.UI.WindowsAndMessaging.SetWindowsHookEx 27 | Windows.Win32.UI.WindowsAndMessaging.UnhookWindowsHookEx 28 | Windows.Win32.UI.WindowsAndMessaging.WindowFromPoint 29 | -------------------------------------------------------------------------------- /KeyboardMouseMonitor/KeyboardMouseMonitor.cs: -------------------------------------------------------------------------------- 1 | /************************************************* 2 | * 由于使用全局键盘鼠标钩子总是会出现回调事件 3 | * 没有反应的情况,故使用单写一个进程调用 4 | * 这个EXE并进行通信,获取键鼠钩子事件。 5 | * 启动传参为: 钩子类型(1=鼠标 2=键盘) 指定键值(见代码) 6 | * 当指定键动作时输出一行返回值 7 | * 使用时将这个项目单独编译,生成的EXE文件放入lib中即可 8 | *************************************************/ 9 | 10 | using System; 11 | using System.Drawing; 12 | using Windows.Win32; 13 | using Windows.Win32.Foundation; 14 | using Windows.Win32.UI.WindowsAndMessaging; 15 | 16 | namespace KeyboardMouseMonitor 17 | { 18 | internal static class Program 19 | { 20 | private static int keyCode; 21 | 22 | private static int Main(string[] args) 23 | { 24 | if (args.Length != 2) 25 | { 26 | return -1; 27 | } 28 | HHOOK hook = default; 29 | int actID = Convert.ToInt32(args[0]); 30 | keyCode = Convert.ToInt32(args[1]); 31 | if (actID == 1) 32 | { 33 | //鼠标 keyCode=1代表左键 keyCode=2代表右键 34 | hook = PInvoke.SetWindowsHookEx(WINDOWS_HOOK_ID.WH_MOUSE_LL, mymouse, HMODULE.Null, 0); 35 | } 36 | else if (actID == 2) 37 | { 38 | //键盘 keyCode代表对应键的ASCII码 39 | hook = PInvoke.SetWindowsHookEx(WINDOWS_HOOK_ID.WH_KEYBOARD_LL, mykeyboard, HMODULE.Null, 0); 40 | } 41 | if (hook.IsNull) 42 | { 43 | Console.WriteLine("hookFailed"); 44 | } 45 | while (PInvoke.GetMessage(out MSG _, HWND.Null, 0, 0)) { } 46 | PInvoke.UnhookWindowsHookEx(hook); 47 | return 0; 48 | } 49 | 50 | private unsafe static LRESULT mymouse(int nCode, WPARAM wParam, LPARAM lParam) 51 | { 52 | MOUSEHOOKSTRUCT* mhookstruct = (MOUSEHOOKSTRUCT*)lParam.Value; 53 | Point pt = mhookstruct->pt; 54 | if (keyCode == 1) 55 | { 56 | if (wParam.Value == PInvoke.WM_LBUTTONUP) 57 | { 58 | Console.WriteLine($"MouseAction {pt.X} {pt.Y}"); 59 | } 60 | } 61 | else if (keyCode == 2) 62 | { 63 | if (wParam.Value == PInvoke.WM_RBUTTONUP) 64 | { 65 | Console.WriteLine($"MouseAction {pt.X} {pt.Y}"); 66 | } 67 | } 68 | return PInvoke.CallNextHookEx(HHOOK.Null, nCode, wParam, lParam); 69 | } 70 | 71 | private unsafe static LRESULT mykeyboard(int nCode, WPARAM wParam, LPARAM lParam) 72 | { 73 | KBDLLHOOKSTRUCT* pKeyboardHookStruct = (KBDLLHOOKSTRUCT*)lParam.Value; 74 | 75 | if (wParam.Value == PInvoke.WM_KEYUP) 76 | { 77 | if (pKeyboardHookStruct->vkCode == keyCode) 78 | { 79 | Console.WriteLine("KeyboardAction"); 80 | } 81 | } 82 | return PInvoke.CallNextHookEx(HHOOK.Null, nCode, wParam, lParam); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /KeyboardMouseMonitor/KeyboardMouseMonitor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | true 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /KeyboardMouseMonitor/NativeMethods.txt: -------------------------------------------------------------------------------- 1 | // enum 2 | Windows.Win32.UI.WindowsAndMessaging.WM_LBUTTONUP 3 | Windows.Win32.UI.WindowsAndMessaging.WM_RBUTTONUP 4 | Windows.Win32.UI.WindowsAndMessaging.WM_KEYUP 5 | 6 | // structure 7 | Windows.Win32.UI.WindowsAndMessaging.MOUSEHOOKSTRUCT 8 | Windows.Win32.UI.WindowsAndMessaging.KBDLLHOOKSTRUCT 9 | 10 | // function 11 | Windows.Win32.UI.WindowsAndMessaging.CallNextHookEx 12 | Windows.Win32.UI.WindowsAndMessaging.SetWindowsHookEx 13 | Windows.Win32.UI.WindowsAndMessaging.UnhookWindowsHookEx 14 | Windows.Win32.UI.WindowsAndMessaging.GetMessage 15 | -------------------------------------------------------------------------------- /KeyboardMouseMonitor/Properties/LaunchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "MouseMonitor": { 4 | "commandName": "Project", 5 | "commandLineArgs": "1 1" 6 | }, 7 | "KeyboardMonitor": { 8 | "commandName": "Project", 9 | "commandLineArgs": "2 8" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /MecabHelperLibrary/MecabHelperLibrary.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/AddOptWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/DictResWindow.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/DictResWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using DictionaryHelperLibrary; 2 | using HandyControl.Controls; 3 | using MecabHelperLibrary; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | using System.Windows.Controls; 11 | using System.Windows.Data; 12 | using System.Windows.Documents; 13 | using System.Windows.Input; 14 | using System.Windows.Media; 15 | using System.Windows.Media.Imaging; 16 | using System.Windows.Shapes; 17 | using TTSHelperLibrary; 18 | 19 | namespace MisakaTranslator_WPF 20 | { 21 | /// 22 | /// DictResWindow.xaml 的交互逻辑 23 | /// 24 | public partial class DictResWindow : System.Windows.Window 25 | { 26 | private string sourceWord; 27 | private TextSpeechHelper _textSpeechHelper; 28 | private IDict _dict; 29 | 30 | public DictResWindow(string word,string kana = "----", TextSpeechHelper tsh = null) 31 | { 32 | sourceWord = word; 33 | InitializeComponent(); 34 | if (tsh == null) 35 | { 36 | _textSpeechHelper = new TextSpeechHelper(); 37 | } 38 | else { 39 | _textSpeechHelper = tsh; 40 | } 41 | 42 | 43 | if (Common.appSettings.ttsVoice == "") 44 | { 45 | Growl.InfoGlobal(Application.Current.Resources["TranslateWin_NoTTS_Hint"].ToString()); 46 | } 47 | else 48 | { 49 | _textSpeechHelper.SetTTSVoice(Common.appSettings.ttsVoice); 50 | _textSpeechHelper.SetVolume(Common.appSettings.ttsVolume); 51 | _textSpeechHelper.SetRate(Common.appSettings.ttsRate); 52 | } 53 | 54 | if (Common.appSettings.xxgPath != string.Empty) 55 | { 56 | _dict = new XxgJpzhDict(); 57 | _dict.DictInit(Common.appSettings.xxgPath, string.Empty); 58 | } 59 | 60 | string ret = _dict.SearchInDict(sourceWord); 61 | 62 | SourceWord.Text = sourceWord; 63 | 64 | Kana.Text = kana; 65 | 66 | this.Topmost = true; 67 | DicResText.Text = XxgJpzhDict.RemoveHTML(ret); 68 | } 69 | 70 | ~DictResWindow() { 71 | _textSpeechHelper = null; 72 | _dict = null; 73 | } 74 | 75 | private void TTS_Btn_Click(object sender, RoutedEventArgs e) 76 | { 77 | _textSpeechHelper.SpeakAsync(sourceWord); 78 | } 79 | 80 | private void Search_Btn_Click(object sender, RoutedEventArgs e) 81 | { 82 | System.Diagnostics.Process.Start("https://www.baidu.com/s?wd=" + sourceWord); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GameGuideWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GlobalOCRWindow.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GuidePages/ChooseLanguagePage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GuidePages/ChooseLanguagePage.xaml.cs: -------------------------------------------------------------------------------- 1 | using SQLHelperLibrary; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using System.Windows; 8 | using System.Windows.Controls; 9 | using System.Windows.Data; 10 | using System.Windows.Documents; 11 | using System.Windows.Input; 12 | using System.Windows.Media; 13 | using System.Windows.Media.Imaging; 14 | using System.Windows.Navigation; 15 | using System.Windows.Shapes; 16 | using TranslatorLibrary; 17 | 18 | namespace MisakaTranslator_WPF.GuidePages 19 | { 20 | /// 21 | /// ChooseLanguagePage.xaml 的交互逻辑 22 | /// 23 | public partial class ChooseLanguagePage : Page 24 | { 25 | private readonly List _langList; 26 | 27 | public ChooseLanguagePage() 28 | { 29 | InitializeComponent(); 30 | 31 | _langList = CommonFunction.lstLanguage.Keys.ToList(); 32 | SrcLangCombox.ItemsSource = _langList; 33 | DstLangCombox.ItemsSource = _langList; 34 | 35 | SrcLangCombox.SelectedIndex = 2; 36 | DstLangCombox.SelectedIndex = 0; 37 | } 38 | 39 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e) 40 | { 41 | if (SrcLangCombox.SelectedIndex == DstLangCombox.SelectedIndex) 42 | { 43 | HandyControl.Controls.Growl.Error(Application.Current.Resources["ChooseLanguagePage_NextErrorHint"].ToString()); 44 | } 45 | else { 46 | Common.UsingSrcLang = CommonFunction.lstLanguage[_langList[SrcLangCombox.SelectedIndex]]; 47 | Common.UsingDstLang = CommonFunction.lstLanguage[_langList[DstLangCombox.SelectedIndex]]; 48 | 49 | //写数据库信息 50 | if(Common.GameID != -1) 51 | { 52 | GameLibraryHelper.sqlHelper.ExecuteSql( 53 | $"UPDATE game_library SET src_lang = '{Common.UsingSrcLang}' WHERE gameid = {Common.GameID};"); 54 | GameLibraryHelper.sqlHelper.ExecuteSql( 55 | $"UPDATE game_library SET dst_lang = '{Common.UsingDstLang}' WHERE gameid = {Common.GameID};"); 56 | } 57 | 58 | //使用路由事件机制通知窗口来完成下一步操作 59 | PageChangeRoutedEventArgs args = new PageChangeRoutedEventArgs(PageChange.PageChangeRoutedEvent, this) 60 | { 61 | XamlPath = "GuidePages/CompletationPage.xaml" 62 | }; 63 | this.RaiseEvent(args); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GuidePages/Completation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/MisakaTranslator-WPF/GuidePages/Completation.png -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GuidePages/CompletationPage.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GuidePages/OCR/ChooseOCRAreaPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/GuidePages/PageChangeRoutedEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | 9 | namespace MisakaTranslator_WPF.GuidePages 10 | { 11 | public class PageChangeRoutedEventArgs : RoutedEventArgs 12 | { 13 | public PageChangeRoutedEventArgs(RoutedEvent routedEvent, object source) : base(routedEvent, source) { } 14 | 15 | /// 16 | /// 下一页的XAML地址 17 | /// 18 | public string XamlPath { get; set; } 19 | 20 | /// 21 | /// 部分方法需要用到的额外参数 22 | /// 23 | public object ExtraArgs; 24 | } 25 | 26 | public class PageChange 27 | { 28 | public string XamlPath; 29 | 30 | //声明和注册路由事件 31 | public static readonly RoutedEvent PageChangeRoutedEvent = 32 | EventManager.RegisterRoutedEvent("PageChange", RoutingStrategy.Bubble, typeof(EventHandler), typeof(PageChange)); 33 | 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/MisakaTranslator-WPF.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | true 6 | true 7 | Properties\App.manifest 8 | logo.ico 9 | MisakaTranslator_WPF 10 | MisakaTranslator_WPF.Program 11 | true 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | true 50 | MSIX 51 | true 52 | false 53 | 54 | 55 | 56 | 10.0.14393.0 57 | $(TargetPlatformVersion) 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Runtime.InteropServices; 5 | using Windows.Win32; 6 | using Windows.Win32.Foundation; 7 | using Windows.Win32.Security; 8 | 9 | namespace MisakaTranslator_WPF 10 | { 11 | static internal class Program 12 | { 13 | static unsafe bool IsElevated() 14 | { 15 | HANDLE hToken = HANDLE.Null; 16 | TOKEN_ELEVATION tokenType = new() 17 | { 18 | TokenIsElevated = 0 19 | }; 20 | if (PInvoke.OpenProcessToken((HANDLE)Process.GetCurrentProcess().Handle, TOKEN_ACCESS_MASK.TOKEN_ALL_ACCESS, &hToken)) 21 | { 22 | PInvoke.GetTokenInformation(hToken, TOKEN_INFORMATION_CLASS.TokenElevation, &tokenType, (uint)Marshal.SizeOf(tokenType), out var _); 23 | PInvoke.CloseHandle(hToken); 24 | } 25 | return (BOOL)(int)tokenType.TokenIsElevated; 26 | } 27 | 28 | static unsafe bool CanElevate() 29 | { 30 | HANDLE hToken = HANDLE.Null; 31 | TOKEN_ELEVATION_TYPE tokenType = 0; 32 | if (PInvoke.OpenProcessToken((HANDLE)Process.GetCurrentProcess().Handle, TOKEN_ACCESS_MASK.TOKEN_ALL_ACCESS, &hToken)) 33 | { 34 | PInvoke.GetTokenInformation(hToken, TOKEN_INFORMATION_CLASS.TokenElevationType, &tokenType, sizeof(TOKEN_ELEVATION_TYPE), out var _); 35 | PInvoke.CloseHandle(hToken); 36 | } 37 | return tokenType == TOKEN_ELEVATION_TYPE.TokenElevationTypeLimited; 38 | } 39 | 40 | static bool RunElevate() 41 | { 42 | ProcessStartInfo elevationInfo = new() 43 | { 44 | FileName = Process.GetCurrentProcess().ProcessName, 45 | UseShellExecute = true, 46 | Verb = "runas", 47 | WorkingDirectory = Environment.CurrentDirectory 48 | }; 49 | try 50 | { 51 | Process.Start(elevationInfo); 52 | Environment.Exit(0); 53 | return true; 54 | } 55 | catch 56 | { 57 | return false; 58 | } 59 | } 60 | 61 | [STAThread] 62 | static void Main() 63 | { 64 | Environment.CurrentDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName); 65 | if (CanElevate()) 66 | { 67 | RunElevate(); 68 | } 69 | App.Main(); 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Properties/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Properties/App.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | true 24 | amd64 arm64 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Properties/LaunchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "MisakaTranslator (Unpackage)": { 4 | "commandName": "Project", 5 | "nativeDebugging": true 6 | }, 7 | "MisakaTranslator (Package)": { 8 | "commandName": "MsixPackage", 9 | "nativeDebugging": true 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Properties/NativeMethods.txt: -------------------------------------------------------------------------------- 1 | // enum 2 | Windows.Win32.Security.TOKEN_ELEVATION_TYPE 3 | Windows.Win32.UI.WindowsAndMessaging.HWND_TOPMOST 4 | 5 | // structure 6 | Windows.Win32.Security.TOKEN_ELEVATION 7 | 8 | // function 9 | Windows.Win32.Security.GetTokenInformation 10 | Windows.Win32.System.Threading.OpenProcessToken 11 | Windows.Win32.UI.Shell.StrCmpLogicalW 12 | Windows.Win32.UI.WindowsAndMessaging.GetCursorPos 13 | Windows.Win32.UI.WindowsAndMessaging.SetWindowPos 14 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/Properties/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 8 | 9 | 13 | 14 | 15 | MisakaTranslator 16 | MisakaProject 17 | Assets\PackageLogo.png 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 35 | 41 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/ScreenCaptureWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 14 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/AboutPage.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/AboutPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace MisakaTranslator_WPF.SettingsPages 17 | { 18 | /// 19 | /// AboutPage.xaml 的交互逻辑 20 | /// 21 | public partial class AboutPage : Page 22 | { 23 | public AboutPage() 24 | { 25 | InitializeComponent(); 26 | } 27 | 28 | private void BtnHelp_Click(object sender, RoutedEventArgs e) 29 | { 30 | System.Diagnostics.Process.Start("https://github.com/hanmin0822/MisakaTranslator/issues"); 31 | } 32 | 33 | private void BtnGithub_Click(object sender, RoutedEventArgs e) 34 | { 35 | System.Diagnostics.Process.Start("https://github.com/hanmin0822/MisakaTranslator"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/Aboutv2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/MisakaTranslator-WPF/SettingsPages/Aboutv2.jpg -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/Aboutv2_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/MisakaTranslator-WPF/SettingsPages/Aboutv2_small.jpg -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/ArtificialTransSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/DictionaryPages/XxgJpZhDictPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using DictionaryHelperLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.DictionaryPages 18 | { 19 | /// 20 | /// XxgJpZhDictPage.xaml 的交互逻辑 21 | /// 22 | public partial class XxgJpZhDictPage : Page 23 | { 24 | public XxgJpZhDictPage() 25 | { 26 | InitializeComponent(); 27 | PathBox.Text = Common.appSettings.xxgPath; 28 | } 29 | 30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | 33 | Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog 34 | { 35 | Multiselect = false, 36 | Title = Application.Current.Resources["XxgJpZhDictPage_ChoosePathHint"].ToString(), 37 | Filter = "所有文件(*.*)|*.*" 38 | }; 39 | if (dialog.ShowDialog() == true) 40 | { 41 | if (string.IsNullOrEmpty(dialog.FileName)) 42 | { 43 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString()); 44 | } 45 | else 46 | { 47 | PathBox.Text = dialog.FileName; 48 | Common.appSettings.xxgPath = PathBox.Text; 49 | } 50 | } 51 | } 52 | 53 | private void TestBtn_Click(object sender, RoutedEventArgs e) 54 | { 55 | IDict dict = new XxgJpzhDict(); 56 | 57 | dict.DictInit(Common.appSettings.xxgPath, ""); 58 | 59 | string ret = dict.SearchInDict(TestSrcText.Text); 60 | if (ret != null) 61 | { 62 | DictResWindow dictResWindow = new DictResWindow(TestSrcText.Text); 63 | dictResWindow.Show(); 64 | } 65 | else 66 | { 67 | HandyControl.Controls.Growl.Error($"查询错误!{dict.GetLastError()}"); 68 | } 69 | 70 | } 71 | } 72 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/LESettingsPage.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/LESettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | 16 | namespace MisakaTranslator_WPF.SettingsPages 17 | { 18 | /// 19 | /// LESettingsPage.xaml 的交互逻辑 20 | /// 21 | public partial class LESettingsPage : Page 22 | { 23 | public LESettingsPage() 24 | { 25 | InitializeComponent(); 26 | 27 | PathBox.Text = Common.appSettings.LEPath; 28 | } 29 | 30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog 33 | { 34 | Description = Application.Current.Resources["LESettingsPage_ChooseFilePathHint"].ToString() 35 | }; 36 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 37 | { 38 | if (string.IsNullOrEmpty(dialog.SelectedPath)) 39 | { 40 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString()); 41 | } 42 | else 43 | { 44 | PathBox.Text = dialog.SelectedPath; 45 | Common.appSettings.LEPath = PathBox.Text; 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/OCRPages/BaiduFanyiOCRSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/OCRPages/BaiduOCRSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TTSSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TTSHelperLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages 18 | { 19 | /// 20 | /// TTSSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class TTSSettingsPage : Page 23 | { 24 | TextSpeechHelper tsh; 25 | 26 | public TTSSettingsPage() 27 | { 28 | tsh = new TextSpeechHelper(); 29 | InitializeComponent(); 30 | 31 | List lst = tsh.GetAllTTSEngine(); 32 | TTSSourceCombox.ItemsSource = lst; 33 | 34 | for (int i = 0; i < lst.Count; i++) 35 | { 36 | if (lst[i] == Common.appSettings.ttsVoice) 37 | { 38 | TTSSourceCombox.SelectedIndex = i; 39 | break; 40 | } 41 | } 42 | VolumeBar.Value = Common.appSettings.ttsVolume; 43 | RateBar.Value = Common.appSettings.ttsRate; 44 | } 45 | 46 | private void TTSSourceCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) 47 | { 48 | tsh.SetTTSVoice((string) TTSSourceCombox.SelectedValue); 49 | } 50 | 51 | private void TestBtn_Click(object sender, RoutedEventArgs e) 52 | { 53 | tsh.SpeakAsync(TestSrcText.Text); 54 | Common.appSettings.ttsVoice = (string) TTSSourceCombox.SelectedValue; 55 | Common.appSettings.ttsVolume = (int) VolumeBar.Value; 56 | Common.appSettings.ttsRate = (int) RateBar.Value; 57 | } 58 | 59 | private void VolumeBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) 60 | { 61 | tsh.SetVolume((int) VolumeBar.Value); 62 | } 63 | 64 | private void RateBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) 65 | { 66 | tsh.SetRate((int) RateBar.Value); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/AzureOpenAITransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using TranslatorLibrary; 4 | 5 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 6 | { 7 | /// 8 | /// AzureOpenAITransSettingsPage.xaml 的交互逻辑 9 | /// 10 | public partial class AzureOpenAITransSettingsPage : Page 11 | { 12 | public AzureOpenAITransSettingsPage() 13 | { 14 | InitializeComponent(); 15 | AzureOpenAITransSecretKeyBox.Text = Common.appSettings.AzureOpenAIApiKey; 16 | AzureOpenAITransUrlBox.Text = Common.appSettings.AzureOpenAIApiUrl; 17 | } 18 | 19 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 20 | { 21 | Common.appSettings.AzureOpenAIApiKey = AzureOpenAITransSecretKeyBox.Text; 22 | Common.appSettings.AzureOpenAIApiUrl = AzureOpenAITransUrlBox.Text; 23 | 24 | ITranslator trans = new AzureOpenAITranslator(); 25 | trans.TranslatorInit(AzureOpenAITransSecretKeyBox.Text, AzureOpenAITransUrlBox.Text); 26 | 27 | if (await trans.TranslateAsync("apple", "zh", "en") != null) 28 | { 29 | HandyControl.Controls.Growl.Success($"Azure OpenAI {Application.Current.Resources["APITest_Success_Hint"]}"); 30 | } 31 | else 32 | { 33 | HandyControl.Controls.Growl.Error($"Azure OpenAI {Application.Current.Resources["APITest_Error_Hint"]}\n{trans.GetLastError()}"); 34 | } 35 | } 36 | 37 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 38 | { 39 | System.Diagnostics.Process.Start("https://azure.microsoft.com/en-us/solutions/ai/"); 40 | } 41 | 42 | private void DocBtn_Click(object sender, RoutedEventArgs e) 43 | { 44 | System.Diagnostics.Process.Start("https://learn.microsoft.com/en-us/azure/ai-services/cognitive-services-support-options"); 45 | } 46 | 47 | private void BillBtn_Click(object sender, RoutedEventArgs e) 48 | { 49 | // System.Diagnostics.Process.Start(ChatGPTTranslator.BILL_URL); 50 | } 51 | 52 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 53 | { 54 | ITranslator trans = new AzureOpenAITranslator(); 55 | trans.TranslatorInit(AzureOpenAITransSecretKeyBox.Text, AzureOpenAITransUrlBox.Text); 56 | string res = await trans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 57 | 58 | if (res != null) 59 | { 60 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 61 | } 62 | else 63 | { 64 | HandyControl.Controls.Growl.Error( 65 | $"Azure OpenAI {Application.Current.Resources["APITest_Error_Hint"]}\n{trans.GetLastError()}"); 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/CaiyunTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// CaiyunTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class CaiyunTransSettingsPage : Page 23 | { 24 | public CaiyunTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | TransTokenBox.Text = Common.appSettings.CaiyunToken; 28 | } 29 | 30 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | Common.appSettings.CaiyunToken = TransTokenBox.Text; 33 | ITranslator Trans = new CaiyunTranslator(); 34 | Trans.TranslatorInit(TransTokenBox.Text, ""); 35 | if (await Trans.TranslateAsync("apple", "zh", "en") != null) 36 | { 37 | HandyControl.Controls.Growl.Success($"彩云小译{Application.Current.Resources["APITest_Success_Hint"]}"); 38 | } 39 | else 40 | { 41 | HandyControl.Controls.Growl.Error($"彩云小译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 42 | } 43 | } 44 | 45 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 46 | { 47 | System.Diagnostics.Process.Start(CaiyunTranslator.GetUrl_allpyAPI()); 48 | } 49 | 50 | private void DocBtn_Click(object sender, RoutedEventArgs e) 51 | { 52 | System.Diagnostics.Process.Start(CaiyunTranslator.GetUrl_Doc()); 53 | } 54 | 55 | private void BillBtn_Click(object sender, RoutedEventArgs e) 56 | { 57 | System.Diagnostics.Process.Start(CaiyunTranslator.GetUrl_bill()); 58 | } 59 | 60 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 61 | { 62 | ITranslator Trans = new CaiyunTranslator(); 63 | Trans.TranslatorInit(Common.appSettings.CaiyunToken, ""); 64 | string res = await Trans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 65 | if (res != null) 66 | { 67 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 68 | } 69 | else 70 | { 71 | HandyControl.Controls.Growl.Error($"彩云小译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 72 | } 73 | } 74 | } 75 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/ChatGPTTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | using System.Windows.Controls; 3 | using TranslatorLibrary; 4 | 5 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 6 | { 7 | /// 8 | /// ChatGPTTransSettingsPage.xaml 的交互逻辑 9 | /// 10 | public partial class ChatGPTTransSettingsPage : Page 11 | { 12 | public ChatGPTTransSettingsPage() 13 | { 14 | InitializeComponent(); 15 | ChatGPTTransSecretKeyBox.Text = Common.appSettings.ChatGPTapiKey; 16 | ChatGPTTransUrlBox.Text = Common.appSettings.ChatGPTapiUrl; 17 | } 18 | 19 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 20 | { 21 | Common.appSettings.ChatGPTapiKey = ChatGPTTransSecretKeyBox.Text; 22 | Common.appSettings.ChatGPTapiUrl = ChatGPTTransUrlBox.Text; 23 | 24 | ITranslator chatGPTTrans = new ChatGPTTranslator(); 25 | chatGPTTrans.TranslatorInit(ChatGPTTransSecretKeyBox.Text, ChatGPTTransUrlBox.Text); 26 | 27 | if (await chatGPTTrans.TranslateAsync("apple", "zh", "en") != null) 28 | { 29 | HandyControl.Controls.Growl.Success($"ChatGPT {Application.Current.Resources["APITest_Success_Hint"]}"); 30 | } 31 | else 32 | { 33 | HandyControl.Controls.Growl.Error($"ChatGPT {Application.Current.Resources["APITest_Error_Hint"]}\n{chatGPTTrans.GetLastError()}"); 34 | } 35 | } 36 | 37 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 38 | { 39 | System.Diagnostics.Process.Start(ChatGPTTranslator.SIGN_UP_URL); 40 | } 41 | 42 | private void DocBtn_Click(object sender, RoutedEventArgs e) 43 | { 44 | System.Diagnostics.Process.Start(ChatGPTTranslator.DOCUMENT_URL); 45 | } 46 | 47 | private void BillBtn_Click(object sender, RoutedEventArgs e) 48 | { 49 | System.Diagnostics.Process.Start(ChatGPTTranslator.BILL_URL); 50 | } 51 | 52 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 53 | { 54 | ITranslator chatGPTTrans = new ChatGPTTranslator(); 55 | chatGPTTrans.TranslatorInit(ChatGPTTransSecretKeyBox.Text, ChatGPTTransUrlBox.Text); 56 | string res = await chatGPTTrans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 57 | 58 | if (res != null) 59 | { 60 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 61 | } 62 | else 63 | { 64 | HandyControl.Controls.Growl.Error( 65 | $"ChatGPT {Application.Current.Resources["APITest_Error_Hint"]}\n{chatGPTTrans.GetLastError()}"); 66 | } 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/DeepLTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// DeepLTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class DeepLTransSettingsPage : Page 23 | { 24 | public DeepLTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | DeepLTransSecretKeyBox.Text = Common.appSettings.DeepLsecretKey; 28 | } 29 | 30 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | Common.appSettings.DeepLsecretKey = DeepLTransSecretKeyBox.Text; 33 | ITranslator deepLTrans = new DeepLTranslator(); 34 | deepLTrans.TranslatorInit(DeepLTransSecretKeyBox.Text, DeepLTransSecretKeyBox.Text); 35 | 36 | if (await deepLTrans.TranslateAsync("apple", "zh", "en") != null) 37 | { 38 | HandyControl.Controls.Growl.Success($"DeepL {Application.Current.Resources["APITest_Success_Hint"]}"); 39 | } 40 | else 41 | { 42 | HandyControl.Controls.Growl.Error($"DeepL {Application.Current.Resources["APITest_Error_Hint"]}\n{deepLTrans.GetLastError()}"); 43 | } 44 | } 45 | 46 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 47 | { 48 | System.Diagnostics.Process.Start(DeepLTranslator.SIGN_UP_URL); 49 | } 50 | 51 | private void DocBtn_Click(object sender, RoutedEventArgs e) 52 | { 53 | System.Diagnostics.Process.Start(DeepLTranslator.DOCUMENT_URL); 54 | } 55 | 56 | private void BillBtn_Click(object sender, RoutedEventArgs e) 57 | { 58 | System.Diagnostics.Process.Start(DeepLTranslator.BILL_URL); 59 | } 60 | 61 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 62 | { 63 | ITranslator deepLTrans = new DeepLTranslator(); 64 | deepLTrans.TranslatorInit(DeepLTransSecretKeyBox.Text, DeepLTransSecretKeyBox.Text); 65 | string res = await deepLTrans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 66 | 67 | if (res != null) 68 | { 69 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 70 | } 71 | else 72 | { 73 | HandyControl.Controls.Growl.Error( 74 | $"DeepL {Application.Current.Resources["APITest_Error_Hint"]}\n{deepLTrans.GetLastError()}"); 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/DreyeTransSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/DreyeTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// DreyeTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class DreyeTransSettingsPage : Page 23 | { 24 | public DreyeTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | PathBox.Text = Common.appSettings.DreyePath; 28 | } 29 | 30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); 33 | dialog.Description = Application.Current.Resources["DreyeTransSettingsPage_ChoosePathHint"].ToString(); 34 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 35 | { 36 | if (string.IsNullOrEmpty(dialog.SelectedPath)) 37 | { 38 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString()); 39 | } 40 | else 41 | { 42 | PathBox.Text = dialog.SelectedPath; 43 | Common.appSettings.DreyePath = PathBox.Text; 44 | } 45 | } 46 | } 47 | 48 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 49 | { 50 | ITranslator Trans = new DreyeTranslator(); 51 | Trans.TranslatorInit(Common.appSettings.DreyePath, ""); 52 | string res = await Trans.TranslateAsync(TestSrcText.Text, "zh", TestSrcLang.Text); 53 | if (res != null) 54 | { 55 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 56 | } 57 | else 58 | { 59 | HandyControl.Controls.Growl.Error( 60 | $"译典通翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/IBMTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using TranslatorLibrary; 9 | 10 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 11 | { 12 | /// 13 | /// IBMTransSettingsPage.xaml 的交互逻辑 14 | /// 15 | public partial class IBMTransSettingsPage : Page 16 | { 17 | public IBMTransSettingsPage() 18 | { 19 | InitializeComponent(); 20 | IBMTransApiKeyBox.Text = Common.appSettings.IBMApiKey; 21 | IBMTransURLBox.Text = Common.appSettings.IBMURL; 22 | } 23 | 24 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 25 | { 26 | Common.appSettings.IBMApiKey = IBMTransApiKeyBox.Text; 27 | Common.appSettings.IBMURL = IBMTransURLBox.Text; 28 | ITranslator IBMTrans = new IBMTranslator(); 29 | IBMTrans.TranslatorInit(IBMTransApiKeyBox.Text, IBMTransURLBox.Text); 30 | 31 | if (await IBMTrans.TranslateAsync("apple", "zh", "en") != null) 32 | { 33 | HandyControl.Controls.Growl.Success($"IBM {Application.Current.Resources["APITest_Success_Hint"]}"); 34 | } 35 | else 36 | { 37 | HandyControl.Controls.Growl.Error($"IBM {Application.Current.Resources["APITest_Error_Hint"]}\n{IBMTrans.GetLastError()}"); 38 | } 39 | } 40 | 41 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 42 | { 43 | System.Diagnostics.Process.Start(IBMTranslator.GetUrl_allpyAPI()); 44 | } 45 | 46 | private void DocBtn_Click(object sender, RoutedEventArgs e) 47 | { 48 | System.Diagnostics.Process.Start(IBMTranslator.GetUrl_Doc()); 49 | } 50 | 51 | private void BillBtn_Click(object sender, RoutedEventArgs e) 52 | { 53 | System.Diagnostics.Process.Start(IBMTranslator.GetUrl_bill()); 54 | } 55 | 56 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 57 | { 58 | ITranslator IBMTrans = new IBMTranslator(); 59 | IBMTrans.TranslatorInit(IBMTransApiKeyBox.Text, IBMTransURLBox.Text); 60 | string res = await IBMTrans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 61 | 62 | if (res != null) 63 | { 64 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 65 | } 66 | else 67 | { 68 | HandyControl.Controls.Growl.Error( 69 | $"IBM {Application.Current.Resources["APITest_Error_Hint"]}\n{IBMTrans.GetLastError()}"); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/JbeijingTransSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/JbeijingTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// JbeijingTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class JbeijingTransSettingsPage : Page 23 | { 24 | public JbeijingTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | PathBox.Text = Common.appSettings.JBJCTDllPath; 28 | } 29 | 30 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | ITranslator Trans = new JBeijingTranslator(); 33 | Trans.TranslatorInit(Common.appSettings.JBJCTDllPath, ""); 34 | string res = await Trans.TranslateAsync(TestSrcText.Text, "", ""); 35 | if (res != null) 36 | { 37 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 38 | } 39 | else 40 | { 41 | HandyControl.Controls.Growl.Error( 42 | $"JBeijing翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 43 | } 44 | } 45 | 46 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e) 47 | { 48 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog(); 49 | dialog.Description = Application.Current.Resources["JbeijingTransSettingsPage_ChoosePathHint"].ToString(); 50 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 51 | { 52 | if (string.IsNullOrEmpty(dialog.SelectedPath)) 53 | { 54 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString()); 55 | } 56 | else 57 | { 58 | PathBox.Text = dialog.SelectedPath; 59 | Common.appSettings.JBJCTDllPath = PathBox.Text; 60 | } 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/KingsoftFAITTransSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/KingsoftFAITTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// KingsoftFAITTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class KingsoftFAITTransSettingsPage : Page 23 | { 24 | public KingsoftFAITTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | PathBox.Text = Common.appSettings.KingsoftFastAITPath; 28 | } 29 | 30 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog 33 | { 34 | Description = Application.Current.Resources["KingsoftFAITTransSettingsPage_ChoosePathHint"] 35 | .ToString() 36 | }; 37 | if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) 38 | { 39 | if (string.IsNullOrEmpty(dialog.SelectedPath)) 40 | { 41 | HandyControl.Controls.Growl.Error(Application.Current.Resources["FilePath_Null_Hint"].ToString()); 42 | } 43 | else 44 | { 45 | PathBox.Text = dialog.SelectedPath; 46 | Common.appSettings.KingsoftFastAITPath = PathBox.Text; 47 | } 48 | } 49 | } 50 | 51 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 52 | { 53 | ITranslator Trans = new KingsoftFastAITTranslator(); 54 | Trans.TranslatorInit(Common.appSettings.KingsoftFastAITPath, ""); 55 | string res = await Trans.TranslateAsync(TestSrcText.Text, "zh", TestSrcLang.Text); 56 | if (res != null) 57 | { 58 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 59 | } 60 | else 61 | { 62 | HandyControl.Controls.Growl.Error( 63 | $"金山快译翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 64 | } 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/TencentFYJTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// TencentFYJTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class TencentFYJTransSettingsPage : Page 23 | { 24 | public TencentFYJTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | TransAppIDBox.Text = Common.appSettings.TXappID; 28 | TransSecretKeyBox.Text = Common.appSettings.TXappKey; 29 | } 30 | 31 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 32 | { 33 | Common.appSettings.TXappID = TransAppIDBox.Text; 34 | Common.appSettings.TXappKey = TransSecretKeyBox.Text; 35 | ITranslator Trans = new TencentFYJTranslator(); 36 | Trans.TranslatorInit(TransAppIDBox.Text, TransSecretKeyBox.Text); 37 | if (await Trans.TranslateAsync("apple", "zh", "en") != null) 38 | { 39 | HandyControl.Controls.Growl.Success($"翻译君{Application.Current.Resources["APITest_Success_Hint"]}"); 40 | } 41 | else 42 | { 43 | HandyControl.Controls.Growl.Error($"翻译君{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 44 | } 45 | } 46 | 47 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 48 | { 49 | System.Diagnostics.Process.Start(TencentFYJTranslator.GetUrl_allpyAPI()); 50 | } 51 | 52 | private void DocBtn_Click(object sender, RoutedEventArgs e) 53 | { 54 | System.Diagnostics.Process.Start(TencentFYJTranslator.GetUrl_Doc()); 55 | } 56 | 57 | private void BillBtn_Click(object sender, RoutedEventArgs e) 58 | { 59 | System.Diagnostics.Process.Start(TencentFYJTranslator.GetUrl_bill()); 60 | } 61 | 62 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 63 | { 64 | ITranslator Trans = new TencentFYJTranslator(); 65 | Trans.TranslatorInit(Common.appSettings.TXappID, Common.appSettings.TXappKey); 66 | string res = await Trans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 67 | if (res != null) 68 | { 69 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 70 | } 71 | else 72 | { 73 | HandyControl.Controls.Growl.Error($"翻译君{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 74 | } 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/TencentOldTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// TencentOldTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class TencentOldTransSettingsPage : Page 23 | { 24 | public TencentOldTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | TransAppIDBox.Text = Common.appSettings.TXOSecretId; 28 | TransSecretKeyBox.Text = Common.appSettings.TXOSecretKey; 29 | } 30 | 31 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 32 | { 33 | Common.appSettings.TXOSecretId = TransAppIDBox.Text; 34 | Common.appSettings.TXOSecretKey = TransSecretKeyBox.Text; 35 | ITranslator Trans = new TencentOldTranslator(); 36 | Trans.TranslatorInit(TransAppIDBox.Text, TransSecretKeyBox.Text); 37 | if (await Trans.TranslateAsync("apple", "zh", "en") != null) 38 | { 39 | HandyControl.Controls.Growl.Success($"腾讯云{Application.Current.Resources["APITest_Success_Hint"]}"); 40 | } 41 | else 42 | { 43 | HandyControl.Controls.Growl.Error($"腾讯云{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 44 | } 45 | } 46 | 47 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 48 | { 49 | System.Diagnostics.Process.Start(TencentOldTranslator.GetUrl_allpyAPI()); 50 | } 51 | 52 | private void DocBtn_Click(object sender, RoutedEventArgs e) 53 | { 54 | System.Diagnostics.Process.Start(TencentOldTranslator.GetUrl_Doc()); 55 | } 56 | 57 | private void BillBtn_Click(object sender, RoutedEventArgs e) 58 | { 59 | System.Diagnostics.Process.Start(TencentOldTranslator.GetUrl_bill()); 60 | } 61 | 62 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 63 | { 64 | ITranslator Trans = new TencentOldTranslator(); 65 | Trans.TranslatorInit(Common.appSettings.TXOSecretId, Common.appSettings.TXOSecretKey); 66 | string res = await Trans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 67 | if (res != null) 68 | { 69 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 70 | } 71 | else 72 | { 73 | HandyControl.Controls.Growl.Error($"腾讯云{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 74 | } 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/TranslatorGeneralSettingsPage.xaml: -------------------------------------------------------------------------------- 1 |  11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/TranslatorGeneralSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages 18 | { 19 | /// 20 | /// TranslatorGeneralSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class TranslatorGeneralSettingsPage : Page 23 | { 24 | private List TranslatorList; 25 | 26 | public TranslatorGeneralSettingsPage() 27 | { 28 | InitializeComponent(); 29 | TranslatorList = CommonFunction.GetTranslatorList(); 30 | FirstTransCombox.ItemsSource = TranslatorList; 31 | SecondTransCombox.ItemsSource = TranslatorList; 32 | 33 | FirstTransCombox.SelectedIndex = CommonFunction.GetTranslatorIndex(Common.appSettings.FirstTranslator); 34 | SecondTransCombox.SelectedIndex = CommonFunction.GetTranslatorIndex(Common.appSettings.SecondTranslator); 35 | 36 | EachRowTransCheckBox.IsChecked = Common.appSettings.EachRowTrans; 37 | HttpProxyBox.Text = Common.appSettings.HttpProxy; 38 | 39 | TransLimitBox.Value = Common.appSettings.TransLimitNums; 40 | // 给TransLimitBox添加Minimum后,初始化它时就会触发一次ValueChanged,导致Settings被设为1,因此只能从设置中读取数据后再添加事件处理函数 41 | TransLimitBox.ValueChanged += TransLimitBox_ValueChanged; 42 | } 43 | 44 | private void FirstTransCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) 45 | { 46 | Common.appSettings.FirstTranslator = CommonFunction.lstTranslator[(string)FirstTransCombox.SelectedValue]; 47 | } 48 | 49 | private void SecondTransCombox_SelectionChanged(object sender, SelectionChangedEventArgs e) 50 | { 51 | Common.appSettings.SecondTranslator = CommonFunction.lstTranslator[(string)SecondTransCombox.SelectedValue]; 52 | } 53 | 54 | private void EachRowTransCheckBox_Click(object sender, RoutedEventArgs e) 55 | { 56 | Common.appSettings.EachRowTrans = EachRowTransCheckBox.IsChecked ?? false; 57 | } 58 | 59 | private void HttpProxyBox_LostFocus(object sender, RoutedEventArgs e) 60 | { 61 | string text = HttpProxyBox.Text.Trim(); 62 | try { new Uri(text); } 63 | catch (UriFormatException) { HandyControl.Controls.Growl.Error("Proxy url unsupported."); return; }; 64 | Common.appSettings.HttpProxy = text; 65 | } 66 | 67 | private void TransLimitBox_ValueChanged(object sender, HandyControl.Data.FunctionEventArgs e) 68 | { 69 | Common.appSettings.TransLimitNums = (int)TransLimitBox.Value; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/XiaoniuTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// XiaoniuTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class XiaoniuTransSettingsPage : Page 23 | { 24 | public XiaoniuTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | TransTokenBox.Text = Common.appSettings.xiaoniuApiKey; 28 | } 29 | 30 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 31 | { 32 | Common.appSettings.xiaoniuApiKey = TransTokenBox.Text; 33 | ITranslator Trans = new XiaoniuTranslator(); 34 | Trans.TranslatorInit(TransTokenBox.Text, ""); 35 | if (await Trans.TranslateAsync("apple", "zh", "en") != null) 36 | { 37 | HandyControl.Controls.Growl.Success($"小牛翻译{Application.Current.Resources["APITest_Success_Hint"]}"); 38 | } 39 | else 40 | { 41 | HandyControl.Controls.Growl.Error($"小牛翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 42 | } 43 | } 44 | 45 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 46 | { 47 | System.Diagnostics.Process.Start(XiaoniuTranslator.GetUrl_allpyAPI()); 48 | } 49 | 50 | private void DocBtn_Click(object sender, RoutedEventArgs e) 51 | { 52 | System.Diagnostics.Process.Start(XiaoniuTranslator.GetUrl_Doc()); 53 | } 54 | 55 | private void BillBtn_Click(object sender, RoutedEventArgs e) 56 | { 57 | System.Diagnostics.Process.Start(XiaoniuTranslator.GetUrl_bill()); 58 | } 59 | 60 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 61 | { 62 | ITranslator Trans = new XiaoniuTranslator(); 63 | Trans.TranslatorInit(Common.appSettings.xiaoniuApiKey, ""); 64 | string res = await Trans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 65 | if (res != null) 66 | { 67 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 68 | } 69 | else 70 | { 71 | HandyControl.Controls.Growl.Error($"小牛翻译{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/YandexTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using TranslatorLibrary; 9 | 10 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 11 | { 12 | /// 13 | /// YandexTransSettingsPage.xaml 的交互逻辑 14 | /// 15 | public partial class YandexTransSettingsPage : Page 16 | { 17 | public YandexTransSettingsPage() 18 | { 19 | InitializeComponent(); 20 | YandexTransApiKeyBox.Text = Common.appSettings.YandexApiKey; 21 | } 22 | 23 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 24 | { 25 | Common.appSettings.YandexApiKey = YandexTransApiKeyBox.Text; 26 | ITranslator YandexTrans = new YandexTranslator(); 27 | YandexTrans.TranslatorInit(YandexTransApiKeyBox.Text, ""); 28 | 29 | if (await YandexTrans.TranslateAsync("apple", "zh", "en") != null) 30 | { 31 | HandyControl.Controls.Growl.Success($"Yandex {Application.Current.Resources["APITest_Success_Hint"]}"); 32 | } 33 | else 34 | { 35 | HandyControl.Controls.Growl.Error($"Yandex {Application.Current.Resources["APITest_Error_Hint"]}\n{YandexTrans.GetLastError()}"); 36 | } 37 | } 38 | 39 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 40 | { 41 | System.Diagnostics.Process.Start(YandexTranslator.GetUrl_allpyAPI()); 42 | } 43 | 44 | private void DocBtn_Click(object sender, RoutedEventArgs e) 45 | { 46 | System.Diagnostics.Process.Start(YandexTranslator.GetUrl_Doc()); 47 | } 48 | 49 | private void BillBtn_Click(object sender, RoutedEventArgs e) 50 | { 51 | System.Diagnostics.Process.Start(YandexTranslator.GetUrl_bill()); 52 | } 53 | 54 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 55 | { 56 | ITranslator YandexTrans = new YandexTranslator(); 57 | YandexTrans.TranslatorInit(YandexTransApiKeyBox.Text, ""); 58 | string res = await YandexTrans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 59 | 60 | if (res != null) 61 | { 62 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 63 | } 64 | else 65 | { 66 | HandyControl.Controls.Growl.Error( 67 | $"Yandex {Application.Current.Resources["APITest_Error_Hint"]}\n{YandexTrans.GetLastError()}"); 68 | } 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/SettingsPages/TranslatorPages/YoudaoZhiyunTransSettingsPage.xaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows; 7 | using System.Windows.Controls; 8 | using System.Windows.Data; 9 | using System.Windows.Documents; 10 | using System.Windows.Input; 11 | using System.Windows.Media; 12 | using System.Windows.Media.Imaging; 13 | using System.Windows.Navigation; 14 | using System.Windows.Shapes; 15 | using TranslatorLibrary; 16 | 17 | namespace MisakaTranslator_WPF.SettingsPages.TranslatorPages 18 | { 19 | /// 20 | /// YoudaoZhiyunTransSettingsPage.xaml 的交互逻辑 21 | /// 22 | public partial class YoudaoZhiyunTransSettingsPage : Page 23 | { 24 | public YoudaoZhiyunTransSettingsPage() 25 | { 26 | InitializeComponent(); 27 | YDZYTransAppIDBox.Text = Common.appSettings.YDZYAppId; 28 | YDZYTransAppSecretBox.Text = Common.appSettings.YDZYAppSecret; 29 | } 30 | 31 | private async void AuthTestBtn_Click(object sender, RoutedEventArgs e) 32 | { 33 | Common.appSettings.YDZYAppId = YDZYTransAppIDBox.Text; 34 | Common.appSettings.YDZYAppSecret = YDZYTransAppSecretBox.Text; 35 | ITranslator Trans = new YoudaoZhiyun(); 36 | Trans.TranslatorInit(YDZYTransAppIDBox.Text, YDZYTransAppSecretBox.Text); 37 | if (await Trans.TranslateAsync("apple", "zh", "en") != null) 38 | { 39 | HandyControl.Controls.Growl.Success($"有道智云{Application.Current.Resources["APITest_Success_Hint"]}"); 40 | } 41 | else 42 | { 43 | HandyControl.Controls.Growl.Error($"有道智云{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 44 | } 45 | } 46 | 47 | private void ApplyBtn_Click(object sender, RoutedEventArgs e) 48 | { 49 | System.Diagnostics.Process.Start(YoudaoZhiyun.GetUrl_allpyAPI()); 50 | } 51 | 52 | private void DocBtn_Click(object sender, RoutedEventArgs e) 53 | { 54 | System.Diagnostics.Process.Start(YoudaoZhiyun.GetUrl_Doc()); 55 | } 56 | 57 | private void BillBtn_Click(object sender, RoutedEventArgs e) 58 | { 59 | System.Diagnostics.Process.Start(YoudaoZhiyun.GetUrl_bill()); 60 | } 61 | 62 | private async void TransTestBtn_Click(object sender, RoutedEventArgs e) 63 | { 64 | ITranslator Trans = new YoudaoZhiyun(); 65 | Trans.TranslatorInit(Common.appSettings.YDZYAppId, Common.appSettings.YDZYAppSecret); 66 | string res = await Trans.TranslateAsync(TestSrcText.Text, TestDstLang.Text, TestSrcLang.Text); 67 | if (res != null) 68 | { 69 | HandyControl.Controls.MessageBox.Show(res, Application.Current.Resources["MessageBox_Result"].ToString()); 70 | } 71 | else 72 | { 73 | HandyControl.Controls.Growl.Error($"有道智云{Application.Current.Resources["APITest_Error_Hint"]}\n{Trans.GetLastError()}"); 74 | } 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /MisakaTranslator-WPF/UserControls/GameNameDialog.xaml: -------------------------------------------------------------------------------- 1 |  10 | 11 | 12 | 13 |