├── .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 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/AddOptWindow.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.Shapes;
14 | using TransOptimizationLibrary;
15 |
16 | namespace MisakaTranslator_WPF
17 | {
18 | ///
19 | /// AddOptWindow.xaml 的交互逻辑
20 | ///
21 | public partial class AddOptWindow : Window
22 | {
23 | public AddOptWindow(string src = "")
24 | {
25 | InitializeComponent();
26 | this.Topmost = true;
27 |
28 | List wordtype = new List()
29 | {
30 | "人名",
31 | "地名"
32 | };
33 |
34 | srcText.Text = src;
35 | wordTypeCombox.ItemsSource = wordtype;
36 | }
37 |
38 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
39 | {
40 | if (srcWord.Text != "" && dstWord.Text != "" && wordTypeCombox.SelectedIndex != -1)
41 | {
42 | NounTransOptimization opt = new NounTransOptimization("" + Common.GameID, Common.UsingSrcLang, Common.UsingDstLang);
43 | bool res = opt.AddNounTrans(srcWord.Text, wordTypeCombox.SelectedIndex + 1, dstWord.Text);
44 | if (res)
45 | {
46 | HandyControl.Controls.Growl.InfoGlobal(Application.Current.Resources["AddOptWin_Success_Hint"].ToString());
47 | }
48 | else {
49 | HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["AddOptWin_Error_Hint"].ToString());
50 | }
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/Appearance.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ArtificialTransAddWindow.xaml:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ArtificialTransAddWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using ArtificialTransHelperLibrary;
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.Shapes;
15 |
16 | namespace MisakaTranslator_WPF
17 | {
18 | ///
19 | /// ArtificialTransAddWindow.xaml 的交互逻辑
20 | ///
21 | public partial class ArtificialTransAddWindow : Window
22 | {
23 | private string secondTransRes;
24 |
25 | public ArtificialTransAddWindow(string src,string trans,string secondTrans)
26 | {
27 | InitializeComponent();
28 |
29 | srcText.Text = src;
30 | transText.Text = trans;
31 |
32 | secondTransRes = secondTrans;
33 |
34 | this.Topmost = true;
35 | }
36 |
37 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
38 | {
39 | ArtificialTransHelper ath = new ArtificialTransHelper(Convert.ToString(Common.GameID));
40 |
41 | bool res = ath.UpdateTrans(srcText.Text,transText.Text);
42 | if (res)
43 | {
44 | HandyControl.Controls.Growl.InfoGlobal(Application.Current.Resources["ArtificialTransWin_Success_Hint"].ToString());
45 | }
46 | else
47 | {
48 | HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["ArtificialTransWin_Error_Hint"].ToString());
49 | }
50 | }
51 |
52 | private void ResetBtn_Click(object sender, RoutedEventArgs e)
53 | {
54 | transText.Text = "";
55 | }
56 |
57 | private void SecondTransBtn_Click(object sender, RoutedEventArgs e)
58 | {
59 | transText.Text = secondTransRes;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/ComicTranslator/ImageProcWindow.xaml:
--------------------------------------------------------------------------------
1 |
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 |
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 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/CompletationPage.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.GuidePages
17 | {
18 | ///
19 | /// CompletationPage.xaml 的交互逻辑
20 | ///
21 | public partial class CompletationPage : Page
22 | {
23 | public CompletationPage()
24 | {
25 | InitializeComponent();
26 | }
27 |
28 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
29 | {
30 | //使用路由事件机制通知窗口来完成下一步操作
31 | PageChangeRoutedEventArgs args = new PageChangeRoutedEventArgs(PageChange.PageChangeRoutedEvent, this);
32 | args.XamlPath = "1";//表示完成
33 | this.RaiseEvent(args);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Completation_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/MisakaTranslator-WPF/GuidePages/Completation_small.png
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ChooseGamePage.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 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ReChooseHookFuncPage.xaml:
--------------------------------------------------------------------------------
1 |
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 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/Hook/ReChooseHookFuncPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
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 TextHookLibrary;
17 |
18 | namespace MisakaTranslator_WPF.GuidePages.Hook
19 | {
20 | ///
21 | /// ReChooseHookFuncPage.xaml 的交互逻辑
22 | ///
23 | public partial class ReChooseHookFuncPage : Page
24 | {
25 | BindingList lstData = new BindingList();
26 | int sum = 0;
27 |
28 | public ReChooseHookFuncPage()
29 | {
30 | InitializeComponent();
31 | HookFunListView.ItemsSource = lstData;
32 | sum = 0;
33 | Common.textHooker.HFRSevent += DataRecvEventHandler;
34 | Common.textHooker.StartHook(Convert.ToBoolean(Common.appSettings.AutoHook));
35 | var task_1 = System.Threading.Tasks.Task.Run(async delegate
36 | {
37 | await System.Threading.Tasks.Task.Delay(3000);
38 | Common.textHooker.Auto_AddHookToGame();
39 | });
40 |
41 | }
42 |
43 | public void DataRecvEventHandler(object sender, HookSelectRecvEventArgs e)
44 | {
45 | Application.Current.Dispatcher.BeginInvoke((Action)(() =>
46 | {
47 | if (e.Index < sum)
48 | {
49 | lstData[e.Index] = e.Data;
50 | }
51 | else
52 | {
53 | lstData.Add(e.Data);
54 | sum++;
55 | }
56 | }));
57 | }
58 |
59 | private void ConfirmBtn_Click(object sender, RoutedEventArgs e)
60 | {
61 | if (HookFunListView.SelectedIndex != -1)
62 | {
63 | //先关闭对本窗口的输出
64 | Common.textHooker.HFRSevent -= DataRecvEventHandler;
65 |
66 | Common.textHooker.MisakaCodeList.Add(lstData[HookFunListView.SelectedIndex].MisakaHookCode);
67 |
68 | //Common.textHooker.DetachUnrelatedHookWhenDataRecv = Convert.ToBoolean(Common.appSettings.AutoDetach);
69 | //用户开启了自动卸载
70 | if (Convert.ToBoolean(Common.appSettings.AutoDetach) == true)
71 | {
72 | List usedHook = new List();
73 | usedHook.Add(lstData[HookFunListView.SelectedIndex].HookAddress);
74 | Common.textHooker.DetachUnrelatedHooks(lstData[HookFunListView.SelectedIndex].GamePID, usedHook);
75 | }
76 |
77 |
78 | //使用路由事件机制通知窗口来完成下一步操作
79 | PageChangeRoutedEventArgs args = new PageChangeRoutedEventArgs(PageChange.PageChangeRoutedEvent, this);
80 | args.XamlPath = "GuidePages/CompletationPage.xaml";
81 | this.RaiseEvent(args);
82 | }
83 |
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/GuidePages/OCR/ChooseHandleFuncPage.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 |
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 |
26 |
27 |
28 |
29 |
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 |
16 |
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 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/DictionaryPages/MecabDictPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/DictionaryPages/MecabDictPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Forms;
5 |
6 | namespace MisakaTranslator_WPF.SettingsPages.DictionaryPages
7 | {
8 | ///
9 | /// Interaction logic for MecabDictPage.xaml
10 | ///
11 | public partial class MecabDictPage : Page
12 | {
13 | public MecabDictPage()
14 | {
15 | InitializeComponent();
16 | }
17 |
18 | private void ChoosePathBtn_Click(object sender, RoutedEventArgs e)
19 | {
20 | FolderBrowserDialog dialog = new();
21 | if (dialog.ShowDialog() == DialogResult.OK)
22 | {
23 | PathBox.Text = dialog.SelectedPath;
24 | Common.appSettings.Mecab_dicPath = PathBox.Text;
25 | }
26 | }
27 |
28 | protected override void OnInitialized(EventArgs e)
29 | {
30 | base.OnInitialized(e);
31 | PathBox.Text = Common.appSettings.Mecab_dicPath;
32 | }
33 |
34 | private void ClearPathBtn_Click(object sender, RoutedEventArgs e)
35 | {
36 | PathBox.Text = string.Empty;
37 | Common.appSettings.Mecab_dicPath = PathBox.Text;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/DictionaryPages/XxgJpZhDictPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
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 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/BaiduOCRSettingsPage.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 OCRLibrary;
16 |
17 | namespace MisakaTranslator_WPF.SettingsPages.OCRPages
18 | {
19 | ///
20 | /// BaiduOCRPage.xaml 的交互逻辑
21 | ///
22 | public partial class BaiduOCRPage : Page
23 | {
24 | public BaiduOCRPage()
25 | {
26 | InitializeComponent();
27 | APIKEYBox.Text = Common.appSettings.BDOCR_APIKEY;
28 | SecretKeyBox.Text = Common.appSettings.BDOCR_SecretKey;
29 | }
30 |
31 | private void AuthTestBtn_Click(object sender, RoutedEventArgs e)
32 | {
33 | Common.appSettings.BDOCR_APIKEY = APIKEYBox.Text;
34 | Common.appSettings.BDOCR_SecretKey = SecretKeyBox.Text;
35 |
36 | if(APIKEYBox.Text.Length == 17)
37 | {
38 | HandyControl.Controls.Growl.Error($"百度智能云OCR {Application.Current.Resources["APITest_Error_Hint"]}\nDo not use fanyi.baidu.com endpoint.");
39 | return;
40 | }
41 |
42 | BaiduGeneralOCR bgocr = new BaiduGeneralOCR();
43 |
44 | bool ret = bgocr.OCR_Init(APIKEYBox.Text, SecretKeyBox.Text);
45 |
46 | if (ret == true)
47 | {
48 | HandyControl.Controls.Growl.Success($"百度智能云OCR {Application.Current.Resources["APITest_Success_Hint"]}");
49 | }
50 | else
51 | {
52 | HandyControl.Controls.Growl.Error($"百度智能云OCR {Application.Current.Resources["APITest_Error_Hint"]}\n{bgocr.GetLastError()}");
53 | }
54 | }
55 |
56 | private void ApplyBtn_Click(object sender, RoutedEventArgs e)
57 | {
58 | System.Diagnostics.Process.Start(BaiduGeneralOCR.GetUrl_allpyAPI());
59 | }
60 |
61 | private void DocBtn_Click(object sender, RoutedEventArgs e)
62 | {
63 | System.Diagnostics.Process.Start(BaiduGeneralOCR.GetUrl_Doc());
64 | }
65 |
66 | private void BillBtn_Click(object sender, RoutedEventArgs e)
67 | {
68 | System.Diagnostics.Process.Start(BaiduGeneralOCR.GetUrl_bill());
69 | }
70 | }
71 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/OCRGeneralSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/TencentOCRSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/OCRPages/TesseractCliSettingsPage.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 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/SoftwareSettingsPage.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/SoftwareSettingsPage.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 | /// SoftwareSettingsPage.xaml 的交互逻辑
20 | ///
21 | public partial class SoftwareSettingsPage : Page
22 | {
23 | public SoftwareSettingsPage()
24 | {
25 | InitializeComponent();
26 |
27 | var appSettingsOnClickCloseButton = Common.appSettings.OnClickCloseButton;
28 | switch (appSettingsOnClickCloseButton)
29 | {
30 | case "Minimization":
31 | MinimizationRadioButton.IsChecked = true;
32 | break;
33 | case "Exit":
34 | ExitRadioButton.IsChecked = true;
35 | break;
36 | }
37 |
38 | GrowlEnabledCheckBox.IsChecked = Common.appSettings.GrowlEnabled;
39 | }
40 |
41 | private void RadioButtonBase_OnClick(object sender, RoutedEventArgs e)
42 | {
43 | var radioButton = sender as RadioButton;
44 | switch (radioButton.Name)
45 | {
46 | case "MinimizationRadioButton":
47 | Common.appSettings.OnClickCloseButton = "Minimization";
48 | break;
49 | case "ExitRadioButton":
50 | Common.appSettings.OnClickCloseButton = "Exit";
51 | break;
52 | }
53 | }
54 |
55 | private void GrowlEnabledCheckBox_Click(object sender, RoutedEventArgs e)
56 | {
57 | Common.appSettings.GrowlEnabled = GrowlEnabledCheckBox.IsChecked.Value;
58 | }
59 | }
60 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/SettingsPages/TTSSettingsPage.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 |
--------------------------------------------------------------------------------
/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 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/GameNameDialog.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using HandyControl.Controls;
5 | using SQLHelperLibrary;
6 |
7 | namespace MisakaTranslator_WPF
8 | {
9 | ///
10 | /// GameNameDialog.xaml 的交互逻辑
11 | ///
12 | public partial class GameNameDialog : UserControl
13 | {
14 | List gameInfolst;
15 | int gid; //当前选中的顺序,并非游戏ID
16 | public GameNameDialog(List gameInfo, int id)
17 | {
18 | InitializeComponent();
19 | gameInfolst = gameInfo;
20 | gid = id;
21 | }
22 |
23 | private void Button_Click(object sender, RoutedEventArgs e)
24 | {
25 | if (nameBox.Text != "")
26 | {
27 | GameLibraryHelper.UpdateGameNameByID(gameInfolst[gid].GameID, nameBox.Text);
28 | HandyControl.Controls.MessageBox.Show("已修改,重启后生效!", "提示");
29 | }
30 |
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/SelectTransLangDialog.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/UserControls/SelectTransLangDialog.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.UserControls
18 | {
19 | ///
20 | /// SelectTransLangDialog.xaml 的交互逻辑
21 | ///
22 | public partial class SelectTransLangDialog : UserControl
23 | {
24 | private readonly List _langList;
25 | ComicTranslator.ComicTransMainWindow _win;
26 |
27 | public SelectTransLangDialog(ComicTranslator.ComicTransMainWindow win)
28 | {
29 | InitializeComponent();
30 |
31 | _win = win;
32 |
33 | _langList = CommonFunction.lstLanguage.Keys.ToList();
34 | SrcLangCombox.ItemsSource = _langList;
35 | DstLangCombox.ItemsSource = _langList;
36 |
37 | SrcLangCombox.SelectedIndex = 2;
38 | DstLangCombox.SelectedIndex = 0;
39 | }
40 |
41 | private void Button_Click(object sender, RoutedEventArgs e)
42 | {
43 | _win.SrcLang = CommonFunction.lstLanguage[_langList[SrcLangCombox.SelectedIndex]];
44 | _win.DstLang = CommonFunction.lstLanguage[_langList[DstLangCombox.SelectedIndex]];
45 |
46 | if (_win.SrcLang == "" || _win.DstLang == "" || _win.SrcLang == _win.DstLang)
47 | {
48 | HandyControl.Controls.Growl.ErrorGlobal(Application.Current.Resources["ChooseLanguagePage_NextErrorHint"].ToString());
49 | _win.Close();
50 | }
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/MisakaTranslator-WPF/logo.ico
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/textRepairPlugins/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/MisakaTranslator-WPF/textRepairPlugins/__init__.py
--------------------------------------------------------------------------------
/MisakaTranslator-WPF/textRepairPlugins/example.py:
--------------------------------------------------------------------------------
1 | # coding=utf-8
2 | # 不加上面那行就不能写中文注释
3 | # Iron Python自带了re,如果要使用其他标准库,可以把Python2.7 lib目录下的文件复制到翻译器的lib目录下。
4 | import re
5 |
6 | # 函数名必须是process,接受一个string,返回一个string,其他随意
7 | def process(source):
8 | #去除HTML标签
9 | source = re.sub("<[^>]+>", "", source)
10 | source = re.sub("&[^;]+;", "", source)
11 | #句子去重(根据空格分割句子,取最后一段)
12 | parts = [p for p in source.split(" ") if len(p) > 0]
13 | return parts[-1] if len(parts) != 0 else ""
14 |
--------------------------------------------------------------------------------
/NativeMethods.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://aka.ms/CsWin32.schema.json",
3 | "useSafeHandles": false
4 | }
5 |
--------------------------------------------------------------------------------
/OCRLibrary/NativeMethods.txt:
--------------------------------------------------------------------------------
1 | // enum
2 | Windows.Win32.UI.WindowsAndMessaging.IMAGE_FLAGS
3 |
4 | // function
5 | Windows.Win32.Graphics.Gdi.BitBlt
6 | Windows.Win32.Graphics.Gdi.CreateCompatibleBitmap
7 | Windows.Win32.Graphics.Gdi.CreateCompatibleDC
8 | Windows.Win32.Graphics.Gdi.DeleteDC
9 | Windows.Win32.Graphics.Gdi.DeleteObject
10 | Windows.Win32.Graphics.Gdi.SelectObject
11 | Windows.Win32.Graphics.Gdi.GetWindowDC
12 | Windows.Win32.Graphics.Gdi.ReleaseDC
13 | Windows.Win32.UI.WindowsAndMessaging.DestroyIcon
14 | Windows.Win32.UI.WindowsAndMessaging.GetCursorPos
15 | Windows.Win32.UI.WindowsAndMessaging.GetDesktopWindow
16 | Windows.Win32.UI.WindowsAndMessaging.GetWindowRect
17 | Windows.Win32.UI.WindowsAndMessaging.PrivateExtractIcons
18 | Windows.Win32.UI.WindowsAndMessaging.ShowWindow
19 |
--------------------------------------------------------------------------------
/OCRLibrary/OCRCommon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace OCRLibrary
5 | {
6 | public static class OCRCommon
7 | {
8 | public static List lstOCR = new List()
9 | {
10 | "BaiduOCR",
11 | "BaiduFanyiOCR",
12 | "TencentOCR",
13 | "TesseractOCR",
14 | "TesseractCli"
15 | };
16 |
17 | static OCRCommon()
18 | {
19 | if (Environment.OSVersion.Version.Build >= 10240)
20 | {
21 | lstOCR.Add("WindowsOCR");
22 | }
23 | }
24 |
25 | public static List GetOCRList()
26 | {
27 | return lstOCR;
28 | }
29 |
30 | public static OCREngine OCRAuto(string ocr)
31 | {
32 | switch (ocr)
33 | {
34 | case "BaiduOCR":
35 | return new BaiduGeneralOCR();
36 | case "BaiduFanyiOCR":
37 | return new BaiduFanyiOCR();
38 | case "TencentOCR":
39 | return new TencentOCR();
40 | case "TesseractOCR":
41 | return new TesseractOCR();
42 | case "TesseractCli":
43 | return new TesseractCli();
44 | case "WindowsOCR":
45 | return new WindowsOCR();
46 | default:
47 | return null;
48 | }
49 | }
50 |
51 | public static System.Text.Json.JsonSerializerOptions JsonOP = new()
52 | {
53 | IncludeFields = true
54 | };
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/OCRLibrary/OCREngine.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace OCRLibrary
9 | {
10 | public abstract class OCREngine
11 | {
12 | protected string errorInfo;
13 | private IntPtr WinHandle;
14 | private Rectangle OCRArea;
15 | private bool isAllWin;
16 | private string imgProc;
17 | ///
18 | /// OCR处理,将图片上的文字提取得到一句话
19 | ///
20 | /// 欲处理的图片
21 | /// 返回识别结果,如果为空可通过GetLastError得到错误提示
22 | public abstract Task OCRProcessAsync(Bitmap img);
23 |
24 | ///
25 | /// OCR处理,根据设定的截图区域自动截图后识别
26 | ///
27 | /// 返回识别结果,如果为空可通过GetLastError得到错误提示
28 | public Task OCRProcessAsync()
29 | {
30 | Bitmap img = ScreenCapture.GetWindowRectCapture(WinHandle, OCRArea, isAllWin);
31 | if (img == null)
32 | {
33 | errorInfo = "未设置截图区域";
34 | return null;
35 | }
36 | Bitmap processedImg = ImageProcFunc.Auto_Thresholding(img, imgProc);
37 | return OCRProcessAsync(processedImg);
38 | }
39 |
40 | ///
41 | /// 设定截图区域
42 | ///
43 | /// (窗口模式)窗口句柄
44 | /// 截图区域
45 | /// 是否全屏截取
46 | public void SetOCRArea(IntPtr handle, Rectangle rec, bool AllWin)
47 | {
48 | WinHandle = handle;
49 | OCRArea = rec;
50 | isAllWin = AllWin;
51 | }
52 |
53 | ///
54 | /// 得到OCR区域截图
55 | ///
56 | ///
57 | public Bitmap GetOCRAreaCap()
58 | {
59 | return ScreenCapture.GetWindowRectCapture(WinHandle, OCRArea, isAllWin);
60 | }
61 |
62 | ///
63 | /// 设置OCR源语言
64 | ///
65 | /// 指定目标语言 OCR识别语言 jpn=日语 eng=英语
66 | public abstract void SetOCRSourceLang(string lang);
67 |
68 | ///
69 | /// 设置OCR图像预处理方法
70 | ///
71 | /// 指定处理方法 ImgFunc_NoDeal=不处理 ImgFunc_OTSU=OTSU二值化处理
72 | public void SetOCRSourceImgProc(string imgProc)
73 | {
74 | this.imgProc = imgProc;
75 | }
76 |
77 | ///
78 | /// OCR初始化,对于在线API,参数1和参数2有效
79 | ///
80 | /// 参数一 一般是appID
81 | /// 参数二 一般是密钥
82 | public abstract bool OCR_Init(string param1, string param2);
83 |
84 | ///
85 | /// 返回最后一次错误的ID或原因
86 | ///
87 | public string GetLastError()
88 | {
89 | return errorInfo;
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/OCRLibrary/OCRLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | true
6 | true
7 | true
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/OCRLibrary/ScreenCapture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 | using Windows.Win32;
5 | using Windows.Win32.Foundation;
6 | using Windows.Win32.Graphics.Gdi;
7 | using Windows.Win32.UI.WindowsAndMessaging;
8 |
9 | namespace OCRLibrary
10 | {
11 | public class ScreenCapture
12 | {
13 | ///
14 | /// 根据窗口HWND截取窗口
15 | ///
16 | ///
17 | ///
18 | public static Bitmap GetWindowCapture(IntPtr handle)
19 | {
20 | // get te hDC of the target window
21 | HDC hdcSrc = PInvoke.GetWindowDC((HWND)handle);
22 | PInvoke.ShowWindow((HWND)handle, SHOW_WINDOW_CMD.SW_SHOWNA);
23 | // get the size
24 | PInvoke.GetWindowRect((HWND)handle, out RECT windowRect);
25 | int width = windowRect.right - windowRect.left;
26 | int height = windowRect.bottom - windowRect.top;
27 | // create a device context we can copy to
28 | HDC hdcDest = PInvoke.CreateCompatibleDC(hdcSrc);
29 | // create a bitmap we can copy it to,
30 | // using GetDeviceCaps to get the width/height
31 | HBITMAP hBitmap = PInvoke.CreateCompatibleBitmap(hdcSrc, width, height);
32 | // select the bitmap object
33 | HGDIOBJ hOld = PInvoke.SelectObject(hdcDest, hBitmap);
34 | // bitblt over
35 | PInvoke.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, 0, 0, ROP_CODE.SRCCOPY | ROP_CODE.CAPTUREBLT);
36 | // restore selection
37 | PInvoke.SelectObject(hdcDest, hOld);
38 | // clean up
39 | PInvoke.DeleteDC(hdcDest);
40 | PInvoke.ReleaseDC((HWND)handle, hdcSrc);
41 | // get a .NET image object for it
42 | Bitmap img = Image.FromHbitmap(hBitmap);
43 | // free up the Bitmap object
44 | PInvoke.DeleteObject(hBitmap);
45 | return img;
46 | }
47 |
48 | ///
49 | /// 得到截图中的某个区域
50 | ///
51 | ///
52 | ///
53 | /// 是否是全屏截屏
54 | ///
55 | public static Bitmap GetWindowRectCapture(IntPtr handle, Rectangle rec, bool isAllWin)
56 | {
57 | if (rec.Width == 0 || rec.Height == 0)
58 | return null;
59 |
60 | using (Bitmap img = isAllWin? GetAllWindow():GetWindowCapture(handle))
61 | return img.Clone(rec, img.PixelFormat);
62 | }
63 |
64 | ///
65 | /// 全屏截屏
66 | ///
67 | ///
68 | public static Bitmap GetAllWindow()
69 | {
70 | int w = Screen.PrimaryScreen.Bounds.Width;
71 | int h = Screen.PrimaryScreen.Bounds.Height;
72 |
73 | Bitmap bitmap = new Bitmap(w, h);
74 | Graphics graphics = Graphics.FromImage(bitmap);
75 | graphics.CopyFromScreen(0, 0, 0, 0, new Size(w, h));
76 | graphics.Dispose();
77 |
78 | return bitmap;
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/OCRLibrary/TesseractCli.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Drawing;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 |
10 | namespace OCRLibrary
11 | {
12 | public class TesseractCli : OCREngine
13 | {
14 | private string path;
15 | private string args;
16 |
17 | public override Task OCRProcessAsync(Bitmap img)
18 | {
19 | try
20 | {
21 | Process p = Process.Start(new ProcessStartInfo()
22 | {
23 | FileName = path,
24 | Arguments = "- - " + args,
25 | UseShellExecute = false,
26 | CreateNoWindow = true,
27 | RedirectStandardInput = true,
28 | RedirectStandardOutput = true,
29 | RedirectStandardError = true,
30 | StandardOutputEncoding = Encoding.UTF8
31 | });
32 | var imgdata = ImageProcFunc.Image2Bytes(img);
33 | p.StandardInput.BaseStream.Write(imgdata, 0, imgdata.Length);
34 | p.StandardInput.Close();
35 | p.WaitForExit();
36 |
37 | string err = p.StandardError.ReadToEnd();
38 | if (err.ToLower().Contains("error"))
39 | {
40 | errorInfo = err;
41 | return Task.FromResult(null);
42 | }
43 |
44 | string result = p.StandardOutput.ReadToEnd();
45 | p.Dispose();
46 | return Task.FromResult(result);
47 | }
48 | catch (Exception ex)
49 | {
50 | errorInfo = ex.Message;
51 | return Task.FromResult(null);
52 | }
53 | }
54 |
55 | public override bool OCR_Init(string path, string args)
56 | {
57 | if(!File.Exists(path))
58 | return false;
59 | this.path = path;
60 | this.args = args;
61 | return true;
62 | }
63 |
64 | public override void SetOCRSourceLang(string lang)
65 | {
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/OCRLibrary/TesseractOCR.cs:
--------------------------------------------------------------------------------
1 | extern alias Tesseract;
2 | using tesseract = Tesseract.TesseractOCR;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Drawing;
6 | using System.Drawing.Imaging;
7 | using System.IO;
8 | using System.Linq;
9 | using System.Text;
10 | using System.Threading.Tasks;
11 |
12 | namespace OCRLibrary
13 | {
14 | public class TesseractOCR : OCREngine
15 | {
16 | private string srcLangCode; //OCR识别语言 jpn=日语 eng=英语
17 | private tesseract.Engine engine;
18 |
19 | public override Task OCRProcessAsync(Bitmap img)
20 | {
21 | try
22 | {
23 | var stream = new MemoryStream();
24 | img.Save(stream, ImageFormat.Bmp);
25 | var pix = tesseract.Pix.Image.LoadFromMemory(stream);
26 |
27 | var recog = engine.Process(pix);
28 | string text = recog.Text;
29 | stream.Dispose();
30 | recog.Dispose();
31 |
32 | return Task.FromResult(text);
33 | }
34 | catch (Exception ex)
35 | {
36 | errorInfo = ex.Message;
37 | return Task.FromResult(null);
38 | }
39 | }
40 |
41 | public override bool OCR_Init(string param1 = "", string param2 = "")
42 | {
43 | try
44 | {
45 | engine = new tesseract.Engine(Environment.CurrentDirectory + "\\tessdata", srcLangCode);
46 | return true;
47 | }
48 | catch(Exception ex)
49 | {
50 | errorInfo = ex.Message;
51 | return false;
52 | }
53 | }
54 |
55 | public override void SetOCRSourceLang(string lang)
56 | {
57 | srcLangCode = lang;
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/OCRLibrary/WindowsOCR.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Drawing.Imaging;
5 | using System.IO;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using Windows.Globalization;
9 | using Windows.Graphics.Imaging;
10 | using Windows.Media.Ocr;
11 | using Windows.System;
12 |
13 | namespace OCRLibrary
14 | {
15 | public class WindowsOCR : OCREngine
16 | {
17 | public string srcLangCode;
18 | private OcrEngine rtOcr;
19 |
20 | public override async Task OCRProcessAsync(Bitmap img)
21 | {
22 | try
23 | {
24 | using var stream = new Windows.Storage.Streams.InMemoryRandomAccessStream();
25 | img.Save(stream.AsStream(), ImageFormat.Bmp);
26 | var decoder = await BitmapDecoder.CreateAsync(stream);
27 | var bitmap = await decoder.GetSoftwareBitmapAsync();
28 | var res = await rtOcr.RecognizeAsync(bitmap);
29 | return res.Text;
30 | }
31 | catch (Exception ex)
32 | {
33 | errorInfo = ex.Message;
34 | return string.Empty;
35 | }
36 |
37 | }
38 |
39 | public override bool OCR_Init(string param1 = "", string param2 = "")
40 | {
41 | try
42 | {
43 | Language lang = new(srcLangCode);
44 | rtOcr = OcrEngine.TryCreateFromLanguage(lang);
45 | if (rtOcr == null)
46 | {
47 | if (MessageBox.Show($"请在Windows语言设置中添加目标语言并等待OCR组件安装完成。{Environment.NewLine}Please add the target language in Windows Settings and wait for OCR component to be installed.", "Error", MessageBoxButton.OKCancel, MessageBoxImage.Error) == MessageBoxResult.OK)
48 | {
49 | _ = Launcher.LaunchUriAsync(new Uri("ms-settings:regionlanguage-adddisplaylanguage"));
50 | }
51 | return false;
52 | }
53 | return true;
54 | }
55 | catch (Exception ex)
56 | {
57 | errorInfo = ex.Message;
58 | return false;
59 | }
60 | }
61 |
62 | public override void SetOCRSourceLang(string lang)
63 | {
64 | srcLangCode = lang switch
65 | {
66 | "jpn" => "ja",
67 | "eng" => "en",
68 | _ => lang
69 | };
70 | }
71 |
72 | public IReadOnlyList GetSupportLang()
73 | {
74 | return OcrEngine.AvailableRecognizerLanguages;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/SQLHelperLibrary/SQLHelperLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/THANKLIST.MD:
--------------------------------------------------------------------------------
1 | # 贡献者名单
2 |
3 | ## 感谢所有对本软件提供反馈、建议和在制作过程中提供帮助的人
4 |
5 | ### 以下是资助作者开发的网友(排名不分先后)
6 |
7 | * 樱桦
8 | * 昔日
9 | * (空白名)
10 | * 莎狗芙芙
11 | * F+*
12 | * 凌枫Haku
13 | * 镜花╰ァ水月
14 | * WSHCK
15 | * 余悸
16 | * 平野宿地
17 | * 约定的彼方
18 | * Disviel
19 | * 陈旧
20 | * 金风
21 | * 神代杏は勇者である
22 |
23 | ### 以下是热心提供反馈和建议的网友(排名不分先后)
24 |
25 | * Disviel
26 | * 幽寂
27 | * 禦滝尹の介
28 | * 陈旧
29 | * 梓柒
30 | * unlsycn
31 | * woctordho
32 | * lgztx
33 | * 洛奚
34 | * 夜夜
35 | * 神代杏は勇者である
36 | * 迷の子
37 |
38 |
39 |
40 | 如果您也对本软件提供了支持却没有出现在名单上,请联系作者处理,对您造成的不便表示歉意。
41 |
--------------------------------------------------------------------------------
/TTSHelperLibrary/TTSHelperLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/TTSHelperLibrary/TextSpeechHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Speech.Synthesis;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TTSHelperLibrary
9 | {
10 | public class TextSpeechHelper
11 | {
12 | private SpeechSynthesizer synth;
13 |
14 | public TextSpeechHelper() {
15 | synth = new SpeechSynthesizer();
16 | }
17 |
18 | ~TextSpeechHelper() {
19 | synth = null;
20 | }
21 |
22 | ///
23 | /// 获得当前所有可用的TTS引擎
24 | ///
25 | /// 返回引擎信息的集合
26 | public List GetAllTTSEngine() {
27 | List res = new List();
28 |
29 | foreach (InstalledVoice iv in synth.GetInstalledVoices())
30 | {
31 | res.Add(iv.VoiceInfo.Name);
32 | }
33 |
34 | if (res.Count > 0)
35 | {
36 | return res;
37 | }
38 | else
39 | {
40 | return null;
41 | }
42 | }
43 |
44 | ///
45 | /// 设置TTS语音的音量
46 | ///
47 | /// 音量大小 0-100之间
48 | public void SetVolume(int vol) {
49 | synth.Volume = vol;
50 | }
51 |
52 | ///
53 | /// 设置TTS语音的语速
54 | ///
55 | /// 语速的值 -10~10之间 值越小速度越慢
56 | public void SetRate(int ra)
57 | {
58 | synth.Rate = ra;
59 | }
60 |
61 | ///
62 | /// 设置TTS的语音
63 | ///
64 | /// 通过GetAllTTSEngine()得到的VoiceInfo对象的Name属性
65 | public void SetTTSVoice(string name) {
66 | if (name != null && name != "") {
67 | synth.SelectVoice(name);
68 | }
69 | }
70 |
71 | ///
72 | /// 以同步方式说出字符串的内容。
73 | ///
74 | /// 要说的字符串
75 | public void Speak(string text) {
76 | synth.Speak(text);
77 | }
78 |
79 | ///
80 | /// 以异步方式说出字符串的内容。
81 | ///
82 | /// 要说的字符串
83 | public void SpeakAsync(string text) {
84 | synth.SpeakAsync(text);
85 | }
86 |
87 | ///
88 | /// 取消所有排队、 异步语音合成操作。
89 | ///
90 | public void CancelAllSpeakAsync() {
91 | synth.SpeakAsyncCancelAll();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/TextHookLibrary/ClipboardNotification.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows.Forms;
8 | using Windows.Win32;
9 | using Windows.Win32.Foundation;
10 |
11 | namespace TextHookLibrary
12 | {
13 | public class ClipboardNotification
14 | {
15 | HWND winHandle;
16 | HWND ClipboardViewerNext;
17 |
18 | public ClipboardNotification(IntPtr winH)
19 | {
20 | winHandle = (HWND)winH;
21 | }
22 |
23 | public void RegisterClipboardViewer()
24 | {
25 | ClipboardViewerNext = PInvoke.SetClipboardViewer(winHandle);
26 | }
27 |
28 | public void UnregisterClipboardViewer()
29 | {
30 | PInvoke.ChangeClipboardChain(winHandle, ClipboardViewerNext);
31 | }
32 | }
33 |
34 |
35 | ///
36 | /// 剪贴板更新事件
37 | ///
38 | /// 更新的文本
39 | public delegate void ClipboardUpdateEventHandler(string ClipboardText);
40 |
41 | ///
42 | /// 使用一个隐藏窗口来接受窗口消息,对外就是剪贴板监视类
43 | ///
44 | public class ClipboardMonitor : Form
45 | {
46 | public event ClipboardUpdateEventHandler onClipboardUpdate;
47 | private IntPtr hWnd;
48 | public ClipboardNotification cn;
49 |
50 | public ClipboardMonitor(ClipboardUpdateEventHandler onClipboardUpdate)
51 | {
52 | this.onClipboardUpdate = onClipboardUpdate;
53 | this.hWnd = this.Handle;
54 | cn = new ClipboardNotification(hWnd);
55 | cn.RegisterClipboardViewer();
56 | }
57 |
58 | ~ClipboardMonitor()
59 | {
60 | cn.UnregisterClipboardViewer();
61 | }
62 |
63 | protected override void WndProc(ref Message m)
64 | {
65 | switch ((int)m.Msg)
66 | {
67 | case 0x308: //WM_DRAWCLIPBOARD
68 | {
69 | IDataObject iData = Clipboard.GetDataObject();
70 | if (iData != null)
71 | {
72 | string str = (string)iData.GetData(DataFormats.UnicodeText);
73 | this.onClipboardUpdate(str);
74 | }
75 | else {
76 | this.onClipboardUpdate("剪贴板更新失败 ClipBoard Update Failed");
77 | }
78 | break;
79 | }
80 | default:
81 | {
82 | base.WndProc(ref m);
83 | break;
84 | }
85 | }
86 | }
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/TextHookLibrary/NativeMethods.txt:
--------------------------------------------------------------------------------
1 | // function
2 | Windows.Win32.System.DataExchange.ChangeClipboardChain
3 | Windows.Win32.System.DataExchange.SetClipboardViewer
4 |
--------------------------------------------------------------------------------
/TextHookLibrary/RecvEventArgs.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 TextHookLibrary
8 | {
9 | ///
10 | /// TextHook数据结构体
11 | ///
12 | public class TextHookData{
13 | ///
14 | /// 游戏进程ID
15 | ///
16 | public int GamePID { set; get; }
17 |
18 | ///
19 | /// Hook入口地址
20 | ///
21 | public string HookAddress { set; get; }
22 |
23 | ///
24 | /// 通用特殊码
25 | ///
26 | public string HookCode { set; get; }
27 |
28 | ///
29 | /// MisakaTranslator专用特殊码
30 | /// 注意 本软件单独处理一套特殊码规则:即Textrator输出的从进程到方法名之间的三组数字做记录
31 | /// 格式如下:特殊码【值1:值2:值3】(值1即HookAddress)
32 | ///
33 | public string MisakaHookCode { set; get; }
34 |
35 | ///
36 | /// Hook方法名
37 | ///
38 | public string HookFunc { set; get; }
39 |
40 | ///
41 | /// 实际内容
42 | ///
43 | public string Data { set; get; }
44 | }
45 |
46 |
47 | ///
48 | /// Hook功能选择界面提供的数据收到事件,满足条件:任何一个不重复的输出都将触发此事件
49 | ///
50 | ///
51 | ///
52 | public delegate void HookFunSelectDataRecvEventHandler(object sender, HookSelectRecvEventArgs e);
53 |
54 | ///
55 | /// Hook功能重新选择界面提供的数据收到事件,满足条件:特殊码满足,但附加特殊码不重复的输出都将触发此事件
56 | ///
57 | ///
58 | ///
59 | public delegate void HookFunReSelectDataRecvEventHandler(object sender, HookSelectRecvEventArgs e);
60 |
61 | ///
62 | /// 翻译界面或文本去重界面提供的数据收到事件,满足条件:特殊码满足,且附加特殊码满足或为NoMulti将触发此事件
63 | ///
64 | ///
65 | ///
66 | public delegate void SolvedDataRecvEventHandler(object sender, SolvedDataRecvEventArgs e);
67 |
68 | public class HookSelectRecvEventArgs : EventArgs
69 | {
70 | //方法序号(仅在HookFunSelectDataRecvEventHandler和HookFunReSelectDataRecvEventHandler事件中有效)
71 | //这个序号可以直接用于ListView
72 | public int Index { get; set;}
73 | public TextHookData Data { get; set; }
74 | }
75 |
76 | public class SolvedDataRecvEventArgs : EventArgs
77 | {
78 | public TextHookData Data { get; set; }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/TextHookLibrary/TextHookLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | true
5 | true
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/TextHookLibrary/TextHostLib.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TextHookLibrary
9 | {
10 | public class TextHostLib
11 | {
12 | public delegate void ProcessEvent(Int32 processId);
13 | public delegate void OnCreateThreadFunc(Int64 threadId,
14 | UInt32 processId,
15 | Int64 address,
16 | Int64 context,
17 | Int64 subcontext,
18 | [MarshalAs(UnmanagedType.LPWStr)] string name,
19 | [MarshalAs(UnmanagedType.LPWStr)] string hookCode
20 | );
21 | public delegate void OnRemoveThreadFunc(Int64 threadId);
22 | public delegate void OnOutputFunc(Int64 threadId, [MarshalAs(UnmanagedType.LPWStr)] string data);
23 |
24 | [DllImport("texthost.dll")]
25 | public static extern Int32 TextHostInit(ProcessEvent OnConnect,
26 | ProcessEvent OnDisconnect,
27 | OnCreateThreadFunc OnCreateThread,
28 | OnRemoveThreadFunc OnRemoveThread,
29 | OnOutputFunc OnOutput
30 | );
31 |
32 | [DllImport("texthost.dll")]
33 | public static extern Int32 InsertHook(UInt32 processId, [MarshalAs(UnmanagedType.LPWStr)] string hookCode);
34 |
35 | [DllImport("texthost.dll")]
36 | public static extern Int32 RemoveHook(UInt32 processId, Int64 address);
37 |
38 | [DllImport("texthost.dll")]
39 | public extern static Int32 InjectProcess(UInt32 processId);
40 |
41 | [DllImport("texthost.dll")]
42 | public extern static Int32 DetachProcess(UInt32 processId);
43 |
44 | [DllImport("texthost.dll")]
45 | public extern static Int32 AddClipboardThread(IntPtr windowHandle);
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TextRepairLibrary/TextRepairLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Tools/ProcessHelperExt.cs:
--------------------------------------------------------------------------------
1 | // 无参使用时输出所有进程的 pid|绝对路径,有参使用时输出指定pid进程的路径
2 | // 编译:csc ProcessHelperExt.cs /o /platform:x64
3 | using System;
4 | using System.Diagnostics;
5 |
6 | if (args.Length > 1)
7 | return 1;
8 |
9 | try
10 | {
11 | if (args.Length == 1)
12 | {
13 | int pid = int.Parse(args[0]);
14 | try
15 | {
16 | Process p = Process.GetProcessById(pid);
17 | Console.WriteLine(p.MainModule.FileName);
18 | }
19 | catch (ArgumentException) { return 3; } // 不存在pid对应的进程
20 | catch (InvalidOperationException) { return 3; } // 进程已退出
21 | }
22 | else
23 | foreach (var p in Process.GetProcesses())
24 | try { Console.WriteLine("{0}|{1}", p.Id, p.MainModule.FileName); }
25 | catch (System.ComponentModel.Win32Exception) { } // 跳过权限不够的进程
26 | catch (InvalidOperationException) { } // 进程已退出
27 |
28 | return 0;
29 | }
30 | catch (Exception e)
31 | {
32 | Console.Error.WriteLine(e);
33 | return 2;
34 | }
35 |
--------------------------------------------------------------------------------
/TransOptimizationLibrary/AfterTransHandle.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 TransOptimizationLibrary
8 | {
9 | public class AfterTransHandle
10 | {
11 | NounTransOptimization nto;
12 | BeforeTransHandle bth;
13 |
14 | public AfterTransHandle(BeforeTransHandle b)
15 | {
16 | bth = b;
17 | }
18 |
19 | ///
20 | /// 外部调用的共用方法,自动进行翻译后处理
21 | ///
22 | /// 通过翻译接口翻译后的句子
23 | /// 处理后句子
24 | public string AutoHandle(string text)
25 | {
26 | if (text == null || text == "")
27 | {
28 | return "";
29 | }
30 |
31 | //目前只支持名词的预处理,处理后检查是否有对话人名,如果有则加上
32 | if (bth.GetPeopleChatName() != "") {
33 | text = bth.GetPeopleChatName() + ": " + text;
34 | }
35 |
36 | return text;
37 | }
38 |
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/TransOptimizationLibrary/BeforeTransHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TransOptimizationLibrary
9 | {
10 | public class BeforeTransHandle
11 | {
12 |
13 | NounTransOptimization nto;
14 |
15 |
16 |
17 | public BeforeTransHandle(string gameName,string srcLang,string dstLang) {
18 | if (!Directory.Exists(Environment.CurrentDirectory + "\\TransOptimization"))
19 | Directory.CreateDirectory(Environment.CurrentDirectory + "\\TransOptimization");
20 |
21 | nto = new NounTransOptimization(gameName,srcLang,dstLang);
22 | }
23 |
24 | ///
25 | /// 外部调用的共用方法,自动进行翻译前处理
26 | ///
27 | /// Hook或OCR得到的原句
28 | /// 处理后句子
29 | public string AutoHandle(string text) {
30 | if (text == null || text == "") {
31 | return "";
32 | }
33 |
34 | //暂支持人名地名预处理
35 | return nto.ReplacePeoPleLocNameInSentence(text);
36 |
37 | }
38 |
39 | ///
40 | /// 显示在结果中的对话人名 以 人名:对话 的形式展示
41 | ///
42 | ///
43 | public string GetPeopleChatName() {
44 | return nto.PeopleChatName;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/TransOptimizationLibrary/TransOptimizationLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/TranslatorLibrary/GoogleCNTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using System.Web;
3 |
4 | namespace TranslatorLibrary
5 | {
6 | public class GoogleCNTranslator : ITranslator
7 | {
8 | private string errorInfo;//错误信息
9 |
10 | public string GetLastError()
11 | {
12 | return errorInfo;
13 | }
14 |
15 | public async Task TranslateAsync(string sourceText, string desLang, string srcLang)
16 | {
17 | if (desLang == "zh")
18 | desLang = "zh-cn";
19 | if (srcLang == "zh")
20 | srcLang = "zh-cn";
21 |
22 | if (desLang == "jp")
23 | desLang = "ja";
24 | if (srcLang == "jp")
25 | srcLang = "ja";
26 |
27 | if (desLang == "kr")
28 | desLang = "ko";
29 | if (srcLang == "kr")
30 | srcLang = "ko";
31 |
32 | string fun = string.Format(@"TL('{0}')", sourceText);
33 |
34 | string googleTransUrl = "https://translate.googleapis.com/translate_a/single?client=gtx&dt=t&sl=" + srcLang + "&tl=" + desLang + "&q=" + HttpUtility.UrlEncode(sourceText);
35 |
36 | var hc = CommonFunction.GetHttpClient();
37 |
38 | try
39 | {
40 | var ResultHtml = await hc.GetStringAsync(googleTransUrl);
41 |
42 | dynamic TempResult = System.Text.Json.JsonSerializer.Deserialize(ResultHtml, CommonFunction.JsonOP);
43 |
44 | string ResultText = "";
45 |
46 | for (int i = 0; i < TempResult[0].GetArrayLength(); i++)
47 | {
48 | ResultText += TempResult[0][i][0];
49 | }
50 |
51 | return ResultText;
52 | }
53 | catch (System.Net.Http.HttpRequestException ex)
54 | {
55 | errorInfo = ex.Message;
56 | return null;
57 | }
58 | catch (System.Threading.Tasks.TaskCanceledException ex)
59 | {
60 | errorInfo = ex.Message;
61 | return null;
62 | }
63 | }
64 |
65 | public void TranslatorInit(string param1 = "", string param2 = "") {; }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/TranslatorLibrary/ITranslator.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 TranslatorLibrary
8 | {
9 | public interface ITranslator
10 | {
11 | ///
12 | /// 翻译API初始化
13 | ///
14 | /// 参数一 一般是appID或者路径(为路径时参数二无效)
15 | /// 参数二 一般是密钥
16 | void TranslatorInit(string param1,string param2);
17 |
18 | ///
19 | /// 翻译一条语句
20 | ///
21 | /// 源文本
22 | /// 目标语言
23 | /// 源语言
24 | /// 翻译后的语句,如果翻译有错误会返回空,可以通过GetLastError来获取错误
25 | Task TranslateAsync(string sourceText, string desLang, string srcLang);
26 |
27 | ///
28 | /// 返回最后一次错误的ID或原因
29 | ///
30 | ///
31 | string GetLastError();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/TranslatorLibrary/JBeijingTranslator.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TranslatorLibrary
9 | {
10 | public class JBeijingTranslator : ITranslator
11 | {
12 | /*
13 | * 根据猜测得到的DLL函数 来源 https://github.com/Artikash/VNR-Core/blob/6ed038bda9dcd35696040bd45d31afa6a30e8978/py/libs/jbeijing/jbjct.py
14 | int __cdecl JC_Transfer_Unicode(
15 | HWND hwnd,
16 | UINT fromCodePage,
17 | UINT toCodePage,
18 | int unknown,
19 | int unknown,
20 | LPCWSTR from,
21 | LPWSTR to,
22 | int &toCapacity,
23 | LPWSTR buffer,
24 | int &bufferCapacity)
25 | */
26 |
27 | [DllImport("JBJCT.dll", EntryPoint = "JC_Transfer_Unicode", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
28 | private static extern int JC_Transfer_Unicode(
29 | int hwnd,
30 | uint fromCodePage,
31 | uint toCodePage,
32 | int unknown,
33 | int unknown1,
34 | IntPtr from,
35 | IntPtr to,
36 | ref int toCapacity,
37 | IntPtr buffer,
38 | ref int bufferCapacity);
39 |
40 | public string JBJCTDllPath;//DLL路径
41 | private string errorInfo;//错误信息
42 |
43 | public string GetLastError()
44 | {
45 | return errorInfo;
46 | }
47 |
48 | public Task TranslateAsync(string sourceText, string desLang, string srcLang)
49 | {
50 | string JBeijingTranslatorPath = JBJCTDllPath;
51 |
52 | if (JBeijingTranslatorPath == "")
53 | {
54 | return Task.FromResult(null);
55 | }
56 |
57 | /*
58 | CP932 SAP Shift-JIS
59 | CP950 SAP 繁体中文
60 | CP936 SAP 简体中文
61 | */
62 |
63 | string path = Environment.CurrentDirectory;
64 | Environment.CurrentDirectory = JBeijingTranslatorPath;
65 |
66 | IntPtr jp = Marshal.StringToHGlobalUni(sourceText);
67 |
68 | IntPtr jp2 = Marshal.AllocHGlobal(3000);
69 | IntPtr jp3 = Marshal.AllocHGlobal(3000);
70 |
71 | int p1 = 1500;
72 | int p2 = 1500;
73 |
74 | try
75 | {
76 | int a = JC_Transfer_Unicode(0, 932, 936, 1, 1, jp, jp2, ref p1, jp3, ref p2);
77 | }
78 | catch (Exception ex)
79 | {
80 | errorInfo = ex.Message;
81 | return Task.FromResult(null);
82 | }
83 |
84 | Environment.CurrentDirectory = path;
85 |
86 | string ret = Marshal.PtrToStringAuto(jp2);
87 |
88 | Marshal.FreeHGlobal(jp);
89 | Marshal.FreeHGlobal(jp2);
90 | Marshal.FreeHGlobal(jp3);
91 |
92 | return Task.FromResult(ret);
93 | }
94 |
95 | public void TranslatorInit(string param1, string param2 = "")
96 | {
97 | JBJCTDllPath = param1;
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/TranslatorLibrary/TranslatorLibrary.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/TranslatorLibrary/YandexTranslator.cs:
--------------------------------------------------------------------------------
1 | using System.Threading.Tasks;
2 | using System.Text.Json;
3 | using System.Web;
4 |
5 | namespace TranslatorLibrary
6 | {
7 | public class YandexTranslator : ITranslator
8 | {
9 | public string ApiKey;
10 |
11 | private string errorInfo;
12 |
13 | public string GetLastError()
14 | {
15 | return errorInfo;
16 | }
17 |
18 | public async Task TranslateAsync(string sourceText, string desLang, string srcLang)
19 | {
20 | if (desLang == "kr")
21 | desLang = "ko";
22 | if (srcLang == "kr")
23 | srcLang = "ko";
24 | if (desLang == "jp")
25 | desLang = "ja";
26 | if (srcLang == "jp")
27 | srcLang = "ja";
28 |
29 | var hc = CommonFunction.GetHttpClient();
30 | string apiurl = "https://translate.yandex.net/api/v1.5/tr.json/translate?key=" + ApiKey + "&lang=" + srcLang + "-" + desLang + "&text=";
31 |
32 | try
33 | {
34 | string retString = await hc.GetStringAsync(apiurl + HttpUtility.UrlEncode(sourceText));
35 | var doc = JsonSerializer.Deserialize(retString, CommonFunction.JsonOP);
36 | return doc.text[0];
37 | }
38 | catch (System.Net.Http.HttpRequestException ex)
39 | {
40 | errorInfo = ex.Message;
41 | return null;
42 | }
43 | catch (System.Threading.Tasks.TaskCanceledException ex)
44 | {
45 | errorInfo = ex.Message;
46 | return null;
47 | }
48 | }
49 |
50 | public void TranslatorInit(string param1, string param2="")
51 | {
52 | ApiKey = param1;
53 | }
54 |
55 | ///
56 | /// Yandex翻译API申请地址
57 | ///
58 | ///
59 | public static string GetUrl_allpyAPI()
60 | {
61 | return "https://translate.yandex.com/developers/keys";
62 | }
63 |
64 | ///
65 | /// Yandex翻译API额度查询地址
66 | ///
67 | ///
68 | public static string GetUrl_bill()
69 | {
70 | return "https://translate.yandex.com/developers/stat";
71 | }
72 |
73 | ///
74 | /// Yandex翻译API文档地址
75 | ///
76 | ///
77 | public static string GetUrl_Doc()
78 | {
79 | return "https://yandex.com/dev/translate/doc/dg/reference/translate.html";
80 | }
81 |
82 | #pragma warning disable 0649
83 | struct Result
84 | {
85 | public int code;
86 | public string[] text;
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hanmin0822/MisakaTranslator/2549bcd4bbec27bcf2126588510502c7e57ff91e/background.png
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 | This is AutoUpdateCheck's Page.
2 | LatestVersion[2.12.2.0]
3 | DownloadPath[https://github.com/hanmin0822/MisakaTranslator/releases]
4 |
--------------------------------------------------------------------------------